gitdataai/lib/channel/event/voice.rs
2026-05-30 01:38:40 +08:00

126 lines
3.2 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use crate::event::{RoomInfo, UserInfo, WorkspaceInfo};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum VoiceEventType {
ChannelJoined,
ChannelLeft,
MuteUpdated,
DeafUpdated,
ScreenShareStarted,
ScreenShareStopped,
SpeakingStarted,
SpeakingStopped,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum VoiceEvent {
#[serde(rename = "voice.channel_joined")]
ChannelJoined(VoiceChannelJoinedService),
#[serde(rename = "voice.channel_left")]
ChannelLeft(VoiceChannelLeftService),
#[serde(rename = "voice.mute_updated")]
MuteUpdated(VoiceMuteUpdatedService),
#[serde(rename = "voice.deaf_updated")]
DeafUpdated(VoiceDeafUpdatedService),
#[serde(rename = "voice.screen_share_started")]
ScreenShareStarted(ScreenShareStartedService),
#[serde(rename = "voice.screen_share_stopped")]
ScreenShareStopped(ScreenShareStoppedService),
#[serde(rename = "voice.speaking_started")]
SpeakingStarted(SpeakingStartedService),
#[serde(rename = "voice.speaking_stopped")]
SpeakingStopped(SpeakingStoppedService),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceChannelJoinedService {
pub room: RoomInfo,
pub workspace: Option<WorkspaceInfo>,
pub user: UserInfo,
pub muted: bool,
pub deafened: bool,
pub video: bool,
pub joined_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceChannelLeftService {
pub room: RoomInfo,
pub workspace: Option<WorkspaceInfo>,
pub user: UserInfo,
pub left_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceMuteUpdatedService {
pub room: RoomInfo,
pub user: UserInfo,
pub muted: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceDeafUpdatedService {
pub room: RoomInfo,
pub user: UserInfo,
pub deafened: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScreenShareStartedService {
pub room: RoomInfo,
pub user: UserInfo,
pub started_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScreenShareStoppedService {
pub room: RoomInfo,
pub user: UserInfo,
pub stopped_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SpeakingStartedService {
pub room: RoomInfo,
pub user: UserInfo,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SpeakingStoppedService {
pub room: RoomInfo,
pub user: UserInfo,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceJoinClient {
pub room: RoomInfo,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceLeaveClient {
pub room: RoomInfo,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceMuteClient {
pub room: RoomInfo,
pub muted: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VoiceDeafClient {
pub room: RoomInfo,
pub deafened: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScreenShareClient {
pub room: RoomInfo,
pub start: bool,
}