From a2e8f5bf5b88b2f2cb00b50ff6cd221b592aa9b0 Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Mon, 20 Apr 2026 15:45:03 +0800 Subject: [PATCH] feat(models/rooms): add room attachment model and update room message/notifications --- libs/models/rooms/mod.rs | 2 ++ libs/models/rooms/room_attachment.rs | 22 ++++++++++++++++++++++ libs/models/rooms/room_message.rs | 2 ++ libs/models/rooms/room_notifications.rs | 6 ++++++ 4 files changed, 32 insertions(+) create mode 100644 libs/models/rooms/room_attachment.rs diff --git a/libs/models/rooms/mod.rs b/libs/models/rooms/mod.rs index 8fcdac9..949a77e 100644 --- a/libs/models/rooms/mod.rs +++ b/libs/models/rooms/mod.rs @@ -114,6 +114,7 @@ impl std::fmt::Display for ToolCallStatus { pub use room::Entity as Room; pub use room_ai::Entity as RoomAi; +pub use room_attachment::Entity as RoomAttachment; pub use room_category::Entity as RoomCategory; pub use room_member::Entity as RoomMember; pub use room_message::Entity as RoomMessage; @@ -125,6 +126,7 @@ pub use room_pin::Entity as RoomPin; pub use room_thread::Entity as RoomThread; pub mod room; pub mod room_ai; +pub mod room_attachment; pub mod room_category; pub mod room_member; pub mod room_message; diff --git a/libs/models/rooms/room_attachment.rs b/libs/models/rooms/room_attachment.rs new file mode 100644 index 0000000..3be74e9 --- /dev/null +++ b/libs/models/rooms/room_attachment.rs @@ -0,0 +1,22 @@ +use crate::{DateTimeUtc, MessageId, RoomId, UserId}; +use sea_orm::entity::prelude::*; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] +#[sea_orm(table_name = "room_attachment")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: Uuid, + pub room: RoomId, + pub message: MessageId, + pub uploader: UserId, + pub file_name: String, + pub file_size: i64, + pub content_type: String, + pub s3_key: String, + pub created_at: DateTimeUtc, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation {} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/libs/models/rooms/room_message.rs b/libs/models/rooms/room_message.rs index 901c117..ef1a90a 100644 --- a/libs/models/rooms/room_message.rs +++ b/libs/models/rooms/room_message.rs @@ -13,6 +13,8 @@ pub struct Model { pub room: RoomId, pub sender_type: MessageSenderType, pub sender_id: Option, + /// AI model ID — set when sender_type = "ai", used for display name lookups. + pub model_id: Option, pub thread: Option, pub in_reply_to: Option, pub content: String, diff --git a/libs/models/rooms/room_notifications.rs b/libs/models/rooms/room_notifications.rs index d37adf6..a0162f1 100644 --- a/libs/models/rooms/room_notifications.rs +++ b/libs/models/rooms/room_notifications.rs @@ -18,6 +18,10 @@ pub enum NotificationType { RoomDeleted, #[sea_orm(string_value = "system_announcement")] SystemAnnouncement, + #[sea_orm(string_value = "project_invitation")] + ProjectInvitation, + #[sea_orm(string_value = "workspace_invitation")] + WorkspaceInvitation, } impl std::fmt::Display for NotificationType { @@ -29,6 +33,8 @@ impl std::fmt::Display for NotificationType { NotificationType::RoomCreated => "room_created", NotificationType::RoomDeleted => "room_deleted", NotificationType::SystemAnnouncement => "system_announcement", + NotificationType::ProjectInvitation => "project_invitation", + NotificationType::WorkspaceInvitation => "workspace_invitation", }; write!(f, "{}", s) }