popular topics

This commit is contained in:
Ubuntu 2025-08-01 13:18:38 +05:30
parent 9fef0f12ee
commit 7d2a419bae
2 changed files with 86 additions and 1575 deletions

File diff suppressed because it is too large Load Diff

View File

@ -371,6 +371,51 @@ wss.on("connection", (ws) => {
}
}
if(data.event === "get-app-queries"){
if (!data.token || (!data.hospital_code || !data.app_user_id) ) {
emitEvent("get-app-queries", { error: "Token missing or hospital_code or app_user_id missing" }, ws.userId);
return;
}
try {
const decoded = jwt.verify(data.token, process.env.JWT_ACCESS_TOKEN_SECRET);
const allowedRoles = ['Admin',8];
// Role-based access check
if (!allowedRoles.includes(decoded.role)) {
emitEvent("get-app-queries", { error: "You are not authorized!" }, decoded.id);
return;
}
let interaction_logs;
// Fetch notifications of new signup
if(data.hospital_code.length == 0){
interaction_logs = await db.query(
"SELECT * FROM interaction_logs WHERE app_user_id = ?",
[data.app_user_id]
);
}
else if(data.app_user_id.length == 0){
interaction_logs = await db.query(
"SELECT * FROM interaction_logs WHERE app_user_id = ?",
[ data.app_user_id]
);
}
emitEvent("get-app-queries", {
message: "interaction logs fetched successfully.",
interaction_logs
}, decoded.id);
} catch (error) {
emitEvent("get-app-queries", { error: error.message }, ws.userId);
}
}