From 215aa5932eaa3c21eab4b3e3350d0fa55f430848 Mon Sep 17 00:00:00 2001 From: silverpill Date: Wed, 24 Nov 2021 19:00:36 +0000 Subject: [PATCH] Make "href" property optional on Tag object --- src/activitypub/activity.rs | 6 +++--- src/activitypub/receiver.rs | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/activitypub/activity.rs b/src/activitypub/activity.rs index 42202a3..ef4d934 100644 --- a/src/activitypub/activity.rs +++ b/src/activitypub/activity.rs @@ -32,7 +32,7 @@ pub struct Tag { #[serde(rename = "type")] pub tag_type: String, - pub href: String, + pub href: Option, } #[derive(Default, Deserialize, Serialize)] @@ -149,7 +149,7 @@ pub fn create_note( Tag { name: profile.actor_address(instance_host), tag_type: MENTION.to_string(), - href: actor_id, + href: Some(actor_id), } }).collect(); let in_reply_to_object_id = match post.in_reply_to_id { @@ -419,7 +419,7 @@ mod tests { let tags = note.tag.unwrap(); assert_eq!(tags.len(), 1); assert_eq!(tags[0].name, parent_author_acct); - assert_eq!(tags[0].href, parent_author_actor_id); + assert_eq!(tags[0].href.as_ref().unwrap(), parent_author_actor_id); assert_eq!( note.to.unwrap(), json!([AP_PUBLIC, parent_author_actor_id]), diff --git a/src/activitypub/receiver.rs b/src/activitypub/receiver.rs index 412fdd6..97b5857 100644 --- a/src/activitypub/receiver.rs +++ b/src/activitypub/receiver.rs @@ -200,11 +200,14 @@ pub async fn process_note( let mut mentions: Vec = Vec::new(); if let Some(list) = object.tag { for tag in list { - if tag.tag_type == MENTION { + if tag.tag_type != MENTION { + continue; + }; + if let Some(href) = tag.href { let profile = get_or_fetch_profile_by_actor_id( db_client, &instance, - &tag.href, + &href, &config.media_dir(), ).await?; mentions.push(profile.id);