treewide: fix various UI bugs; optimize crypto dependencies & format
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: If8fe8b38c1d9c4fecd40ff71f88d2ae06a6a6964
This commit is contained in:
parent
764aafa88d
commit
3ccddce7fd
178 changed files with 58342 additions and 54241 deletions
|
|
@ -1,78 +1,78 @@
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::model::*;
|
||||
use crate::storage::DynStorageBackend;
|
||||
use crate::{error::Result, model::*, storage::DynStorageBackend};
|
||||
|
||||
pub async fn create_collection(
|
||||
storage: &DynStorageBackend,
|
||||
name: &str,
|
||||
kind: CollectionKind,
|
||||
description: Option<&str>,
|
||||
filter_query: Option<&str>,
|
||||
storage: &DynStorageBackend,
|
||||
name: &str,
|
||||
kind: CollectionKind,
|
||||
description: Option<&str>,
|
||||
filter_query: Option<&str>,
|
||||
) -> Result<Collection> {
|
||||
storage
|
||||
.create_collection(name, kind, description, filter_query)
|
||||
.await
|
||||
storage
|
||||
.create_collection(name, kind, description, filter_query)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn add_member(
|
||||
storage: &DynStorageBackend,
|
||||
collection_id: Uuid,
|
||||
media_id: MediaId,
|
||||
position: i32,
|
||||
storage: &DynStorageBackend,
|
||||
collection_id: Uuid,
|
||||
media_id: MediaId,
|
||||
position: i32,
|
||||
) -> Result<()> {
|
||||
storage
|
||||
.add_to_collection(collection_id, media_id, position)
|
||||
.await?;
|
||||
crate::audit::record_action(
|
||||
storage,
|
||||
Some(media_id),
|
||||
AuditAction::AddedToCollection,
|
||||
Some(format!("collection_id={collection_id}")),
|
||||
)
|
||||
.await
|
||||
storage
|
||||
.add_to_collection(collection_id, media_id, position)
|
||||
.await?;
|
||||
crate::audit::record_action(
|
||||
storage,
|
||||
Some(media_id),
|
||||
AuditAction::AddedToCollection,
|
||||
Some(format!("collection_id={collection_id}")),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn remove_member(
|
||||
storage: &DynStorageBackend,
|
||||
collection_id: Uuid,
|
||||
media_id: MediaId,
|
||||
storage: &DynStorageBackend,
|
||||
collection_id: Uuid,
|
||||
media_id: MediaId,
|
||||
) -> Result<()> {
|
||||
storage
|
||||
.remove_from_collection(collection_id, media_id)
|
||||
.await?;
|
||||
crate::audit::record_action(
|
||||
storage,
|
||||
Some(media_id),
|
||||
AuditAction::RemovedFromCollection,
|
||||
Some(format!("collection_id={collection_id}")),
|
||||
)
|
||||
.await
|
||||
storage
|
||||
.remove_from_collection(collection_id, media_id)
|
||||
.await?;
|
||||
crate::audit::record_action(
|
||||
storage,
|
||||
Some(media_id),
|
||||
AuditAction::RemovedFromCollection,
|
||||
Some(format!("collection_id={collection_id}")),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_members(
|
||||
storage: &DynStorageBackend,
|
||||
collection_id: Uuid,
|
||||
storage: &DynStorageBackend,
|
||||
collection_id: Uuid,
|
||||
) -> Result<Vec<MediaItem>> {
|
||||
let collection = storage.get_collection(collection_id).await?;
|
||||
let collection = storage.get_collection(collection_id).await?;
|
||||
|
||||
match collection.kind {
|
||||
CollectionKind::Virtual => {
|
||||
// Virtual collections evaluate their filter_query dynamically
|
||||
if let Some(ref query_str) = collection.filter_query {
|
||||
let query = crate::search::parse_search_query(query_str)?;
|
||||
let request = crate::search::SearchRequest {
|
||||
query,
|
||||
sort: crate::search::SortOrder::DateDesc,
|
||||
pagination: Pagination::new(0, 10000, None),
|
||||
};
|
||||
let results = storage.search(&request).await?;
|
||||
Ok(results.items)
|
||||
} else {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
}
|
||||
CollectionKind::Manual => storage.get_collection_members(collection_id).await,
|
||||
}
|
||||
match collection.kind {
|
||||
CollectionKind::Virtual => {
|
||||
// Virtual collections evaluate their filter_query dynamically
|
||||
if let Some(ref query_str) = collection.filter_query {
|
||||
let query = crate::search::parse_search_query(query_str)?;
|
||||
let request = crate::search::SearchRequest {
|
||||
query,
|
||||
sort: crate::search::SortOrder::DateDesc,
|
||||
pagination: Pagination::new(0, 10000, None),
|
||||
};
|
||||
let results = storage.search(&request).await?;
|
||||
Ok(results.items)
|
||||
} else {
|
||||
Ok(Vec::new())
|
||||
}
|
||||
},
|
||||
CollectionKind::Manual => {
|
||||
storage.get_collection_members(collection_id).await
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue