fix(room): add cascade deletes and fix QuerySelect trait import
- Import room_message_reaction, room_message_edit_history, room_notifications modules - Fix room_message_edit_history: no Room column, use subquery via messages - Change publish_project_room_event from Result to () handling - Add QuerySelect import for limit() method in workers.rs
This commit is contained in:
parent
65627a8662
commit
e7a250357f
@ -4,6 +4,7 @@ use crate::ws_context::WsUserContext;
|
||||
use chrono::Utc;
|
||||
use models::rooms::{
|
||||
RoomMemberRole, room, room_ai, room_category, room_member, room_message, room_pin, room_thread,
|
||||
room_message_reaction, room_message_edit_history, room_notifications,
|
||||
};
|
||||
use models::projects::{project_members, MemberRole as Role};
|
||||
use queue::ProjectRoomEvent;
|
||||
@ -212,13 +213,10 @@ impl RoomService {
|
||||
seq: None,
|
||||
timestamp: Utc::now(),
|
||||
};
|
||||
if let Err(e) = self
|
||||
let _ = self
|
||||
.queue
|
||||
.publish_project_room_event(project.id, event)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to publish room created event");
|
||||
}
|
||||
.await;
|
||||
|
||||
self.notify_project_members(
|
||||
project.id,
|
||||
@ -293,13 +291,10 @@ impl RoomService {
|
||||
seq: None,
|
||||
timestamp: Utc::now(),
|
||||
};
|
||||
if let Err(e) = self
|
||||
let _ = self
|
||||
.queue
|
||||
.publish_project_room_event(updated.project, event)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to publish room event");
|
||||
}
|
||||
.await;
|
||||
}
|
||||
if moved {
|
||||
let event = ProjectRoomEvent {
|
||||
@ -311,13 +306,10 @@ impl RoomService {
|
||||
seq: None,
|
||||
timestamp: Utc::now(),
|
||||
};
|
||||
if let Err(e) = self
|
||||
let _ = self
|
||||
.queue
|
||||
.publish_project_room_event(updated.project, event)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to publish room event");
|
||||
}
|
||||
.await;
|
||||
}
|
||||
|
||||
Ok(super::RoomResponse::from(updated))
|
||||
@ -361,8 +353,14 @@ impl RoomService {
|
||||
.exec(&txn)
|
||||
.await?;
|
||||
|
||||
// room_message_edit_history has no room column; delete via messages in this room
|
||||
let subquery = room_message::Entity::find()
|
||||
.filter(room_message::Column::Room.eq(room_id))
|
||||
.select_only()
|
||||
.column(room_message::Column::Id)
|
||||
.into_query();
|
||||
room_message_edit_history::Entity::delete_many()
|
||||
.filter(room_message_edit_history::Column::Room.eq(room_id))
|
||||
.filter(room_message_edit_history::Column::Message.in_subquery(subquery))
|
||||
.exec(&txn)
|
||||
.await?;
|
||||
|
||||
@ -402,13 +400,10 @@ impl RoomService {
|
||||
seq: None,
|
||||
timestamp: Utc::now(),
|
||||
};
|
||||
if let Err(e) = self
|
||||
let _ = self
|
||||
.queue
|
||||
.publish_project_room_event(project_id, event)
|
||||
.await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to publish room deleted event");
|
||||
}
|
||||
.await;
|
||||
|
||||
self.notify_project_members(
|
||||
project_id,
|
||||
|
||||
@ -5,7 +5,7 @@ use db::cache::AppCache;
|
||||
use db::database::AppDatabase;
|
||||
use models::rooms::room;
|
||||
use queue::{AgentTaskEvent, MessageProducer};
|
||||
use sea_orm::EntityTrait;
|
||||
use sea_orm::{EntityTrait, QuerySelect};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::connection::{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user