2020-05-16 14:04:08 +00:00
|
|
|
use crate::{
|
2020-09-16 10:25:22 +00:00
|
|
|
websocket::handlers::{do_user_operation, to_json_string, Args},
|
2020-08-18 13:43:50 +00:00
|
|
|
LemmyContext,
|
2020-05-16 14:04:08 +00:00
|
|
|
};
|
2020-09-01 13:20:22 +00:00
|
|
|
use actix::prelude::*;
|
2020-08-13 15:46:31 +00:00
|
|
|
use anyhow::Context as acontext;
|
2020-08-31 13:48:02 +00:00
|
|
|
use background_jobs::QueueHandle;
|
2020-09-01 13:20:22 +00:00
|
|
|
use diesel::{
|
|
|
|
r2d2::{ConnectionManager, Pool},
|
|
|
|
PgConnection,
|
|
|
|
};
|
2020-09-01 14:25:34 +00:00
|
|
|
use lemmy_rate_limit::RateLimit;
|
2020-09-16 13:31:30 +00:00
|
|
|
use lemmy_structs::{comment::*, community::*, post::*, site::*, user::*, websocket::*};
|
2020-09-03 19:45:12 +00:00
|
|
|
use lemmy_utils::{
|
|
|
|
location_info,
|
|
|
|
APIError,
|
|
|
|
CommunityId,
|
|
|
|
ConnectionId,
|
|
|
|
IPAddr,
|
|
|
|
LemmyError,
|
|
|
|
PostId,
|
|
|
|
UserId,
|
|
|
|
};
|
2020-09-01 13:20:22 +00:00
|
|
|
use rand::rngs::ThreadRng;
|
2020-08-31 13:48:02 +00:00
|
|
|
use reqwest::Client;
|
2020-09-01 13:20:22 +00:00
|
|
|
use serde::Serialize;
|
|
|
|
use serde_json::Value;
|
|
|
|
use std::{
|
|
|
|
collections::{HashMap, HashSet},
|
|
|
|
str::FromStr,
|
|
|
|
};
|
2020-02-01 01:02:20 +00:00
|
|
|
|
2019-03-21 01:22:31 +00:00
|
|
|
/// `ChatServer` manages chat rooms and responsible for coordinating chat
|
2020-02-01 01:02:20 +00:00
|
|
|
/// session.
|
2019-03-21 01:22:31 +00:00
|
|
|
pub struct ChatServer {
|
2020-02-01 01:02:20 +00:00
|
|
|
/// A map from generated random ID to session addr
|
2020-04-19 22:08:25 +00:00
|
|
|
pub sessions: HashMap<ConnectionId, SessionInfo>,
|
2020-02-01 01:02:20 +00:00
|
|
|
|
|
|
|
/// A map from post_id to set of connectionIDs
|
2020-04-19 22:08:25 +00:00
|
|
|
pub post_rooms: HashMap<PostId, HashSet<ConnectionId>>,
|
2020-02-01 01:02:20 +00:00
|
|
|
|
|
|
|
/// A map from community to set of connectionIDs
|
2020-04-19 22:08:25 +00:00
|
|
|
pub community_rooms: HashMap<CommunityId, HashSet<ConnectionId>>,
|
2020-02-01 01:02:20 +00:00
|
|
|
|
|
|
|
/// A map from user id to its connection ID for joined users. Remember a user can have multiple
|
|
|
|
/// sessions (IE clients)
|
2020-08-31 15:20:13 +00:00
|
|
|
pub(super) user_rooms: HashMap<UserId, HashSet<ConnectionId>>,
|
2020-02-01 01:02:20 +00:00
|
|
|
|
2020-08-31 15:20:13 +00:00
|
|
|
pub(super) rng: ThreadRng,
|
2020-04-19 22:08:25 +00:00
|
|
|
|
|
|
|
/// The DB Pool
|
2020-08-31 15:20:13 +00:00
|
|
|
pub(super) pool: Pool<ConnectionManager<PgConnection>>,
|
2020-04-19 22:08:25 +00:00
|
|
|
|
|
|
|
/// Rate limiting based on rate type and IP addr
|
2020-08-31 15:20:13 +00:00
|
|
|
pub(super) rate_limiter: RateLimit,
|
2020-07-01 12:54:29 +00:00
|
|
|
|
2020-07-29 13:02:46 +00:00
|
|
|
/// A list of the current captchas
|
2020-08-31 15:20:13 +00:00
|
|
|
pub(super) captchas: Vec<CaptchaItem>,
|
2020-07-29 13:02:46 +00:00
|
|
|
|
2020-07-01 12:54:29 +00:00
|
|
|
/// An HTTP Client
|
|
|
|
client: Client,
|
2020-08-31 13:48:02 +00:00
|
|
|
|
|
|
|
activity_queue: QueueHandle,
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 15:20:13 +00:00
|
|
|
pub struct SessionInfo {
|
|
|
|
pub addr: Recipient<WSMessage>,
|
|
|
|
pub ip: IPAddr,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// `ChatServer` is an actor. It maintains list of connection client session.
|
|
|
|
/// And manages available rooms. Peers send messages to other peers in same
|
|
|
|
/// room through `ChatServer`.
|
2020-01-12 15:31:51 +00:00
|
|
|
impl ChatServer {
|
2020-04-19 22:08:25 +00:00
|
|
|
pub fn startup(
|
|
|
|
pool: Pool<ConnectionManager<PgConnection>>,
|
2020-04-20 03:59:07 +00:00
|
|
|
rate_limiter: RateLimit,
|
2020-07-01 12:54:29 +00:00
|
|
|
client: Client,
|
2020-08-31 13:48:02 +00:00
|
|
|
activity_queue: QueueHandle,
|
2020-04-19 22:08:25 +00:00
|
|
|
) -> ChatServer {
|
2019-03-21 01:22:31 +00:00
|
|
|
ChatServer {
|
|
|
|
sessions: HashMap::new(),
|
2020-02-01 01:02:20 +00:00
|
|
|
post_rooms: HashMap::new(),
|
|
|
|
community_rooms: HashMap::new(),
|
|
|
|
user_rooms: HashMap::new(),
|
2019-03-21 01:22:31 +00:00
|
|
|
rng: rand::thread_rng(),
|
2020-04-19 22:08:25 +00:00
|
|
|
pool,
|
|
|
|
rate_limiter,
|
2020-07-29 13:02:46 +00:00
|
|
|
captchas: Vec::new(),
|
2020-07-01 12:54:29 +00:00
|
|
|
client,
|
2020-08-31 13:48:02 +00:00
|
|
|
activity_queue,
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 15:46:31 +00:00
|
|
|
pub fn join_community_room(
|
|
|
|
&mut self,
|
|
|
|
community_id: CommunityId,
|
|
|
|
id: ConnectionId,
|
|
|
|
) -> Result<(), LemmyError> {
|
2020-02-01 01:02:20 +00:00
|
|
|
// remove session from all rooms
|
|
|
|
for sessions in self.community_rooms.values_mut() {
|
|
|
|
sessions.remove(&id);
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|
2020-02-01 01:02:20 +00:00
|
|
|
|
2020-02-08 04:05:15 +00:00
|
|
|
// Also leave all post rooms
|
|
|
|
// This avoids double messages
|
|
|
|
for sessions in self.post_rooms.values_mut() {
|
|
|
|
sessions.remove(&id);
|
|
|
|
}
|
|
|
|
|
2020-02-01 01:02:20 +00:00
|
|
|
// If the room doesn't exist yet
|
|
|
|
if self.community_rooms.get_mut(&community_id).is_none() {
|
|
|
|
self.community_rooms.insert(community_id, HashSet::new());
|
|
|
|
}
|
|
|
|
|
|
|
|
self
|
|
|
|
.community_rooms
|
|
|
|
.get_mut(&community_id)
|
2020-08-13 15:46:31 +00:00
|
|
|
.context(location_info!())?
|
2020-02-01 01:02:20 +00:00
|
|
|
.insert(id);
|
2020-08-13 15:46:31 +00:00
|
|
|
Ok(())
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|
2019-04-15 23:12:06 +00:00
|
|
|
|
2020-08-13 15:46:31 +00:00
|
|
|
pub fn join_post_room(&mut self, post_id: PostId, id: ConnectionId) -> Result<(), LemmyError> {
|
2019-05-05 05:20:38 +00:00
|
|
|
// remove session from all rooms
|
2020-02-01 01:02:20 +00:00
|
|
|
for sessions in self.post_rooms.values_mut() {
|
2019-05-05 05:20:38 +00:00
|
|
|
sessions.remove(&id);
|
|
|
|
}
|
|
|
|
|
2020-02-08 04:05:15 +00:00
|
|
|
// Also leave all communities
|
|
|
|
// This avoids double messages
|
2020-07-20 17:37:39 +00:00
|
|
|
// TODO found a bug, whereby community messages like
|
|
|
|
// delete and remove aren't sent, because
|
|
|
|
// you left the community room
|
2020-02-08 04:05:15 +00:00
|
|
|
for sessions in self.community_rooms.values_mut() {
|
|
|
|
sessions.remove(&id);
|
|
|
|
}
|
|
|
|
|
2019-05-05 05:20:38 +00:00
|
|
|
// If the room doesn't exist yet
|
2020-02-01 01:02:20 +00:00
|
|
|
if self.post_rooms.get_mut(&post_id).is_none() {
|
|
|
|
self.post_rooms.insert(post_id, HashSet::new());
|
2019-05-05 05:20:38 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 15:46:31 +00:00
|
|
|
self
|
|
|
|
.post_rooms
|
|
|
|
.get_mut(&post_id)
|
|
|
|
.context(location_info!())?
|
|
|
|
.insert(id);
|
|
|
|
|
|
|
|
Ok(())
|
2019-05-05 05:20:38 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 15:46:31 +00:00
|
|
|
pub fn join_user_room(&mut self, user_id: UserId, id: ConnectionId) -> Result<(), LemmyError> {
|
2020-02-01 01:02:20 +00:00
|
|
|
// remove session from all rooms
|
|
|
|
for sessions in self.user_rooms.values_mut() {
|
|
|
|
sessions.remove(&id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the room doesn't exist yet
|
|
|
|
if self.user_rooms.get_mut(&user_id).is_none() {
|
|
|
|
self.user_rooms.insert(user_id, HashSet::new());
|
|
|
|
}
|
2020-01-12 15:31:51 +00:00
|
|
|
|
2020-08-13 15:46:31 +00:00
|
|
|
self
|
|
|
|
.user_rooms
|
|
|
|
.get_mut(&user_id)
|
|
|
|
.context(location_info!())?
|
|
|
|
.insert(id);
|
|
|
|
|
|
|
|
Ok(())
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
2019-12-07 12:03:03 +00:00
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
fn send_post_room_message<Response>(
|
|
|
|
&self,
|
|
|
|
op: &UserOperation,
|
|
|
|
response: &Response,
|
|
|
|
post_id: PostId,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id: Option<ConnectionId>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> Result<(), LemmyError>
|
2020-04-19 22:08:25 +00:00
|
|
|
where
|
|
|
|
Response: Serialize,
|
|
|
|
{
|
|
|
|
let res_str = &to_json_string(op, response)?;
|
2020-02-01 01:02:20 +00:00
|
|
|
if let Some(sessions) = self.post_rooms.get(&post_id) {
|
|
|
|
for id in sessions {
|
2020-08-24 11:58:24 +00:00
|
|
|
if let Some(my_id) = websocket_id {
|
2020-04-19 22:08:25 +00:00
|
|
|
if *id == my_id {
|
|
|
|
continue;
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
self.sendit(res_str, *id);
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
Ok(())
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
2019-12-07 12:03:03 +00:00
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
pub fn send_community_room_message<Response>(
|
2020-02-01 01:02:20 +00:00
|
|
|
&self,
|
2020-04-19 22:08:25 +00:00
|
|
|
op: &UserOperation,
|
|
|
|
response: &Response,
|
2020-02-01 01:02:20 +00:00
|
|
|
community_id: CommunityId,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id: Option<ConnectionId>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> Result<(), LemmyError>
|
2020-04-19 22:08:25 +00:00
|
|
|
where
|
|
|
|
Response: Serialize,
|
|
|
|
{
|
|
|
|
let res_str = &to_json_string(op, response)?;
|
2020-02-01 01:02:20 +00:00
|
|
|
if let Some(sessions) = self.community_rooms.get(&community_id) {
|
|
|
|
for id in sessions {
|
2020-08-24 11:58:24 +00:00
|
|
|
if let Some(my_id) = websocket_id {
|
2020-04-19 22:08:25 +00:00
|
|
|
if *id == my_id {
|
|
|
|
continue;
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
self.sendit(res_str, *id);
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
Ok(())
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
pub fn send_all_message<Response>(
|
|
|
|
&self,
|
|
|
|
op: &UserOperation,
|
|
|
|
response: &Response,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id: Option<ConnectionId>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> Result<(), LemmyError>
|
2020-04-19 22:08:25 +00:00
|
|
|
where
|
|
|
|
Response: Serialize,
|
|
|
|
{
|
|
|
|
let res_str = &to_json_string(op, response)?;
|
|
|
|
for id in self.sessions.keys() {
|
2020-08-24 11:58:24 +00:00
|
|
|
if let Some(my_id) = websocket_id {
|
2020-04-19 22:08:25 +00:00
|
|
|
if *id == my_id {
|
|
|
|
continue;
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
self.sendit(res_str, *id);
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
Ok(())
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
2019-04-21 07:26:26 +00:00
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
pub fn send_user_room_message<Response>(
|
|
|
|
&self,
|
|
|
|
op: &UserOperation,
|
|
|
|
response: &Response,
|
|
|
|
recipient_id: UserId,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id: Option<ConnectionId>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> Result<(), LemmyError>
|
2020-04-19 22:08:25 +00:00
|
|
|
where
|
|
|
|
Response: Serialize,
|
|
|
|
{
|
|
|
|
let res_str = &to_json_string(op, response)?;
|
|
|
|
if let Some(sessions) = self.user_rooms.get(&recipient_id) {
|
|
|
|
for id in sessions {
|
2020-08-24 11:58:24 +00:00
|
|
|
if let Some(my_id) = websocket_id {
|
2020-04-19 22:08:25 +00:00
|
|
|
if *id == my_id {
|
|
|
|
continue;
|
|
|
|
}
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
self.sendit(res_str, *id);
|
2020-02-01 01:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
Ok(())
|
2019-04-15 23:12:06 +00:00
|
|
|
}
|
2019-05-01 22:44:39 +00:00
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
pub fn send_comment(
|
2020-02-02 17:45:41 +00:00
|
|
|
&self,
|
2020-04-19 22:08:25 +00:00
|
|
|
user_operation: &UserOperation,
|
|
|
|
comment: &CommentResponse,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id: Option<ConnectionId>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> Result<(), LemmyError> {
|
2020-02-02 17:45:41 +00:00
|
|
|
let mut comment_reply_sent = comment.clone();
|
|
|
|
comment_reply_sent.comment.my_vote = None;
|
|
|
|
comment_reply_sent.comment.user_id = None;
|
|
|
|
|
|
|
|
let mut comment_post_sent = comment_reply_sent.clone();
|
|
|
|
comment_post_sent.recipient_ids = Vec::new();
|
|
|
|
|
|
|
|
// Send it to the post room
|
2020-04-19 22:08:25 +00:00
|
|
|
self.send_post_room_message(
|
|
|
|
user_operation,
|
|
|
|
&comment_post_sent,
|
|
|
|
comment_post_sent.comment.post_id,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id,
|
2020-04-19 22:08:25 +00:00
|
|
|
)?;
|
2020-02-02 17:45:41 +00:00
|
|
|
|
|
|
|
// Send it to the recipient(s) including the mentioned users
|
2020-04-19 22:08:25 +00:00
|
|
|
for recipient_id in &comment_reply_sent.recipient_ids {
|
2020-08-24 11:58:24 +00:00
|
|
|
self.send_user_room_message(
|
|
|
|
user_operation,
|
|
|
|
&comment_reply_sent,
|
|
|
|
*recipient_id,
|
|
|
|
websocket_id,
|
|
|
|
)?;
|
2020-02-02 17:45:41 +00:00
|
|
|
}
|
|
|
|
|
2020-02-08 04:05:15 +00:00
|
|
|
// Send it to the community too
|
2020-08-24 11:58:24 +00:00
|
|
|
self.send_community_room_message(user_operation, &comment_post_sent, 0, websocket_id)?;
|
2020-04-19 22:08:25 +00:00
|
|
|
self.send_community_room_message(
|
|
|
|
user_operation,
|
|
|
|
&comment_post_sent,
|
|
|
|
comment.comment.community_id,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id,
|
2020-04-19 22:08:25 +00:00
|
|
|
)?;
|
|
|
|
|
|
|
|
Ok(())
|
2020-02-02 17:45:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
pub fn send_post(
|
2020-02-02 17:45:41 +00:00
|
|
|
&self,
|
2020-04-19 22:08:25 +00:00
|
|
|
user_operation: &UserOperation,
|
|
|
|
post: &PostResponse,
|
2020-08-24 11:58:24 +00:00
|
|
|
websocket_id: Option<ConnectionId>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> Result<(), LemmyError> {
|
2020-02-02 17:45:41 +00:00
|
|
|
let community_id = post.post.community_id;
|
|
|
|
|
|
|
|
// Don't send my data with it
|
|
|
|
let mut post_sent = post.clone();
|
|
|
|
post_sent.post.my_vote = None;
|
|
|
|
post_sent.post.user_id = None;
|
|
|
|
|
|
|
|
// Send it to /c/all and that community
|
2020-08-24 11:58:24 +00:00
|
|
|
self.send_community_room_message(user_operation, &post_sent, 0, websocket_id)?;
|
|
|
|
self.send_community_room_message(user_operation, &post_sent, community_id, websocket_id)?;
|
2020-02-02 17:45:41 +00:00
|
|
|
|
2020-02-09 20:04:41 +00:00
|
|
|
// Send it to the post room
|
2020-08-24 11:58:24 +00:00
|
|
|
self.send_post_room_message(user_operation, &post_sent, post.post.id, websocket_id)?;
|
2020-02-09 20:04:41 +00:00
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
Ok(())
|
2020-02-02 17:45:41 +00:00
|
|
|
}
|
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
fn sendit(&self, message: &str, id: ConnectionId) {
|
|
|
|
if let Some(info) = self.sessions.get(&id) {
|
|
|
|
let _ = info.addr.do_send(WSMessage(message.to_owned()));
|
|
|
|
}
|
2019-09-03 20:18:07 +00:00
|
|
|
}
|
|
|
|
|
2020-08-31 15:20:13 +00:00
|
|
|
pub(super) fn parse_json_message(
|
2020-02-06 21:07:59 +00:00
|
|
|
&mut self,
|
2020-04-19 22:08:25 +00:00
|
|
|
msg: StandardMessage,
|
|
|
|
ctx: &mut Context<Self>,
|
2020-07-01 12:54:29 +00:00
|
|
|
) -> impl Future<Output = Result<String, LemmyError>> {
|
2020-04-20 03:59:07 +00:00
|
|
|
let addr = ctx.address();
|
|
|
|
let pool = self.pool.clone();
|
|
|
|
let rate_limiter = self.rate_limiter.clone();
|
2020-04-19 22:08:25 +00:00
|
|
|
|
|
|
|
let ip: IPAddr = match self.sessions.get(&msg.id) {
|
|
|
|
Some(info) => info.ip.to_owned(),
|
|
|
|
None => "blank_ip".to_string(),
|
|
|
|
};
|
|
|
|
|
2020-07-01 12:54:29 +00:00
|
|
|
let client = self.client.clone();
|
2020-08-31 13:48:02 +00:00
|
|
|
let activity_queue = self.activity_queue.clone();
|
2020-04-20 03:59:07 +00:00
|
|
|
async move {
|
|
|
|
let msg = msg;
|
|
|
|
let json: Value = serde_json::from_str(&msg.msg)?;
|
|
|
|
let data = &json["data"].to_string();
|
|
|
|
let op = &json["op"].as_str().ok_or(APIError {
|
|
|
|
message: "Unknown op type".to_string(),
|
|
|
|
})?;
|
|
|
|
|
|
|
|
let user_operation: UserOperation = UserOperation::from_str(&op)?;
|
|
|
|
|
2020-08-18 13:43:50 +00:00
|
|
|
let context = LemmyContext {
|
2020-07-01 12:54:29 +00:00
|
|
|
pool,
|
2020-08-18 13:43:50 +00:00
|
|
|
chat_server: addr,
|
|
|
|
client,
|
2020-08-31 13:48:02 +00:00
|
|
|
activity_queue,
|
2020-08-18 13:43:50 +00:00
|
|
|
};
|
|
|
|
let args = Args {
|
2020-08-24 11:58:24 +00:00
|
|
|
context,
|
2020-07-01 12:54:29 +00:00
|
|
|
rate_limiter,
|
|
|
|
id: msg.id,
|
|
|
|
ip,
|
|
|
|
op: user_operation.clone(),
|
|
|
|
data,
|
|
|
|
};
|
|
|
|
|
2020-04-20 03:59:07 +00:00
|
|
|
match user_operation {
|
|
|
|
// User ops
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::Login => do_user_operation::<Login>(args).await,
|
|
|
|
UserOperation::Register => do_user_operation::<Register>(args).await,
|
2020-07-29 13:02:46 +00:00
|
|
|
UserOperation::GetCaptcha => do_user_operation::<GetCaptcha>(args).await,
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::GetUserDetails => do_user_operation::<GetUserDetails>(args).await,
|
|
|
|
UserOperation::GetReplies => do_user_operation::<GetReplies>(args).await,
|
|
|
|
UserOperation::AddAdmin => do_user_operation::<AddAdmin>(args).await,
|
|
|
|
UserOperation::BanUser => do_user_operation::<BanUser>(args).await,
|
|
|
|
UserOperation::GetUserMentions => do_user_operation::<GetUserMentions>(args).await,
|
2020-07-20 14:56:40 +00:00
|
|
|
UserOperation::MarkUserMentionAsRead => {
|
|
|
|
do_user_operation::<MarkUserMentionAsRead>(args).await
|
|
|
|
}
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::MarkAllAsRead => do_user_operation::<MarkAllAsRead>(args).await,
|
|
|
|
UserOperation::DeleteAccount => do_user_operation::<DeleteAccount>(args).await,
|
|
|
|
UserOperation::PasswordReset => do_user_operation::<PasswordReset>(args).await,
|
|
|
|
UserOperation::PasswordChange => do_user_operation::<PasswordChange>(args).await,
|
2020-07-20 04:29:44 +00:00
|
|
|
UserOperation::UserJoin => do_user_operation::<UserJoin>(args).await,
|
2020-09-15 19:26:47 +00:00
|
|
|
UserOperation::PostJoin => do_user_operation::<PostJoin>(args).await,
|
|
|
|
UserOperation::CommunityJoin => do_user_operation::<CommunityJoin>(args).await,
|
2020-07-20 04:29:44 +00:00
|
|
|
UserOperation::SaveUserSettings => do_user_operation::<SaveUserSettings>(args).await,
|
|
|
|
|
|
|
|
// Private Message ops
|
2020-04-20 03:59:07 +00:00
|
|
|
UserOperation::CreatePrivateMessage => {
|
2020-07-01 12:54:29 +00:00
|
|
|
do_user_operation::<CreatePrivateMessage>(args).await
|
2020-04-20 03:59:07 +00:00
|
|
|
}
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::EditPrivateMessage => do_user_operation::<EditPrivateMessage>(args).await,
|
2020-07-20 04:29:44 +00:00
|
|
|
UserOperation::DeletePrivateMessage => {
|
|
|
|
do_user_operation::<DeletePrivateMessage>(args).await
|
|
|
|
}
|
|
|
|
UserOperation::MarkPrivateMessageAsRead => {
|
|
|
|
do_user_operation::<MarkPrivateMessageAsRead>(args).await
|
|
|
|
}
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::GetPrivateMessages => do_user_operation::<GetPrivateMessages>(args).await,
|
2020-04-19 22:08:25 +00:00
|
|
|
|
2020-04-20 03:59:07 +00:00
|
|
|
// Site ops
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::GetModlog => do_user_operation::<GetModlog>(args).await,
|
|
|
|
UserOperation::CreateSite => do_user_operation::<CreateSite>(args).await,
|
|
|
|
UserOperation::EditSite => do_user_operation::<EditSite>(args).await,
|
|
|
|
UserOperation::GetSite => do_user_operation::<GetSite>(args).await,
|
|
|
|
UserOperation::GetSiteConfig => do_user_operation::<GetSiteConfig>(args).await,
|
|
|
|
UserOperation::SaveSiteConfig => do_user_operation::<SaveSiteConfig>(args).await,
|
|
|
|
UserOperation::Search => do_user_operation::<Search>(args).await,
|
|
|
|
UserOperation::TransferCommunity => do_user_operation::<TransferCommunity>(args).await,
|
|
|
|
UserOperation::TransferSite => do_user_operation::<TransferSite>(args).await,
|
|
|
|
UserOperation::ListCategories => do_user_operation::<ListCategories>(args).await,
|
2020-04-20 03:59:07 +00:00
|
|
|
|
|
|
|
// Community ops
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::GetCommunity => do_user_operation::<GetCommunity>(args).await,
|
|
|
|
UserOperation::ListCommunities => do_user_operation::<ListCommunities>(args).await,
|
|
|
|
UserOperation::CreateCommunity => do_user_operation::<CreateCommunity>(args).await,
|
|
|
|
UserOperation::EditCommunity => do_user_operation::<EditCommunity>(args).await,
|
2020-07-20 17:37:39 +00:00
|
|
|
UserOperation::DeleteCommunity => do_user_operation::<DeleteCommunity>(args).await,
|
|
|
|
UserOperation::RemoveCommunity => do_user_operation::<RemoveCommunity>(args).await,
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::FollowCommunity => do_user_operation::<FollowCommunity>(args).await,
|
2020-04-20 03:59:07 +00:00
|
|
|
UserOperation::GetFollowedCommunities => {
|
2020-07-01 12:54:29 +00:00
|
|
|
do_user_operation::<GetFollowedCommunities>(args).await
|
2020-04-20 03:59:07 +00:00
|
|
|
}
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::BanFromCommunity => do_user_operation::<BanFromCommunity>(args).await,
|
|
|
|
UserOperation::AddModToCommunity => do_user_operation::<AddModToCommunity>(args).await,
|
2020-04-20 03:59:07 +00:00
|
|
|
|
|
|
|
// Post ops
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::CreatePost => do_user_operation::<CreatePost>(args).await,
|
|
|
|
UserOperation::GetPost => do_user_operation::<GetPost>(args).await,
|
|
|
|
UserOperation::GetPosts => do_user_operation::<GetPosts>(args).await,
|
|
|
|
UserOperation::EditPost => do_user_operation::<EditPost>(args).await,
|
2020-07-21 03:46:36 +00:00
|
|
|
UserOperation::DeletePost => do_user_operation::<DeletePost>(args).await,
|
|
|
|
UserOperation::RemovePost => do_user_operation::<RemovePost>(args).await,
|
|
|
|
UserOperation::LockPost => do_user_operation::<LockPost>(args).await,
|
|
|
|
UserOperation::StickyPost => do_user_operation::<StickyPost>(args).await,
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::CreatePostLike => do_user_operation::<CreatePostLike>(args).await,
|
|
|
|
UserOperation::SavePost => do_user_operation::<SavePost>(args).await,
|
2020-04-20 03:59:07 +00:00
|
|
|
|
|
|
|
// Comment ops
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::CreateComment => do_user_operation::<CreateComment>(args).await,
|
|
|
|
UserOperation::EditComment => do_user_operation::<EditComment>(args).await,
|
2020-07-21 01:37:44 +00:00
|
|
|
UserOperation::DeleteComment => do_user_operation::<DeleteComment>(args).await,
|
|
|
|
UserOperation::RemoveComment => do_user_operation::<RemoveComment>(args).await,
|
|
|
|
UserOperation::MarkCommentAsRead => do_user_operation::<MarkCommentAsRead>(args).await,
|
2020-07-01 12:54:29 +00:00
|
|
|
UserOperation::SaveComment => do_user_operation::<SaveComment>(args).await,
|
|
|
|
UserOperation::GetComments => do_user_operation::<GetComments>(args).await,
|
|
|
|
UserOperation::CreateCommentLike => do_user_operation::<CreateCommentLike>(args).await,
|
2020-04-20 03:59:07 +00:00
|
|
|
}
|
2019-05-01 22:44:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-21 01:22:31 +00:00
|
|
|
}
|