From 5230435b31ec2ca159901831c97dfa62646c993d Mon Sep 17 00:00:00 2001 From: default Date: Mon, 20 Feb 2023 09:32:44 +0100 Subject: [PATCH] New boolean argument 'priv' to msg_note(). --- activitypub.c | 8 ++++---- html.c | 3 ++- main.c | 2 +- snac.h | 5 ++++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/activitypub.c b/activitypub.c index fc01466..2d84b0e 100644 --- a/activitypub.c +++ b/activitypub.c @@ -632,7 +632,8 @@ d_char *msg_follow(snac *snac, char *url_or_uid) } -xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach) +xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, + xs_str *in_reply_to, xs_list *attach, int priv) /* creates a 'Note' message */ { xs *ntid = tid(0); @@ -702,8 +703,7 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_t ctxt = xs_dup(v); /* if this message is public, ours will also be */ - if (is_msg_public(snac, p_msg) && - xs_list_in(to, public_address) == -1) + if (!priv && is_msg_public(snac, p_msg) && xs_list_in(to, public_address) == -1) to = xs_list_append(to, public_address); } @@ -749,7 +749,7 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_t } /* no recipients? must be for everybody */ - if (xs_list_len(to) == 0) + if (!priv && xs_list_len(to) == 0) to = xs_list_append(to, public_address); /* delete all cc recipients that also are in the to */ diff --git a/html.c b/html.c index 386354d..bfb837b 100644 --- a/html.c +++ b/html.c @@ -1392,6 +1392,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, char *edit_id = xs_dict_get(p_vars, "edit_id"); char *alt_text = xs_dict_get(p_vars, "alt_text"); xs *attach_list = xs_list_new(); + int priv = 0; /* default alt text */ if (xs_is_null(alt_text)) @@ -1436,7 +1437,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, xs *c_msg = NULL; xs *content_2 = xs_replace(content, "\r", ""); - msg = msg_note(&snac, content_2, to, in_reply_to, attach_list); + msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv); if (sensitive != NULL) { xs *t = xs_val_new(XSTYPE_TRUE); diff --git a/main.c b/main.c index f05cb51..6a0bb74 100644 --- a/main.c +++ b/main.c @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) else content = xs_dup(url); - msg = msg_note(&snac, content, NULL, in_reply_to, NULL); + msg = msg_note(&snac, content, NULL, in_reply_to, NULL, 0); c_msg = msg_create(&snac, msg); diff --git a/snac.h b/snac.h index b501607..79d2182 100644 --- a/snac.h +++ b/snac.h @@ -170,7 +170,10 @@ const char *default_avatar_base64(void); d_char *msg_admiration(snac *snac, char *object, char *type); d_char *msg_create(snac *snac, char *object); d_char *msg_follow(snac *snac, char *actor); -xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach); + +xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, + xs_str *in_reply_to, xs_list *attach, int priv); + d_char *msg_undo(snac *snac, char *object); d_char *msg_delete(snac *snac, char *id); d_char *msg_actor(snac *snac);