v1.7.0/start of video call
- remove user check updatePlayer api
This commit is contained in:
@@ -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' });
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user