1
0
mirror of https://git.ngram.ca/OpenJam/rc-servers synced 2026-08-23 23:08:52 +00:00

Add some basic commands for sysadmins and permission system for them

This commit is contained in:
NG (Graham)
2025-10-31 21:02:10 -04:00
parent 77b6d8c11f
commit 3ef1aa20d0
13 changed files with 290 additions and 29 deletions

View File

@@ -18,13 +18,29 @@ pub async fn services_ws(req: HttpRequest, stream: Payload, auth: Data<super::In
// start task but don't wait for it
rt::spawn(async move {
while let Some(msg) = rx.recv().await {
if let Err(e) = session.text(serde_json::to_string(&msg).unwrap()).await {
log::warn!("Failed to send services intercom to user {}: {}", name, e);
break;
let mut is_ok = false;
while let Some(op) = rx.recv().await {
match op {
super::IntercomOp::Message(msg) => {
if let Err(e) = session.text(serde_json::to_string(&msg).unwrap()).await {
log::warn!("Failed to send services intercom to user {}: {}", name, e);
break;
}
},
super::IntercomOp::Info(info) => {
match info {
super::IntercomInfo::Close => {
is_ok = true;
break;
},
}
}
}
}
if !is_ok {
reg.remove_service(name.clone()).await;
}
reg.remove_service(name.clone()).await;
rx.close();
session.close(Some(actix_ws::CloseReason {
code: actix_ws::CloseCode::Normal,