add trigger for updated user

This commit is contained in:
Ian Philips 2022-06-27 14:49:56 -05:00
parent 969cdcaa16
commit 60e41a7f79

View File

@ -0,0 +1,18 @@
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
import { User } from '../../common/user'
const firestore = admin.firestore()
export const onUpdateGroup = functions.firestore
.document('users/{userId}')
.onUpdate(async (change) => {
const prevUser = change.before.data() as User
const user = change.after.data() as User
// if they're updating their referredId, send the
await firestore
.collection('groups')
.doc(group.id)
.update({ mostRecentActivityTime: Date.now() })
})