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

93 lines
2.0 KiB
Rust

use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserInfo {
pub id: Uuid,
pub username: String,
pub display_name: String,
pub avatar_url: String,
}
impl UserInfo {
pub fn unknown(id: Uuid) -> Self {
Self {
id,
username: String::new(),
display_name: String::new(),
avatar_url: String::new(),
}
}
pub fn from_model(m: &model::users::UserModel) -> Self {
Self {
id: m.id,
username: m.username.clone(),
display_name: m.display_name.clone(),
avatar_url: m.avatar_url.clone(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomInfo {
pub id: Uuid,
pub name: String,
}
impl RoomInfo {
pub fn unknown(id: Uuid) -> Self {
Self {
id,
name: String::new(),
}
}
pub fn from_model(m: &model::room::RoomModel) -> Self {
Self {
id: m.id,
name: m.name.clone(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkspaceInfo {
pub id: Uuid,
pub name: String,
pub avatar_url: String,
}
impl WorkspaceInfo {
pub fn unknown(id: Uuid) -> Self {
Self {
id,
name: String::new(),
avatar_url: String::new(),
}
}
pub fn from_model(m: &model::workspace::WorkspaceModel) -> Self {
Self {
id: m.id,
name: m.name.clone(),
avatar_url: m.avatar_url.clone(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AgentInfo {
pub id: Uuid,
pub name: String,
pub agent_type: String,
pub model_name: Option<String>,
}
impl AgentInfo {
pub fn unknown(id: Uuid) -> Self {
Self {
id,
name: String::new(),
agent_type: String::new(),
model_name: None,
}
}
}