2 extern crate strum_macros;
4 use crate::chat_server::ChatServer;
6 use lemmy_db_schema::{source::secret::Secret, utils::DbPool};
9 settings::{structs::Settings, SETTINGS},
11 use reqwest_middleware::ClientWithMiddleware;
20 pub struct LemmyContext {
22 chat_server: Addr<ChatServer>,
23 client: ClientWithMiddleware,
31 chat_server: Addr<ChatServer>,
32 client: ClientWithMiddleware,
44 pub fn pool(&self) -> &DbPool {
47 pub fn chat_server(&self) -> &Addr<ChatServer> {
50 pub fn client(&self) -> &ClientWithMiddleware {
53 pub fn settings(&self) -> &'static Settings {
56 pub fn secret(&self) -> &Secret {
61 impl Clone for LemmyContext {
62 fn clone(&self) -> Self {
64 pool: self.pool.clone(),
65 chat_server: self.chat_server.clone(),
66 client: self.client.clone(),
67 settings: self.settings.clone(),
68 secret: self.secret.clone(),
74 struct WebsocketResponse<T> {
79 pub fn serialize_websocket_message<OP, Response>(
82 ) -> Result<String, LemmyError>
87 let response = WebsocketResponse {
91 Ok(serde_json::to_string(&response)?)
94 #[derive(EnumString, Display, Debug, Clone)]
95 pub enum UserOperation {
101 ResolveCommentReport,
117 MarkPersonMentionAsRead,
118 MarkCommentReplyAsRead,
123 GetUnreadRegistrationApplicationCount,
124 ListRegistrationApplications,
125 ApproveRegistrationApplication,
136 MarkPrivateMessageAsRead,
137 CreatePrivateMessageReport,
138 ResolvePrivateMessageReport,
139 ListPrivateMessageReports,
154 #[derive(EnumString, Display, Debug, Clone)]
155 pub enum UserOperationCrud {
186 CreatePrivateMessage,
189 DeletePrivateMessage,
192 pub trait OperationType {}
194 impl OperationType for UserOperationCrud {}
196 impl OperationType for UserOperation {}