115 lines
2.7 KiB
Rust
115 lines
2.7 KiB
Rust
use chrono::{DateTime, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use models::{RoomId, Uuid};
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum MemberEventType {
|
|
Joined,
|
|
Removed,
|
|
ReadReceipt,
|
|
TypingStart,
|
|
TypingStop,
|
|
DndUpdated,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
#[serde(tag = "type", rename_all = "snake_case")]
|
|
pub enum MemberEvent {
|
|
Joined(MemberJoinedService),
|
|
Removed(MemberRemovedService),
|
|
ReadReceipt(ReadReceiptService),
|
|
TypingStart(TypingStartService),
|
|
TypingStop(TypingStopService),
|
|
DndUpdated(DndUpdatedService),
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct MemberJoinedService {
|
|
pub room: RoomId,
|
|
pub user: Uuid,
|
|
pub username: String,
|
|
pub project_role: String,
|
|
pub joined_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct MemberRemovedService {
|
|
pub room: RoomId,
|
|
pub user: Uuid,
|
|
pub removed_by: Uuid,
|
|
pub removed_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct ReadReceiptService {
|
|
pub room: RoomId,
|
|
pub user: Uuid,
|
|
pub last_read_seq: i64,
|
|
pub updated_at: DateTime<Utc>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TypingStartService {
|
|
pub room: RoomId,
|
|
pub user: Uuid,
|
|
pub username: String,
|
|
pub avatar_url: Option<String>,
|
|
pub sender_type: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct TypingStopService {
|
|
pub room: RoomId,
|
|
pub user: Uuid,
|
|
pub username: String,
|
|
pub avatar_url: Option<String>,
|
|
pub sender_type: Option<String>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct DndUpdatedService {
|
|
pub room: RoomId,
|
|
pub user: Uuid,
|
|
pub do_not_disturb: bool,
|
|
pub dnd_start_hour: Option<i16>,
|
|
pub dnd_end_hour: Option<i16>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct AccessGrantClient {
|
|
pub room: RoomId,
|
|
pub user_id: Uuid,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct AccessRevokeClient {
|
|
pub room: RoomId,
|
|
pub user_id: Uuid,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct ReadReceiptClient {
|
|
pub room: RoomId,
|
|
pub last_read_seq: i64,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct TypingStartClient {
|
|
pub room: RoomId,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct TypingStopClient {
|
|
pub room: RoomId,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Serialize)]
|
|
pub struct DndUpdateClient {
|
|
pub room: RoomId,
|
|
pub do_not_disturb: Option<bool>,
|
|
pub dnd_start_hour: Option<i16>,
|
|
pub dnd_end_hour: Option<i16>,
|
|
}
|