use uuid::Uuid; use crate::error::AppError; use crate::models::channels::ChannelEvent; use crate::service::ImService; use super::session::ImSession; impl ImService { pub async fn audit_list( &self, _ctx: &ImSession, channel_id: Uuid, limit: i64, offset: i64, ) -> Result, AppError> { let limit = limit.clamp(1, 100); let offset = offset.max(0); sqlx::query_as::<_, ChannelEvent>( "SELECT id, channel_id, actor_id, event_type, target_type, target_id, \ old_value, new_value, metadata, created_at \ FROM channel_event WHERE channel_id = $1 \ ORDER BY created_at DESC LIMIT $2 OFFSET $3", ) .bind(channel_id) .bind(limit) .bind(offset) .fetch_all(self.ctx.db.reader()) .await .map_err(AppError::Database) } }