v1.6.2/release

-website update
-dynamic showName and video element
-time update on playing
This commit is contained in:
2020-08-14 00:36:44 -04:00
parent 3c4fffe598
commit aaf2506f78
14 changed files with 582 additions and 338 deletions
+55 -26
View File
@@ -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) => {
adminOnly: bodydata.adminOnly,
})
.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,24 +68,47 @@ module.exports = async (req, res) => {
err
);
});
if (
bodydata.player &&
(bodydata.player.source === 'amazon.' || bodydata.player.source === 'hulu.')
) {
if (bodydata.player && bodydata.player.source === "amazon.") {
await admin
.firestore()
.collection('rooms')
.collection("rooms")
.doc(bodydata.partyName)
.collection('messages')
.collection("messages")
.add({
uid: '<system>',
name: '',
uid: "<system>",
name: "Update to V1.6.1",
endpoint: "https://get.chromewatchparty.com",
type: "interactive/link",
text: `If Watch Party doesn't work make sure you're on V1.6.1. Try removing and re-adding if an update option is not visible`,
time: new Date(),
})
.catch((err) => {
console.error(
`Failed to add amazon error message : \n\t Room: ${bodydata.partyName}`,
err
);
});
}
if (bodydata.player && bodydata.player.source === "hulu.") {
await admin
.firestore()
.collection("rooms")
.doc(bodydata.partyName)
.collection("messages")
.add({
uid: "<system>",
name: "",
text: `Watch Party may not work temporarily. An update is coming to fix this.`,
time: new Date(),
})
.catch((err) => {
console.error(`Failed to add amazon error message : \n\t Room: ${bodydata.partyName}`, err);
console.error(
`Failed to add amazon error message : \n\t Room: ${bodydata.partyName}`,
err
);
});
}
res.status(201).send({ roomId: bodydata.partyName, message: 'Started a party!' });
res
.status(201)
.send({ roomId: bodydata.partyName, message: "Started a party!" });
};