add trigger for updated user
This commit is contained in:
parent
969cdcaa16
commit
60e41a7f79
18
functions/src/on-update-user.ts
Normal file
18
functions/src/on-update-user.ts
Normal 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() })
|
||||
})
|
Loading…
Reference in New Issue
Block a user