From 5930d7141dc2eccaab135319cfe0289efff035fc Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Wed, 23 Oct 2024 21:07:11 +0000 Subject: [PATCH 1/2] send dotless uuids in payloads --- desci-server/src/services/NotificationService.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/desci-server/src/services/NotificationService.ts b/desci-server/src/services/NotificationService.ts index 8661dddc..6d2931ff 100644 --- a/desci-server/src/services/NotificationService.ts +++ b/desci-server/src/services/NotificationService.ts @@ -250,26 +250,29 @@ export const emitNotificationForAnnotation = async (annotationId: number) => { return; } + const dotlessUuid = node.uuid.replace(/\./g, ''); + const notificationData: CreateNotificationData = { userId: nodeOwner.id, type: NotificationType.COMMENTS, title: `${annotationAuthor?.name} commented on your research object`, message: `Your research object titled ${node.title}, has received a new comment.`, // TODO:: Ideally deserialize some of the message body from the annotation and show a truncated snippet nodeUuid: node.uuid, - payload: { type: NotificationType.COMMENTS, nodeUuid: node.uuid, annotationId } as CommentPayload, + payload: { type: NotificationType.COMMENTS, nodeUuid: dotlessUuid, annotationId } as CommentPayload, }; await createUserNotification(notificationData); }; // export const emitNotificationOnPublish = async (node: Node, user: User, dpid: string) => { + const dotlessUuid = node.uuid.replace(/\./g, ''); const notificationData: CreateNotificationData = { userId: user.id, type: NotificationType.PUBLISH, title: `Your research object has been published!`, message: `Your research object titled "${node.title}" has been published and is now available for public access.`, nodeUuid: node.uuid, - payload: { type: NotificationType.PUBLISH, nodeUuid: node.uuid, dpid } as PublishPayload, + payload: { type: NotificationType.PUBLISH, nodeUuid: dotlessUuid, dpid } as PublishPayload, }; await createUserNotification(notificationData); From 622f51c7528fd934a292de502cc2a79c694df66e Mon Sep 17 00:00:00 2001 From: kadami <86646883+kadamidev@users.noreply.github.com> Date: Wed, 23 Oct 2024 21:08:18 +0000 Subject: [PATCH 2/2] placeholder user name if null --- desci-server/src/services/NotificationService.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desci-server/src/services/NotificationService.ts b/desci-server/src/services/NotificationService.ts index 6d2931ff..10044d3a 100644 --- a/desci-server/src/services/NotificationService.ts +++ b/desci-server/src/services/NotificationService.ts @@ -242,6 +242,7 @@ export const emitNotificationForAnnotation = async (annotationId: number) => { } const annotationAuthor = annotation.author; + const annotationAuthorName = annotationAuthor?.name || 'A user'; const node = annotation.node || annotation.attestation?.node; const nodeOwner = node?.owner; @@ -255,7 +256,7 @@ export const emitNotificationForAnnotation = async (annotationId: number) => { const notificationData: CreateNotificationData = { userId: nodeOwner.id, type: NotificationType.COMMENTS, - title: `${annotationAuthor?.name} commented on your research object`, + title: `${annotationAuthorName} commented on your research object`, message: `Your research object titled ${node.title}, has received a new comment.`, // TODO:: Ideally deserialize some of the message body from the annotation and show a truncated snippet nodeUuid: node.uuid, payload: { type: NotificationType.COMMENTS, nodeUuid: dotlessUuid, annotationId } as CommentPayload,