49bd28e2d4
* Adding visual captchas for register and login. * Adding audio wav file for Captcha using espeak. * Lots of captcha fixes. - Removed login captchas. - Added settings to disable captchas, and change difficulty. - Captchas can only be checked / used once, front end gives a new one on failure. - Added front end button for regenerating captcha. - Added a disabled / pause button audio playing. * Some more fixes.
85 lines
1.5 KiB
Rust
85 lines
1.5 KiB
Rust
pub mod server;
|
|
|
|
use crate::ConnectionId;
|
|
use actix::prelude::*;
|
|
use diesel::{
|
|
r2d2::{ConnectionManager, Pool},
|
|
PgConnection,
|
|
};
|
|
use log::{error, info};
|
|
use rand::{rngs::ThreadRng, Rng};
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_json::Value;
|
|
use server::ChatServer;
|
|
use std::{
|
|
collections::{HashMap, HashSet},
|
|
str::FromStr,
|
|
};
|
|
|
|
#[derive(EnumString, ToString, Debug, Clone)]
|
|
pub enum UserOperation {
|
|
Login,
|
|
Register,
|
|
GetCaptcha,
|
|
CreateCommunity,
|
|
CreatePost,
|
|
ListCommunities,
|
|
ListCategories,
|
|
GetPost,
|
|
GetCommunity,
|
|
CreateComment,
|
|
EditComment,
|
|
DeleteComment,
|
|
RemoveComment,
|
|
MarkCommentAsRead,
|
|
SaveComment,
|
|
CreateCommentLike,
|
|
GetPosts,
|
|
CreatePostLike,
|
|
EditPost,
|
|
DeletePost,
|
|
RemovePost,
|
|
LockPost,
|
|
StickyPost,
|
|
SavePost,
|
|
EditCommunity,
|
|
DeleteCommunity,
|
|
RemoveCommunity,
|
|
FollowCommunity,
|
|
GetFollowedCommunities,
|
|
GetUserDetails,
|
|
GetReplies,
|
|
GetUserMentions,
|
|
MarkUserMentionAsRead,
|
|
GetModlog,
|
|
BanFromCommunity,
|
|
AddModToCommunity,
|
|
CreateSite,
|
|
EditSite,
|
|
GetSite,
|
|
AddAdmin,
|
|
BanUser,
|
|
Search,
|
|
MarkAllAsRead,
|
|
SaveUserSettings,
|
|
TransferCommunity,
|
|
TransferSite,
|
|
DeleteAccount,
|
|
PasswordReset,
|
|
PasswordChange,
|
|
CreatePrivateMessage,
|
|
EditPrivateMessage,
|
|
DeletePrivateMessage,
|
|
MarkPrivateMessageAsRead,
|
|
GetPrivateMessages,
|
|
UserJoin,
|
|
GetComments,
|
|
GetSiteConfig,
|
|
SaveSiteConfig,
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub struct WebsocketInfo {
|
|
pub chatserver: Addr<ChatServer>,
|
|
pub id: Option<ConnectionId>,
|
|
}
|