feat: init
This commit is contained in:
@@ -0,0 +1,256 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum WsOutbound {
|
||||
AuthOk {
|
||||
request_id: Uuid,
|
||||
connection_id: Uuid,
|
||||
heartbeat_interval_secs: u64,
|
||||
},
|
||||
AuthError {
|
||||
request_id: Uuid,
|
||||
message: String,
|
||||
},
|
||||
HeartbeatAck {
|
||||
request_id: Uuid,
|
||||
timestamp_ms: i64,
|
||||
},
|
||||
Error {
|
||||
request_id: Uuid,
|
||||
code: String,
|
||||
message: String,
|
||||
},
|
||||
Typing {
|
||||
request_id: Uuid,
|
||||
data: TypingEvent,
|
||||
},
|
||||
Presence {
|
||||
request_id: Uuid,
|
||||
data: PresenceEvent,
|
||||
},
|
||||
Message {
|
||||
request_id: Uuid,
|
||||
data: MessageEvent,
|
||||
},
|
||||
Channel {
|
||||
request_id: Uuid,
|
||||
data: ChannelEvent,
|
||||
},
|
||||
Thread {
|
||||
request_id: Uuid,
|
||||
data: ThreadEvent,
|
||||
},
|
||||
Member {
|
||||
request_id: Uuid,
|
||||
data: MemberEvent,
|
||||
},
|
||||
Reaction {
|
||||
request_id: Uuid,
|
||||
data: ReactionEvent,
|
||||
},
|
||||
Poll {
|
||||
request_id: Uuid,
|
||||
data: PollEvent,
|
||||
},
|
||||
Article {
|
||||
request_id: Uuid,
|
||||
data: ArticleEvent,
|
||||
},
|
||||
Category {
|
||||
request_id: Uuid,
|
||||
data: CategoryEvent,
|
||||
},
|
||||
Draft {
|
||||
request_id: Uuid,
|
||||
data: DraftEvent,
|
||||
},
|
||||
Follow {
|
||||
request_id: Uuid,
|
||||
data: FollowEvent,
|
||||
},
|
||||
ReadReceiptAck {
|
||||
request_id: Uuid,
|
||||
channel_id: Uuid,
|
||||
last_read_message_id: Uuid,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
last_seq: Option<i64>,
|
||||
},
|
||||
SeqAck {
|
||||
request_id: Uuid,
|
||||
channel_id: Uuid,
|
||||
seq: i64,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct TypingEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub thread_id: Option<Uuid>,
|
||||
pub user_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PresenceEvent {
|
||||
pub user_id: Uuid,
|
||||
pub status: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub custom_status_text: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub custom_status_emoji: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct MessageEvent {
|
||||
pub channel_id: Uuid,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub thread_id: Option<Uuid>,
|
||||
pub message_id: Uuid,
|
||||
pub author_id: Uuid,
|
||||
pub action: MessageAction,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub body: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub seq: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum MessageAction {
|
||||
Created,
|
||||
Edited,
|
||||
Deleted,
|
||||
Pinned,
|
||||
Unpinned,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ChannelEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub action: ChannelAction,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub workspace_name: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ChannelAction {
|
||||
Created,
|
||||
Updated,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ThreadEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub thread_id: Uuid,
|
||||
pub action: ThreadAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ThreadAction {
|
||||
Created,
|
||||
Updated,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct MemberEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub action: MemberAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum MemberAction {
|
||||
Joined,
|
||||
Left,
|
||||
Kicked,
|
||||
Updated,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReactionEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub message_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub action: ReactionAction,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub content: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ReactionAction {
|
||||
Added,
|
||||
Removed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PollEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub poll_id: Uuid,
|
||||
pub action: PollAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum PollAction {
|
||||
Created,
|
||||
Voted,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ArticleEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub article_id: Uuid,
|
||||
pub action: ArticleAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ArticleAction {
|
||||
Created,
|
||||
Updated,
|
||||
Published,
|
||||
Unpublished,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct CategoryEvent {
|
||||
pub workspace_name: String,
|
||||
pub category_id: Uuid,
|
||||
pub action: CategoryAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum CategoryAction {
|
||||
Created,
|
||||
Updated,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct DraftEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub thread_id: Option<Uuid>,
|
||||
pub action: DraftAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum DraftAction {
|
||||
Saved,
|
||||
Deleted,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FollowEvent {
|
||||
pub channel_id: Uuid,
|
||||
pub follow_id: Uuid,
|
||||
pub action: FollowAction,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum FollowAction {
|
||||
Created,
|
||||
Deleted,
|
||||
Retried,
|
||||
}
|
||||
Reference in New Issue
Block a user