From cce6b50c8b36c904d2f0af77fd86d9c8ad39ac6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 26 Jul 2023 10:31:24 +0200 Subject: [PATCH] Set 'only' in test and cosole.log's for it --- .../notifications/notificationsMiddleware.spec.ts | 2 +- .../notifications/notificationsMiddleware.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/src/middleware/notifications/notificationsMiddleware.spec.ts b/backend/src/middleware/notifications/notificationsMiddleware.spec.ts index 114caaf7c..d8454647f 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.spec.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.spec.ts @@ -501,7 +501,7 @@ describe('notifications', () => { ) }) - it('sends only one notification with reason mentioned_in_comment', async () => { + it.only('sends only one notification with reason mentioned_in_comment', async () => { postAuthor = await neode.create( 'User', { diff --git a/backend/src/middleware/notifications/notificationsMiddleware.ts b/backend/src/middleware/notifications/notificationsMiddleware.ts index 0e8aa40b4..e5608a4d7 100644 --- a/backend/src/middleware/notifications/notificationsMiddleware.ts +++ b/backend/src/middleware/notifications/notificationsMiddleware.ts @@ -53,6 +53,10 @@ const publishNotifications = async (context, promises) => { } const notifyPublishUsersOfMentionInclAll = async (label, id, idsOfUsers, reason, context) => { + console.log('notifyPublishUsersOfMentionInclAll – idsOfUsers: ', label) + console.log('notifyPublishUsersOfMentionInclAll – idsOfUsers: ', id) + console.log('notifyPublishUsersOfMentionInclAll – idsOfUsers: ', idsOfUsers) + console.log('notifyPublishUsersOfMentionInclAll – idsOfUsers: ', reason) if (idsOfUsers.find((id) => id === 'all')) { if (context.user.role !== 'admin') throw new AuthenticationError('You are not allowed to use the "@all" mention!') @@ -74,7 +78,8 @@ const notifyPublishUsersOfMentionInclAll = async (label, id, idsOfUsers, reason, } } } else { - // Wolle console.log('notifyPublishUsersOfMentionInclAll – no all') + // Wolle + console.log('notifyPublishUsersOfMentionInclAll – no all – idsOfUsers: ', idsOfUsers) await publishNotifications(context, [ notifyUsersOfMention(label, id, idsOfUsers, reason, context), ]) @@ -145,10 +150,14 @@ const handleContentDataOfComment = async (resolve, root, args, context, resolveI let idsOfUsers = await extractMentionedUsers(content) const comment = await resolve(root, args, context, resolveInfo) const [postAuthor] = await postAuthorOfComment(comment.id, { context }) + console.log('handleContentDataOfComment – before filter – postAuthor.id: ', postAuthor.id) + console.log('handleContentDataOfComment – before filter – idsOfUsers: ', idsOfUsers) idsOfUsers = idsOfUsers.filter((id) => id !== postAuthor.id) + console.log('handleContentDataOfComment – after filter – idsOfUsers: ', idsOfUsers) await publishNotifications(context, [ notifyUsersOfComment('Comment', comment.id, postAuthor.id, 'commented_on_post', context), ]) + console.log('handleContentDataOfComment – after notifyUsersOfComment – idsOfUsers: ', idsOfUsers) await notifyPublishUsersOfMentionInclAll( 'Comment', comment.id,