Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4c4815ad145650a07f108614034d2e996a6a6964
39 lines
829 B
Rust
39 lines
829 B
Rust
use uuid::Uuid;
|
|
|
|
use crate::{
|
|
error::Result,
|
|
model::{AuditAction, AuditEntry, MediaId},
|
|
storage::DynStorageBackend,
|
|
};
|
|
|
|
/// Records an audit action for a media item.
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `storage` - Storage backend for persistence
|
|
/// * `media_id` - Optional media item that was affected
|
|
/// * `action` - The action being performed
|
|
/// * `details` - Optional additional details
|
|
///
|
|
/// # Returns
|
|
///
|
|
/// `Ok(())` on success
|
|
///
|
|
/// # Errors
|
|
///
|
|
/// Returns errors from the storage backend
|
|
pub async fn record_action(
|
|
storage: &DynStorageBackend,
|
|
media_id: Option<MediaId>,
|
|
action: AuditAction,
|
|
details: Option<String>,
|
|
) -> Result<()> {
|
|
let entry = AuditEntry {
|
|
id: Uuid::now_v7(),
|
|
media_id,
|
|
action,
|
|
details,
|
|
timestamp: chrono::Utc::now(),
|
|
};
|
|
storage.record_audit(&entry).await
|
|
}
|