fix(notifications): handle user mentioned notification
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kolaente 2024-12-11 19:12:52 +01:00
parent b3c93ae811
commit b3040b8466
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 17 additions and 6 deletions

View File

@ -159,6 +159,7 @@ function to(n, index) {
case names.TASK_COMMENT:
case names.TASK_ASSIGNED:
case names.TASK_REMINDER:
case names.TASK_MENTIONED:
to.name = 'task.detail'
to.params.id = n.notification.task.id
break

View File

@ -12,25 +12,27 @@ export const NOTIFICATION_NAMES = {
'TASK_REMINDER': 'task.reminder',
'PROJECT_CREATED': 'project.created',
'TEAM_MEMBER_ADDED': 'team.member.added',
'TASK_MENTIONED': 'task.mentioned',
} as const
interface Notification {
doer: IUser
}
interface NotificationTask extends Notification {
interface NotificationTaskComment extends Notification {
task: ITask
comment: ITaskComment
}
interface NotificationTask extends Notification {
task: ITask
}
interface NotificationAssigned extends Notification {
task: ITask
assignee: IUser
}
interface NotificationDeleted extends Notification {
task: ITask
}
interface NotificationCreated extends Notification {
task: ITask
project: IProject
@ -49,7 +51,7 @@ interface NotificationMemberAdded extends Notification {
export interface INotification extends IAbstract {
id: number
name: string
notification: NotificationTask | NotificationAssigned | NotificationDeleted | NotificationCreated | NotificationMemberAdded | NotificationTaskReminder
notification: NotificationTaskComment | NotificationTask | NotificationAssigned | NotificationCreated | NotificationMemberAdded | NotificationTaskReminder
read: boolean
readAt: Date | null

View File

@ -62,6 +62,12 @@ export default class NotificationModel extends AbstractModel<INotification> impl
project: new ProjectModel(this.notification.project),
}
break
case NOTIFICATION_NAMES.TASK_MENTIONED:
this.notification = {
doer: new UserModel(this.notification.doer),
task: new TaskModel(this.notification.task),
}
break
}
this.created = new Date(this.created)
@ -96,6 +102,8 @@ export default class NotificationModel extends AbstractModel<INotification> impl
return `added ${who} to the ${this.notification.team.name} team`
case NOTIFICATION_NAMES.TASK_REMINDER:
return `Reminder for ${this.notification.task.getTextIdentifier()} ${this.notification.task.title} (${this.notification.project.title})`
case NOTIFICATION_NAMES.TASK_MENTIONED:
return `${getDisplayName(this.notification.doer)} mentioned you on ${this.notification.task.getTextIdentifier()}`
}
return ''