v1.6.2/mass message, filters
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
const superAuth = require('./superAuth');
|
||||
const partyDashboard = require('./partyDashboard');
|
||||
const serverDashboard = require('./serverDashboard');
|
||||
const updateVersionActive = require('./updateVersionActive');
|
||||
const updateVideoSelectors = require('./updateVideoSelectors');
|
||||
const superAuth = require("./superAuth");
|
||||
const partyDashboard = require("./partyDashboard");
|
||||
const serverDashboard = require("./serverDashboard");
|
||||
const updateVersionActive = require("./updateVersionActive");
|
||||
const updateVideoSelectors = require("./updateVideoSelectors");
|
||||
const updateVideoNameSelectors = require("./updateVideoNameSelectors");
|
||||
const sendMessage = require("./sendMessage");
|
||||
|
||||
module.exports = {
|
||||
sendMessage,
|
||||
updateVideoNameSelectors,
|
||||
updateVideoSelectors,
|
||||
updateVersionActive,
|
||||
serverDashboard,
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/* eslint-disable promise/no-nesting */
|
||||
const admin = require('firebase-admin');
|
||||
const Logger = require('../Logger');
|
||||
const mLogger = new Logger('admin', 'partyDashboard');
|
||||
const admin = require("firebase-admin");
|
||||
const Logger = require("../Logger");
|
||||
const mLogger = new Logger("admin", "partyDashboard");
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
mLogger.start();
|
||||
|
||||
var partyData = await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.collection("rooms")
|
||||
.get()
|
||||
.then((roomSnapshot) => {
|
||||
const docData = [];
|
||||
@@ -18,38 +18,43 @@ module.exports = async (req, res) => {
|
||||
createTime: doc.createTime.toDate().toUTCString(),
|
||||
updateTime: doc.updateTime.toDate().toUTCString(),
|
||||
source: doc.data().player.source,
|
||||
onCall: doc.data().hasOwnProperty('conference'),
|
||||
showName: doc.data().player.showName || '',
|
||||
onCall: doc.data().hasOwnProperty("conference"),
|
||||
showName: doc.data().player.showName || "",
|
||||
time: doc.data().player.time || 0,
|
||||
status: doc.data().player.status || '',
|
||||
status: doc.data().player.status || "",
|
||||
});
|
||||
});
|
||||
return docData;
|
||||
})
|
||||
.catch((err) => {
|
||||
mLogger.error('FAILED TO RESOLVE PARTIES', err);
|
||||
res.status(500).send({ message: 'Unable to get all parties', error: err });
|
||||
mLogger.error("FAILED TO RESOLVE PARTIES", err);
|
||||
res
|
||||
.status(500)
|
||||
.send({ message: "Unable to get all parties", error: err });
|
||||
});
|
||||
|
||||
await partyData.forEach((party) => {
|
||||
const messageCount = admin
|
||||
const p = await partyData.map(async (party) => {
|
||||
const messageCount = await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.collection("rooms")
|
||||
.doc(party.id)
|
||||
.collection('messages')
|
||||
.collection("messages")
|
||||
.get()
|
||||
.then((snap) => snap.size);
|
||||
const userCount = admin
|
||||
const userCount = await admin
|
||||
.firestore()
|
||||
.collection('rooms')
|
||||
.collection("rooms")
|
||||
.doc(party.id)
|
||||
.collection('users')
|
||||
.collection("users")
|
||||
.get()
|
||||
.then((snap) => snap.size);
|
||||
party.messageCount = messageCount || 0;
|
||||
party.userCount = userCount || 0;
|
||||
return party;
|
||||
});
|
||||
|
||||
mLogger.success('GOT ALL PARTIES', { parties: partyData.length });
|
||||
return res.status(200).send({ partyData });
|
||||
return Promise.all(p).then((v) => {
|
||||
mLogger.success("GOT ALL PARTIES", { parties: partyData.length });
|
||||
return res.status(200).send({ partyData });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
const admin = require("firebase-admin");
|
||||
const Logger = require("../Logger");
|
||||
const mLogger = new Logger("admin", "sendMessage");
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
mLogger.start();
|
||||
const { selectedParties, newMessage } = JSON.parse(req.body);
|
||||
if (selectedParties && newMessage && selectedParties.length > 0) {
|
||||
if (newMessage.text && newMessage.time && newMessage.uid) {
|
||||
newMessage.time = new Date();
|
||||
await selectedParties.map(async (partyId) => {
|
||||
await admin
|
||||
.firestore()
|
||||
.collection("rooms")
|
||||
.doc(partyId)
|
||||
.collection("messages")
|
||||
.add(newMessage)
|
||||
.catch((err) => {
|
||||
mLogger.error("FAILED TO SEND MESSAGE", { partyId, err });
|
||||
});
|
||||
});
|
||||
mLogger.success("SENT MESSAGES", { newMessage, selectedParties });
|
||||
res.status(200).send({ message: "SENT MESSAGES" });
|
||||
} else {
|
||||
mLogger.error("MESSAGE NOT VALID");
|
||||
res.status(500).send({ message: "Message is missing fields" });
|
||||
}
|
||||
} else {
|
||||
mLogger.error("VALUES NOT RECEIVED");
|
||||
res.status(500).send({ message: "Values not received" });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
const admin = require("firebase-admin");
|
||||
const Logger = require("../Logger");
|
||||
const mLogger = new Logger("admin", "updateVideoNameSelectors");
|
||||
|
||||
module.exports = async (req, res) => {
|
||||
mLogger.start();
|
||||
const { nameSelectors } = JSON.parse(req.body);
|
||||
if (nameSelectors) {
|
||||
await admin
|
||||
.firestore()
|
||||
.collection("server")
|
||||
.doc("status")
|
||||
.update({
|
||||
nameSelectors,
|
||||
})
|
||||
.catch((err) => {
|
||||
mLogger.error("FAILED TO UPDATE", err);
|
||||
res.status(500).send({ message: "FAILED TO UPDATE", error: err });
|
||||
});
|
||||
mLogger.success("UPDATED NAME SELECTORS");
|
||||
res.status(200).send({ message: "Updated video name selectors" });
|
||||
} else {
|
||||
mLogger.error("VALUES NOT RECEIVED");
|
||||
res.status(500).send({ message: "Values not received" });
|
||||
}
|
||||
};
|
||||
+30
-24
@@ -1,40 +1,46 @@
|
||||
const FunctionModules = require('./modules/index');
|
||||
const Webhooks = require('./webhooks/index');
|
||||
const AdminModules = require('./admin/index');
|
||||
const express = require('express');
|
||||
const cors = require('cors');
|
||||
const FunctionModules = require("./modules/index");
|
||||
const Webhooks = require("./webhooks/index");
|
||||
const AdminModules = require("./admin/index");
|
||||
const express = require("express");
|
||||
const cors = require("cors");
|
||||
|
||||
// WEBHOOKS
|
||||
const webhooks = express();
|
||||
webhooks.use(cors({ origin: true }));
|
||||
webhooks.all('/conferenceEnded', Webhooks.conferenceEnd);
|
||||
webhooks.all('/scheduledCleanup', Webhooks.scheduledCleanUp);
|
||||
webhooks.all('/ask', Webhooks.ask);
|
||||
webhooks.all('/userCleanUp', Webhooks.userCleanUp);
|
||||
webhooks.all("/conferenceEnded", Webhooks.conferenceEnd);
|
||||
webhooks.all("/scheduledCleanup", Webhooks.scheduledCleanUp);
|
||||
webhooks.all("/ask", Webhooks.ask);
|
||||
webhooks.all("/userCleanUp", Webhooks.userCleanUp);
|
||||
|
||||
// VERSION 1
|
||||
const app = express();
|
||||
app.use(cors({ origin: true }));
|
||||
app.use(FunctionModules.authenticator);
|
||||
app.get('/validator/:partyName', FunctionModules.tokenValidator);
|
||||
app.get('/refresher/:token', FunctionModules.tokenRefresher);
|
||||
app.post('/create', FunctionModules.createRoom);
|
||||
app.post('/join', FunctionModules.joinRoom);
|
||||
app.post('/message', FunctionModules.sendMessage);
|
||||
app.post('/updatePlayer', FunctionModules.updatePlayer);
|
||||
app.post('/updateVoxeet', FunctionModules.updateVoxeet);
|
||||
app.delete('/leave/:rid/users/:uid', FunctionModules.leaveRoom);
|
||||
app.delete('/delete/:rid', FunctionModules.deleteRoom);
|
||||
app.put('/updateAdminOnly/:rid/:adminOnly', FunctionModules.updateAdminOnly);
|
||||
app.get("/validator/:partyName", FunctionModules.tokenValidator);
|
||||
app.get("/refresher/:token", FunctionModules.tokenRefresher);
|
||||
app.post("/create", FunctionModules.createRoom);
|
||||
app.post("/join", FunctionModules.joinRoom);
|
||||
app.post("/message", FunctionModules.sendMessage);
|
||||
app.post("/updatePlayer", FunctionModules.updatePlayer);
|
||||
app.post("/updateVoxeet", FunctionModules.updateVoxeet);
|
||||
app.delete("/leave/:rid/users/:uid", FunctionModules.leaveRoom);
|
||||
app.delete("/delete/:rid", FunctionModules.deleteRoom);
|
||||
app.put("/updateAdminOnly/:rid/:adminOnly", FunctionModules.updateAdminOnly);
|
||||
|
||||
// ADMIN
|
||||
const admin = express();
|
||||
admin.use(cors({ origin: ['http://localhost:3000', 'https://admin.chromewatchparty.com/*'] }));
|
||||
admin.use(
|
||||
cors({
|
||||
origin: ["http://localhost:3000", "https://admin.chromewatchparty.com/*"],
|
||||
})
|
||||
);
|
||||
admin.use(AdminModules.superAuth);
|
||||
admin.get('/partyDashboard', AdminModules.partyDashboard);
|
||||
admin.get('/serverDashboard', AdminModules.serverDashboard);
|
||||
admin.post('/updateVersionActive', AdminModules.updateVersionActive);
|
||||
admin.post('/updateVideoSelectors', AdminModules.updateVideoSelectors);
|
||||
admin.get("/partyDashboard", AdminModules.partyDashboard);
|
||||
admin.get("/serverDashboard", AdminModules.serverDashboard);
|
||||
admin.post("/updateVersionActive", AdminModules.updateVersionActive);
|
||||
admin.post("/updateVideoSelectors", AdminModules.updateVideoSelectors);
|
||||
admin.post("/updateVideoNameSelectors", AdminModules.updateVideoNameSelectors);
|
||||
admin.post("/sendMessage", AdminModules.sendMessage);
|
||||
|
||||
module.exports = {
|
||||
v1: app,
|
||||
|
||||
Reference in New Issue
Block a user