diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/AniList/notifications.ts | 28 | ||||
| -rw-r--r-- | 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<Notification[]> => { - 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<Notification[] query: `{ Page(page: 1, perPage: 50) { notifications { ${activityNotification('FollowingNotification')} ${activityNotification('ActivityMessageNotification')} - ${activityNotification('ActivityMentionNotification')} - ${activityNotification('ActivityReplyNotification')} - ${activityNotification('ActivityReplySubscribedNotification')} - ${activityNotification('ActivityLikeNotification')} - ${activityNotification('ActivityReplyLikeNotification')} + ${richActivityNotification('ActivityMentionNotification')} + ${richActivityNotification('ActivityReplyNotification')} + ${richActivityNotification('ActivityReplySubscribedNotification')} + ${richActivityNotification('ActivityLikeNotification')} + ${richActivityNotification('ActivityReplyLikeNotification')} ${threadNotification('ThreadCommentMentionNotification')} ${threadNotification('ThreadCommentReplyNotification')} ${threadNotification('ThreadCommentSubscribedNotification')} diff --git a/src/routes/feeds/activity-notifications/+server.ts b/src/routes/feeds/activity-notifications/+server.ts index e72482e8..94ff60c0 100644 --- a/src/routes/feeds/activity-notifications/+server.ts +++ b/src/routes/feeds/activity-notifications/+server.ts @@ -29,7 +29,12 @@ export const GET = async ({ url }) => { 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}`; } |