v1.6.0/v1.5.2 update msgs
This commit is contained in:
@@ -1,21 +1,27 @@
|
|||||||
const admin = require('firebase-admin');
|
const admin = require("firebase-admin");
|
||||||
|
|
||||||
module.exports = async (req, res) => {
|
module.exports = async (req, res) => {
|
||||||
const bodydata = JSON.parse(req.body);
|
const bodydata = JSON.parse(req.body);
|
||||||
console.log('Requested Create - UID - ', bodydata.uid);
|
console.log("Requested Create - UID - ", bodydata.uid);
|
||||||
if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' });
|
if (!bodydata.userName)
|
||||||
if (!bodydata.partyName) res.status(400).send({ message: 'Missing party name' });
|
res.status(400).send({ message: "Missing user name" });
|
||||||
if (!bodydata.partyPin) res.status(400).send({ message: 'Missing party pin' });
|
if (!bodydata.partyName)
|
||||||
|
res.status(400).send({ message: "Missing party name" });
|
||||||
|
if (!bodydata.partyPin)
|
||||||
|
res.status(400).send({ message: "Missing party pin" });
|
||||||
const roomNameTaken = await admin
|
const roomNameTaken = await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection("rooms")
|
||||||
.doc(bodydata.partyName.replace('/', '\\'))
|
.doc(bodydata.partyName.replace("/", "\\"))
|
||||||
.get()
|
.get()
|
||||||
.then((docSnap) => docSnap.exists);
|
.then((docSnap) => docSnap.exists);
|
||||||
if (roomNameTaken) return res.status(409).send({ message: 'That party name is already taken' });
|
if (roomNameTaken)
|
||||||
|
return res
|
||||||
|
.status(409)
|
||||||
|
.send({ message: "That party name is already taken" });
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection("rooms")
|
||||||
.doc(bodydata.partyName)
|
.doc(bodydata.partyName)
|
||||||
.set({
|
.set({
|
||||||
name: bodydata.partyName,
|
name: bodydata.partyName,
|
||||||
@@ -26,17 +32,17 @@ module.exports = async (req, res) => {
|
|||||||
adminUid: bodydata.uid,
|
adminUid: bodydata.uid,
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
res.status(500).send({ message: 'Unable to start party.' });
|
res.status(500).send({ message: "Unable to start party." });
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection("rooms")
|
||||||
.doc(bodydata.partyName)
|
.doc(bodydata.partyName)
|
||||||
.collection('messages')
|
.collection("messages")
|
||||||
.add({
|
.add({
|
||||||
uid: '<system>',
|
uid: "<system>",
|
||||||
name: '',
|
name: "",
|
||||||
text: `${bodydata.userName} started the party.`,
|
text: `${bodydata.userName} started the party.`,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
})
|
})
|
||||||
@@ -48,9 +54,9 @@ module.exports = async (req, res) => {
|
|||||||
});
|
});
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection("rooms")
|
||||||
.doc(bodydata.partyName)
|
.doc(bodydata.partyName)
|
||||||
.collection('users')
|
.collection("users")
|
||||||
.doc(bodydata.uid)
|
.doc(bodydata.uid)
|
||||||
.set({
|
.set({
|
||||||
admin: true,
|
admin: true,
|
||||||
@@ -62,21 +68,34 @@ module.exports = async (req, res) => {
|
|||||||
err
|
err
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
res.status(201).send({ roomId: bodydata.partyName, message: 'Started a party!' });
|
|
||||||
|
|
||||||
admin.firestore().collection('rooms').doc(bodydata.partyName).collection('messages').add({
|
admin
|
||||||
uid: '<system>',
|
.firestore()
|
||||||
name: '',
|
.collection("rooms")
|
||||||
|
.doc(bodydata.partyName)
|
||||||
|
.collection("messages")
|
||||||
|
.add({
|
||||||
|
uid: "<system>",
|
||||||
|
name: "",
|
||||||
text: `Big update coming on Monday (Aug. 10). Watch Party will be unavailable during the afternoon as we upgrade our services. See what's new at whatsnew.chromewatchparty.com`,
|
text: `Big update coming on Monday (Aug. 10). Watch Party will be unavailable during the afternoon as we upgrade our services. See what's new at whatsnew.chromewatchparty.com`,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (player.source === 'peacocktv.') {
|
if (player.source === "peacocktv.") {
|
||||||
admin.firestore().collection('rooms').doc(bodydata.partyName).collection('messages').add({
|
admin
|
||||||
uid: '<system>',
|
.firestore()
|
||||||
name: '',
|
.collection("rooms")
|
||||||
|
.doc(bodydata.partyName)
|
||||||
|
.collection("messages")
|
||||||
|
.add({
|
||||||
|
uid: "<system>",
|
||||||
|
name: "",
|
||||||
text: `Sync may not work flawlessly with PeacockTV till Monday's update. Please stick with us as we address this issue.`,
|
text: `Sync may not work flawlessly with PeacockTV till Monday's update. Please stick with us as we address this issue.`,
|
||||||
time: new Date(),
|
time: new Date(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
res
|
||||||
|
.status(201)
|
||||||
|
.send({ roomId: bodydata.partyName, message: "Started a party!" });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user