snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit fc9140bf1a94ea927c10db9c6bfb70afe5438bef
parent 1039c2dff51173b46278c6b89555af7b273a9eae
Author: default <nobody@localhost>
Date:   Tue,  7 Jan 2025 19:01:46 +0100

Added a tweak to follow LitePub (Pleroma-style, https://litepub.social/) relays.

Usage: create a magic user named 'relay' and make it follow a relay actor (examples:
https://relay.c.im/actor or https://relay.ie9.org/actor).

Unfollowing returns a 400 status and posts keep arriving (at least with ie9.org),
so this is a problem at this moment.

Diffstat:
Mactivitypub.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/activitypub.c b/activitypub.c @@ -675,7 +675,7 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg) if (pub_msg) { /* a public message for someone we follow? (probably cc'ed) accept */ - if (following_check(snac, v)) + if (strcmp(v, public_address) != 0 && following_check(snac, v)) return 5; } else @@ -1242,6 +1242,10 @@ xs_dict *msg_actor(snac *snac) if (xs_type(xs_dict_get(snac->config, "bot")) == XSTYPE_TRUE) msg = xs_dict_set(msg, "type", "Service"); + /* if it's named "relay", then identify as an "Application" */ + if (strcmp(snac->uid, "relay") == 0) + msg = xs_dict_set(msg, "type", "Application"); + /* add the header image, if there is one defined */ const char *header = xs_dict_get(snac->config, "header"); if (!xs_is_null(header)) { @@ -2773,11 +2777,12 @@ void process_queue_item(xs_dict *q_item) snac user; if (user_open(&user, v)) { - if (is_msg_for_me(&user, msg)) { + int rsn = is_msg_for_me(&user, msg); + if (rsn) { xs *fn = xs_fmt("%s/queue/%s.json", user.basedir, ntid); snac_debug(&user, 1, - xs_fmt("enqueue_input (from shared inbox) %s", xs_dict_get(msg, "id"))); + xs_fmt("enqueue_input (from shared inbox) %s [%d]", xs_dict_get(msg, "id"), rsn)); if (link(tmpfn, fn) < 0) srv_log(xs_fmt("link(%s, %s) error", tmpfn, fn));