1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-01-08 11:42:35 +00:00
comunicapiv3/src/controllers/user_ws_actions.rs

29 lines
935 B
Rust
Raw Normal View History

2021-02-05 13:24:00 +00:00
//! # User WebSocket actions
//!
//! This module contains all the base action that can be executed by the WebSocket
use crate::data::base_request_handler::BaseRequestHandler;
use crate::data::error::Res;
use crate::data::user_ws_request_handler::UserWsRequestHandler;
/// Update incognito status of the connection
pub fn set_incognito(r: &mut UserWsRequestHandler) -> Res {
let new_state = r.post_bool("enable")?;
r.update_conn(|c| c.incognito = new_state)?;
r.success("Updated.")
}
/// Register a conversation
pub fn register_conv(r: &mut UserWsRequestHandler) -> Res {
let conv_id = r.post_conv_id("convID")?;
r.update_conn(|c| { c.conversations.insert(conv_id); })?;
r.success("ok")
}
/// Un-register a conversation
pub fn unregister_conv(r: &mut UserWsRequestHandler) -> Res {
let conv_id = r.post_u64("convID")?;
r.update_conn(|c| { c.conversations.remove(&conv_id); })?;
r.success("ok")
2021-02-05 13:24:00 +00:00
}