Skip to content

Commit

Permalink
refs #1665 Handle move notification type for Pleroma
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Apr 10, 2023
1 parent 12f6af5 commit 03b15ae
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions megalodon/src/entities/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Entity {
status?: Status
emoji?: string
type: NotificationType
target?: Account
}

export type NotificationType = string
Expand Down
1 change: 1 addition & 0 deletions megalodon/src/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace NotificationType {
export const PollVote: Entity.NotificationType = 'poll_vote'
export const PollExpired: Entity.NotificationType = 'poll_expired'
export const Update: Entity.NotificationType = 'update'
export const Move: Entity.NotificationType = 'move'
}

export default NotificationType
12 changes: 12 additions & 0 deletions megalodon/src/pleroma/api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace PleromaAPI {
return NotificationType.FollowRequest
case PleromaNotificationType.Update:
return NotificationType.Update
case PleromaNotificationType.Move:
return NotificationType.Move
default:
return t
}
Expand All @@ -92,6 +94,8 @@ namespace PleromaAPI {
return PleromaNotificationType.FollowRequest
case NotificationType.Update:
return PleromaNotificationType.Update
case NotificationType.Move:
return PleromaNotificationType.Move
default:
return t
}
Expand Down Expand Up @@ -190,6 +194,14 @@ namespace PleromaAPI {
status: status(n.status),
type: decodeNotificationType(n.type)
}
} else if (n.target) {
return {
id: n.id,
account: n.account,
created_at: n.created_at,
target: n.target,
type: decodeNotificationType(n.type)
}
} else {
return {
id: n.id,
Expand Down
1 change: 1 addition & 0 deletions megalodon/src/pleroma/entities/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace PleromaEntity {
status?: Status
emoji?: string
type: NotificationType
target?: Account
}

export type NotificationType = string
Expand Down
1 change: 1 addition & 0 deletions megalodon/src/pleroma/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace PleromaNotificationType {
export const PleromaEmojiReaction: PleromaEntity.NotificationType = 'pleroma:emoji_reaction'
export const FollowRequest: PleromaEntity.NotificationType = 'follow_request'
export const Update: PleromaEntity.NotificationType = 'update'
export const Move: PleromaEntity.NotificationType = 'move'
}

export default PleromaNotificationType
16 changes: 16 additions & 0 deletions megalodon/test/unit/pleroma/api_client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ describe('api_client', () => {
{
src: MegalodonNotificationType.FollowRequest,
dist: PleromaNotificationType.FollowRequest
},
{
src: MegalodonNotificationType.Update,
dist: PleromaNotificationType.Update
},
{
src: MegalodonNotificationType.Move,
dist: PleromaNotificationType.Move
}
]
cases.forEach(c => {
Expand Down Expand Up @@ -95,6 +103,14 @@ describe('api_client', () => {
{
src: PleromaNotificationType.FollowRequest,
dist: MegalodonNotificationType.FollowRequest
},
{
src: PleromaNotificationType.Update,
dist: MegalodonNotificationType.Update
},
{
src: PleromaNotificationType.Move,
dist: MegalodonNotificationType.Move
}
]
cases.forEach(c => {
Expand Down

0 comments on commit 03b15ae

Please sign in to comment.