snac2

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

commit ff44142b30ceded6ed7db24d033296b0966edb27
parent 6a5ea9783aac7947fed8b40cc78f67e11bb9a99c
Author: default <nobody@localhost>
Date:   Sat, 11 Jan 2025 01:39:37 +0100

Moved creation of "quiet public" posts to msg_note(), where it belongs.

Diffstat:
Mactivitypub.c | 8+++++++-
Mmain.c | 11++---------
2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/activitypub.c b/activitypub.c @@ -1486,7 +1486,7 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts, xs_list *p; const xs_val *v; - /* FIXME: implement scopes 2 and 3 */ + /* FIXME: implement scope 3 */ int priv = scope == 1; if (rcpts == NULL) @@ -1606,6 +1606,12 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts, } } + if (scope == 2) { + /* Mastodon's "quiet public": add public address to cc */ + if (xs_list_in(cc, public_address) == -1) + cc = xs_list_append(cc, public_address); + } + else /* no recipients? must be for everybody */ if (!priv && xs_list_len(to) == 0) to = xs_list_append(to, public_address); diff --git a/main.c b/main.c @@ -668,15 +668,8 @@ int main(int argc, char *argv[]) else content = xs_dup(url); - msg = msg_note(&snac, content, NULL, NULL, attl, 0, getenv("LANG")); - - if (strcmp(cmd, "note_unlisted") == 0) { - /* according to Mastodon, "unlisted" posts (now called "quiet public") - has the public address as a cc instead of to, so toggle it */ - xs *to = xs_dup(xs_dict_get(msg, "to")); - msg = xs_dict_set(msg, "cc", to); - msg = xs_dict_set(msg, "to", xs_stock(XSTYPE_LIST)); - } + msg = msg_note(&snac, content, NULL, NULL, attl, + strcmp(cmd, "note_unlisted") == 0 ? 2 : 0, getenv("LANG")); c_msg = msg_create(&snac, msg);