Fix duplicate push notification as reply and subscription (#1392)
This commit is contained in:
parent
0bf9fb0780
commit
0e0fe1af69
|
@ -227,7 +227,7 @@ export async function onPaid ({ invoice, id }, context) {
|
|||
for (const { refereeItem } of item.itemReferrers) {
|
||||
notifyItemMention({ models, referrerItem: item, refereeItem }).catch(console.error)
|
||||
}
|
||||
notifyUserSubscribers({ models, item }).catch(console.error)
|
||||
notifyUserSubscribers({ models: tx, item }).catch(console.error)
|
||||
notifyTerritorySubscribers({ models, item }).catch(console.error)
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,15 @@ export const notifyUserSubscribers = async ({ models, item }) => {
|
|||
INNER JOIN users ON users.id = "UserSubscription"."followeeId"
|
||||
WHERE "followeeId" = $1 AND ${isPost ? '"postsSubscribedAt"' : '"commentsSubscribedAt"'} IS NOT NULL
|
||||
AND NOT EXISTS (SELECT 1 FROM "Mute" WHERE "Mute"."muterId" = "UserSubscription"."followerId" AND "Mute"."mutedId" = $1)
|
||||
`, Number(item.userId))
|
||||
-- ignore subscription if user was already notified of item as a reply
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM "Reply"
|
||||
INNER JOIN users follower ON follower.id = "UserSubscription"."followerId"
|
||||
WHERE "Reply"."itemId" = $2
|
||||
AND "Reply"."ancestorUserId" = follower.id
|
||||
AND follower."noteAllDescendants"
|
||||
)
|
||||
`, Number(item.userId), Number(item.id))
|
||||
const subType = isPost ? 'POST' : 'COMMENT'
|
||||
const tag = `FOLLOW-${item.userId}-${subType}`
|
||||
await Promise.allSettled(userSubsExcludingMutes.map(({ followerId, followeeName }) => sendUserNotification(followerId, {
|
||||
|
|
Loading…
Reference in New Issue