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 chrono::Utc;
|
||||||
use models::rooms::{
|
use models::rooms::{
|
||||||
RoomMemberRole, room, room_ai, room_category, room_member, room_message, room_pin, room_thread,
|
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 models::projects::{project_members, MemberRole as Role};
|
||||||
use queue::ProjectRoomEvent;
|
use queue::ProjectRoomEvent;
|
||||||
@ -212,13 +213,10 @@ impl RoomService {
|
|||||||
seq: None,
|
seq: None,
|
||||||
timestamp: Utc::now(),
|
timestamp: Utc::now(),
|
||||||
};
|
};
|
||||||
if let Err(e) = self
|
let _ = self
|
||||||
.queue
|
.queue
|
||||||
.publish_project_room_event(project.id, event)
|
.publish_project_room_event(project.id, event)
|
||||||
.await
|
.await;
|
||||||
{
|
|
||||||
tracing::warn!(error = %e, "failed to publish room created event");
|
|
||||||
}
|
|
||||||
|
|
||||||
self.notify_project_members(
|
self.notify_project_members(
|
||||||
project.id,
|
project.id,
|
||||||
@ -293,13 +291,10 @@ impl RoomService {
|
|||||||
seq: None,
|
seq: None,
|
||||||
timestamp: Utc::now(),
|
timestamp: Utc::now(),
|
||||||
};
|
};
|
||||||
if let Err(e) = self
|
let _ = self
|
||||||
.queue
|
.queue
|
||||||
.publish_project_room_event(updated.project, event)
|
.publish_project_room_event(updated.project, event)
|
||||||
.await
|
.await;
|
||||||
{
|
|
||||||
tracing::warn!(error = %e, "failed to publish room event");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if moved {
|
if moved {
|
||||||
let event = ProjectRoomEvent {
|
let event = ProjectRoomEvent {
|
||||||
@ -311,13 +306,10 @@ impl RoomService {
|
|||||||
seq: None,
|
seq: None,
|
||||||
timestamp: Utc::now(),
|
timestamp: Utc::now(),
|
||||||
};
|
};
|
||||||
if let Err(e) = self
|
let _ = self
|
||||||
.queue
|
.queue
|
||||||
.publish_project_room_event(updated.project, event)
|
.publish_project_room_event(updated.project, event)
|
||||||
.await
|
.await;
|
||||||
{
|
|
||||||
tracing::warn!(error = %e, "failed to publish room event");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(super::RoomResponse::from(updated))
|
Ok(super::RoomResponse::from(updated))
|
||||||
@ -361,8 +353,14 @@ impl RoomService {
|
|||||||
.exec(&txn)
|
.exec(&txn)
|
||||||
.await?;
|
.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()
|
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)
|
.exec(&txn)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@ -402,13 +400,10 @@ impl RoomService {
|
|||||||
seq: None,
|
seq: None,
|
||||||
timestamp: Utc::now(),
|
timestamp: Utc::now(),
|
||||||
};
|
};
|
||||||
if let Err(e) = self
|
let _ = self
|
||||||
.queue
|
.queue
|
||||||
.publish_project_room_event(project_id, event)
|
.publish_project_room_event(project_id, event)
|
||||||
.await
|
.await;
|
||||||
{
|
|
||||||
tracing::warn!(error = %e, "failed to publish room deleted event");
|
|
||||||
}
|
|
||||||
|
|
||||||
self.notify_project_members(
|
self.notify_project_members(
|
||||||
project_id,
|
project_id,
|
||||||
|
|||||||
@ -5,7 +5,7 @@ use db::cache::AppCache;
|
|||||||
use db::database::AppDatabase;
|
use db::database::AppDatabase;
|
||||||
use models::rooms::room;
|
use models::rooms::room;
|
||||||
use queue::{AgentTaskEvent, MessageProducer};
|
use queue::{AgentTaskEvent, MessageProducer};
|
||||||
use sea_orm::EntityTrait;
|
use sea_orm::{EntityTrait, QuerySelect};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::connection::{
|
use crate::connection::{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user