snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit a06930f4daa270660151c256d2283b9b3c57ab83
parent 36ff9721737f24615e0c5eaefb70046e567412eb
Author: default <nobody@localhost>
Date:   Wed, 16 Nov 2022 11:42:16 +0100

Posts can be marked as 'sensitive content' (not yet for replies).

Diffstat:
Mdata.c | 2+-
Mhtml.c | 10++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/data.c b/data.c @@ -79,7 +79,7 @@ int srv_open(char *basedir) if (error != NULL) srv_log(error); -/* disabled temporarily; messages can't be sent */ +/* disabled temporarily; messages can't be sent (libcurl issue?) */ #if 0 #ifdef __OpenBSD__ srv_debug(2, xs_fmt("Calling unveil()")); diff --git a/html.c b/html.c @@ -242,6 +242,7 @@ d_char *html_top_controls(snac *snac, d_char *s) "<textarea class=\"snac-textarea\" name=\"content\" " "rows=\"8\" wrap=\"virtual\" required=\"required\"></textarea>\n" "<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n" + "<p><input type=\"checkbox\" name=\"sensitive\"> %s\n" "<p><input type=\"file\" name=\"attach\">\n" "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n" "</form><p>\n" @@ -297,6 +298,7 @@ d_char *html_top_controls(snac *snac, d_char *s) xs *s1 = xs_fmt(_tmpl, snac->actor, + L("Sensitive content"), L("Post"), L("More options..."), @@ -1120,6 +1122,7 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, char *attach_url = xs_dict_get(p_vars, "attach_url"); char *attach_file = xs_dict_get(p_vars, "attach"); char *to = xs_dict_get(p_vars, "to"); + char *sensitive = xs_dict_get(p_vars, "sensitive"); xs *attach_list = xs_list_new(); /* is attach_url set? */ @@ -1152,6 +1155,13 @@ int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, msg = msg_note(&snac, content_2, to, in_reply_to, attach_list); + if (sensitive != NULL) { + xs *t = xs_val_new(XSTYPE_TRUE); + + msg = xs_dict_set(msg, "sensitive", t); + msg = xs_dict_set(msg, "summary", "..."); + } + c_msg = msg_create(&snac, msg); post(&snac, c_msg);