Fix users with no profile record not being shown #7

Merged
astra merged 5 commits from kc/profileless-users-not-being-shown into main 2025-05-30 03:05:06 +00:00
Showing only changes of commit cda82035d9 - Show all commits

View file

@ -133,6 +133,13 @@ const getAccountMetadata = async (
did: `did:${string}:${string}`,
) => {
// gonna assume self exists in the app.bsky.actor.profile
const account: AccountMetadata = {
did: did,
handle: "",
displayName: "",
avatarCid: null,
};
try {
const { data } = await rpc.get("com.atproto.repo.getRecord", {
params: {
@ -142,21 +149,22 @@ const getAccountMetadata = async (
},
});
const value = data.value as AppBskyActorProfile.Record;
const handle = await blueskyHandleFromDid(did);
const account: AccountMetadata = {
did: did,
handle: handle,
displayName: value.displayName || "",
avatarCid: null,
};
account.displayName = value.displayName || "";
if (value.avatar) {
account.avatarCid = value.avatar.ref["$link"];
}
return account;
} catch (e) {
console.error(`Error fetching metadata for ${did}:`, e);
console.warn(`Error fetching profile for ${did}:`, e);
}
try {
account.handle = await blueskyHandleFromDid(did);
} catch (e) {
console.error(`Error fetching handle for ${did}:`, e);
return null;
}
return account;
};
const getAllMetadataFromPds = async (): Promise<AccountMetadata[]> => {