1 use crate::UserOperation;
2 use actix::{prelude::*, Recipient};
3 use lemmy_api_structs::{comment::CommentResponse, post::PostResponse};
4 use lemmy_db_schema::{CommunityId, LocalUserId, PostId};
5 use lemmy_utils::{ConnectionId, IpAddr};
6 use serde::{Deserialize, Serialize};
8 /// Chat server sends this messages to session
10 #[rtype(result = "()")]
11 pub struct WsMessage(pub String);
13 /// Message for chat server communications
15 /// New chat session is created
19 pub addr: Recipient<WsMessage>,
23 /// Session is disconnected
25 #[rtype(result = "()")]
26 pub struct Disconnect {
31 /// The messages sent to websocket clients
32 #[derive(Serialize, Deserialize, Message)]
33 #[rtype(result = "Result<String, std::convert::Infallible>")]
34 pub struct StandardMessage {
35 /// Id of the client session
42 #[rtype(result = "()")]
43 pub struct SendAllMessage<Response> {
44 pub op: UserOperation,
45 pub response: Response,
46 pub websocket_id: Option<ConnectionId>,
50 #[rtype(result = "()")]
51 pub struct SendUserRoomMessage<Response> {
52 pub op: UserOperation,
53 pub response: Response,
54 pub local_recipient_id: LocalUserId,
55 pub websocket_id: Option<ConnectionId>,
59 #[rtype(result = "()")]
60 pub struct SendCommunityRoomMessage<Response> {
61 pub op: UserOperation,
62 pub response: Response,
63 pub community_id: CommunityId,
64 pub websocket_id: Option<ConnectionId>,
68 #[rtype(result = "()")]
69 pub struct SendModRoomMessage<Response> {
70 pub op: UserOperation,
71 pub response: Response,
72 pub community_id: CommunityId,
73 pub websocket_id: Option<ConnectionId>,
77 #[rtype(result = "()")]
79 pub op: UserOperation,
80 pub post: PostResponse,
81 pub websocket_id: Option<ConnectionId>,
85 #[rtype(result = "()")]
86 pub struct SendComment {
87 pub op: UserOperation,
88 pub comment: CommentResponse,
89 pub websocket_id: Option<ConnectionId>,
93 #[rtype(result = "()")]
94 pub struct JoinUserRoom {
95 pub local_user_id: LocalUserId,
100 #[rtype(result = "()")]
101 pub struct JoinCommunityRoom {
102 pub community_id: CommunityId,
103 pub id: ConnectionId,
107 #[rtype(result = "()")]
108 pub struct JoinModRoom {
109 pub community_id: CommunityId,
110 pub id: ConnectionId,
114 #[rtype(result = "()")]
115 pub struct JoinPostRoom {
117 pub id: ConnectionId,
122 pub struct GetUsersOnline;
126 pub struct GetPostUsersOnline {
132 pub struct GetCommunityUsersOnline {
133 pub community_id: CommunityId,
136 #[derive(Message, Debug)]
137 #[rtype(result = "()")]
138 pub struct CaptchaItem {
141 pub expires: chrono::NaiveDateTime,
146 pub struct CheckCaptcha {