2 extern crate strum_macros;
4 use crate::chat_server::ChatServer;
6 use background_jobs::QueueHandle;
8 use lemmy_utils::LemmyError;
16 pub struct LemmyContext {
18 pub chat_server: Addr<ChatServer>,
20 pub activity_queue: QueueHandle,
26 chat_server: Addr<ChatServer>,
28 activity_queue: QueueHandle,
37 pub fn pool(&self) -> &DbPool {
40 pub fn chat_server(&self) -> &Addr<ChatServer> {
43 pub fn client(&self) -> &Client {
46 pub fn activity_queue(&self) -> &QueueHandle {
51 impl Clone for LemmyContext {
52 fn clone(&self) -> Self {
54 pool: self.pool.clone(),
55 chat_server: self.chat_server.clone(),
56 client: self.client.clone(),
57 activity_queue: self.activity_queue.clone(),
63 struct WebsocketResponse<T> {
68 pub fn serialize_websocket_message<Response>(
71 ) -> Result<String, LemmyError>
75 let response = WebsocketResponse {
79 Ok(serde_json::to_string(&response)?)
82 #[derive(EnumString, ToString, Debug, Clone)]
83 pub enum UserOperation {
112 GetFollowedCommunities,
116 MarkUserMentionAsRead,
133 CreatePrivateMessage,
135 DeletePrivateMessage,
136 MarkPrivateMessageAsRead,