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) => {
|
||||
const bodydata = JSON.parse(req.body);
|
||||
console.log('Requested Create - UID - ', bodydata.uid);
|
||||
if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' });
|
||||
if (!bodydata.partyName) res.status(400).send({ message: 'Missing party name' });
|
||||
if (!bodydata.partyPin) res.status(400).send({ message: 'Missing party pin' });
|
||||
console.log("Requested Create - UID - ", bodydata.uid);
|
||||
if (!bodydata.userName)
|
||||
res.status(400).send({ message: "Missing user name" });
|
||||
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
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.doc(bodydata.partyName.replace('/', '\\'))
|
||||
.collection("rooms")
|
||||
.doc(bodydata.partyName.replace("/", "\\"))
|
||||
.get()
|
||||
.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
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.collection("rooms")
|
||||
.doc(bodydata.partyName)
|
||||
.set({
|
||||
name: bodydata.partyName,
|
||||
@@ -26,17 +32,17 @@ module.exports = async (req, res) => {
|
||||
adminUid: bodydata.uid,
|
||||
})
|
||||
.catch((err) => {
|
||||
res.status(500).send({ message: 'Unable to start party.' });
|
||||
res.status(500).send({ message: "Unable to start party." });
|
||||
console.error(err);
|
||||
});
|
||||
await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.collection("rooms")
|
||||
.doc(bodydata.partyName)
|
||||
.collection('messages')
|
||||
.collection("messages")
|
||||
.add({
|
||||
uid: '<system>',
|
||||
name: '',
|
||||
uid: "<system>",
|
||||
name: "",
|
||||
text: `${bodydata.userName} started the party.`,
|
||||
time: new Date(),
|
||||
})
|
||||
@@ -48,9 +54,9 @@ module.exports = async (req, res) => {
|
||||
});
|
||||
await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.collection("rooms")
|
||||
.doc(bodydata.partyName)
|
||||
.collection('users')
|
||||
.collection("users")
|
||||
.doc(bodydata.uid)
|
||||
.set({
|
||||
admin: true,
|
||||
@@ -62,21 +68,34 @@ module.exports = async (req, res) => {
|
||||
err
|
||||
);
|
||||
});
|
||||
res.status(201).send({ roomId: bodydata.partyName, message: 'Started a party!' });
|
||||
|
||||
admin.firestore().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`,
|
||||
time: new Date(),
|
||||
});
|
||||
|
||||
if (player.source === 'peacocktv.') {
|
||||
admin.firestore().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.`,
|
||||
admin
|
||||
.firestore()
|
||||
.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`,
|
||||
time: new Date(),
|
||||
});
|
||||
|
||||
if (player.source === "peacocktv.") {
|
||||
admin
|
||||
.firestore()
|
||||
.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.`,
|
||||
time: new Date(),
|
||||
});
|
||||
}
|
||||
|
||||
res
|
||||
.status(201)
|
||||
.send({ roomId: bodydata.partyName, message: "Started a party!" });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user