diff --git a/json-api/src/channels.rs b/json-api/src/channels.rs index 9dc5b07..c85d71a 100644 --- a/json-api/src/channels.rs +++ b/json-api/src/channels.rs @@ -10,7 +10,6 @@ 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, params: HashMap) { @@ -56,7 +55,9 @@ pub async fn create_channel(pool: &Pool, response: &mut Response, params: match Channel::add(pool, name, description, kind).await { Ok(resp) => { match resp { + #[cfg(feature = "rtc")] Row(channel) => { + use crate::rtc; set_json_body(response, json!({"channel": channel})); rtc::create_channel(channel).await; StatusCode::OK @@ -114,7 +115,9 @@ pub async fn delete_channel(pool: &Pool, response: &mut Response, params: if let Some(id) = channel_id { match Channel::delete(pool, id).await { + #[cfg(feature = "rtc")] Ok(Success) => { + use crate::rtc; rtc::delete_channel(id).await; }, Ok(_) => {/* can't actually happen */} diff --git a/json-api/src/main.rs b/json-api/src/main.rs index 343b22e..40e33d2 100644 --- a/json-api/src/main.rs +++ b/json-api/src/main.rs @@ -36,6 +36,7 @@ mod members; mod perms; mod messages; mod admin; +#[cfg(feature="rtc")] mod rtc; mod http; diff --git a/json-api/src/members.rs b/json-api/src/members.rs index 1939b97..b0b62e0 100644 --- a/json-api/src/members.rs +++ b/json-api/src/members.rs @@ -9,7 +9,6 @@ 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) { @@ -70,10 +69,14 @@ pub async fn post_self_nickname(p: &Pool, response: &mut Response, params: let uid = qs_param!(params, "id", u64).unwrap(); match Member::update_nick(p, uid, nick.as_ref()).await { + #[cfg(feature = "rtc")] Ok(_) => { + use crate::rtc; rtc::update_nickname(uid, nick.as_str()).await; StatusCode::OK }, + #[cfg(not(feature = "rtc"))] + Ok(_) => StatusCode::OK, Err(e) => { eprintln!("{}", e); StatusCode::INTERNAL_SERVER_ERROR diff --git a/json-api/src/messages.rs b/json-api/src/messages.rs index 1edcd6a..a848cc6 100644 --- a/json-api/src/messages.rs +++ b/json-api/src/messages.rs @@ -98,6 +98,7 @@ pub async fn send_message(pool: &Pool, response: &mut Response, body: Body else { // Safe unwrap with ctype - its container type is checked prior match db::Message::send(pool, &content, ctype.unwrap(), channel_id.unwrap(), uid).await { + #[cfg(feature = "rtc")] Ok(Row(msg)) => { use crate::rtc; rtc::new_message(pool, msg).await; diff --git a/roadmap.md b/roadmap.md index f99ce90..bf1c5bd 100644 --- a/roadmap.md +++ b/roadmap.md @@ -44,7 +44,7 @@ I'd like to be able to support people that make good software and give them a pl * RTC Permissions: Unprivileged users shouldn't receive messaegs if they don't have the required permissions -* Optional RTC: Optionally compile RTC communications(Easy) +* ~~Optional RTC: Optionally compile RTC communications(Easy)~~ * Optional decentralization: Optionally compile decentralization comms to users. All of this can be done at the API level(Probably easy).