This commit is contained in:
Ian Philips 2022-07-05 17:12:57 -06:00
parent 4c9842291d
commit e1847da9c7

View File

@ -13,24 +13,25 @@ export const onCreateCommentOnGroup = functions.firestore
const { groupId } = context.params as {
groupId: string
}
const comment = change.data() as Comment
const creatorSnapshot = await firestore
.collection('users')
.doc(comment.userId)
.get()
if (!creatorSnapshot.exists) throw new Error('Could not find user')
// find members of group
// send them a notification with a custom isSeenOnHref set to the group's /group/slug
const groupSnapshot = await firestore
.collection('groups')
.doc(groupId)
.get()
if (!groupSnapshot.exists) throw new Error('Could not find group')
const group = groupSnapshot.data() as Group
// update group's most recent activity
await firestore.collection('groups').doc(groupId).update({
mostRecentActivityTime: comment.createdTime,
})
await Promise.all(
group.memberIds.map(async (memberId) => {
return await createNotification(