+1
-1
config.ts
+1
-1
config.ts
-58
src/lib/pdsfetch.ts
-58
src/lib/pdsfetch.ts
···
161
161
return metadata.filter((account) => account !== null) as AccountMetadata[];
162
162
};
163
163
164
-
// OLD
165
-
const fetchPosts = async (did: string) => {
166
-
try {
167
-
const { data } = await rpc.get("com.atproto.repo.listRecords", {
168
-
params: {
169
-
repo: did as At.Identifier,
170
-
collection: "app.bsky.feed.post",
171
-
limit: Config.MAX_POSTS,
172
-
},
173
-
});
174
-
return {
175
-
records: data.records as ComAtprotoRepoListRecords.Record[],
176
-
did: did,
177
-
error: false,
178
-
};
179
-
} catch (e) {
180
-
console.error(`Error fetching posts for ${did}:`, e);
181
-
return {
182
-
records: [],
183
-
did: did,
184
-
error: true,
185
-
};
186
-
}
187
-
};
188
-
189
164
const identityResolve = async (did: At.Did) => {
190
165
const resolver = new CompositeDidDocumentResolver({
191
166
methods: {
···
364
339
}
365
340
};
366
341
367
-
// const fetchAllPosts = async () => {
368
-
// const users: AccountMetadata[] = await getAllMetadataFromPds();
369
-
// const postRecords = await Promise.all(
370
-
// users.map(
371
-
// async (metadata: AccountMetadata) => await fetchPosts(metadata.did),
372
-
// ),
373
-
// );
374
-
// // Filter out any records that have an error
375
-
// const validPostRecords = postRecords.filter((record) => !record.error);
376
-
377
-
// const posts: Post[] = validPostRecords.flatMap((userFetch) =>
378
-
// userFetch.records.map((record) => {
379
-
// const user = users.find(
380
-
// (user: AccountMetadata) => user.did == userFetch.did,
381
-
// );
382
-
// if (!user) {
383
-
// throw new Error(`User with DID ${userFetch.did} not found`);
384
-
// }
385
-
// return new Post(record, user);
386
-
// })
387
-
// );
388
-
389
-
// posts.sort((a, b) => b.timestamp - a.timestamp);
390
-
391
-
// if (!Config.SHOW_FUTURE_POSTS) {
392
-
// // Filter out posts that are in the future
393
-
// const now = Date.now();
394
-
// const filteredPosts = posts.filter((post) => post.timestamp <= now);
395
-
// return filteredPosts.slice(0, Config.MAX_POSTS);
396
-
// }
397
-
398
-
// return posts.slice(0, Config.MAX_POSTS);
399
-
// };
400
342
export { getAllMetadataFromPds, getNextPosts, Post };
401
343
export type { AccountMetadata };