From 672f700271ee935ea9f6bf66802517e720c3c097 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 17 Sep 2023 22:50:42 -0700 Subject: feat(notifications): link to activity --- src/lib/AniList/notifications.ts | 28 ++++++++++++++-------- src/routes/feeds/activity-notifications/+server.ts | 7 +++++- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/lib/AniList/notifications.ts b/src/lib/AniList/notifications.ts index b236e994..42b4c84b 100644 --- a/src/lib/AniList/notifications.ts +++ b/src/lib/AniList/notifications.ts @@ -28,12 +28,20 @@ export interface Notification { } export const notifications = async (accessToken: string): Promise => { - const activityNotification = (type: string) => `... on ${type} { - id user { name avatar { large } } context createdAt type - }`; - const threadNotification = (type: string) => `... on ${type} { - id user { name avatar { large } } context createdAt type thread { title id } + const activityNotification = (type: string, extend = '') => `... on ${type} { + id user { name avatar { large } } context createdAt type ${extend} }`; + const richActivityNotification = (type: string) => + `${activityNotification( + type, + `activity { + ... on TextActivity { id } + ... on ListActivity { id } + ... on MessageActivity { id } + }` + )}`; + const threadNotification = (type: string) => + `${activityNotification(type, `thread { title id }`)}`; return ( await ( @@ -48,11 +56,11 @@ export const notifications = async (accessToken: string): Promise { return text.charAt(0).toUpperCase() + text.substr(1).toLowerCase(); }); - if (notification.type.toString().includes('THREAD')) { + if ( + !['FOLLOWING', 'ACTIVITY_MESSAGE'].includes(notification.type.toString()) && + !notification.type.toString().includes('THREAD') + ) { + link = `https://anilist.co/activity/${notification.activity.id}`; + } else if (notification.type.toString().includes('THREAD')) { title += `${notification.thread.title}`; link = `https://anilist.co/forum/thread/${notification.thread.id}`; } -- cgit v1.2.3