v1.2.1-beta/functions admin change source
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "watch-party-crx",
|
"name": "watch-party-crx",
|
||||||
"version": "1.2.0",
|
"version": "1.2.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@giphy/js-fetch-api": "^1.5.8",
|
"@giphy/js-fetch-api": "^1.5.8",
|
||||||
|
|||||||
+26
-5
@@ -144,14 +144,14 @@ const joinRoom = async (req, res) => {
|
|||||||
err
|
err
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
const userExists = await admin
|
const [userExists, userAdmin] = await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection('rooms')
|
||||||
.doc(bodydata.roomId)
|
.doc(bodydata.roomId)
|
||||||
.collection('users')
|
.collection('users')
|
||||||
.doc(bodydata.uid)
|
.doc(bodydata.uid)
|
||||||
.get()
|
.get()
|
||||||
.then((userSnap) => userSnap.exists)
|
.then((userSnap) => [userSnap.exists, userSnap.exists ? userSnap.data().admin : false])
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(
|
console.error(
|
||||||
`Failed to get user when joining room : \n\t Room: ${bodydata.roomId} \n\t User: ${bodydata.uid}`,
|
`Failed to get user when joining room : \n\t Room: ${bodydata.roomId} \n\t User: ${bodydata.uid}`,
|
||||||
@@ -216,9 +216,30 @@ const joinRoom = async (req, res) => {
|
|||||||
res.status(200).send({ roomId: bodydata.roomId, message: 'Joined a party' });
|
res.status(200).send({ roomId: bodydata.roomId, message: 'Joined a party' });
|
||||||
} else if (!userExists && !bodydata.userName)
|
} else if (!userExists && !bodydata.userName)
|
||||||
res.status(400).send({ message: 'Missing user name' });
|
res.status(400).send({ message: 'Missing user name' });
|
||||||
else if (exists && roomSource !== bodydata.source)
|
else if (exists && roomSource !== bodydata.source) {
|
||||||
res.status(417).send({ message: `This party is on ${roomSource}` });
|
if (userAdmin === true) {
|
||||||
else res.status(404).send({ message: 'Party Not Found' });
|
await admin
|
||||||
|
.firestore()
|
||||||
|
.collection('rooms')
|
||||||
|
.doc(bodydata.roomId)
|
||||||
|
.update({
|
||||||
|
player: {
|
||||||
|
showName: null,
|
||||||
|
source: roomSource,
|
||||||
|
status: 'NOT_PLAYING',
|
||||||
|
time: 0,
|
||||||
|
updatedBy: bodydata.uid,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(
|
||||||
|
`Failed to update player source when admin joining party \n\t Room: ${roomId} \n\t User: ${bodydata.uid}`
|
||||||
|
);
|
||||||
|
res.status(500).send({ message: 'Unable to move party, please try again' });
|
||||||
|
});
|
||||||
|
res.status(200).send({ message: `Moved party to ${roomSource}` });
|
||||||
|
} else res.status(417).send({ message: `This party is on ${roomSource}` });
|
||||||
|
} else res.status(404).send({ message: 'Party Not Found' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendMessage = async (req, res) => {
|
const sendMessage = async (req, res) => {
|
||||||
|
|||||||
Generated
+3
-2
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "functions",
|
"name": "watchparty",
|
||||||
"requires": true,
|
"version": "1.0.0-beta",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/code-frame": {
|
"@babel/code-frame": {
|
||||||
"version": "7.8.3",
|
"version": "7.8.3",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "watchparty",
|
"name": "watch-party-api",
|
||||||
"version": "1.0.0-beta",
|
"version": "1.2.1",
|
||||||
"description": "Cloud Functions for Watch Party",
|
"description": "Cloud Functions for Watch Party",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
|
|||||||
Reference in New Issue
Block a user