This repository has no description
0

Configure Feed

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

fix 213

+80 -13
+80 -13
app/src/app/api/bluesky/profile/route.ts
··· 154 154 155 155 // Step 3: Call the repo.listRecords API to get the user's flushing statuses 156 156 try { 157 - const listRecordsUrl = `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`; 157 + // Add logging for debugging handle/domain/serviceEndpoint relationships 158 + console.log(`PROFILE DEBUG: 159 + - Handle: ${handle} 160 + - DID: ${did} 161 + - PDS Service Endpoint: ${serviceEndpoint} 162 + - Service PDS Host: ${servicePds || 'unknown'} 163 + `); 164 + 165 + // Check if the serviceEndpoint includes "/xrpc" already, which some PDS endpoints might 166 + let listRecordsUrl; 167 + if (serviceEndpoint.endsWith('/xrpc')) { 168 + listRecordsUrl = `${serviceEndpoint}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`; 169 + } else { 170 + listRecordsUrl = `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`; 171 + } 172 + 158 173 console.log(`Fetching records from ${listRecordsUrl}`); 159 174 160 175 const recordsResponse = await fetch(listRecordsUrl, { ··· 179 194 if (servicePds) { 180 195 try { 181 196 console.log(`Trying direct PDS domain: https://${servicePds}`); 182 - const pdsDirectUrl = `https://${servicePds}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`; 197 + 198 + // Some PDS services have different URL structures 199 + const urls = [ 200 + `https://${servicePds}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`, 201 + // Try without /xrpc prefix in case it's already in the hostname 202 + `https://${servicePds}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`, 203 + ]; 183 204 184 - const pdsDirectResponse = await fetch(pdsDirectUrl, { 185 - headers: { 'Accept': 'application/json' } 186 - }); 205 + // Start with the most common pattern 206 + let pdsDirectResponse = null; 207 + let pdsDirectUrl = ''; 208 + let directData = null; 209 + let succeeded = false; 210 + 211 + for (const url of urls) { 212 + try { 213 + console.log(`Attempting URL: ${url}`); 214 + pdsDirectUrl = url; 215 + pdsDirectResponse = await fetch(url, { 216 + headers: { 'Accept': 'application/json' } 217 + }); 218 + 219 + if (pdsDirectResponse.ok) { 220 + console.log(`Success with URL: ${url}`); 221 + directData = await pdsDirectResponse.json(); 222 + succeeded = true; 223 + break; 224 + } else { 225 + console.warn(`Failed with URL ${url}: ${pdsDirectResponse.status}`); 226 + } 227 + } catch (urlErr) { 228 + console.error(`Error trying URL ${url}: ${urlErr}`); 229 + } 230 + } 187 231 188 - if (pdsDirectResponse.ok) { 232 + if (succeeded && directData) { 189 233 console.log(`Successfully accessed records directly from PDS domain: ${servicePds}`); 190 - const directData = await pdsDirectResponse.json(); 191 234 192 235 // Process the direct response 193 236 const directEntries = directData.records ··· 244 287 const domain = handle.split('.').slice(1).join('.'); 245 288 try { 246 289 console.log(`Trying handle domain access: https://${domain}`); 247 - const domainUrl = `https://${domain}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`; 248 290 249 - const domainResponse = await fetch(domainUrl, { 250 - headers: { 'Accept': 'application/json' } 251 - }); 291 + // Try multiple URL patterns for handle domain 292 + const urls = [ 293 + `https://${domain}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`, 294 + `https://${domain}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}` 295 + ]; 252 296 253 - if (domainResponse.ok) { 297 + let domainResponse = null; 298 + let domainData = null; 299 + let succeeded = false; 300 + 301 + for (const url of urls) { 302 + try { 303 + console.log(`Attempting URL: ${url}`); 304 + domainResponse = await fetch(url, { 305 + headers: { 'Accept': 'application/json' } 306 + }); 307 + 308 + if (domainResponse.ok) { 309 + console.log(`Success with URL: ${url}`); 310 + domainData = await domainResponse.json(); 311 + succeeded = true; 312 + break; 313 + } else { 314 + console.warn(`Failed with URL ${url}: ${domainResponse.status}`); 315 + } 316 + } catch (urlErr) { 317 + console.error(`Error trying URL ${url}: ${urlErr}`); 318 + } 319 + } 320 + 321 + if (succeeded && domainData) { 254 322 console.log(`Successfully accessed records from handle domain: ${domain}`); 255 - const domainData = await domainResponse.json(); 256 323 257 324 // Process the domain response 258 325 const domainEntries = domainData.records