This repository has no description
0

Configure Feed

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

fixes

+114 -36
+114 -35
app/src/app/api/bluesky/feed/route.ts
··· 101 101 // Get the DID 102 102 const authorDid = entry.did; 103 103 104 + // Determine the best handle to use 105 + let authorHandle: string; 106 + 104 107 // First check if we have a valid handle in the database record 105 108 // and it's not "unknown" 106 - let authorHandle: string; 107 109 if (entry.handle && entry.handle !== 'unknown') { 108 110 // Use the handle from the database 109 111 authorHandle = entry.handle; ··· 111 113 112 114 // Store in cache for future use 113 115 dbHandleCache.set(authorDid, authorHandle); 114 - } else if (dbHandleCache.has(authorDid)) { 116 + } 117 + // Next, check if we have it in the cache 118 + else if (dbHandleCache.has(authorDid)) { 115 119 // Use cached handle from previous database entries 116 120 authorHandle = dbHandleCache.get(authorDid)!; 117 121 console.log(`Using cached DB handle for ${authorDid}: ${authorHandle}`); 118 - } else { 119 - // Resolve handle from DID 120 - authorHandle = await resolveDidToHandle(authorDid); 121 - console.log(`Resolved handle for ${authorDid}: ${authorHandle}`); 122 + } 123 + // If not in database or cache, try to resolve it 124 + else { 125 + // Try to resolve the handle from PLC directory 126 + const resolvedHandle = await resolveDidToHandle(authorDid); 127 + 128 + // Only use the resolved handle if it's not in the user.xyz format (our fallback format) 129 + if (!resolvedHandle.startsWith('user.')) { 130 + authorHandle = resolvedHandle; 131 + console.log(`Successfully resolved handle for ${authorDid}: ${authorHandle}`); 132 + 133 + // Also update the database with the resolved handle if possible 134 + try { 135 + if (supabaseUrl && supabaseKey) { 136 + const supabase = createClient(supabaseUrl, supabaseKey); 137 + await supabase 138 + .from('flushing_records') 139 + .update({ handle: authorHandle }) 140 + .eq('did', authorDid); 141 + console.log(`Updated database with resolved handle for ${authorDid}: ${authorHandle}`); 142 + } 143 + } catch (updateError) { 144 + console.error(`Failed to update handle in database for ${authorDid}:`, updateError); 145 + } 146 + } else { 147 + // If resolution failed, still use the resolved handle (which will be our fallback format) 148 + authorHandle = resolvedHandle; 149 + console.log(`Could not resolve real handle for ${authorDid}, using: ${authorHandle}`); 150 + } 122 151 } 123 152 124 153 if (containsBannedWords(entry.text)) { ··· 196 225 // Get the DID 197 226 const authorDid = entry.did; 198 227 228 + // Determine the best handle to use 229 + let authorHandle: string; 230 + 199 231 // First check if we have a valid handle in the database record 200 232 // and it's not "unknown" 201 - let authorHandle: string; 202 233 if (entry.handle && entry.handle !== 'unknown') { 203 234 // Use the handle from the database 204 235 authorHandle = entry.handle; ··· 206 237 207 238 // Store in cache for future use 208 239 dbHandleCache.set(authorDid, authorHandle); 209 - } else if (dbHandleCache.has(authorDid)) { 240 + } 241 + // Next, check if we have it in the cache 242 + else if (dbHandleCache.has(authorDid)) { 210 243 // Use cached handle from previous database entries 211 244 authorHandle = dbHandleCache.get(authorDid)!; 212 245 console.log(`Using cached DB handle for ${authorDid}: ${authorHandle}`); 213 - } else { 214 - // Resolve handle from DID 215 - authorHandle = await resolveDidToHandle(authorDid); 216 - console.log(`Resolved handle for ${authorDid}: ${authorHandle}`); 246 + } 247 + // If not in database or cache, try to resolve it 248 + else { 249 + // Try to resolve the handle from PLC directory 250 + const resolvedHandle = await resolveDidToHandle(authorDid); 251 + 252 + // Only use the resolved handle if it's not in the user.xyz format (our fallback format) 253 + if (!resolvedHandle.startsWith('user.')) { 254 + authorHandle = resolvedHandle; 255 + console.log(`Successfully resolved handle for ${authorDid}: ${authorHandle}`); 256 + 257 + // Also update the database with the resolved handle if possible 258 + try { 259 + if (supabaseUrl && supabaseKey) { 260 + const supabase = createClient(supabaseUrl, supabaseKey); 261 + await supabase 262 + .from('flushing_records') 263 + .update({ handle: authorHandle }) 264 + .eq('did', authorDid); 265 + console.log(`Updated database with resolved handle for ${authorDid}: ${authorHandle}`); 266 + } 267 + } catch (updateError) { 268 + console.error(`Failed to update handle in database for ${authorDid}:`, updateError); 269 + } 270 + } else { 271 + // If resolution failed, still use the resolved handle (which will be our fallback format) 272 + authorHandle = resolvedHandle; 273 + console.log(`Could not resolve real handle for ${authorDid}, using: ${authorHandle}`); 274 + } 217 275 } 218 276 219 277 // Skip entries with banned content ··· 340 398 const plcResolver = async () => { 341 399 console.log(`Trying PLC directory for DID: ${did}`); 342 400 401 + // Function to extract handle from PLC data 402 + const extractHandleFromPlcData = (plcData: any): string | null => { 403 + if (!plcData || !plcData.alsoKnownAs || !Array.isArray(plcData.alsoKnownAs)) { 404 + return null; 405 + } 406 + 407 + // Loop through alsoKnownAs and find entries starting with "at://" 408 + for (const aka of plcData.alsoKnownAs) { 409 + if (typeof aka === 'string' && aka.startsWith('at://')) { 410 + // Extract the handle (everything after "at://") 411 + const handle = aka.split('//')[1]; 412 + if (handle) { 413 + return handle; 414 + } 415 + } 416 + } 417 + 418 + return null; 419 + }; 420 + 343 421 try { 344 422 // Try main PLC endpoint 423 + console.log(`Fetching from https://plc.directory/${did}`); 345 424 const controller = new AbortController(); 346 425 const timeoutId = setTimeout(() => controller.abort(), 3000); 347 426 const plcResponse = await fetch(`https://plc.directory/${did}`, { ··· 351 430 352 431 if (plcResponse.ok) { 353 432 const plcData = await plcResponse.json(); 354 - if (plcData && plcData.alsoKnownAs && plcData.alsoKnownAs.length > 0) { 355 - // alsoKnownAs contains values like 'at://user.bsky.social' 356 - for (const aka of plcData.alsoKnownAs) { 357 - if (aka.startsWith('at://')) { 358 - const handle = aka.split('//')[1]; 359 - if (handle) { 360 - console.log(`Resolved ${did} to handle ${handle} via PLC directory`); 361 - didResolutionCache.set(did, handle); 362 - return handle; 363 - } 364 - } 365 - } 433 + console.log(`PLC response for ${did}:`, JSON.stringify(plcData).substring(0, 200) + '...'); 434 + 435 + const handle = extractHandleFromPlcData(plcData); 436 + if (handle) { 437 + console.log(`Successfully resolved ${did} to handle ${handle} via PLC directory`); 438 + didResolutionCache.set(did, handle); 439 + return handle; 440 + } else { 441 + console.log(`PLC data for ${did} did not contain a valid handle in alsoKnownAs:`, plcData.alsoKnownAs); 366 442 } 443 + } else { 444 + console.log(`PLC response not OK: ${plcResponse.status} ${plcResponse.statusText}`); 367 445 } 368 446 } catch (err) { 369 447 console.warn(`Error with main PLC endpoint for ${did}:`, err); ··· 371 449 372 450 try { 373 451 // Try alternate PLC endpoint 452 + console.log(`Fetching from https://plc.directory/${did}/data`); 374 453 const altController = new AbortController(); 375 454 const altTimeoutId = setTimeout(() => altController.abort(), 3000); 376 455 const altPlcResponse = await fetch(`https://plc.directory/${did}/data`, { ··· 380 459 381 460 if (altPlcResponse.ok) { 382 461 const altPlcData = await altPlcResponse.json(); 383 - if (altPlcData && altPlcData.alsoKnownAs && altPlcData.alsoKnownAs.length > 0) { 384 - for (const aka of altPlcData.alsoKnownAs) { 385 - if (aka.startsWith('at://')) { 386 - const handle = aka.split('//')[1]; 387 - if (handle) { 388 - console.log(`Resolved ${did} to handle ${handle} via PLC directory (alternate endpoint)`); 389 - didResolutionCache.set(did, handle); 390 - return handle; 391 - } 392 - } 393 - } 462 + console.log(`PLC alternate response for ${did}:`, JSON.stringify(altPlcData).substring(0, 200) + '...'); 463 + 464 + const handle = extractHandleFromPlcData(altPlcData); 465 + if (handle) { 466 + console.log(`Successfully resolved ${did} to handle ${handle} via PLC directory (alternate endpoint)`); 467 + didResolutionCache.set(did, handle); 468 + return handle; 469 + } else { 470 + console.log(`PLC alternate data for ${did} did not contain a valid handle in alsoKnownAs:`, altPlcData.alsoKnownAs); 394 471 } 472 + } else { 473 + console.log(`PLC alternate response not OK: ${altPlcResponse.status} ${altPlcResponse.statusText}`); 395 474 } 396 475 } catch (err) { 397 476 console.warn(`Error with alternate PLC endpoint for ${did}:`, err);
-1
app/src/app/stats/stats.module.css
··· 223 223 padding: 1.5rem; 224 224 box-shadow: 0 2px 8px var(--shadow-color); 225 225 border: 1px solid var(--tile-border); 226 - background-image: repeating-linear-gradient(0deg, var(--tile-border), var(--tile-border) 1px, transparent 1px, transparent 20px); 227 226 } 228 227 229 228 .overallStats h2, .chartSection h2, .leaderboardSection h2 {