Adding rtc notifications to relevant endpoints
! Still need a feature flag to compile this optionally instead of all the time - Removed warning in main's auth::login_get_jwt call
This commit is contained in:
parent
be54ce6a57
commit
3f1dfbf824
@ -10,6 +10,7 @@ use db::{ self, Channel};
|
||||
|
||||
use crate::http::set_json_body;
|
||||
use crate::qs_param;
|
||||
use crate::rtc;
|
||||
|
||||
|
||||
pub async fn list_channels(pool: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
||||
@ -58,6 +59,7 @@ pub async fn create_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
match resp {
|
||||
Row(channel) => {
|
||||
set_json_body(response, json!(channel));
|
||||
rtc::create_channel(channel).await;
|
||||
StatusCode::OK
|
||||
},
|
||||
|
||||
@ -112,7 +114,9 @@ pub async fn delete_channel(pool: &Pool, response: &mut Response<Body>, params:
|
||||
|
||||
if let Some(id) = channel_id {
|
||||
match Channel::delete(pool, id).await {
|
||||
Ok(Success) => {/* nothing to do on sucess */},
|
||||
Ok(Success) => {
|
||||
rtc::delete_channel(id).await;
|
||||
},
|
||||
Ok(_) => {/* can't actually happen */}
|
||||
Err(e) => { // ngmi
|
||||
eprintln!("{}", e);
|
||||
|
@ -117,7 +117,7 @@ async fn main_responder(request: Request<Body>) -> Result<Response<Body>, hyper:
|
||||
route_dispatcher(&DB_POOL, &mut response, &method, path, body, params, headers).await;
|
||||
},
|
||||
LoginValid => {
|
||||
auth::login_get_jwt(&DB_POOL, &mut response, params).await;
|
||||
auth::login_get_jwt(&mut response, params).await;
|
||||
},
|
||||
NoKey | BadKey => {
|
||||
println!("[DEBUG] NoKey | BadKey");
|
||||
|
@ -9,6 +9,7 @@ use db::Response::*;
|
||||
|
||||
use crate::http::set_json_body;
|
||||
use crate::qs_param;
|
||||
use crate::rtc;
|
||||
|
||||
|
||||
pub async fn get_online_members(p: &Pool, response: &mut Response<Body>) {
|
||||
@ -69,7 +70,10 @@ pub async fn post_self_nickname(p: &Pool, response: &mut Response<Body>, params:
|
||||
|
||||
let uid = qs_param!(params, "id", u64).unwrap();
|
||||
match Member::update_nick(p, uid, nick.as_ref()).await {
|
||||
Ok(_) => StatusCode::OK,
|
||||
Ok(_) => {
|
||||
rtc::update_nickname(uid, nick.as_str()).await;
|
||||
StatusCode::OK
|
||||
},
|
||||
Err(e) => {
|
||||
eprintln!("{}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
|
@ -81,7 +81,10 @@ pub async fn send_message(pool: &Pool, response: &mut Response<Body>, body: Body
|
||||
Row(user) => user.permissions,
|
||||
_ => 0
|
||||
},
|
||||
Err(e) => 0
|
||||
Err(e) => {
|
||||
eprintln!("[DB-SQL] {}",e );
|
||||
0
|
||||
}
|
||||
};
|
||||
if perms::has_perm(permissions, perms::SEND_MESSAGES) == false {
|
||||
*response.status_mut() = StatusCode::BAD_REQUEST;
|
||||
|
Loading…
Reference in New Issue
Block a user