Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors when loading bad data from the DB #3

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/dispatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ async function getUserData(ctx: RequestContext<ContextData>, handle: string) {
const existing = await ctx.data.db.get<PersonData>(['handle', handle]);

if (existing) {
let icon = null;
try {
icon = new Image({ url: new URL(existing.icon) });
} catch (err) {
console.log('Could not create Image from Icon value', existing.icon);
console.log(err);
}
return {
id: new URL(existing.id),
name: existing.name,
summary: existing.summary,
preferredUsername: existing.preferredUsername,
icon: new Image({ url: new URL(existing.icon) }),
icon,
inbox: new URL(existing.inbox),
outbox: new URL(existing.outbox),
following: new URL(existing.following),
Expand Down Expand Up @@ -69,7 +76,7 @@ async function getUserData(ctx: RequestContext<ContextData>, handle: string) {
name: data.name,
summary: data.summary,
preferredUsername: data.preferredUsername,
icon: data.icon.url!.href as string,
icon: 'https://ghost.org/favicon.ico',
inbox: data.inbox.href,
outbox: data.outbox.href,
following: data.following.href,
Expand Down
Loading