commit 5230435
default
·
2023-02-20 08:32:44 +0000 UTC
parent 9083bef
New boolean argument 'priv' to msg_note().
4 files changed,
+11,
-7
+4,
-4
1@@ -632,7 +632,8 @@ d_char *msg_follow(snac *snac, char *url_or_uid)
2 }
3
4
5-xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach)
6+xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts,
7+ xs_str *in_reply_to, xs_list *attach, int priv)
8 /* creates a 'Note' message */
9 {
10 xs *ntid = tid(0);
11@@ -702,8 +703,7 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_t
12 ctxt = xs_dup(v);
13
14 /* if this message is public, ours will also be */
15- if (is_msg_public(snac, p_msg) &&
16- xs_list_in(to, public_address) == -1)
17+ if (!priv && is_msg_public(snac, p_msg) && xs_list_in(to, public_address) == -1)
18 to = xs_list_append(to, public_address);
19 }
20
21@@ -749,7 +749,7 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_t
22 }
23
24 /* no recipients? must be for everybody */
25- if (xs_list_len(to) == 0)
26+ if (!priv && xs_list_len(to) == 0)
27 to = xs_list_append(to, public_address);
28
29 /* delete all cc recipients that also are in the to */
M
html.c
+2,
-1
1@@ -1392,6 +1392,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
2 char *edit_id = xs_dict_get(p_vars, "edit_id");
3 char *alt_text = xs_dict_get(p_vars, "alt_text");
4 xs *attach_list = xs_list_new();
5+ int priv = 0;
6
7 /* default alt text */
8 if (xs_is_null(alt_text))
9@@ -1436,7 +1437,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,
10 xs *c_msg = NULL;
11 xs *content_2 = xs_replace(content, "\r", "");
12
13- msg = msg_note(&snac, content_2, to, in_reply_to, attach_list);
14+ msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv);
15
16 if (sensitive != NULL) {
17 xs *t = xs_val_new(XSTYPE_TRUE);
M
main.c
+1,
-1
1@@ -292,7 +292,7 @@ int main(int argc, char *argv[])
2 else
3 content = xs_dup(url);
4
5- msg = msg_note(&snac, content, NULL, in_reply_to, NULL);
6+ msg = msg_note(&snac, content, NULL, in_reply_to, NULL, 0);
7
8 c_msg = msg_create(&snac, msg);
9
M
snac.h
+4,
-1
1@@ -170,7 +170,10 @@ const char *default_avatar_base64(void);
2 d_char *msg_admiration(snac *snac, char *object, char *type);
3 d_char *msg_create(snac *snac, char *object);
4 d_char *msg_follow(snac *snac, char *actor);
5-xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach);
6+
7+xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts,
8+ xs_str *in_reply_to, xs_list *attach, int priv);
9+
10 d_char *msg_undo(snac *snac, char *object);
11 d_char *msg_delete(snac *snac, char *id);
12 d_char *msg_actor(snac *snac);