···33// Simplified API client for OAuth session
44// TODO: Implement proper API integration after authentication is working
5566-// Create a post - simplified implementation
66+// Create a post using the OAuth session as a fetch handler
77export async function createPost(session: OAuthSession, options: {
88 text: string;
99 reply?: {
···2020 }
21212222 try {
2323- // For now, we'll make a direct API call to our existing endpoint
2424- // Later this can be improved to use the OAuth session directly
2523 console.log('Creating post with session:', session.sub);
2624 console.log('Post text:', options.text);
27252626+ // Extract emoji from text if present, default to toilet
2727+ let emoji = '🚽';
2828+ let cleanText = options.text;
2929+3030+ // Simple emoji extraction - look for common toilet/bathroom emojis
3131+ const toiletEmojis = ['🚽', '🧻', '💩', '💨', '🚾', '🧼', '🪠', '🚻', '🩸', '💧', '💦', '😌',
3232+ '😣', '🤢', '🤮', '🥴', '😮💨', '😳', '😵', '🌾', '🍦', '📱', '📖', '💭',
3333+ '1️⃣', '2️⃣', '🟡', '🟤'];
3434+3535+ // Look for any of these emojis in the text
3636+ for (const testEmoji of toiletEmojis) {
3737+ if (options.text.includes(testEmoji)) {
3838+ emoji = testEmoji;
3939+ cleanText = options.text.replace(testEmoji, '').trim();
4040+ break;
4141+ }
4242+ }
4343+4444+ // Use regular fetch to call our own API endpoint
4545+ // TODO: Later we can modify this to call the user's PDS directly using session.fetchHandler
2846 const response = await fetch('/api/bluesky/flushing', {
2947 method: 'POST',
3048 headers: {
3149 'Content-Type': 'application/json',
3250 },
3351 body: JSON.stringify({
3434- text: options.text,
3535- emoji: '🚽', // Default emoji for now
3636- did: session.sub
5252+ text: cleanText,
5353+ emoji,
5454+ did: session.sub,
5555+ // For now, we'll just pass the session info and let the API endpoint
5656+ // figure out how to use the OAuth session
5757+ sessionSub: session.sub
3758 })
3859 });
39604061 if (!response.ok) {
6262+ const errorData = await response.json().catch(() => ({}));
6363+ console.error('API response error:', errorData);
4164 throw new Error(`Failed to create post: ${response.status}`);
4265 }
43664467 const result = await response.json();
6868+ console.log('Post created successfully:', result);
4569 return result;
4670 } catch (error) {
4771 console.error('Failed to create post:', error);