Unwatch applies to email comment notifs too
This commit is contained in:
parent
26aba26da5
commit
74b6df2e44
|
@ -723,3 +723,17 @@ export const createLikeNotification = async (
|
||||||
}
|
}
|
||||||
return await notificationRef.set(removeUndefinedProps(notification))
|
return await notificationRef.set(removeUndefinedProps(notification))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function filterUserIdsForOnlyFollowerIds(
|
||||||
|
userIds: string[],
|
||||||
|
contractId: string
|
||||||
|
) {
|
||||||
|
// get contract follower documents and check here if they're a follower
|
||||||
|
const contractFollowersSnap = await firestore
|
||||||
|
.collection(`contracts/${contractId}/follows`)
|
||||||
|
.get()
|
||||||
|
const contractFollowersIds = contractFollowersSnap.docs.map(
|
||||||
|
(doc) => doc.data().id
|
||||||
|
)
|
||||||
|
return userIds.filter((id) => contractFollowersIds.includes(id))
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,10 @@ import { ContractComment } from '../../common/comment'
|
||||||
import { sendNewCommentEmail } from './emails'
|
import { sendNewCommentEmail } from './emails'
|
||||||
import { Bet } from '../../common/bet'
|
import { Bet } from '../../common/bet'
|
||||||
import { Answer } from '../../common/answer'
|
import { Answer } from '../../common/answer'
|
||||||
import { createCommentOrAnswerOrUpdatedContractNotification } from './create-notification'
|
import {
|
||||||
|
createCommentOrAnswerOrUpdatedContractNotification,
|
||||||
|
filterUserIdsForOnlyFollowerIds,
|
||||||
|
} from './create-notification'
|
||||||
import { parseMentions, richTextToString } from '../../common/util/parse'
|
import { parseMentions, richTextToString } from '../../common/util/parse'
|
||||||
import { addUserToContractFollowers } from './follow-market'
|
import { addUserToContractFollowers } from './follow-market'
|
||||||
|
|
||||||
|
@ -95,10 +98,13 @@ export const onCreateCommentOnContract = functions
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const recipientUserIds = uniq([
|
const recipientUserIds = await filterUserIdsForOnlyFollowerIds(
|
||||||
contract.creatorId,
|
uniq([
|
||||||
...comments.map((comment) => comment.userId),
|
contract.creatorId,
|
||||||
]).filter((id) => id !== comment.userId)
|
...comments.map((comment) => comment.userId),
|
||||||
|
]).filter((id) => id !== comment.userId),
|
||||||
|
contractId
|
||||||
|
)
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
recipientUserIds.map((userId) =>
|
recipientUserIds.map((userId) =>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user