diff options
| author | 2023-02-20 09:32:44 +0100 | |
|---|---|---|
| committer | 2023-02-20 09:32:44 +0100 | |
| commit | 5230435b31ec2ca159901831c97dfa62646c993d (patch) | |
| tree | 24a831e61f4153313a124352155cd7dcf8bee56c | |
| parent | Don't try to send to empty email addresses. (diff) | |
| download | penes-snac2-5230435b31ec2ca159901831c97dfa62646c993d.tar.gz penes-snac2-5230435b31ec2ca159901831c97dfa62646c993d.tar.xz penes-snac2-5230435b31ec2ca159901831c97dfa62646c993d.zip | |
New boolean argument 'priv' to msg_note().
| -rw-r--r-- | activitypub.c | 8 | ||||
| -rw-r--r-- | html.c | 3 | ||||
| -rw-r--r-- | main.c | 2 | ||||
| -rw-r--r-- | 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) | |||
| 632 | } | 632 | } |
| 633 | 633 | ||
| 634 | 634 | ||
| 635 | xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach) | 635 | xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, |
| 636 | xs_str *in_reply_to, xs_list *attach, int priv) | ||
| 636 | /* creates a 'Note' message */ | 637 | /* creates a 'Note' message */ |
| 637 | { | 638 | { |
| 638 | xs *ntid = tid(0); | 639 | 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 | |||
| 702 | ctxt = xs_dup(v); | 703 | ctxt = xs_dup(v); |
| 703 | 704 | ||
| 704 | /* if this message is public, ours will also be */ | 705 | /* if this message is public, ours will also be */ |
| 705 | if (is_msg_public(snac, p_msg) && | 706 | if (!priv && is_msg_public(snac, p_msg) && xs_list_in(to, public_address) == -1) |
| 706 | xs_list_in(to, public_address) == -1) | ||
| 707 | to = xs_list_append(to, public_address); | 707 | to = xs_list_append(to, public_address); |
| 708 | } | 708 | } |
| 709 | 709 | ||
| @@ -749,7 +749,7 @@ xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_t | |||
| 749 | } | 749 | } |
| 750 | 750 | ||
| 751 | /* no recipients? must be for everybody */ | 751 | /* no recipients? must be for everybody */ |
| 752 | if (xs_list_len(to) == 0) | 752 | if (!priv && xs_list_len(to) == 0) |
| 753 | to = xs_list_append(to, public_address); | 753 | to = xs_list_append(to, public_address); |
| 754 | 754 | ||
| 755 | /* delete all cc recipients that also are in the to */ | 755 | /* delete all cc recipients that also are in the to */ |
| @@ -1392,6 +1392,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, | |||
| 1392 | char *edit_id = xs_dict_get(p_vars, "edit_id"); | 1392 | char *edit_id = xs_dict_get(p_vars, "edit_id"); |
| 1393 | char *alt_text = xs_dict_get(p_vars, "alt_text"); | 1393 | char *alt_text = xs_dict_get(p_vars, "alt_text"); |
| 1394 | xs *attach_list = xs_list_new(); | 1394 | xs *attach_list = xs_list_new(); |
| 1395 | int priv = 0; | ||
| 1395 | 1396 | ||
| 1396 | /* default alt text */ | 1397 | /* default alt text */ |
| 1397 | if (xs_is_null(alt_text)) | 1398 | 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, | |||
| 1436 | xs *c_msg = NULL; | 1437 | xs *c_msg = NULL; |
| 1437 | xs *content_2 = xs_replace(content, "\r", ""); | 1438 | xs *content_2 = xs_replace(content, "\r", ""); |
| 1438 | 1439 | ||
| 1439 | msg = msg_note(&snac, content_2, to, in_reply_to, attach_list); | 1440 | msg = msg_note(&snac, content_2, to, in_reply_to, attach_list, priv); |
| 1440 | 1441 | ||
| 1441 | if (sensitive != NULL) { | 1442 | if (sensitive != NULL) { |
| 1442 | xs *t = xs_val_new(XSTYPE_TRUE); | 1443 | xs *t = xs_val_new(XSTYPE_TRUE); |
| @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) | |||
| 292 | else | 292 | else |
| 293 | content = xs_dup(url); | 293 | content = xs_dup(url); |
| 294 | 294 | ||
| 295 | msg = msg_note(&snac, content, NULL, in_reply_to, NULL); | 295 | msg = msg_note(&snac, content, NULL, in_reply_to, NULL, 0); |
| 296 | 296 | ||
| 297 | c_msg = msg_create(&snac, msg); | 297 | c_msg = msg_create(&snac, msg); |
| 298 | 298 | ||
| @@ -170,7 +170,10 @@ const char *default_avatar_base64(void); | |||
| 170 | d_char *msg_admiration(snac *snac, char *object, char *type); | 170 | d_char *msg_admiration(snac *snac, char *object, char *type); |
| 171 | d_char *msg_create(snac *snac, char *object); | 171 | d_char *msg_create(snac *snac, char *object); |
| 172 | d_char *msg_follow(snac *snac, char *actor); | 172 | d_char *msg_follow(snac *snac, char *actor); |
| 173 | xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, xs_str *in_reply_to, xs_list *attach); | 173 | |
| 174 | xs_dict *msg_note(snac *snac, xs_str *content, xs_val *rcpts, | ||
| 175 | xs_str *in_reply_to, xs_list *attach, int priv); | ||
| 176 | |||
| 174 | d_char *msg_undo(snac *snac, char *object); | 177 | d_char *msg_undo(snac *snac, char *object); |
| 175 | d_char *msg_delete(snac *snac, char *id); | 178 | d_char *msg_delete(snac *snac, char *id); |
| 176 | d_char *msg_actor(snac *snac); | 179 | d_char *msg_actor(snac *snac); |