Allow alsoKnownAs attribute value to be string

This commit is contained in:
silverpill 2022-11-17 22:49:31 +00:00
parent 8045b9f543
commit 3b470a04f7
3 changed files with 5 additions and 9 deletions

View file

@ -110,7 +110,7 @@ pub struct Actor {
pub summary: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub also_known_as: Option<Vec<String>>,
pub also_known_as: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attachment: Option<Vec<ActorAttachment>>,

View file

@ -43,11 +43,6 @@ async fn create_remote_profile(
if actor_address.is_local(&instance.host()) {
return Err(HandlerError::LocalObject);
};
let maybe_also_known_as = actor.also_known_as.as_ref()
.and_then(|aliases| aliases.first());
if let Some(ref also_known_as) = maybe_also_known_as {
log::warn!("actor also known as {}", also_known_as);
};
let (maybe_avatar, maybe_banner) = fetch_actor_images(
instance,
&actor,

View file

@ -7,7 +7,7 @@ use crate::activitypub::{
undo_follow::prepare_undo_follow,
},
fetcher::helpers::get_or_import_profile_by_actor_id,
receiver::find_object_id,
receiver::{find_object_id, parse_array},
vocabulary::PERSON,
};
use crate::config::Config;
@ -53,8 +53,9 @@ pub async fn handle_move_person(
).await?;
let new_actor = new_profile.actor_json.unwrap();
let maybe_also_known_as = new_actor.also_known_as.as_ref()
.and_then(|aliases| aliases.first());
if maybe_also_known_as != Some(&old_actor.id) {
.and_then(|value| parse_array(value).ok())
.and_then(|aliases| aliases.first().cloned());
if maybe_also_known_as.as_ref() != Some(&old_actor.id) {
return Err(ValidationError("target ID is not an alias").into());
};