feat(models/rooms): add room attachment model and update room message/notifications

This commit is contained in:
ZhenYi 2026-04-20 15:45:03 +08:00
parent 98e6f77341
commit a2e8f5bf5b
4 changed files with 32 additions and 0 deletions

View File

@ -114,6 +114,7 @@ impl std::fmt::Display for ToolCallStatus {
pub use room::Entity as Room; pub use room::Entity as Room;
pub use room_ai::Entity as RoomAi; pub use room_ai::Entity as RoomAi;
pub use room_attachment::Entity as RoomAttachment;
pub use room_category::Entity as RoomCategory; pub use room_category::Entity as RoomCategory;
pub use room_member::Entity as RoomMember; pub use room_member::Entity as RoomMember;
pub use room_message::Entity as RoomMessage; 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 use room_thread::Entity as RoomThread;
pub mod room; pub mod room;
pub mod room_ai; pub mod room_ai;
pub mod room_attachment;
pub mod room_category; pub mod room_category;
pub mod room_member; pub mod room_member;
pub mod room_message; pub mod room_message;

View File

@ -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 {}

View File

@ -13,6 +13,8 @@ pub struct Model {
pub room: RoomId, pub room: RoomId,
pub sender_type: MessageSenderType, pub sender_type: MessageSenderType,
pub sender_id: Option<UserId>, pub sender_id: Option<UserId>,
/// AI model ID — set when sender_type = "ai", used for display name lookups.
pub model_id: Option<Uuid>,
pub thread: Option<RoomThreadId>, pub thread: Option<RoomThreadId>,
pub in_reply_to: Option<MessageId>, pub in_reply_to: Option<MessageId>,
pub content: String, pub content: String,

View File

@ -18,6 +18,10 @@ pub enum NotificationType {
RoomDeleted, RoomDeleted,
#[sea_orm(string_value = "system_announcement")] #[sea_orm(string_value = "system_announcement")]
SystemAnnouncement, SystemAnnouncement,
#[sea_orm(string_value = "project_invitation")]
ProjectInvitation,
#[sea_orm(string_value = "workspace_invitation")]
WorkspaceInvitation,
} }
impl std::fmt::Display for NotificationType { impl std::fmt::Display for NotificationType {
@ -29,6 +33,8 @@ impl std::fmt::Display for NotificationType {
NotificationType::RoomCreated => "room_created", NotificationType::RoomCreated => "room_created",
NotificationType::RoomDeleted => "room_deleted", NotificationType::RoomDeleted => "room_deleted",
NotificationType::SystemAnnouncement => "system_announcement", NotificationType::SystemAnnouncement => "system_announcement",
NotificationType::ProjectInvitation => "project_invitation",
NotificationType::WorkspaceInvitation => "workspace_invitation",
}; };
write!(f, "{}", s) write!(f, "{}", s)
} }