New boolean argument 'priv' to msg_note().

This commit is contained in:
default 2023-02-20 09:32:44 +01:00
parent 9083bef5cb
commit 5230435b31
4 changed files with 11 additions and 7 deletions

View file

@ -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 */ /* creates a 'Note' message */
{ {
xs *ntid = tid(0); 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); ctxt = xs_dup(v);
/* if this message is public, ours will also be */ /* if this message is public, ours will also be */
if (is_msg_public(snac, p_msg) && if (!priv && is_msg_public(snac, p_msg) && xs_list_in(to, public_address) == -1)
xs_list_in(to, public_address) == -1)
to = xs_list_append(to, public_address); 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 */ /* 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); to = xs_list_append(to, public_address);
/* delete all cc recipients that also are in the to */ /* delete all cc recipients that also are in the to */

3
html.c
View file

@ -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 *edit_id = xs_dict_get(p_vars, "edit_id");
char *alt_text = xs_dict_get(p_vars, "alt_text"); char *alt_text = xs_dict_get(p_vars, "alt_text");
xs *attach_list = xs_list_new(); xs *attach_list = xs_list_new();
int priv = 0;
/* default alt text */ /* default alt text */
if (xs_is_null(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 *c_msg = NULL;
xs *content_2 = xs_replace(content, "\r", ""); 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) { if (sensitive != NULL) {
xs *t = xs_val_new(XSTYPE_TRUE); xs *t = xs_val_new(XSTYPE_TRUE);

2
main.c
View file

@ -292,7 +292,7 @@ int main(int argc, char *argv[])
else else
content = xs_dup(url); 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); c_msg = msg_create(&snac, msg);

5
snac.h
View file

@ -170,7 +170,10 @@ const char *default_avatar_base64(void);
d_char *msg_admiration(snac *snac, char *object, char *type); d_char *msg_admiration(snac *snac, char *object, char *type);
d_char *msg_create(snac *snac, char *object); d_char *msg_create(snac *snac, char *object);
d_char *msg_follow(snac *snac, char *actor); 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_undo(snac *snac, char *object);
d_char *msg_delete(snac *snac, char *id); d_char *msg_delete(snac *snac, char *id);
d_char *msg_actor(snac *snac); d_char *msg_actor(snac *snac);