Separate email and browser ids list

This commit is contained in:
Ian Philips 2022-09-12 11:00:24 -06:00
parent 4f19220778
commit 3cb36a36ec

View File

@ -222,7 +222,8 @@ export const createCommentOrAnswerOrUpdatedContractNotification = async (
repliedToId,
} = miscData ?? {}
const recipientIdsList: string[] = []
const browserRecipientIdsList: string[] = []
const emailRecipientIdsList: string[] = []
const contractFollowersSnap = await firestore
.collection(`contracts/${sourceContract.id}/follows`)
@ -271,8 +272,7 @@ export const createCommentOrAnswerOrUpdatedContractNotification = async (
) => {
if (
!stillFollowingContract(sourceContract.creatorId) ||
sourceUser.id == userId ||
recipientIdsList.includes(userId)
sourceUser.id == userId
)
return
const privateUser = await getPrivateUser(userId)
@ -282,11 +282,11 @@ export const createCommentOrAnswerOrUpdatedContractNotification = async (
reason
)
if (sendToBrowser) {
if (sendToBrowser && !browserRecipientIdsList.includes(userId)) {
await createBrowserNotification(userId, reason)
recipientIdsList.push(userId)
browserRecipientIdsList.push(userId)
}
if (sendToEmail) {
if (sendToEmail && !emailRecipientIdsList.includes(userId)) {
if (sourceType === 'comment') {
// TODO: change subject of email title to be more specific, i.e.: replied to you on/tagged you on/comment
await sendNewCommentEmail(
@ -327,7 +327,7 @@ export const createCommentOrAnswerOrUpdatedContractNotification = async (
resolutionData.resolutionProbability,
resolutionData.resolutions
)
recipientIdsList.push(userId)
emailRecipientIdsList.push(userId)
}
}