2019-03-21 01:22:31 +00:00
|
|
|
pub mod server;
|
2020-01-16 14:39:08 +00:00
|
|
|
|
2020-04-19 22:08:25 +00:00
|
|
|
use crate::ConnectionId;
|
|
|
|
use actix::prelude::*;
|
2020-05-16 14:04:08 +00:00
|
|
|
use diesel::{
|
|
|
|
r2d2::{ConnectionManager, Pool},
|
|
|
|
PgConnection,
|
|
|
|
};
|
2020-04-19 22:08:25 +00:00
|
|
|
use log::{error, info};
|
|
|
|
use rand::{rngs::ThreadRng, Rng};
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use serde_json::Value;
|
|
|
|
use server::ChatServer;
|
2020-05-16 14:04:08 +00:00
|
|
|
use std::{
|
|
|
|
collections::{HashMap, HashSet},
|
|
|
|
str::FromStr,
|
|
|
|
};
|
2020-04-19 22:08:25 +00:00
|
|
|
|
|
|
|
#[derive(EnumString, ToString, Debug, Clone)]
|
2020-01-16 14:39:08 +00:00
|
|
|
pub enum UserOperation {
|
|
|
|
Login,
|
|
|
|
Register,
|
2020-07-29 13:02:46 +00:00
|
|
|
GetCaptcha,
|
2020-01-16 14:39:08 +00:00
|
|
|
CreateCommunity,
|
|
|
|
CreatePost,
|
|
|
|
ListCommunities,
|
|
|
|
ListCategories,
|
|
|
|
GetPost,
|
|
|
|
GetCommunity,
|
|
|
|
CreateComment,
|
|
|
|
EditComment,
|
2020-07-21 01:37:44 +00:00
|
|
|
DeleteComment,
|
|
|
|
RemoveComment,
|
|
|
|
MarkCommentAsRead,
|
2020-01-16 14:39:08 +00:00
|
|
|
SaveComment,
|
|
|
|
CreateCommentLike,
|
|
|
|
GetPosts,
|
|
|
|
CreatePostLike,
|
|
|
|
EditPost,
|
2020-07-21 03:46:36 +00:00
|
|
|
DeletePost,
|
|
|
|
RemovePost,
|
|
|
|
LockPost,
|
|
|
|
StickyPost,
|
2020-01-16 14:39:08 +00:00
|
|
|
SavePost,
|
|
|
|
EditCommunity,
|
2020-07-20 17:37:39 +00:00
|
|
|
DeleteCommunity,
|
|
|
|
RemoveCommunity,
|
2020-01-16 14:39:08 +00:00
|
|
|
FollowCommunity,
|
|
|
|
GetFollowedCommunities,
|
|
|
|
GetUserDetails,
|
|
|
|
GetReplies,
|
|
|
|
GetUserMentions,
|
2020-07-20 14:56:40 +00:00
|
|
|
MarkUserMentionAsRead,
|
2020-01-16 14:39:08 +00:00
|
|
|
GetModlog,
|
|
|
|
BanFromCommunity,
|
|
|
|
AddModToCommunity,
|
|
|
|
CreateSite,
|
|
|
|
EditSite,
|
|
|
|
GetSite,
|
|
|
|
AddAdmin,
|
|
|
|
BanUser,
|
|
|
|
Search,
|
|
|
|
MarkAllAsRead,
|
|
|
|
SaveUserSettings,
|
|
|
|
TransferCommunity,
|
|
|
|
TransferSite,
|
|
|
|
DeleteAccount,
|
|
|
|
PasswordReset,
|
|
|
|
PasswordChange,
|
2020-01-24 00:17:42 +00:00
|
|
|
CreatePrivateMessage,
|
|
|
|
EditPrivateMessage,
|
2020-07-20 04:29:44 +00:00
|
|
|
DeletePrivateMessage,
|
|
|
|
MarkPrivateMessageAsRead,
|
2020-01-24 00:17:42 +00:00
|
|
|
GetPrivateMessages,
|
2020-02-01 01:02:20 +00:00
|
|
|
UserJoin,
|
2020-02-08 04:05:15 +00:00
|
|
|
GetComments,
|
2020-04-10 20:55:57 +00:00
|
|
|
GetSiteConfig,
|
|
|
|
SaveSiteConfig,
|
2020-01-16 14:39:08 +00:00
|
|
|
}
|
2020-04-19 22:08:25 +00:00
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub struct WebsocketInfo {
|
|
|
|
pub chatserver: Addr<ChatServer>,
|
|
|
|
pub id: Option<ConnectionId>,
|
|
|
|
}
|