v1.7.0/start of video call

- remove user check updatePlayer api
This commit is contained in:
2020-09-05 11:21:20 -04:00
parent 1c8930cc2a
commit 201283fc8f
6 changed files with 106 additions and 61 deletions
+24 -36
View File
@@ -10,47 +10,35 @@ module.exports = async (req, res) => {
.get()
.then((docSnap) => [docSnap.exists, docSnap.data()]);
if (!roomExists) return res.status(404).send({ message: 'Party not found.' });
const userExists = await admin
.firestore()
.collection('rooms')
.doc(roomId)
.collection('users')
.doc(uid)
.get()
.then((userSnap) => userSnap.exists);
if (userExists) {
if (showChanged === true && player.showName) {
if (roomData.player.showName !== player.showName) {
await admin
.firestore()
.collection('rooms')
.doc(roomId)
.collection('messages')
.add({
uid: '<system>',
name: '',
text: `${userName} changed \n${player.showName ? 'to ' + player.showName : ''}`,
time: new Date(),
});
}
}
if (roomData.status !== player.status) {
await admin
if (showChanged === true && player.showName) {
if (roomData.player.showName !== player.showName) {
admin
.firestore()
.collection('rooms')
.doc(roomId)
.update({
player,
})
.catch((err) => {
console.error(`Failed to update player : \n\t Room: ${roomId} \n\t ${uid}`, err);
res.status(500).send({ message: "Uh oh party could't be synced", err });
.collection('messages')
.add({
uid: '<system>',
name: '',
text: `${userName} changed \n${player.showName ? 'to ' + player.showName : ''}`,
time: new Date(),
});
return res.status(200).send({ message: 'Synced party player' });
} else {
return res.status(208).send({ message: 'Player already up to date' });
}
}
if (roomData.status !== player.status) {
await admin
.firestore()
.collection('rooms')
.doc(roomId)
.update({
player,
})
.catch((err) => {
console.error(`Failed to update player : \n\t Room: ${roomId} \n\t ${uid}`, err);
res.status(500).send({ message: "Uh oh party could't be synced", err });
});
return res.status(200).send({ message: 'Synced party player' });
} else {
return res.status(401).send({ message: 'Not in room to sync' });
return res.status(208).send({ message: 'Player already up to date' });
}
};