This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

hardcode

+109
+109
app/src/app/api/bluesky/profile/route.ts
··· 60 60 ); 61 61 } 62 62 63 + // Special case for mackuba.eu - hardcoded workaround for third-party PDS 64 + if (handle === 'mackuba.eu') { 65 + console.log('SPECIAL CASE: mackuba.eu detected, using hardcoded solution'); 66 + try { 67 + // Use public API to resolve the DID first 68 + const resolveResponse = await fetch(`https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=mackuba.eu`); 69 + if (!resolveResponse.ok) { 70 + return NextResponse.json({ error: 'Failed to resolve mackuba.eu handle' }, { status: resolveResponse.status }); 71 + } 72 + 73 + const resolveData = await resolveResponse.json(); 74 + const did = resolveData.did; 75 + 76 + // Get profile data 77 + const profileResponse = await fetch(`https://public.api.bsky.app/xrpc/app.bsky.actor.getProfile?actor=mackuba.eu`); 78 + let userProfile = null; 79 + if (profileResponse.ok) { 80 + userProfile = await profileResponse.json(); 81 + } 82 + 83 + // Directly call the PDS we know works 84 + const directUrl = `https://lab.martianbase.net/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=im.flushing.right.now&limit=50`; 85 + console.log(`Making direct request to: ${directUrl}`); 86 + 87 + const directResponse = await fetch(directUrl, { 88 + headers: { 'Accept': 'application/json' } 89 + }); 90 + 91 + if (!directResponse.ok) { 92 + // If we get a 404, return empty data rather than error 93 + if (directResponse.status === 404) { 94 + return NextResponse.json({ 95 + entries: [], 96 + count: 0, 97 + profile: userProfile, 98 + emojiStats: [], 99 + did, 100 + handle: 'mackuba.eu', 101 + directUrl, 102 + emptyCollection: true 103 + }); 104 + } 105 + 106 + return NextResponse.json({ 107 + error: `Failed to fetch mackuba.eu records: ${directResponse.statusText}`, 108 + directUrl 109 + }, { status: directResponse.status }); 110 + } 111 + 112 + const recordsData = await directResponse.json(); 113 + 114 + // Transform the records into our format 115 + const transformedEntries = recordsData.records 116 + .map((record: any) => { 117 + const text = record.value.text || ''; 118 + 119 + // Skip entries with banned content 120 + if (containsBannedWords(text)) { 121 + return null; 122 + } 123 + 124 + return { 125 + id: record.uri, 126 + uri: record.uri, 127 + cid: record.cid, 128 + did: did, 129 + text: sanitizeText(text), 130 + emoji: record.value.emoji || '🚽', 131 + created_at: record.value.createdAt 132 + }; 133 + }) 134 + .filter((entry: ProfileEntry | null): entry is ProfileEntry => entry !== null); 135 + 136 + // Calculate emoji statistics 137 + const emojiCounts = new Map<string, number>(); 138 + 139 + // Process entries to count emojis 140 + transformedEntries.forEach((entry: ProfileEntry) => { 141 + const emoji = entry.emoji?.trim() || '🚽'; 142 + if (APPROVED_EMOJIS.includes(emoji)) { 143 + emojiCounts.set(emoji, (emojiCounts.get(emoji) || 0) + 1); 144 + } else { 145 + emojiCounts.set('🚽', (emojiCounts.get('🚽') || 0) + 1); 146 + } 147 + }); 148 + 149 + const emojiStats = Array.from(emojiCounts.entries()) 150 + .map(([emoji, count]): EmojiStat => ({ emoji, count })) 151 + .sort((a, b) => b.count - a.count); 152 + 153 + return NextResponse.json({ 154 + entries: transformedEntries, 155 + count: transformedEntries.length, 156 + cursor: recordsData.cursor, 157 + profile: userProfile, 158 + emojiStats, 159 + serviceEndpoint: 'https://lab.martianbase.net', 160 + directUrl, 161 + specialCase: true 162 + }); 163 + } catch (specialErr: any) { 164 + console.error(`Error in special handling for mackuba.eu:`, specialErr); 165 + return NextResponse.json({ 166 + error: `Special handling for mackuba.eu failed: ${specialErr.message}`, 167 + workingUrl: 'https://lab.martianbase.net/xrpc/com.atproto.repo.listRecords?repo=did:plc:oio4hkxaop4ao4wz2pp3f4cr&collection=im.flushing.right.now&limit=100' 168 + }, { status: 500 }); 169 + } 170 + } 171 + 63 172 // Special case for plumber account redirect 64 173 if (handle === 'plumber.flushing.im') { 65 174 console.log('Redirecting from old plumber.flushing.im handle to plumber.flushes.app');