diff options
author | Dessalines <tyhou13@gmx.com> | 2020-04-19 18:08:25 -0400 |
---|---|---|
committer | Dessalines <tyhou13@gmx.com> | 2020-04-19 18:08:25 -0400 |
commit | f300c67a4d9674eef05d180a787cc8352092903d (patch) | |
tree | 49d076d128d065403f5690f92900bdd0679f2d66 /server/src/api/mod.rs | |
parent | be6a7876b49e8f963506f0b05e12495f119afc10 (diff) |
Adding websocket notification system.
- HTTP and APUB clients can now send live updating messages to websocket
clients
- Rate limiting now affects both HTTP and websockets
- Rate limiting / Websocket logic is now moved into the API Perform
functions.
- TODO This broke getting current online users, but that will have to
wait for the perform trait to be made async.
- Fixes #446
Diffstat (limited to 'server/src/api/mod.rs')
-rw-r--r-- | server/src/api/mod.rs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index e4fdfee6..e40d122c 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -18,12 +18,26 @@ use crate::db::user_mention_view::*; use crate::db::user_view::*; use crate::db::*; use crate::{ - extract_usernames, fetch_iframely_and_pictshare_data, naive_from_unix, naive_now, remove_slurs, - slur_check, slurs_vec_to_str, + extract_usernames, fetch_iframely_and_pictshare_data, generate_random_string, naive_from_unix, + naive_now, remove_slurs, send_email, slur_check, slurs_vec_to_str, }; + +use crate::rate_limit::RateLimitInfo; +use crate::settings::Settings; +use crate::websocket::UserOperation; +use crate::websocket::{ + server::{ + JoinCommunityRoom, JoinPostRoom, JoinUserRoom, SendAllMessage, SendComment, + SendCommunityRoomMessage, SendPost, SendUserRoomMessage, + }, + WebsocketInfo, +}; +use diesel::r2d2::{ConnectionManager, Pool}; use diesel::PgConnection; use failure::Error; +use log::{error, info}; use serde::{Deserialize, Serialize}; +use std::str::FromStr; pub mod comment; pub mod community; @@ -56,7 +70,12 @@ impl<T> Oper<T> { } pub trait Perform<T> { - fn perform(&self, conn: &PgConnection) -> Result<T, Error> + fn perform( + &self, + pool: Pool<ConnectionManager<PgConnection>>, + websocket_info: Option<WebsocketInfo>, + rate_limit_info: Option<RateLimitInfo>, + ) -> Result<T, Error> where T: Sized; } |