420dedbc1e
- Add IM service modules: audit, channel roles, custom emojis, forum tags, integrations, invitations, repo links, slash commands, stages, voice, webhooks - Add PR service modules: review requests, templates - Add repo service modules: contributors, release assets, git extras (archive, branch rename, commit extras, diff/merge, tag, tree) - Add user service: social (follow/block) - Add internal auth service - Update existing service modules with expanded functionality - Remove deleted IM modules: articles, delivery trace, drafts, follows, messages, polls, presence, reactions, threads
33 lines
910 B
Rust
33 lines
910 B
Rust
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<Vec<ChannelEvent>, 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)
|
|
}
|
|
}
|