alpha
Login
or
Join now
atpota.to
/
flushes.app
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
fix 213
author
damedotblog
date
1 year ago
(Mar 15, 2025, 9:49 PM -0400)
commit
6b0e5b01
6b0e5b01ce4f371a8ad2997de45463b1a66c79cc
parent
2e45f600
2e45f600f485b98aac213f9aa6e7a8cc1c716271
+80
-13
1 changed file
Expand all
Collapse all
Unified
Split
app
src
app
api
bluesky
profile
route.ts
+80
-13
app/src/app/api/bluesky/profile/route.ts
Reviewed
···
154
154
155
155
// Step 3: Call the repo.listRecords API to get the user's flushing statuses
156
156
try {
157
157
-
const listRecordsUrl = `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`;
157
157
+
// Add logging for debugging handle/domain/serviceEndpoint relationships
158
158
+
console.log(`PROFILE DEBUG:
159
159
+
- Handle: ${handle}
160
160
+
- DID: ${did}
161
161
+
- PDS Service Endpoint: ${serviceEndpoint}
162
162
+
- Service PDS Host: ${servicePds || 'unknown'}
163
163
+
`);
164
164
+
165
165
+
// Check if the serviceEndpoint includes "/xrpc" already, which some PDS endpoints might
166
166
+
let listRecordsUrl;
167
167
+
if (serviceEndpoint.endsWith('/xrpc')) {
168
168
+
listRecordsUrl = `${serviceEndpoint}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`;
169
169
+
} else {
170
170
+
listRecordsUrl = `${serviceEndpoint}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`;
171
171
+
}
172
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
182
-
const pdsDirectUrl = `https://${servicePds}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`;
197
197
+
198
198
+
// Some PDS services have different URL structures
199
199
+
const urls = [
200
200
+
`https://${servicePds}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`,
201
201
+
// Try without /xrpc prefix in case it's already in the hostname
202
202
+
`https://${servicePds}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`,
203
203
+
];
183
204
184
184
-
const pdsDirectResponse = await fetch(pdsDirectUrl, {
185
185
-
headers: { 'Accept': 'application/json' }
186
186
-
});
205
205
+
// Start with the most common pattern
206
206
+
let pdsDirectResponse = null;
207
207
+
let pdsDirectUrl = '';
208
208
+
let directData = null;
209
209
+
let succeeded = false;
210
210
+
211
211
+
for (const url of urls) {
212
212
+
try {
213
213
+
console.log(`Attempting URL: ${url}`);
214
214
+
pdsDirectUrl = url;
215
215
+
pdsDirectResponse = await fetch(url, {
216
216
+
headers: { 'Accept': 'application/json' }
217
217
+
});
218
218
+
219
219
+
if (pdsDirectResponse.ok) {
220
220
+
console.log(`Success with URL: ${url}`);
221
221
+
directData = await pdsDirectResponse.json();
222
222
+
succeeded = true;
223
223
+
break;
224
224
+
} else {
225
225
+
console.warn(`Failed with URL ${url}: ${pdsDirectResponse.status}`);
226
226
+
}
227
227
+
} catch (urlErr) {
228
228
+
console.error(`Error trying URL ${url}: ${urlErr}`);
229
229
+
}
230
230
+
}
187
231
188
188
-
if (pdsDirectResponse.ok) {
232
232
+
if (succeeded && directData) {
189
233
console.log(`Successfully accessed records directly from PDS domain: ${servicePds}`);
190
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
247
-
const domainUrl = `https://${domain}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`;
248
290
249
249
-
const domainResponse = await fetch(domainUrl, {
250
250
-
headers: { 'Accept': 'application/json' }
251
251
-
});
291
291
+
// Try multiple URL patterns for handle domain
292
292
+
const urls = [
293
293
+
`https://${domain}/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`,
294
294
+
`https://${domain}/com.atproto.repo.listRecords?repo=${encodeURIComponent(did)}&collection=${encodeURIComponent(FLUSHING_STATUS_NSID)}&limit=${MAX_ENTRIES}`
295
295
+
];
252
296
253
253
-
if (domainResponse.ok) {
297
297
+
let domainResponse = null;
298
298
+
let domainData = null;
299
299
+
let succeeded = false;
300
300
+
301
301
+
for (const url of urls) {
302
302
+
try {
303
303
+
console.log(`Attempting URL: ${url}`);
304
304
+
domainResponse = await fetch(url, {
305
305
+
headers: { 'Accept': 'application/json' }
306
306
+
});
307
307
+
308
308
+
if (domainResponse.ok) {
309
309
+
console.log(`Success with URL: ${url}`);
310
310
+
domainData = await domainResponse.json();
311
311
+
succeeded = true;
312
312
+
break;
313
313
+
} else {
314
314
+
console.warn(`Failed with URL ${url}: ${domainResponse.status}`);
315
315
+
}
316
316
+
} catch (urlErr) {
317
317
+
console.error(`Error trying URL ${url}: ${urlErr}`);
318
318
+
}
319
319
+
}
320
320
+
321
321
+
if (succeeded && domainData) {
254
322
console.log(`Successfully accessed records from handle domain: ${domain}`);
255
255
-
const domainData = await domainResponse.json();
256
323
257
324
// Process the domain response
258
325
const domainEntries = domainData.records