Deserialize actor tag to Vec<Value>
This commit is contained in:
parent
6335e216a9
commit
4204350375
3 changed files with 13 additions and 16 deletions
|
@ -1,13 +1,11 @@
|
|||
use std::path::Path;
|
||||
|
||||
use serde_json::{Value as JsonValue};
|
||||
|
||||
use mitra_config::Instance;
|
||||
|
||||
use crate::activitypub::{
|
||||
actors::types::Actor,
|
||||
fetcher::fetchers::fetch_file,
|
||||
receiver::{parse_property_value, HandlerError},
|
||||
receiver::HandlerError,
|
||||
};
|
||||
use crate::database::DatabaseClient;
|
||||
use crate::models::{
|
||||
|
@ -81,15 +79,9 @@ async fn fetch_actor_images(
|
|||
}
|
||||
|
||||
fn parse_tags(actor: &Actor) -> () {
|
||||
if let Some(ref tag_list_value) = actor.tag {
|
||||
let maybe_tag_list: Option<Vec<JsonValue>> =
|
||||
parse_property_value(tag_list_value).ok();
|
||||
if let Some(tag_list) = maybe_tag_list {
|
||||
for tag_value in tag_list {
|
||||
for tag_value in &actor.tag {
|
||||
log::debug!("found actor tag: {}", tag_value);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
pub async fn create_remote_profile(
|
||||
|
|
|
@ -29,6 +29,7 @@ use crate::activitypub::{
|
|||
LocalActorCollection,
|
||||
},
|
||||
receiver::parse_property_value,
|
||||
types::deserialize_value_array,
|
||||
vocabulary::{IDENTITY_PROOF, IMAGE, LINK, PERSON, PROPERTY_VALUE, SERVICE},
|
||||
};
|
||||
use crate::errors::ValidationError;
|
||||
|
@ -185,8 +186,12 @@ pub struct Actor {
|
|||
#[serde(default)]
|
||||
pub manually_approves_followers: bool,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub tag: Option<Value>,
|
||||
#[serde(
|
||||
default,
|
||||
deserialize_with = "deserialize_value_array",
|
||||
skip_serializing_if = "Vec::is_empty",
|
||||
)]
|
||||
pub tag: Vec<Value>,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub url: Option<String>,
|
||||
|
@ -351,7 +356,7 @@ pub fn get_local_actor(
|
|||
also_known_as: None,
|
||||
attachment: attachments,
|
||||
manually_approves_followers: false,
|
||||
tag: None,
|
||||
tag: vec![],
|
||||
url: Some(actor_id),
|
||||
};
|
||||
Ok(actor)
|
||||
|
@ -387,7 +392,7 @@ pub fn get_instance_actor(
|
|||
also_known_as: None,
|
||||
attachment: vec![],
|
||||
manually_approves_followers: false,
|
||||
tag: None,
|
||||
tag: vec![],
|
||||
url: None,
|
||||
};
|
||||
Ok(actor)
|
||||
|
|
|
@ -88,7 +88,7 @@ pub struct EmojiTag {
|
|||
pub updated: DateTime<Utc>,
|
||||
}
|
||||
|
||||
fn deserialize_value_array<'de, D>(
|
||||
pub fn deserialize_value_array<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<Vec<Value>, D::Error>
|
||||
where D: Deserializer<'de>
|
||||
|
|
Loading…
Reference in a new issue