* Moving rtc calls to build under rtc feature flag
- Marking additional goal met on roadmap The current build model succesfully builds rtc enabled/disabled builds
This commit is contained in:
parent
4e737d4292
commit
e5e0875037
@ -10,7 +10,6 @@ use db::{ self, Channel};
|
|||||||
|
|
||||||
use crate::http::set_json_body;
|
use crate::http::set_json_body;
|
||||||
use crate::qs_param;
|
use crate::qs_param;
|
||||||
use crate::rtc;
|
|
||||||
|
|
||||||
|
|
||||||
pub async fn list_channels(pool: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
pub async fn list_channels(pool: &Pool, response: &mut Response<Body>, params: HashMap<String, String>) {
|
||||||
@ -56,7 +55,9 @@ pub async fn create_channel(pool: &Pool, response: &mut Response<Body>, params:
|
|||||||
match Channel::add(pool, name, description, kind).await {
|
match Channel::add(pool, name, description, kind).await {
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
match resp {
|
match resp {
|
||||||
|
#[cfg(feature = "rtc")]
|
||||||
Row(channel) => {
|
Row(channel) => {
|
||||||
|
use crate::rtc;
|
||||||
set_json_body(response, json!({"channel": channel}));
|
set_json_body(response, json!({"channel": channel}));
|
||||||
rtc::create_channel(channel).await;
|
rtc::create_channel(channel).await;
|
||||||
StatusCode::OK
|
StatusCode::OK
|
||||||
@ -114,7 +115,9 @@ pub async fn delete_channel(pool: &Pool, response: &mut Response<Body>, params:
|
|||||||
|
|
||||||
if let Some(id) = channel_id {
|
if let Some(id) = channel_id {
|
||||||
match Channel::delete(pool, id).await {
|
match Channel::delete(pool, id).await {
|
||||||
|
#[cfg(feature = "rtc")]
|
||||||
Ok(Success) => {
|
Ok(Success) => {
|
||||||
|
use crate::rtc;
|
||||||
rtc::delete_channel(id).await;
|
rtc::delete_channel(id).await;
|
||||||
},
|
},
|
||||||
Ok(_) => {/* can't actually happen */}
|
Ok(_) => {/* can't actually happen */}
|
||||||
|
@ -36,6 +36,7 @@ mod members;
|
|||||||
mod perms;
|
mod perms;
|
||||||
mod messages;
|
mod messages;
|
||||||
mod admin;
|
mod admin;
|
||||||
|
#[cfg(feature="rtc")]
|
||||||
mod rtc;
|
mod rtc;
|
||||||
|
|
||||||
mod http;
|
mod http;
|
||||||
|
@ -9,7 +9,6 @@ use db::Response::*;
|
|||||||
|
|
||||||
use crate::http::set_json_body;
|
use crate::http::set_json_body;
|
||||||
use crate::qs_param;
|
use crate::qs_param;
|
||||||
use crate::rtc;
|
|
||||||
|
|
||||||
|
|
||||||
pub async fn get_online_members(p: &Pool, response: &mut Response<Body>) {
|
pub async fn get_online_members(p: &Pool, response: &mut Response<Body>) {
|
||||||
@ -70,10 +69,14 @@ pub async fn post_self_nickname(p: &Pool, response: &mut Response<Body>, params:
|
|||||||
|
|
||||||
let uid = qs_param!(params, "id", u64).unwrap();
|
let uid = qs_param!(params, "id", u64).unwrap();
|
||||||
match Member::update_nick(p, uid, nick.as_ref()).await {
|
match Member::update_nick(p, uid, nick.as_ref()).await {
|
||||||
|
#[cfg(feature = "rtc")]
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
|
use crate::rtc;
|
||||||
rtc::update_nickname(uid, nick.as_str()).await;
|
rtc::update_nickname(uid, nick.as_str()).await;
|
||||||
StatusCode::OK
|
StatusCode::OK
|
||||||
},
|
},
|
||||||
|
#[cfg(not(feature = "rtc"))]
|
||||||
|
Ok(_) => StatusCode::OK,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("{}", e);
|
eprintln!("{}", e);
|
||||||
StatusCode::INTERNAL_SERVER_ERROR
|
StatusCode::INTERNAL_SERVER_ERROR
|
||||||
|
@ -98,6 +98,7 @@ pub async fn send_message(pool: &Pool, response: &mut Response<Body>, body: Body
|
|||||||
else {
|
else {
|
||||||
// Safe unwrap with ctype - its container type is checked prior
|
// Safe unwrap with ctype - its container type is checked prior
|
||||||
match db::Message::send(pool, &content, ctype.unwrap(), channel_id.unwrap(), uid).await {
|
match db::Message::send(pool, &content, ctype.unwrap(), channel_id.unwrap(), uid).await {
|
||||||
|
#[cfg(feature = "rtc")]
|
||||||
Ok(Row(msg)) => {
|
Ok(Row(msg)) => {
|
||||||
use crate::rtc;
|
use crate::rtc;
|
||||||
rtc::new_message(pool, msg).await;
|
rtc::new_message(pool, msg).await;
|
||||||
|
@ -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
|
* 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).
|
* Optional decentralization: Optionally compile decentralization comms to users. All of this can be done at the API level(Probably easy).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user