- 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
41 lines
2.0 KiB
Rust
41 lines
2.0 KiB
Rust
use crate::error::RoomError;
|
|
use crate::service::RoomService;
|
|
use crate::ws_context::WsUserContext;
|
|
use chrono::Utc;
|
|
use models::rooms::{room_message, room_message_reaction};
|
|
use sea_orm::*;
|
|
use uuid::Uuid;
|
|
|
|
impl RoomService {
|
|
pub async fn room_message_reaction_list(&self, room_id: Uuid, message_id: Uuid, ctx: &WsUserContext) -> Result<super::reaction::MessageReactionsResponse, RoomError> {
|
|
let user_id = ctx.user_id;
|
|
self.require_room_access(room_id, user_id).await?;
|
|
let _msg = room_message::Entity::find_by_id(message_id).one(&self.db).await?
|
|
.ok_or_else(|| RoomError::NotFound("Message not found".to_string()))?;
|
|
self.get_message_reactions(message_id, Some(user_id)).await
|
|
}
|
|
|
|
pub async fn room_message_reaction_toggle(&self, room_id: Uuid, message_id: Uuid, emoji: String, ctx: &WsUserContext) -> Result<super::reaction::MessageReactionsResponse, RoomError> {
|
|
let user_id = ctx.user_id;
|
|
self.require_room_access(room_id, user_id).await?;
|
|
if emoji.is_empty() || emoji.len() > 50 {
|
|
return Err(RoomError::BadRequest("Invalid emoji format".to_string()));
|
|
}
|
|
|
|
if let Some(existing) = room_message_reaction::Entity::find()
|
|
.filter(room_message_reaction::Column::Room.eq(room_id))
|
|
.filter(room_message_reaction::Column::Message.eq(message_id))
|
|
.filter(room_message_reaction::Column::User.eq(user_id))
|
|
.filter(room_message_reaction::Column::Emoji.eq(&emoji))
|
|
.one(&self.db).await?
|
|
{
|
|
room_message_reaction::Entity::delete_by_id(existing.id).exec(&self.db).await?;
|
|
} else {
|
|
room_message_reaction::ActiveModel {
|
|
id: Set(Uuid::now_v7()), room: Set(room_id), message: Set(message_id),
|
|
user: Set(user_id), emoji: Set(emoji), created_at: Set(Utc::now()),
|
|
}.insert(&self.db).await?;
|
|
}
|
|
self.get_message_reactions(message_id, Some(user_id)).await
|
|
}
|
|
} |