Merge follow-up replies with normal replies (#2027)
This commit is contained in:
parent
e29c6b4842
commit
de7f96a3a4
@ -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'
|
||||
|
@ -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') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user