Add api to get tags for a list of file hashes

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/4/head
trivernis 3 years ago
parent 55fc99bcce
commit af104dedec

@ -1,6 +1,6 @@
[package] [package]
name = "mediarepo-api" name = "mediarepo-api"
version = "0.1.0" version = "0.2.0"
edition = "2018" edition = "2018"
license = "gpl-3" license = "gpl-3"

@ -1,6 +1,6 @@
use crate::client_api::error::ApiResult; use crate::client_api::error::ApiResult;
use crate::client_api::IPCApi; use crate::client_api::IPCApi;
use crate::types::files::GetFileTagsRequest; use crate::types::files::{GetFileTagsRequest, GetFilesTagsRequest};
use crate::types::identifier::FileIdentifier; use crate::types::identifier::FileIdentifier;
use crate::types::tags::TagResponse; use crate::types::tags::TagResponse;
use async_trait::async_trait; use async_trait::async_trait;
@ -45,4 +45,11 @@ impl TagApi {
) )
.await .await
} }
/// Returns a list of all tags that are assigned to the list of files
#[tracing::instrument(level = "debug", skip_all)]
pub async fn get_tags_for_files(&self, hashes: Vec<String>) -> ApiResult<Vec<TagResponse>> {
self.emit_and_get("tags_for_files", GetFilesTagsRequest { hashes })
.await
}
} }

@ -22,6 +22,11 @@ pub struct GetFileTagsRequest {
pub id: FileIdentifier, pub id: FileIdentifier,
} }
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct GetFilesTagsRequest {
pub hashes: Vec<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize)] #[derive(Clone, Debug, Serialize, Deserialize)]
pub struct FindFilesByTagsRequest { pub struct FindFilesByTagsRequest {
pub tags: Vec<TagQuery>, pub tags: Vec<TagQuery>,

Loading…
Cancel
Save