This repository has no description
0

Configure Feed

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

fix again 123

+93 -1
+93 -1
app/src/app/api/bluesky/profile/route.ts
··· 195 195 try { 196 196 console.log(`Trying direct PDS domain: https://${servicePds}`); 197 197 198 + // Special case for known working domains 199 + if (handle === 'mackuba.eu') { 200 + console.log('Detected mackuba.eu, using known working endpoint'); 201 + try { 202 + const specialUrl = `https://lab.martianbase.net/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`; 203 + console.log(`Trying special URL: ${specialUrl}`); 204 + 205 + const specialResponse = await fetch(specialUrl, { 206 + headers: { 'Accept': 'application/json' } 207 + }); 208 + 209 + if (specialResponse.ok) { 210 + console.log('Special URL succeeded!'); 211 + const specialData = await specialResponse.json(); 212 + 213 + // Process the special response 214 + const specialEntries = specialData.records 215 + .map((record: any) => { 216 + const text = record.value.text || ''; 217 + if (containsBannedWords(text)) return null; 218 + 219 + return { 220 + id: record.uri, 221 + uri: record.uri, 222 + cid: record.cid, 223 + did: did, 224 + text: sanitizeText(text), 225 + emoji: record.value.emoji || '🚽', 226 + created_at: record.value.createdAt 227 + }; 228 + }) 229 + .filter((entry: ProfileEntry | null): entry is ProfileEntry => entry !== null); 230 + 231 + // Calculate emoji stats 232 + const specialEmojiCounts = new Map<string, number>(); 233 + specialEntries.forEach((entry: ProfileEntry) => { 234 + const emoji = entry.emoji?.trim() || '🚽'; 235 + if (APPROVED_EMOJIS.includes(emoji)) { 236 + specialEmojiCounts.set(emoji, (specialEmojiCounts.get(emoji) || 0) + 1); 237 + } else { 238 + specialEmojiCounts.set('🚽', (specialEmojiCounts.get('🚽') || 0) + 1); 239 + } 240 + }); 241 + 242 + const specialEmojiStats = Array.from(specialEmojiCounts.entries()) 243 + .map(([emoji, count]): EmojiStat => ({ emoji, count })) 244 + .sort((a, b) => b.count - a.count); 245 + 246 + return NextResponse.json({ 247 + entries: specialEntries, 248 + count: specialEntries.length, 249 + cursor: specialData.cursor, 250 + profile: userProfile, 251 + emojiStats: specialEmojiStats, 252 + serviceEndpoint: 'https://lab.martianbase.net', 253 + specialHandling: true 254 + }); 255 + } else { 256 + console.warn(`Special URL failed: ${specialResponse.status}`); 257 + } 258 + } catch (specialErr) { 259 + console.error(`Error with special URL: ${specialErr}`); 260 + } 261 + } 262 + 198 263 // Some PDS services have different URL structures 199 264 const urls = [ 200 265 `https://${servicePds}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`, 201 266 // Try without /xrpc prefix in case it's already in the hostname 202 267 `https://${servicePds}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`, 268 + // Try explicit lab subdomain if we're using martianbase.net 269 + ...(servicePds.includes('martianbase.net') ? 270 + [`https://lab.martianbase.net/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`] : 271 + []) 203 272 ]; 204 273 205 274 // Start with the most common pattern ··· 603 672 }); 604 673 } 605 674 675 + // If we get a 404, return empty entries rather than an error 676 + // This handles PDS servers that return 404 instead of empty arrays 677 + if (error instanceof Error && error.message.includes('404')) { 678 + console.log(`Returning empty entries list instead of 404 error for ${did}`); 679 + return NextResponse.json({ 680 + entries: [], 681 + count: 0, 682 + profile: userProfile, 683 + emojiStats: [], 684 + did, 685 + handle, 686 + serviceEndpoint, 687 + servicePds, 688 + emptyCollection: true 689 + }); 690 + } 691 + 606 692 return NextResponse.json( 607 - { error: `Failed to fetch records: ${error.message}` }, 693 + { 694 + error: `Failed to fetch records: ${error.message}`, 695 + did, 696 + handle, 697 + serviceEndpoint, 698 + servicePds 699 + }, 608 700 { status: 500 } 609 701 ); 610 702 }