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

21 lines
No EOL
558 B
JavaScript

const { db } = require('./admin');
/**
* Sets `updatedAt` for channel to last activity's timestamp.
*/
const updateLatestActivityForChannel = async (groupId, channelId, activityDate) => {
try {
await db
.collection("/groups/")
.doc(groupId)
.collection("/channels/")
.doc(channelId).update({
updatedAt: activityDate
})
} catch (error) {
console.error("Error updating channel timestamp: ", error);
}
}
module.exports = updateLatestActivityForChannel;