forked from rohit/spurrin-backend
ntfs, msg
This commit is contained in:
parent
1362dd52be
commit
b0325d4860
@ -1573,7 +1573,7 @@ exports.updatePublicSignup = async (req, res) => {
|
|||||||
|
|
||||||
console.log("req user-----", req.user)
|
console.log("req user-----", req.user)
|
||||||
// Check if user has permission
|
// Check if user has permission
|
||||||
if (!["Spurrinadmin", "Superadmin", 7, 6].includes(req.user.role)) {
|
if (!["Spurrinadmin", "Superadmin","Admin", 7, 6,8].includes(req.user.role)) {
|
||||||
return res.status(403).json({
|
return res.status(403).json({
|
||||||
error: "You are not authorized to update public signup settings"
|
error: "You are not authorized to update public signup settings"
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,8 +8,8 @@ const db = require("../config/database");
|
|||||||
const base_url = "https://backend.spurrinai.com";
|
const base_url = "https://backend.spurrinai.com";
|
||||||
|
|
||||||
const server = https.createServer({
|
const server = https.createServer({
|
||||||
cert: fs.readFileSync("/home/ubuntu/spurrin-cleaned-node/certificates/fullchain.pem"),
|
cert: fs.readFileSync("/home/ubuntu/spurrin-backend/certificates/fullchain.pem"),
|
||||||
key: fs.readFileSync("/home/ubuntu/spurrin-cleaned-node/certificates/privkey.pem")
|
key: fs.readFileSync("/home/ubuntu/spurrin-backend/certificates/privkey.pem")
|
||||||
});
|
});
|
||||||
|
|
||||||
const wss = new WebSocket.Server({ server, perMessageDeflate: false });
|
const wss = new WebSocket.Server({ server, perMessageDeflate: false });
|
||||||
@ -348,7 +348,7 @@ if (data.event === "get-signup-notifications") {
|
|||||||
|
|
||||||
// Fetch hospital_code from the DB
|
// Fetch hospital_code from the DB
|
||||||
const result = await db.query(
|
const result = await db.query(
|
||||||
"SELECT hospital_code FROM hospitals WHERE id = ?",
|
"SELECT hospital_code FROM hospital_users WHERE id = ?",
|
||||||
[decoded.id]
|
[decoded.id]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ if (data.event === "get-signup-notifications") {
|
|||||||
|
|
||||||
// Fetch signup notifications
|
// Fetch signup notifications
|
||||||
const notifications = await db.query(
|
const notifications = await db.query(
|
||||||
"SELECT * FROM hospitals WHERE hospital_code = ? AND checked = 0",
|
"SELECT * FROM app_users WHERE hospital_code = ? AND checked = 0",
|
||||||
[hospital_code]
|
[hospital_code]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ if (data.event === "get-signup-notifications") {
|
|||||||
|
|
||||||
// Fetch hospital_code from hospitals table
|
// Fetch hospital_code from hospitals table
|
||||||
const result = await db.query(
|
const result = await db.query(
|
||||||
"SELECT hospital_code FROM hospitals WHERE id = ?",
|
"SELECT hospital_code FROM hospital_users WHERE id = ?",
|
||||||
[decoded.id]
|
[decoded.id]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ if (data.event === "get-signup-notifications") {
|
|||||||
|
|
||||||
// Fetch notifications of new signups
|
// Fetch notifications of new signups
|
||||||
const notifications = await db.query(
|
const notifications = await db.query(
|
||||||
"SELECT * FROM hospitals WHERE hospital_code = ? AND checked = 0",
|
"SELECT * FROM app_users WHERE hospital_code = ? AND checked = 0",
|
||||||
[hospital_code]
|
[hospital_code]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -476,7 +476,6 @@ if (data.event === "get-signup-notifications") {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ws.on("close", () => {
|
ws.on("close", () => {
|
||||||
@ -488,20 +487,21 @@ if (data.event === "get-signup-notifications") {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// function emitEvent(event, data, userId = null) {
|
// Add this function before the server.listen() call
|
||||||
// if (userId && userSockets.has(userId)) {
|
function emitEvent(event, data, userId = null) {
|
||||||
// const client = userSockets.get(userId);
|
if (userId && userSockets.has(userId)) {
|
||||||
// if (client.readyState === WebSocket.OPEN) {
|
const client = userSockets.get(userId);
|
||||||
// client.send(JSON.stringify({ event, data }));
|
if (client.readyState === WebSocket.OPEN) {
|
||||||
// }
|
client.send(JSON.stringify({ event, data }));
|
||||||
// } else {
|
}
|
||||||
// wss.clients.forEach((client) => {
|
} else {
|
||||||
// if (client.readyState === WebSocket.OPEN) {
|
wss.clients.forEach((client) => {
|
||||||
// client.send(JSON.stringify({ event, data }));
|
if (client.readyState === WebSocket.OPEN) {
|
||||||
// }
|
client.send(JSON.stringify({ event, data }));
|
||||||
// });
|
}
|
||||||
// }
|
});
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
server.listen(40520, () => {
|
server.listen(40520, () => {
|
||||||
console.log("📡 Secure WebSocket server listening on wss://backend.spurrinai.com:40520");
|
console.log("📡 Secure WebSocket server listening on wss://backend.spurrinai.com:40520");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user