1 use serde::{Deserialize, Serialize};
4 use crate::db::community::*;
5 use crate::db::user::*;
6 use crate::db::post::*;
7 use crate::db::comment::*;
8 use crate::db::post_view::*;
9 use crate::db::comment_view::*;
10 use crate::db::category::*;
11 use crate::db::community_view::*;
12 use crate::db::user_view::*;
13 use crate::db::moderator_views::*;
14 use crate::db::moderator::*;
15 use crate::{has_slurs, remove_slurs, Settings, naive_now, naive_from_unix};
23 #[derive(EnumString,ToString,Debug)]
24 pub enum UserOperation {
25 Login, Register, CreateCommunity, CreatePost, ListCommunities, ListCategories, GetPost, GetCommunity, CreateComment, EditComment, SaveComment, CreateCommentLike, GetPosts, CreatePostLike, EditPost, SavePost, EditCommunity, FollowCommunity, GetFollowedCommunities, GetUserDetails, GetReplies, GetModlog, BanFromCommunity, AddModToCommunity, CreateSite, EditSite, GetSite, AddAdmin, BanUser, Search, MarkAllAsRead, SaveUserSettings
28 #[derive(Fail, Debug)]
29 #[fail(display = "{{\"op\":\"{}\", \"error\":\"{}\"}}", op, message)]
36 pub fn err(op: &UserOperation, msg: &str) -> Self {
39 message: msg.to_string(),
50 pub fn new(op: UserOperation, data: T) -> Oper<T> {
58 pub trait Perform<T> {
59 fn perform(&self) -> Result<T, Error> where T: Sized;