diff options
| author | Fuwn <[email protected]> | 2023-09-19 20:08:34 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-09-19 20:08:34 -0700 |
| commit | 43203ea52e23efc621246e2ed16eaf54b5f1870b (patch) | |
| tree | 6792936f0f56110fee0dc3073d12692fd3ddcd8f /src | |
| parent | feat(pwa): maskable icon (diff) | |
| download | due.moe-43203ea52e23efc621246e2ed16eaf54b5f1870b.tar.xz due.moe-43203ea52e23efc621246e2ed16eaf54b5f1870b.zip | |
fix(feeds): render empty feed if no token
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/feeds/activity-notifications/+server.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/routes/feeds/activity-notifications/+server.ts b/src/routes/feeds/activity-notifications/+server.ts index 0691eb4c..285d775b 100644 --- a/src/routes/feeds/activity-notifications/+server.ts +++ b/src/routes/feeds/activity-notifications/+server.ts @@ -1,8 +1,6 @@ import { notifications, type Notification } from '$lib/AniList/notifications'; -export const GET = async ({ url }) => { - const data = await notifications(url.searchParams.get('token') || 'null'); - const render = (posts: Notification[]) => `<?xml version="1.0" encoding="UTF-8" ?> +const render = (posts: Notification[] = []) => `<?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" @@ -55,7 +53,10 @@ export const GET = async ({ url }) => { </rss> `; - return new Response(render(data), { +export const GET = async ({ url }) => { + const token = url.searchParams.get('token'); + + return new Response(token ? render(await notifications(token)) : render(), { headers: { 'Cache-Control': `max-age=0, s-max-age=0`, 'Content-Type': 'application/xml' |