Wrap note fetching in a try/catch
This commit is contained in:
parent
34a6e1caa4
commit
6f32efd898
|
@ -399,28 +399,31 @@ router.get("/notes/:note", async (ctx, next) => {
|
||||||
visibility: In(["public", "home"]),
|
visibility: In(["public", "home"]),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (note) {
|
try {
|
||||||
const _note = await Notes.pack(note);
|
if (note) {
|
||||||
const profile = await UserProfiles.findOneByOrFail({ userId: note.userId });
|
const _note = await Notes.pack(note);
|
||||||
const meta = await fetchMeta();
|
|
||||||
await ctx.render("note", {
|
const profile = await UserProfiles.findOneByOrFail({ userId: note.userId });
|
||||||
note: _note,
|
const meta = await fetchMeta();
|
||||||
profile,
|
await ctx.render("note", {
|
||||||
avatarUrl: await Users.getAvatarUrl(
|
note: _note,
|
||||||
await Users.findOneByOrFail({ id: note.userId }),
|
profile,
|
||||||
),
|
avatarUrl: await Users.getAvatarUrl(
|
||||||
// TODO: Let locale changeable by instance setting
|
await Users.findOneByOrFail({ id: note.userId }),
|
||||||
summary: getNoteSummary(_note),
|
),
|
||||||
instanceName: meta.name || "Calckey",
|
// TODO: Let locale changeable by instance setting
|
||||||
icon: meta.iconUrl,
|
summary: getNoteSummary(_note),
|
||||||
privateMode: meta.privateMode,
|
instanceName: meta.name || "Calckey",
|
||||||
themeColor: meta.themeColor,
|
icon: meta.iconUrl,
|
||||||
});
|
privateMode: meta.privateMode,
|
||||||
|
themeColor: meta.themeColor,
|
||||||
|
});
|
||||||
|
|
||||||
ctx.set("Cache-Control", "public, max-age=15");
|
ctx.set("Cache-Control", "public, max-age=15");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
await next();
|
await next();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue