From 7db4de872d043593b63de09cea27bd350e3e5f58 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:07:33 +0200 Subject: Also show unfollows in the notification area. --- activitypub.c | 2 +- html.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/activitypub.c b/activitypub.c index ce72f3f..de7de6a 100644 --- a/activitypub.c +++ b/activitypub.c @@ -686,7 +686,7 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, enqueue_telegram(body, bot, chat_id); /* finally, store it in the notification folder */ - if (strcmp(type, "Follow") == 0) + if (strcmp(type, "Follow") == 0 || strcmp(utype, "Follow") == 0) objid = id; notify_add(snac, type, utype, actor, objid != NULL ? objid : id); diff --git a/html.c b/html.c index 425df4b..ce7f511 100644 --- a/html.c +++ b/html.c @@ -1437,7 +1437,7 @@ xs_str *html_notifications(snac *snac) "
\n" "\n" - "

", snac->actor, L("Clear all")); + "

\n", snac->actor, L("Clear all")); s = xs_str_cat(s, s1); while (xs_list_iter(&p, &v)) { @@ -1498,13 +1498,16 @@ xs_str *html_notifications(snac *snac) else if (strcmp(type, "Update") == 0 && strcmp(utype, "Question") == 0) label = L("Finished poll"); + else + if (strcmp(type, "Undo") == 0 && strcmp(utype, "Follow") == 0) + label = L("Unfollow"); xs *s1 = xs_fmt("

\n" "

%s by %s:

\n", label, actor_id, a_name); s = xs_str_cat(s, s1); - if (strcmp(type, "Follow") == 0) { + if (strcmp(type, "Follow") == 0 || strcmp(utype, "Follow") == 0) { s = xs_str_cat(s, "
\n"); s = html_msg_icon(snac, s, obj); -- cgit v1.2.3 From 51c3fc9267aecabfc795a03994c9f48bb324b9cc Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:08:46 +0200 Subject: Updated RELEASE_NOTES. --- RELEASE_NOTES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4fbe71b..151994f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -18,6 +18,8 @@ For polls, show the time left before it closes. Added some support for post pinning. +Fixed a bug that prevented unfollows to be shown in the notification area. + ## 2.35 Fixed broken URL links with the # symbol on them. -- cgit v1.2.3 From 78b468f013cc2624a4b9044393eb2c86556c98b7 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:23:12 +0200 Subject: More unfollow notification tweaks. --- activitypub.c | 5 ++++- html.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/activitypub.c b/activitypub.c index de7de6a..d0ef866 100644 --- a/activitypub.c +++ b/activitypub.c @@ -686,8 +686,11 @@ void notify(snac *snac, const char *type, const char *utype, const char *actor, enqueue_telegram(body, bot, chat_id); /* finally, store it in the notification folder */ - if (strcmp(type, "Follow") == 0 || strcmp(utype, "Follow") == 0) + if (strcmp(type, "Follow") == 0) objid = id; + else + if (strcmp(utype, "Follow") == 0) + objid = actor; notify_add(snac, type, utype, actor, objid != NULL ? objid : id); } diff --git a/html.c b/html.c index ce7f511..c9d6edd 100644 --- a/html.c +++ b/html.c @@ -1510,7 +1510,7 @@ xs_str *html_notifications(snac *snac) if (strcmp(type, "Follow") == 0 || strcmp(utype, "Follow") == 0) { s = xs_str_cat(s, "
\n"); - s = html_msg_icon(snac, s, obj); + s = html_actor_icon(s, actor, NULL, NULL, NULL, 0); s = xs_str_cat(s, "
\n"); } -- cgit v1.2.3 From bf08fba799d1ee693bf6db09be1a0b1e10f5496c Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:34:32 +0200 Subject: Call index_del() from _object_user_cache(). --- data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/data.c b/data.c index 87cfc98..b3fd8b3 100644 --- a/data.c +++ b/data.c @@ -862,6 +862,7 @@ int _object_user_cache(snac *snac, const char *id, const char *cachedir, int del if (del) { ret = unlink(cfn); + index_del(idx, id); } else { if ((ret = link(ofn, cfn)) != -1) -- cgit v1.2.3 From 66991f43fa57a6bf594b7db4924efb6a1dac86ce Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:37:03 +0200 Subject: Updated TODO. --- TODO.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TODO.md b/TODO.md index 6d4b430..6a84b65 100644 --- a/TODO.md +++ b/TODO.md @@ -12,8 +12,6 @@ Mastodon API: fix whatever the fuck is making the official app and Megalodon to Improve support for audio attachments. -Add a quick way to block complete domains / instances. - Add support for pinning posts. Important: deleting a follower should do more that just delete the object, see https://codeberg.org/grunfink/snac2/issues/43#issuecomment-956721 @@ -33,7 +31,8 @@ Implement bulleted lists. Mastodon is crap and won't show them, but other implem User request: "will it be possible to click on a link and instead of opening the original instance, we'll be able only to see a list of the posts of this person here in comam?. Something like Mastodon does." Test all the possible XSS vulnerabilities in https://raw.githubusercontent.com/danielmiessler/SecLists/master/Fuzzing/big-list-of-naughty-strings.txt -Minor data storage housekeeping: index_list() and index_list_desc() should not return deleted (i.e. dash prefixed) entries; _object_user_cache() should call index_del() (?). + +index_list() and index_list_desc() should not return deleted (i.e. dash prefixed) entries. ## Closed @@ -260,3 +259,7 @@ Replace weird, vestigial 'touch-by-append-spaces' in actor_get() with a more pro With this new disk layout, hidden posts (and their children) can be directly skipped when rendering the HTML timeline (are there any other implications?) (2023-06-23T06:48:51+0200). Implement HTTP caches (If-None-Match / ETag) (2023-07-02T11:11:20+0200). + +Add a quick way to block complete domains / instances (2023-07-04T14:35:44+0200). + +_object_user_cache() should call index_del() (2023-07-04T14:36:37+0200). -- cgit v1.2.3 From f29986f854d16a97b4ddd732cf8b6f38cf1f611a Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:40:31 +0200 Subject: Updated TODO. --- TODO.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/TODO.md b/TODO.md index 6a84b65..1434208 100644 --- a/TODO.md +++ b/TODO.md @@ -16,6 +16,10 @@ Add support for pinning posts. Important: deleting a follower should do more that just delete the object, see https://codeberg.org/grunfink/snac2/issues/43#issuecomment-956721 +Add a content warning description. + +Propagate the CW status and description from the replied messaage. + ## Wishlist Add a list of hashtags to drop. -- cgit v1.2.3 From b55dbf13e40553611be3c01f5dd58766cda2cdc2 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:50:09 +0200 Subject: The sensitive content can have a description. --- html.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/html.c b/html.c index c9d6edd..b412f41 100644 --- a/html.c +++ b/html.c @@ -387,7 +387,8 @@ d_char *html_top_controls(snac *snac, d_char *s) "\n" "\n" - "

%s: \n" + "

%s: " + "\n" "

%s: \n" "

%s\n" /** attach **/ @@ -512,6 +513,7 @@ d_char *html_top_controls(snac *snac, d_char *s) xs *s1 = xs_fmt(_tmpl, snac->actor, L("Sensitive content"), + L("Sensitive content description"), L("Only for mentioned people"), L("Attach..."), @@ -697,7 +699,8 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch "rows=\"4\" wrap=\"virtual\" required=\"required\">%s\n" "\n" - "

%s: \n" + "

%s: " + "\n" "

%s: \n" "

%s\n" @@ -717,6 +720,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch prev_src, id, L("Sensitive content"), + L("Sensitive content description"), L("Only for mentioned people"), L("Attach..."), L("File"), @@ -741,7 +745,8 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch "rows=\"4\" wrap=\"virtual\" required=\"required\">%s\n" "\n" - "

%s: \n" + "

%s: " + "\n" "

%s: \n" "

%s\n" @@ -761,6 +766,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch ct, id, L("Sensitive content"), + L("Sensitive content description"), L("Only for mentioned people"), L("Attach..."), L("File"), @@ -1846,6 +1852,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, xs_list *attach_file = xs_dict_get(p_vars, "attach"); xs_str *to = xs_dict_get(p_vars, "to"); xs_str *sensitive = xs_dict_get(p_vars, "sensitive"); + xs_str *summary = xs_dict_get(p_vars, "summary"); xs_str *edit_id = xs_dict_get(p_vars, "edit_id"); xs_str *alt_text = xs_dict_get(p_vars, "alt_text"); int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only")); @@ -1924,7 +1931,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, if (sensitive != NULL) { msg = xs_dict_set(msg, "sensitive", xs_stock_true); - msg = xs_dict_set(msg, "summary", "..."); + msg = xs_dict_set(msg, "summary", xs_is_null(summary) ? "..." : summary); } if (xs_is_null(edit_id)) { -- cgit v1.2.3 From 339fe5edc52e90e6a0744c7b96eea5f2071ae39b Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 14:55:24 +0200 Subject: Also fill the sensitive content fields in the edit dialog. --- html.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/html.c b/html.c index b412f41..46ce5a5 100644 --- a/html.c +++ b/html.c @@ -688,6 +688,8 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch if (!xs_is_null(prev_src1) && strcmp(actor, snac->actor) == 0) { xs *prev_src = xs_replace(prev_src1, "<", "<"); + const xs_val *sensitive = xs_dict_get(msg, "sensitive"); + const char *summary = xs_dict_get(msg, "summary"); /* post can be edited */ xs *s1 = xs_fmt( @@ -699,8 +701,8 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch "rows=\"4\" wrap=\"virtual\" required=\"required\">%s\n" "\n" - "

%s: " - "\n" + "

%s: " + "\n" "

%s: \n" "

%s\n" @@ -720,7 +722,9 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch prev_src, id, L("Sensitive content"), + xs_type(sensitive) == XSTYPE_TRUE ? "checked" : "", L("Sensitive content description"), + summary, L("Only for mentioned people"), L("Attach..."), L("File"), -- cgit v1.2.3 From 8a392233d22dbcdde794f1a88dcdf812385b4380 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 15:02:04 +0200 Subject: The content warning check and description is propagated from the replied message. --- html.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/html.c b/html.c index 46ce5a5..4a04d7c 100644 --- a/html.c +++ b/html.c @@ -686,7 +686,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch const char *prev_src1 = xs_dict_get(msg, "sourceContent"); - if (!xs_is_null(prev_src1) && strcmp(actor, snac->actor) == 0) { + if (!xs_is_null(prev_src1) && strcmp(actor, snac->actor) == 0) { /** edit **/ xs *prev_src = xs_replace(prev_src1, "<", "<"); const xs_val *sensitive = xs_dict_get(msg, "sensitive"); const char *summary = xs_dict_get(msg, "summary"); @@ -724,7 +724,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch L("Sensitive content"), xs_type(sensitive) == XSTYPE_TRUE ? "checked" : "", L("Sensitive content description"), - summary, + xs_is_null(summary) ? "" : summary, L("Only for mentioned people"), L("Attach..."), L("File"), @@ -736,10 +736,13 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch s = xs_str_cat(s, s1); } - { + { /** reply **/ /* the post textarea */ xs *ct = build_mentions(snac, msg); + const xs_val *sensitive = xs_dict_get(msg, "sensitive"); + const char *summary = xs_dict_get(msg, "summary"); + xs *s1 = xs_fmt( "

%s\n" "

\n" @@ -749,8 +752,8 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch "rows=\"4\" wrap=\"virtual\" required=\"required\">%s\n" "\n" - "

%s: " - "\n" + "

%s: " + "\n" "

%s: \n" "

%s\n" @@ -770,7 +773,9 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch ct, id, L("Sensitive content"), + xs_type(sensitive) == XSTYPE_TRUE ? "checked" : "", L("Sensitive content description"), + xs_is_null(summary) ? "" : summary, L("Only for mentioned people"), L("Attach..."), L("File"), -- cgit v1.2.3 From b1f1f353fa50b5f74f4154b49fbb4a67ef56c17f Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 15:02:44 +0200 Subject: Updated TODO. --- TODO.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index 1434208..7539883 100644 --- a/TODO.md +++ b/TODO.md @@ -16,10 +16,6 @@ Add support for pinning posts. Important: deleting a follower should do more that just delete the object, see https://codeberg.org/grunfink/snac2/issues/43#issuecomment-956721 -Add a content warning description. - -Propagate the CW status and description from the replied messaage. - ## Wishlist Add a list of hashtags to drop. @@ -267,3 +263,7 @@ Implement HTTP caches (If-None-Match / ETag) (2023-07-02T11:11:20+0200). Add a quick way to block complete domains / instances (2023-07-04T14:35:44+0200). _object_user_cache() should call index_del() (2023-07-04T14:36:37+0200). + +Add a content warning description (2023-07-04T15:02:19+0200). + +Propagate the CW status and description from the replied message (2023-07-04T15:02:19+0200). -- cgit v1.2.3 From 9bf872d6030f1d4fb4bad42e4931111eac769806 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 15:03:36 +0200 Subject: Updated RELEASE_NOTES. --- RELEASE_NOTES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 151994f..d6ce13c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,6 +4,8 @@ Added proper HTTP caching when serving static files (attached images, avatars, etc.) +Sensitive content messages can now have a summary (i.e. no longer limited to ...) + Added a way to block full instances (from the command-line tool, as I consider this to be an administration priviledge). If the user style.css does not exist, the server-wide one if served instead. -- cgit v1.2.3 From 9c7cc7b710f48d8ca1105200c0a7ef935d251d25 Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 16:33:54 +0200 Subject: index_list() and index_list_desc() don't return deleted entries. --- data.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/data.c b/data.c index b3fd8b3..c466598 100644 --- a/data.c +++ b/data.c @@ -496,9 +496,11 @@ xs_list *index_list(const char *fn, int max) list = xs_list_new(); while (n < max && fgets(line, sizeof(line), f) != NULL) { - line[32] = '\0'; - list = xs_list_append(list, line); - n++; + if (line[0] != '-') { + line[32] = '\0'; + list = xs_list_append(list, line); + n++; + } } fclose(f); @@ -524,9 +526,11 @@ xs_list *index_list_desc(const char *fn, int skip, int show) /* move to the end minus one entry (or more, if skipping entries) */ if (!fseek(f, 0, SEEK_END) && !fseek(f, (skip + 1) * -33, SEEK_CUR)) { while (n < show && fgets(line, sizeof(line), f) != NULL) { - line[32] = '\0'; - list = xs_list_append(list, line); - n++; + if (line[0] != '-') { + line[32] = '\0'; + list = xs_list_append(list, line); + n++; + } /* move backwards 2 entries */ if (fseek(f, -66, SEEK_CUR) == -1) -- cgit v1.2.3 From 6fce560f015ba126675a770f035bff3971f64f1c Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 16:54:41 +0200 Subject: The actor bio now accepts tags. --- activitypub.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/activitypub.c b/activitypub.c index d0ef866..4791ac3 100644 --- a/activitypub.c +++ b/activitypub.c @@ -839,6 +839,7 @@ xs_dict *msg_actor(snac *snac) xs *ctxt = xs_list_new(); xs *icon = xs_dict_new(); xs *keys = xs_dict_new(); + xs *tags = xs_list_new(); xs *avtr = NULL; xs *kid = NULL; xs *f_bio = NULL; @@ -856,8 +857,10 @@ xs_dict *msg_actor(snac *snac) msg = xs_dict_set(msg, "preferredUsername", snac->uid); msg = xs_dict_set(msg, "published", xs_dict_get(snac->config, "published")); - f_bio = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL); + xs *f_bio_2 = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL); + process_tags(snac, f_bio_2, &f_bio, &tags); msg = xs_dict_set(msg, "summary", f_bio); + msg = xs_dict_set(msg, "tag", tags); char *folders[] = { "inbox", "outbox", "followers", "following", NULL }; for (n = 0; folders[n]; n++) { -- cgit v1.2.3 From 7e5b02be3f3c4bf3b215f300dae240c23065919f Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 16:57:17 +0200 Subject: Fixed weird prototype of process_tags(). --- activitypub.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/activitypub.c b/activitypub.c index 4791ac3..fa592e7 100644 --- a/activitypub.c +++ b/activitypub.c @@ -449,7 +449,7 @@ int is_msg_for_me(snac *snac, const xs_dict *c_msg) } -void process_tags(snac *snac, const char *content, xs_str **n_content, xs_list **tag) +xs_str *process_tags(snac *snac, const char *content, xs_list **tag) /* parses mentions and tags from content */ { xs_str *nc = xs_str_new(NULL); @@ -559,8 +559,9 @@ void process_tags(snac *snac, const char *content, xs_str **n_content, xs_list * n++; } - *n_content = nc; - *tag = tl; + *tag = tl; + + return nc; } @@ -858,7 +859,7 @@ xs_dict *msg_actor(snac *snac) msg = xs_dict_set(msg, "published", xs_dict_get(snac->config, "published")); xs *f_bio_2 = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL); - process_tags(snac, f_bio_2, &f_bio, &tags); + f_bio = process_tags(snac, f_bio_2, &tags); msg = xs_dict_set(msg, "summary", f_bio); msg = xs_dict_set(msg, "tag", tags); @@ -1059,7 +1060,7 @@ xs_dict *msg_note(snac *snac, const xs_str *content, const xs_val *rcpts, irt = xs_val_new(XSTYPE_NULL); /* extract the mentions and hashtags and convert the content */ - process_tags(snac, fc2, &fc1, &tag); + fc1 = process_tags(snac, fc2, &tag); /* create the attachment list, if there are any */ if (!xs_is_null(attach)) { -- cgit v1.2.3 From 38ee86f81e74edec97bf04d999d21221565f44fb Mon Sep 17 00:00:00 2001 From: default Date: Tue, 4 Jul 2023 17:15:38 +0200 Subject: Also call process_tags() when in the public timeline's bio. --- html.c | 6 ++++-- snac.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/html.c b/html.c index 4a04d7c..2eb542a 100644 --- a/html.c +++ b/html.c @@ -362,8 +362,10 @@ d_char *html_user_header(snac *snac, d_char *s, int local) s = xs_str_cat(s, s1); if (local) { - xs *bio = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL); - xs *s1 = xs_fmt("
%s
\n", bio); + xs *bio1 = not_really_markdown(xs_dict_get(snac->config, "bio"), NULL); + xs *tags = xs_list_new(); + xs *bio2 = process_tags(snac, bio1, &tags); + xs *s1 = xs_fmt("
%s
\n", bio2); s = xs_str_cat(s, s1); } diff --git a/snac.h b/snac.h index 74f4969..171d069 100644 --- a/snac.h +++ b/snac.h @@ -207,6 +207,8 @@ int webfinger_get_handler(xs_dict *req, char *q_path, const char *default_avatar_base64(void); +xs_str *process_tags(snac *snac, const char *content, xs_list **tag); + xs_dict *msg_admiration(snac *snac, char *object, char *type); xs_dict *msg_create(snac *snac, const xs_dict *object); xs_dict *msg_follow(snac *snac, const char *actor); -- cgit v1.2.3