From d1c9c7cc3111fbaa5e09362688809635f27116f4 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sun, 9 Jul 2023 21:27:09 +0200 Subject: [PATCH] [mastodon-client] fix poll notifications --- packages/megalodon/src/misskey/api_client.ts | 13 +++++++++---- packages/megalodon/src/misskey/notification.ts | 2 +- packages/megalodon/src/notification.ts | 3 +-- packages/megalodon/test/integration/misskey.spec.ts | 4 ++-- .../megalodon/test/unit/misskey/api_client.spec.ts | 8 ++++---- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/megalodon/src/misskey/api_client.ts b/packages/megalodon/src/misskey/api_client.ts index 34e11784e0..813ffe08a2 100644 --- a/packages/megalodon/src/misskey/api_client.ts +++ b/packages/megalodon/src/misskey/api_client.ts @@ -396,8 +396,8 @@ namespace MisskeyAPI { return MisskeyNotificationType.Reaction case NotificationType.Reblog: return MisskeyNotificationType.Renote - case NotificationType.PollVote: - return MisskeyNotificationType.PollVote + case NotificationType.Poll: + return MisskeyNotificationType.PollEnded case NotificationType.FollowRequest: return MisskeyNotificationType.ReceiveFollowRequest default: @@ -417,8 +417,8 @@ namespace MisskeyAPI { return NotificationType.Reblog case MisskeyNotificationType.Reaction: return NotificationType.EmojiReaction - case MisskeyNotificationType.PollVote: - return NotificationType.PollVote + case MisskeyNotificationType.PollEnded: + return NotificationType.Poll case MisskeyNotificationType.ReceiveFollowRequest: return NotificationType.FollowRequest case MisskeyNotificationType.FollowRequestAccepted: @@ -458,6 +458,11 @@ namespace MisskeyAPI { notification = Object.assign(notification, { status: this.note(n.note, host) }) + if (notification.type === NotificationType.Poll) { + notification = Object.assign(notification, { + account: this.note(n.note, host).account + }) + } } if (n.reaction) { notification = Object.assign(notification, { diff --git a/packages/megalodon/src/misskey/notification.ts b/packages/megalodon/src/misskey/notification.ts index 9cf3dc58a3..e44b6159c6 100644 --- a/packages/megalodon/src/misskey/notification.ts +++ b/packages/megalodon/src/misskey/notification.ts @@ -7,7 +7,7 @@ namespace MisskeyNotificationType { export const Renote: MisskeyEntity.NotificationType = 'renote' export const Quote: MisskeyEntity.NotificationType = 'quote' export const Reaction: MisskeyEntity.NotificationType = 'favourite' - export const PollVote: MisskeyEntity.NotificationType = 'pollVote' + export const PollEnded: MisskeyEntity.NotificationType = 'pollEnded' export const ReceiveFollowRequest: MisskeyEntity.NotificationType = 'receiveFollowRequest' export const FollowRequestAccepted: MisskeyEntity.NotificationType = 'followRequestAccepted' export const GroupInvited: MisskeyEntity.NotificationType = 'groupInvited' diff --git a/packages/megalodon/src/notification.ts b/packages/megalodon/src/notification.ts index 9ea3898c6e..8e8c135795 100644 --- a/packages/megalodon/src/notification.ts +++ b/packages/megalodon/src/notification.ts @@ -8,8 +8,7 @@ namespace NotificationType { export const EmojiReaction: Entity.NotificationType = 'emoji_reaction' export const FollowRequest: Entity.NotificationType = 'follow_request' export const Status: Entity.NotificationType = 'status' - export const PollVote: Entity.NotificationType = 'poll_vote' - export const PollExpired: Entity.NotificationType = 'poll_expired' + export const Poll: Entity.NotificationType = 'poll' } export default NotificationType diff --git a/packages/megalodon/test/integration/misskey.spec.ts b/packages/megalodon/test/integration/misskey.spec.ts index 754f6cc28e..49d39a097e 100644 --- a/packages/megalodon/test/integration/misskey.spec.ts +++ b/packages/megalodon/test/integration/misskey.spec.ts @@ -93,7 +93,7 @@ const pollVote: MisskeyEntity.Notification = { createdAt: '2021-02-01T01:49:29', userId: user.id, user: user, - type: MisskeyNotificationType.PollVote, + type: MisskeyNotificationType.PollEnded, note: note } @@ -168,7 +168,7 @@ describe('getNotifications', () => { }, { event: pollVote, - expected: MegalodonNotificationType.PollVote, + expected: MegalodonNotificationType.Poll, title: 'pollVote' }, { diff --git a/packages/megalodon/test/unit/misskey/api_client.spec.ts b/packages/megalodon/test/unit/misskey/api_client.spec.ts index acaac39ca1..b8e1df048c 100644 --- a/packages/megalodon/test/unit/misskey/api_client.spec.ts +++ b/packages/megalodon/test/unit/misskey/api_client.spec.ts @@ -42,8 +42,8 @@ describe('api_client', () => { dist: MisskeyNotificationType.Renote }, { - src: MegalodonNotificationType.PollVote, - dist: MisskeyNotificationType.PollVote + src: MegalodonNotificationType.Poll, + dist: MisskeyNotificationType.PollEnded }, { src: MegalodonNotificationType.FollowRequest, @@ -83,8 +83,8 @@ describe('api_client', () => { dist: MegalodonNotificationType.EmojiReaction }, { - src: MisskeyNotificationType.PollVote, - dist: MegalodonNotificationType.PollVote + src: MisskeyNotificationType.PollEnded, + dist: MegalodonNotificationType.Poll }, { src: MisskeyNotificationType.ReceiveFollowRequest,