From 3b470a04f7bf76f9791b8a1c7c731d465a808606 Mon Sep 17 00:00:00 2001 From: silverpill Date: Thu, 17 Nov 2022 22:49:31 +0000 Subject: [PATCH] Allow alsoKnownAs attribute value to be string --- src/activitypub/actors/types.rs | 2 +- src/activitypub/fetcher/helpers.rs | 5 ----- src/activitypub/handlers/move_person.rs | 7 ++++--- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/activitypub/actors/types.rs b/src/activitypub/actors/types.rs index 100f758..1942f5a 100644 --- a/src/activitypub/actors/types.rs +++ b/src/activitypub/actors/types.rs @@ -110,7 +110,7 @@ pub struct Actor { pub summary: Option, #[serde(skip_serializing_if = "Option::is_none")] - pub also_known_as: Option>, + pub also_known_as: Option, #[serde(skip_serializing_if = "Option::is_none")] pub attachment: Option>, diff --git a/src/activitypub/fetcher/helpers.rs b/src/activitypub/fetcher/helpers.rs index 96fa5f6..f1e23c6 100644 --- a/src/activitypub/fetcher/helpers.rs +++ b/src/activitypub/fetcher/helpers.rs @@ -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, diff --git a/src/activitypub/handlers/move_person.rs b/src/activitypub/handlers/move_person.rs index fcb5bab..e161269 100644 --- a/src/activitypub/handlers/move_person.rs +++ b/src/activitypub/handlers/move_person.rs @@ -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()); };