From 3698d1947dc8c7dd81955ddbd20727b1195d5e61 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 26 Jun 2024 05:30:19 +0200 Subject: [PATCH] fix: remove addressing ad-hoc cases --- upub/core/src/traits/normalize.rs | 32 ++++--------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/upub/core/src/traits/normalize.rs b/upub/core/src/traits/normalize.rs index d8da478..085843a 100644 --- a/upub/core/src/traits/normalize.rs +++ b/upub/core/src/traits/normalize.rs @@ -166,43 +166,19 @@ impl Normalizer for crate::Context { // since ActivityPub is a mess most software doesnt' really respect addressing, or care // about inserting it correctly. // - // * we can assume that Follow activities should *at least* be + // * we can assume that Follow and Accept activities should *at least* be // addressed to their target, since how would anyone be able to accept it otherwise??? - // - // * announces are messy because everything is in the `to` field. we should probably move - // followers to `cc` and keep just as#Public and the original poster in `to`, so that they - // get notified but everyone else sees the object again - // - // * misskey sends us mentions without including us in the `to` field! basically the Create - // will have a `tag` mention but it will not include the mentioned user in the `to` field match activity_model.activity_type { - apb::ActivityType::Follow => { + apb::ActivityType::Follow + | apb::ActivityType::Accept(apb::AcceptType::Accept) + => { if let Some(ref target) = activity_model.object { if !activity_model.to.0.contains(target) { activity_model.to.0.push(target.clone()); } } }, - apb::ActivityType::Announce => { - for target in activity_model.to.0.iter() { - if target.ends_with("followers") { - activity_model.cc.0.push(target.clone()); - } - } - activity_model.to.0.retain(|x| !x.ends_with("followers")); - }, - apb::ActivityType::Create => { - if let Some(object) = activity.object().get() { - for tag in object.tag().flat() { - if let Node::Link(l) = tag { - if matches!(l.link_type(), Ok(apb::LinkType::Mention)) { - activity_model.to.0.push(l.href().to_string()); - } - } - } - } - }, _ => {}, }