timy-messenger/firebase/functions/message-update.js
Franz Heinfling 64d39ac266 Initial commit.
Co-authored-by: Miguel Beltran <m@beltran.work>
2019-10-01 17:26:36 +02:00

17 lines
587 B
JavaScript

const functions = require('firebase-functions');
const sendPushForNewReaction = require('./reaction-push');
const updatedMessages = functions
.region('europe-west1')
.firestore
.document('/groups/{groupId}/channels/{channelId}/messages/{messageId}')
.onUpdate(async (change, context) => {
const messageBefore = change.before.data();
const messageAfter = change.after.data();
const authorUid = messageAfter.author;
await sendPushForNewReaction(messageBefore, messageAfter, authorUid, context);
});
module.exports = updatedMessages;