gitdataai/libs/transport/event/rooms.rs
ZhenYi 14f6e1e500 feat(core): initialize project with access control and AI integration
- Add gitignore and prettier configuration files for project scaffolding
- Implement room access control service with project member verification
- Create user access key management with CRUD operations and activity logging
- Add accordion UI component for frontend expandable sections
- Implement room AI configuration with list, upsert, and delete operations
- Add AI event types for agent join/leave/status change tracking
- Create streaming AI processing services for mode and react patterns
- Build room AI service with model detection and idempotency handling
- Integrate chat service orchestration for AI message processing
- Add typing indicators and stream cancellation for AI interactions
- Implement mention parsing and context extraction for AI agents
2026-05-03 06:04:31 +08:00

128 lines
3.3 KiB
Rust

use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use models::{ProjectId, RoomCategoryId, RoomId, UserId, Uuid};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RoomEventType {
Created,
Deleted,
Renamed,
TopicUpdated,
SettingsUpdated,
Moved,
AiUpdated,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "type", rename_all = "snake_case")]
pub enum RoomEvent {
Created(RoomCreatedService),
Deleted(RoomDeletedService),
Renamed(RoomRenamedService),
TopicUpdated(RoomTopicUpdatedService),
SettingsUpdated(RoomSettingsUpdatedService),
Moved(RoomMovedService),
AiUpdated(RoomAiUpdatedService),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomCreatedService {
pub id: RoomId,
pub project: ProjectId,
pub room_name: String,
pub public: bool,
pub category: Option<RoomCategoryId>,
pub created_by: UserId,
pub created_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomDeletedService {
pub id: RoomId,
pub project: ProjectId,
pub deleted_by: UserId,
pub deleted_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomRenamedService {
pub id: RoomId,
pub project: ProjectId,
pub old_name: String,
pub new_name: String,
pub renamed_by: UserId,
pub renamed_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomMovedService {
pub id: RoomId,
pub project: ProjectId,
pub old_category: Option<RoomCategoryId>,
pub new_category: Option<RoomCategoryId>,
pub moved_by: UserId,
pub moved_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomAiUpdatedService {
pub id: RoomId,
pub model: Uuid,
pub model_name: Option<String>,
pub version: Option<Uuid>,
pub agent_type: Option<String>,
pub updated_by: UserId,
pub updated_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomTopicUpdatedService {
pub id: RoomId,
pub project: ProjectId,
pub old_topic: Option<String>,
pub new_topic: Option<String>,
pub updated_by: UserId,
pub updated_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RoomSettingsUpdatedService {
pub id: RoomId,
pub project: ProjectId,
pub slowmode_seconds: Option<i32>,
pub nsfw: Option<bool>,
pub default_auto_archive_duration: Option<i32>,
pub updated_by: UserId,
pub updated_at: DateTime<Utc>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RoomCreateClient {
pub project: ProjectId,
pub room_name: String,
#[serde(rename = "room_public")]
pub public: bool,
pub category: Option<RoomCategoryId>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RoomUpdateClient {
pub room_name: Option<String>,
#[serde(rename = "room_public")]
pub public: Option<bool>,
pub category: Option<RoomCategoryId>,
pub topic: Option<String>,
pub slowmode_seconds: Option<i32>,
pub nsfw: Option<bool>,
pub default_auto_archive_duration: Option<i32>,
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RoomDeleteClient {}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct RoomLoadClient {
pub room: RoomId,
}