From de7f96a3a4b7db3aec8766df7e15eb60e8949e1c Mon Sep 17 00:00:00 2001 From: ekzyis Date: Wed, 26 Mar 2025 11:00:04 -0500 Subject: [PATCH] Merge follow-up replies with normal replies (#2027) --- lib/webPush.js | 7 ++++++- sw/eventListener.js | 4 +--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/webPush.js b/lib/webPush.js index 9f0b8acc..b3d9a078 100644 --- a/lib/webPush.js +++ b/lib/webPush.js @@ -99,6 +99,11 @@ async function sendUserNotification (userId, notification) { delete notification.item } const userFilter = createUserFilter(notification.tag) + + // XXX we only want to use the tag to filter follow-up replies by user settings + // but still merge them with normal replies + if (notification.tag === 'THREAD') notification.tag = 'REPLY' + const payload = createPayload(notification) const subscriptions = await models.pushSubscription.findMany({ where: { userId, ...userFilter } @@ -250,7 +255,7 @@ export const notifyItemParents = async ({ models, item }) => { Promise.allSettled( parents.map(({ userId, isDirect }) => { return sendUserNotification(userId, { - title: `@${user.name} ${isDirect ? 'replied to you' : 'replied to someone that replied to you'}`, + title: `@${user.name} replied to you`, body: item.text, item, tag: isDirect ? 'REPLY' : 'THREAD' diff --git a/sw/eventListener.js b/sw/eventListener.js index 84641bce..fcec05be 100644 --- a/sw/eventListener.js +++ b/sw/eventListener.js @@ -91,7 +91,7 @@ const mergeNotification = (event, sw, payload, currentNotifications, tag, nid) = // merge notifications into single notification payload // --- // tags that need to know the amount of notifications with same tag for merging - const AMOUNT_TAGS = ['REPLY', 'THREAD', 'MENTION', 'ITEM_MENTION', 'REFERRAL', 'INVITE', 'FOLLOW', 'TERRITORY_POST'] + const AMOUNT_TAGS = ['REPLY', 'MENTION', 'ITEM_MENTION', 'REFERRAL', 'INVITE', 'FOLLOW', 'TERRITORY_POST'] // tags that need to know the sum of sats of notifications with same tag for merging const SUM_SATS_TAGS = ['DEPOSIT', 'WITHDRAWAL'] // this should reflect the amount of notifications that were already merged before @@ -116,8 +116,6 @@ const mergeNotification = (event, sw, payload, currentNotifications, tag, nid) = if (AMOUNT_TAGS.includes(compareTag)) { if (compareTag === 'REPLY') { title = `you have ${amount} new replies` - } else if (compareTag === 'THREAD') { - title = `you have ${amount} new follow-up replies` } else if (compareTag === 'MENTION') { title = `you were mentioned ${amount} times` } else if (compareTag === 'ITEM_MENTION') {