From 3b8a43013d2e602135d73070dd3922b77bdfaefa Mon Sep 17 00:00:00 2001 From: default Date: Wed, 28 Sep 2022 05:16:17 +0200 Subject: [PATCH] Check for muted actors in Announce messages. --- activitypub.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/activitypub.c b/activitypub.c index 2020caf..fc90fe6 100644 --- a/activitypub.c +++ b/activitypub.c @@ -563,6 +563,7 @@ void process_message(snac *snac, char *msg, char *req) /* actor and type exist, were checked previously */ char *actor = xs_dict_get(msg, "actor"); char *type = xs_dict_get(msg, "type"); + xs *actor_o = NULL; char *object, *utype; @@ -572,6 +573,9 @@ void process_message(snac *snac, char *msg, char *req) else utype = "(null)"; + /* bring the actor */ + actor_request(snac, actor, &actor_o); + /* check the signature */ /* ... */ @@ -632,13 +636,25 @@ void process_message(snac *snac, char *msg, char *req) } else if (strcmp(type, "Announce") == 0) { + xs *a_msg = NULL; + if (xs_type(object) == XSTYPE_DICT) object = xs_dict_get(object, "id"); timeline_request(snac, object, actor); - timeline_admire(snac, object, actor, 0); - snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object)); + if ((a_msg = timeline_find(snac, object)) != NULL) { + char *who = xs_dict_get(a_msg, "attributedTo"); + + if (who && !is_muted(snac, who)) { + timeline_admire(snac, object, actor, 0); + snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object)); + } + else + snac_log(snac, xs_fmt("ignored 'Announce' about muted actor %s", who)); + } + else + snac_log(snac, xs_fmt("error requesting 'Announce' object %s", object)); } /* else