add move notification type

This commit is contained in:
Johann150 2022-05-20 09:28:57 +02:00
parent 1ffa4b08e0
commit 9174d633d4
Signed by: Johann150
GPG key ID: 9EE6577A2A06F8F1
5 changed files with 38 additions and 14 deletions

View file

@ -1290,6 +1290,7 @@ _notification:
yourFollowRequestAccepted: "Your follow request was accepted" yourFollowRequestAccepted: "Your follow request was accepted"
youWereInvitedToGroup: "{userName} invited you to a group" youWereInvitedToGroup: "{userName} invited you to a group"
pollEnded: "Poll results have become available" pollEnded: "Poll results have become available"
moved: "{name} has moved to a different account"
emptyPushNotificationMessage: "Push notifications have been updated" emptyPushNotificationMessage: "Push notifications have been updated"
_types: _types:
follow: "New followers" follow: "New followers"
@ -1303,6 +1304,7 @@ _notification:
receiveFollowRequest: "Received follow requests" receiveFollowRequest: "Received follow requests"
followRequestAccepted: "Accepted follow requests" followRequestAccepted: "Accepted follow requests"
groupInvited: "Group invitations" groupInvited: "Group invitations"
move: "Others moving accounts"
app: "Notifications from linked apps" app: "Notifications from linked apps"
_actions: _actions:
followBack: "followed you back" followBack: "followed you back"

View file

@ -52,19 +52,20 @@ export class Notification {
public notifier: User | null; public notifier: User | null;
/** /**
* * Type of notification.
* follow - * follow - notifier followed notifiee
* mention - 稿 * mention - notifiee was mentioned
* reply - (Watchしている)稿 * reply - notifiee (author or watching) was replied to
* renote - (Watchしている)稿Renoteされた * renote - notifiee (author or watching) was renoted
* quote - (Watchしている)稿Renoteされた * quote - notifiee (author or watching) was quoted
* reaction - (Watchしている)稿 * reaction - notifiee (author or watching) had a reaction added to the note
* pollVote - (Watchしている)稿 * pollVote - new vote in a poll notifiee authored or watched
* pollEnded - * pollEnded - notifiee's poll ended
* receiveFollowRequest - * receiveFollowRequest - notifiee received a new follow request
* followRequestAccepted - * followRequestAccepted - notifier accepted notifees follow request
* groupInvited - * groupInvited - notifiee was invited into a group
* app - * move - notifier moved
* app - custom application notification
*/ */
@Index() @Index()
@Column('enum', { @Column('enum', {
@ -129,6 +130,19 @@ export class Notification {
}) })
public choice: number | null; public choice: number | null;
@Column({
...id(),
nullable: true,
comment: 'The ID of the moved to account.',
})
public moveTargetId: User['id'] | null;
@ManyToOne(() => User, {
onDelete: 'CASCADE',
})
@JoinColumn()
public moveTarget: User | null;
/** /**
* body * body
*/ */

View file

@ -44,6 +44,9 @@ export const NotificationRepository = db.getRepository(Notification).extend({
...(notification.type === 'groupInvited' ? { ...(notification.type === 'groupInvited' ? {
invitation: UserGroupInvitations.pack(notification.userGroupInvitationId!), invitation: UserGroupInvitations.pack(notification.userGroupInvitationId!),
} : {}), } : {}),
...(notification.type === 'move' ? {
moveTarget: Users.pack(notification.moveTarget ?? notification.moveTargetId),
} : {}),
...(notification.type === 'app' ? { ...(notification.type === 'app' ? {
body: notification.customBody, body: notification.customBody,
header: notification.customHeader || token?.name, header: notification.customHeader || token?.name,

View file

@ -1,4 +1,4 @@
export const notificationTypes = ['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app'] as const; export const notificationTypes = ['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'move', 'app'] as const;
export const noteNotificationTypes = ['mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded'] as const; export const noteNotificationTypes = ['mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded'] as const;

View file

@ -223,6 +223,11 @@ export type Notification = {
invitation: UserGroup; invitation: UserGroup;
user: User; user: User;
userId: User['id']; userId: User['id'];
} | {
type: 'move',
user: User;
userId: User['id'];
moveTarget: User;
} | { } | {
type: 'app'; type: 'app';
header?: string | null; header?: string | null;