1 use crate::UserOperation;
2 use actix::{prelude::*, Recipient};
3 use lemmy_structs::{comment::CommentResponse, post::PostResponse};
4 use lemmy_utils::{CommunityId, ConnectionId, IpAddr, PostId, UserId};
5 use serde::{Deserialize, Serialize};
7 /// Chat server sends this messages to session
9 #[rtype(result = "()")]
10 pub struct WsMessage(pub String);
12 /// Message for chat server communications
14 /// New chat session is created
18 pub addr: Recipient<WsMessage>,
22 /// Session is disconnected
24 #[rtype(result = "()")]
25 pub struct Disconnect {
30 /// The messages sent to websocket clients
31 #[derive(Serialize, Deserialize, Message)]
32 #[rtype(result = "Result<String, std::convert::Infallible>")]
33 pub struct StandardMessage {
34 /// Id of the client session
41 #[rtype(result = "()")]
42 pub struct SendAllMessage<Response> {
43 pub op: UserOperation,
44 pub response: Response,
45 pub websocket_id: Option<ConnectionId>,
49 #[rtype(result = "()")]
50 pub struct SendUserRoomMessage<Response> {
51 pub op: UserOperation,
52 pub response: Response,
53 pub recipient_id: UserId,
54 pub websocket_id: Option<ConnectionId>,
58 #[rtype(result = "()")]
59 pub struct SendCommunityRoomMessage<Response> {
60 pub op: UserOperation,
61 pub response: Response,
62 pub community_id: CommunityId,
63 pub websocket_id: Option<ConnectionId>,
67 #[rtype(result = "()")]
68 pub struct SendModRoomMessage<Response> {
69 pub op: UserOperation,
70 pub response: Response,
71 pub community_id: CommunityId,
72 pub websocket_id: Option<ConnectionId>,
76 #[rtype(result = "()")]
78 pub op: UserOperation,
79 pub post: PostResponse,
80 pub websocket_id: Option<ConnectionId>,
84 #[rtype(result = "()")]
85 pub struct SendComment {
86 pub op: UserOperation,
87 pub comment: CommentResponse,
88 pub websocket_id: Option<ConnectionId>,
92 #[rtype(result = "()")]
93 pub struct JoinUserRoom {
99 #[rtype(result = "()")]
100 pub struct JoinCommunityRoom {
101 pub community_id: CommunityId,
102 pub id: ConnectionId,
106 #[rtype(result = "()")]
107 pub struct JoinModRoom {
108 pub community_id: CommunityId,
109 pub id: ConnectionId,
113 #[rtype(result = "()")]
114 pub struct JoinPostRoom {
116 pub id: ConnectionId,
121 pub struct GetUsersOnline;
125 pub struct GetPostUsersOnline {
131 pub struct GetCommunityUsersOnline {
132 pub community_id: CommunityId,
135 #[derive(Message, Debug)]
136 #[rtype(result = "()")]
137 pub struct CaptchaItem {
140 pub expires: chrono::NaiveDateTime,
145 pub struct CheckCaptcha {