diff options
| author | 2024-05-21 14:12:15 +0200 | |
|---|---|---|
| committer | 2024-05-21 14:12:15 +0200 | |
| commit | 4777fc86cb962917a8f34afb3bfa40f26290815d (patch) | |
| tree | 268c078531a018f07c1b6d029f14f87134805f7b /html.c | |
| parent | Version 2.53 RELEASED. (diff) | |
| download | penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.gz penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.tar.xz penes-snac2-4777fc86cb962917a8f34afb3bfa40f26290815d.zip | |
Added const everywhere.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 278 |
1 files changed, 143 insertions, 135 deletions
| @@ -41,7 +41,7 @@ int login(snac *snac, const xs_dict *headers) | |||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | xs_str *replace_shortnames(xs_str *s, xs_list *tag, int ems) | 44 | xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems) |
| 45 | /* replaces all the :shortnames: with the emojis in tag */ | 45 | /* replaces all the :shortnames: with the emojis in tag */ |
| 46 | { | 46 | { |
| 47 | if (!xs_is_null(tag)) { | 47 | if (!xs_is_null(tag)) { |
| @@ -57,18 +57,18 @@ xs_str *replace_shortnames(xs_str *s, xs_list *tag, int ems) | |||
| 57 | 57 | ||
| 58 | xs *style = xs_fmt("height: %dem; width: %dem; vertical-align: middle;", ems, ems); | 58 | xs *style = xs_fmt("height: %dem; width: %dem; vertical-align: middle;", ems, ems); |
| 59 | 59 | ||
| 60 | xs_list *p = tag_list; | ||
| 61 | char *v; | 60 | char *v; |
| 61 | int c = 0; | ||
| 62 | 62 | ||
| 63 | while (xs_list_iter(&p, &v)) { | 63 | while (xs_list_next(tag_list, &v, &c)) { |
| 64 | char *t = xs_dict_get(v, "type"); | 64 | const char *t = xs_dict_get(v, "type"); |
| 65 | 65 | ||
| 66 | if (t && strcmp(t, "Emoji") == 0) { | 66 | if (t && strcmp(t, "Emoji") == 0) { |
| 67 | char *n = xs_dict_get(v, "name"); | 67 | const char *n = xs_dict_get(v, "name"); |
| 68 | char *i = xs_dict_get(v, "icon"); | 68 | const char *i = xs_dict_get(v, "icon"); |
| 69 | 69 | ||
| 70 | if (n && i) { | 70 | if (n && i) { |
| 71 | char *u = xs_dict_get(i, "url"); | 71 | const char *u = xs_dict_get(i, "url"); |
| 72 | xs_html *img = xs_html_sctag("img", | 72 | xs_html *img = xs_html_sctag("img", |
| 73 | xs_html_attr("loading", "lazy"), | 73 | xs_html_attr("loading", "lazy"), |
| 74 | xs_html_attr("src", u), | 74 | xs_html_attr("src", u), |
| @@ -88,7 +88,7 @@ xs_str *replace_shortnames(xs_str *s, xs_list *tag, int ems) | |||
| 88 | xs_str *actor_name(xs_dict *actor) | 88 | xs_str *actor_name(xs_dict *actor) |
| 89 | /* gets the actor name */ | 89 | /* gets the actor name */ |
| 90 | { | 90 | { |
| 91 | char *v; | 91 | const char *v; |
| 92 | 92 | ||
| 93 | if (xs_is_null((v = xs_dict_get(actor, "name"))) || *v == '\0') { | 93 | if (xs_is_null((v = xs_dict_get(actor, "name"))) || *v == '\0') { |
| 94 | if (xs_is_null(v = xs_dict_get(actor, "preferredUsername")) || *v == '\0') { | 94 | if (xs_is_null(v = xs_dict_get(actor, "preferredUsername")) || *v == '\0') { |
| @@ -106,7 +106,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 106 | xs_html *actor_icon = xs_html_tag("p", NULL); | 106 | xs_html *actor_icon = xs_html_tag("p", NULL); |
| 107 | 107 | ||
| 108 | xs *avatar = NULL; | 108 | xs *avatar = NULL; |
| 109 | char *v; | 109 | const char *v; |
| 110 | int fwing = 0; | 110 | int fwing = 0; |
| 111 | int fwer = 0; | 111 | int fwer = 0; |
| 112 | 112 | ||
| @@ -125,7 +125,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 125 | if (avatar == NULL) | 125 | if (avatar == NULL) |
| 126 | avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); | 126 | avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); |
| 127 | 127 | ||
| 128 | char *actor_id = xs_dict_get(actor, "id"); | 128 | const char *actor_id = xs_dict_get(actor, "id"); |
| 129 | xs *href = NULL; | 129 | xs *href = NULL; |
| 130 | 130 | ||
| 131 | if (user) { | 131 | if (user) { |
| @@ -216,7 +216,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | { | 218 | { |
| 219 | char *username, *id; | 219 | const char *username, *id; |
| 220 | 220 | ||
| 221 | if (xs_is_null(username = xs_dict_get(actor, "preferredUsername")) || *username == '\0') { | 221 | if (xs_is_null(username = xs_dict_get(actor, "preferredUsername")) || *username == '\0') { |
| 222 | /* This should never be reached */ | 222 | /* This should never be reached */ |
| @@ -244,15 +244,15 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 244 | } | 244 | } |
| 245 | 245 | ||
| 246 | 246 | ||
| 247 | xs_html *html_msg_icon(snac *user, char *actor_id, const xs_dict *msg) | 247 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg) |
| 248 | { | 248 | { |
| 249 | xs *actor = NULL; | 249 | xs *actor = NULL; |
| 250 | xs_html *actor_icon = NULL; | 250 | xs_html *actor_icon = NULL; |
| 251 | 251 | ||
| 252 | if (actor_id && valid_status(actor_get_refresh(user, actor_id, &actor))) { | 252 | if (actor_id && valid_status(actor_get_refresh(user, actor_id, &actor))) { |
| 253 | char *date = NULL; | 253 | const char *date = NULL; |
| 254 | char *udate = NULL; | 254 | const char *udate = NULL; |
| 255 | char *url = NULL; | 255 | const char *url = NULL; |
| 256 | int priv = 0; | 256 | int priv = 0; |
| 257 | const char *type = xs_dict_get(msg, "type"); | 257 | const char *type = xs_dict_get(msg, "type"); |
| 258 | 258 | ||
| @@ -271,14 +271,14 @@ xs_html *html_msg_icon(snac *user, char *actor_id, const xs_dict *msg) | |||
| 271 | } | 271 | } |
| 272 | 272 | ||
| 273 | 273 | ||
| 274 | xs_html *html_note(snac *user, char *summary, | 274 | xs_html *html_note(snac *user, const char *summary, |
| 275 | char *div_id, char *form_id, | 275 | const char *div_id, const char *form_id, |
| 276 | char *ta_plh, char *ta_content, | 276 | const char *ta_plh, const char *ta_content, |
| 277 | char *edit_id, char *actor_id, | 277 | const char *edit_id, const char *actor_id, |
| 278 | xs_val *cw_yn, char *cw_text, | 278 | const xs_val *cw_yn, const char *cw_text, |
| 279 | xs_val *mnt_only, char *redir, | 279 | const xs_val *mnt_only, const char *redir, |
| 280 | char *in_reply_to, int poll, | 280 | const char *in_reply_to, int poll, |
| 281 | char *att_file, char *att_alt_text) | 281 | const char *att_file, const char *att_alt_text) |
| 282 | { | 282 | { |
| 283 | xs *action = xs_fmt("%s/admin/note", user->actor); | 283 | xs *action = xs_fmt("%s/admin/note", user->actor); |
| 284 | 284 | ||
| @@ -460,9 +460,11 @@ static xs_html *html_base_head(void) | |||
| 460 | /* add server CSS and favicon */ | 460 | /* add server CSS and favicon */ |
| 461 | xs *f; | 461 | xs *f; |
| 462 | f = xs_fmt("%s/favicon.ico", srv_baseurl); | 462 | f = xs_fmt("%s/favicon.ico", srv_baseurl); |
| 463 | xs_list *p = xs_dict_get(srv_config, "cssurls"); | 463 | const xs_list *p = xs_dict_get(srv_config, "cssurls"); |
| 464 | char *v; | 464 | char *v; |
| 465 | while (xs_list_iter(&p, &v)) { | 465 | int c = 0; |
| 466 | |||
| 467 | while (xs_list_next(p, &v, &c)) { | ||
| 466 | xs_html_add(head, | 468 | xs_html_add(head, |
| 467 | xs_html_sctag("link", | 469 | xs_html_sctag("link", |
| 468 | xs_html_attr("rel", "stylesheet"), | 470 | xs_html_attr("rel", "stylesheet"), |
| @@ -498,8 +500,8 @@ xs_html *html_instance_head(void) | |||
| 498 | } | 500 | } |
| 499 | } | 501 | } |
| 500 | 502 | ||
| 501 | char *host = xs_dict_get(srv_config, "host"); | 503 | const char *host = xs_dict_get(srv_config, "host"); |
| 502 | char *title = xs_dict_get(srv_config, "title"); | 504 | const char *title = xs_dict_get(srv_config, "title"); |
| 503 | 505 | ||
| 504 | xs_html_add(head, | 506 | xs_html_add(head, |
| 505 | xs_html_tag("title", | 507 | xs_html_tag("title", |
| @@ -511,10 +513,10 @@ xs_html *html_instance_head(void) | |||
| 511 | 513 | ||
| 512 | static xs_html *html_instance_body(void) | 514 | static xs_html *html_instance_body(void) |
| 513 | { | 515 | { |
| 514 | char *host = xs_dict_get(srv_config, "host"); | 516 | const char *host = xs_dict_get(srv_config, "host"); |
| 515 | char *sdesc = xs_dict_get(srv_config, "short_description"); | 517 | const char *sdesc = xs_dict_get(srv_config, "short_description"); |
| 516 | char *email = xs_dict_get(srv_config, "admin_email"); | 518 | const char *email = xs_dict_get(srv_config, "admin_email"); |
| 517 | char *acct = xs_dict_get(srv_config, "admin_account"); | 519 | const char *acct = xs_dict_get(srv_config, "admin_account"); |
| 518 | 520 | ||
| 519 | xs *blurb = xs_replace(snac_blurb, "%host%", host); | 521 | xs *blurb = xs_replace(snac_blurb, "%host%", host); |
| 520 | 522 | ||
| @@ -760,7 +762,7 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 760 | xs_html_attr("class", "h-card snac-top-user")); | 762 | xs_html_attr("class", "h-card snac-top-user")); |
| 761 | 763 | ||
| 762 | if (read_only) { | 764 | if (read_only) { |
| 763 | char *header = xs_dict_get(user->config, "header"); | 765 | const char *header = xs_dict_get(user->config, "header"); |
| 764 | if (header && *header) { | 766 | if (header && *header) { |
| 765 | xs_html_add(top_user, | 767 | xs_html_add(top_user, |
| 766 | xs_html_tag("div", | 768 | xs_html_tag("div", |
| @@ -797,7 +799,7 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 797 | xs_html_add(top_user, | 799 | xs_html_add(top_user, |
| 798 | top_user_bio); | 800 | top_user_bio); |
| 799 | 801 | ||
| 800 | xs_dict *metadata = xs_dict_get(user->config, "metadata"); | 802 | const xs_dict *metadata = xs_dict_get(user->config, "metadata"); |
| 801 | if (xs_type(metadata) == XSTYPE_DICT) { | 803 | if (xs_type(metadata) == XSTYPE_DICT) { |
| 802 | xs_str *k; | 804 | xs_str *k; |
| 803 | xs_str *v; | 805 | xs_str *v; |
| @@ -816,7 +818,7 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 816 | if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/")) { | 818 | if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/")) { |
| 817 | /* is this link validated? */ | 819 | /* is this link validated? */ |
| 818 | xs *verified_link = NULL; | 820 | xs *verified_link = NULL; |
| 819 | xs_number *val_time = xs_dict_get(val_links, v); | 821 | const xs_number *val_time = xs_dict_get(val_links, v); |
| 820 | 822 | ||
| 821 | if (xs_type(val_time) == XSTYPE_NUMBER) { | 823 | if (xs_type(val_time) == XSTYPE_NUMBER) { |
| 822 | time_t t = xs_number_get(val_time); | 824 | time_t t = xs_number_get(val_time); |
| @@ -928,7 +930,7 @@ xs_html *html_top_controls(snac *snac) | |||
| 928 | 930 | ||
| 929 | /** user settings **/ | 931 | /** user settings **/ |
| 930 | 932 | ||
| 931 | char *email = "[disabled by admin]"; | 933 | const char *email = "[disabled by admin]"; |
| 932 | 934 | ||
| 933 | if (xs_type(xs_dict_get(srv_config, "disable_email_notifications")) != XSTYPE_TRUE) { | 935 | if (xs_type(xs_dict_get(srv_config, "disable_email_notifications")) != XSTYPE_TRUE) { |
| 934 | email = xs_dict_get(snac->config_o, "email"); | 936 | email = xs_dict_get(snac->config_o, "email"); |
| @@ -940,38 +942,38 @@ xs_html *html_top_controls(snac *snac) | |||
| 940 | } | 942 | } |
| 941 | } | 943 | } |
| 942 | 944 | ||
| 943 | char *cw = xs_dict_get(snac->config, "cw"); | 945 | const char *cw = xs_dict_get(snac->config, "cw"); |
| 944 | if (xs_is_null(cw)) | 946 | if (xs_is_null(cw)) |
| 945 | cw = ""; | 947 | cw = ""; |
| 946 | 948 | ||
| 947 | char *telegram_bot = xs_dict_get(snac->config, "telegram_bot"); | 949 | const char *telegram_bot = xs_dict_get(snac->config, "telegram_bot"); |
| 948 | if (xs_is_null(telegram_bot)) | 950 | if (xs_is_null(telegram_bot)) |
| 949 | telegram_bot = ""; | 951 | telegram_bot = ""; |
| 950 | 952 | ||
| 951 | char *telegram_chat_id = xs_dict_get(snac->config, "telegram_chat_id"); | 953 | const char *telegram_chat_id = xs_dict_get(snac->config, "telegram_chat_id"); |
| 952 | if (xs_is_null(telegram_chat_id)) | 954 | if (xs_is_null(telegram_chat_id)) |
| 953 | telegram_chat_id = ""; | 955 | telegram_chat_id = ""; |
| 954 | 956 | ||
| 955 | char *ntfy_server = xs_dict_get(snac->config, "ntfy_server"); | 957 | const char *ntfy_server = xs_dict_get(snac->config, "ntfy_server"); |
| 956 | if (xs_is_null(ntfy_server)) | 958 | if (xs_is_null(ntfy_server)) |
| 957 | ntfy_server = ""; | 959 | ntfy_server = ""; |
| 958 | 960 | ||
| 959 | char *ntfy_token = xs_dict_get(snac->config, "ntfy_token"); | 961 | const char *ntfy_token = xs_dict_get(snac->config, "ntfy_token"); |
| 960 | if (xs_is_null(ntfy_token)) | 962 | if (xs_is_null(ntfy_token)) |
| 961 | ntfy_token = ""; | 963 | ntfy_token = ""; |
| 962 | 964 | ||
| 963 | char *purge_days = xs_dict_get(snac->config, "purge_days"); | 965 | const char *purge_days = xs_dict_get(snac->config, "purge_days"); |
| 964 | if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER) | 966 | if (!xs_is_null(purge_days) && xs_type(purge_days) == XSTYPE_NUMBER) |
| 965 | purge_days = (char *)xs_number_str(purge_days); | 967 | purge_days = (char *)xs_number_str(purge_days); |
| 966 | else | 968 | else |
| 967 | purge_days = "0"; | 969 | purge_days = "0"; |
| 968 | 970 | ||
| 969 | xs_val *d_dm_f_u = xs_dict_get(snac->config, "drop_dm_from_unknown"); | 971 | const xs_val *d_dm_f_u = xs_dict_get(snac->config, "drop_dm_from_unknown"); |
| 970 | xs_val *bot = xs_dict_get(snac->config, "bot"); | 972 | const xs_val *bot = xs_dict_get(snac->config, "bot"); |
| 971 | xs_val *a_private = xs_dict_get(snac->config, "private"); | 973 | const xs_val *a_private = xs_dict_get(snac->config, "private"); |
| 972 | 974 | ||
| 973 | xs *metadata = xs_str_new(NULL); | 975 | xs *metadata = xs_str_new(NULL); |
| 974 | xs_dict *md = xs_dict_get(snac->config, "metadata"); | 976 | const xs_dict *md = xs_dict_get(snac->config, "metadata"); |
| 975 | xs_str *k; | 977 | xs_str *k; |
| 976 | xs_str *v; | 978 | xs_str *v; |
| 977 | 979 | ||
| @@ -1158,13 +1160,14 @@ xs_str *build_mentions(snac *snac, const xs_dict *msg) | |||
| 1158 | /* returns a string with the mentions in msg */ | 1160 | /* returns a string with the mentions in msg */ |
| 1159 | { | 1161 | { |
| 1160 | xs_str *s = xs_str_new(NULL); | 1162 | xs_str *s = xs_str_new(NULL); |
| 1161 | char *list = xs_dict_get(msg, "tag"); | 1163 | const char *list = xs_dict_get(msg, "tag"); |
| 1162 | char *v; | 1164 | char *v; |
| 1165 | int c = 0; | ||
| 1163 | 1166 | ||
| 1164 | while (xs_list_iter(&list, &v)) { | 1167 | while (xs_list_next(list, &v, &c)) { |
| 1165 | char *type = xs_dict_get(v, "type"); | 1168 | const char *type = xs_dict_get(v, "type"); |
| 1166 | char *href = xs_dict_get(v, "href"); | 1169 | const char *href = xs_dict_get(v, "href"); |
| 1167 | char *name = xs_dict_get(v, "name"); | 1170 | const char *name = xs_dict_get(v, "name"); |
| 1168 | 1171 | ||
| 1169 | if (type && strcmp(type, "Mention") == 0 && | 1172 | if (type && strcmp(type, "Mention") == 0 && |
| 1170 | href && strcmp(href, snac->actor) != 0 && name) { | 1173 | href && strcmp(href, snac->actor) != 0 && name) { |
| @@ -1208,10 +1211,11 @@ xs_str *build_mentions(snac *snac, const xs_dict *msg) | |||
| 1208 | } | 1211 | } |
| 1209 | 1212 | ||
| 1210 | 1213 | ||
| 1211 | xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const char *md5) | 1214 | xs_html *html_entry_controls(snac *snac, const char *actor, |
| 1215 | const xs_dict *msg, const char *md5) | ||
| 1212 | { | 1216 | { |
| 1213 | char *id = xs_dict_get(msg, "id"); | 1217 | const char *id = xs_dict_get(msg, "id"); |
| 1214 | char *group = xs_dict_get(msg, "audience"); | 1218 | const char *group = xs_dict_get(msg, "audience"); |
| 1215 | 1219 | ||
| 1216 | xs *likes = object_likes(id); | 1220 | xs *likes = object_likes(id); |
| 1217 | xs *boosts = object_announces(id); | 1221 | xs *boosts = object_announces(id); |
| @@ -1310,7 +1314,7 @@ xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const | |||
| 1310 | html_button("delete", L("Delete"), L("Delete this post")), | 1314 | html_button("delete", L("Delete"), L("Delete this post")), |
| 1311 | html_button("hide", L("Hide"), L("Hide this post and its children"))); | 1315 | html_button("hide", L("Hide"), L("Hide this post and its children"))); |
| 1312 | 1316 | ||
| 1313 | char *prev_src = xs_dict_get(msg, "sourceContent"); | 1317 | const char *prev_src = xs_dict_get(msg, "sourceContent"); |
| 1314 | 1318 | ||
| 1315 | if (!xs_is_null(prev_src) && strcmp(actor, snac->actor) == 0) { /** edit **/ | 1319 | if (!xs_is_null(prev_src) && strcmp(actor, snac->actor) == 0) { /** edit **/ |
| 1316 | /* post can be edited */ | 1320 | /* post can be edited */ |
| @@ -1318,13 +1322,13 @@ xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const | |||
| 1318 | xs *form_id = xs_fmt("%s_edit_form", md5); | 1322 | xs *form_id = xs_fmt("%s_edit_form", md5); |
| 1319 | xs *redir = xs_fmt("%s_entry", md5); | 1323 | xs *redir = xs_fmt("%s_entry", md5); |
| 1320 | 1324 | ||
| 1321 | char *att_file = ""; | 1325 | const char *att_file = ""; |
| 1322 | char *att_alt_text = ""; | 1326 | const char *att_alt_text = ""; |
| 1323 | xs_list *att_list = xs_dict_get(msg, "attachment"); | 1327 | const xs_list *att_list = xs_dict_get(msg, "attachment"); |
| 1324 | 1328 | ||
| 1325 | /* does it have an attachment? */ | 1329 | /* does it have an attachment? */ |
| 1326 | if (xs_type(att_list) == XSTYPE_LIST && xs_list_len(att_list)) { | 1330 | if (xs_type(att_list) == XSTYPE_LIST && xs_list_len(att_list)) { |
| 1327 | xs_dict *d = xs_list_get(att_list, 0); | 1331 | const xs_dict *d = xs_list_get(att_list, 0); |
| 1328 | 1332 | ||
| 1329 | if (xs_type(d) == XSTYPE_DICT) { | 1333 | if (xs_type(d) == XSTYPE_DICT) { |
| 1330 | att_file = xs_dict_get_def(d, "url", ""); | 1334 | att_file = xs_dict_get_def(d, "url", ""); |
| @@ -1370,10 +1374,10 @@ xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const | |||
| 1370 | xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | 1374 | xs_html *html_entry(snac *user, xs_dict *msg, int read_only, |
| 1371 | int level, char *md5, int hide_children) | 1375 | int level, char *md5, int hide_children) |
| 1372 | { | 1376 | { |
| 1373 | char *id = xs_dict_get(msg, "id"); | 1377 | const char *id = xs_dict_get(msg, "id"); |
| 1374 | char *type = xs_dict_get(msg, "type"); | 1378 | const char *type = xs_dict_get(msg, "type"); |
| 1375 | char *actor; | 1379 | const char *actor; |
| 1376 | char *v; | 1380 | const char *v; |
| 1377 | int has_title = 0; | 1381 | int has_title = 0; |
| 1378 | 1382 | ||
| 1379 | /* do not show non-public messages in the public timeline */ | 1383 | /* do not show non-public messages in the public timeline */ |
| @@ -1509,7 +1513,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1509 | 1513 | ||
| 1510 | if (xs_list_len(boosts)) { | 1514 | if (xs_list_len(boosts)) { |
| 1511 | /* if somebody boosted this, show as origin */ | 1515 | /* if somebody boosted this, show as origin */ |
| 1512 | char *p = xs_list_get(boosts, -1); | 1516 | const char *p = xs_list_get(boosts, -1); |
| 1513 | xs *actor_r = NULL; | 1517 | xs *actor_r = NULL; |
| 1514 | 1518 | ||
| 1515 | if (user && xs_list_in(boosts, user->md5) != -1) { | 1519 | if (user && xs_list_in(boosts, user->md5) != -1) { |
| @@ -1529,7 +1533,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1529 | 1533 | ||
| 1530 | if (!xs_is_null(name)) { | 1534 | if (!xs_is_null(name)) { |
| 1531 | xs *href = NULL; | 1535 | xs *href = NULL; |
| 1532 | char *id = xs_dict_get(actor_r, "id"); | 1536 | const char *id = xs_dict_get(actor_r, "id"); |
| 1533 | int fwers = 0; | 1537 | int fwers = 0; |
| 1534 | int fwing = 0; | 1538 | int fwing = 0; |
| 1535 | 1539 | ||
| @@ -1558,7 +1562,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1558 | if (strcmp(type, "Note") == 0) { | 1562 | if (strcmp(type, "Note") == 0) { |
| 1559 | if (level == 0) { | 1563 | if (level == 0) { |
| 1560 | /* is the parent not here? */ | 1564 | /* is the parent not here? */ |
| 1561 | char *parent = xs_dict_get(msg, "inReplyTo"); | 1565 | const char *parent = xs_dict_get(msg, "inReplyTo"); |
| 1562 | 1566 | ||
| 1563 | if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { | 1567 | if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { |
| 1564 | xs_html_add(post_header, | 1568 | xs_html_add(post_header, |
| @@ -1603,7 +1607,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1603 | v = "..."; | 1607 | v = "..."; |
| 1604 | 1608 | ||
| 1605 | /* only show it when not in the public timeline and the config setting is "open" */ | 1609 | /* only show it when not in the public timeline and the config setting is "open" */ |
| 1606 | char *cw = xs_dict_get(user->config, "cw"); | 1610 | const char *cw = xs_dict_get(user->config, "cw"); |
| 1607 | if (xs_is_null(cw) || read_only) | 1611 | if (xs_is_null(cw) || read_only) |
| 1608 | cw = ""; | 1612 | cw = ""; |
| 1609 | 1613 | ||
| @@ -1632,7 +1636,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1632 | 1636 | ||
| 1633 | { | 1637 | { |
| 1634 | /** build the content string **/ | 1638 | /** build the content string **/ |
| 1635 | char *content = xs_dict_get(msg, "content"); | 1639 | const char *content = xs_dict_get(msg, "content"); |
| 1636 | 1640 | ||
| 1637 | xs *c = sanitize(xs_is_null(content) ? "" : content); | 1641 | xs *c = sanitize(xs_is_null(content) ? "" : content); |
| 1638 | 1642 | ||
| @@ -1650,7 +1654,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1650 | c = replace_shortnames(c, xs_dict_get(msg, "tag"), 2); | 1654 | c = replace_shortnames(c, xs_dict_get(msg, "tag"), 2); |
| 1651 | 1655 | ||
| 1652 | /* Peertube videos content is in markdown */ | 1656 | /* Peertube videos content is in markdown */ |
| 1653 | char *mtype = xs_dict_get(msg, "mediaType"); | 1657 | const char *mtype = xs_dict_get(msg, "mediaType"); |
| 1654 | if (xs_type(mtype) == XSTYPE_STRING && strcmp(mtype, "text/markdown") == 0) { | 1658 | if (xs_type(mtype) == XSTYPE_STRING && strcmp(mtype, "text/markdown") == 0) { |
| 1655 | /* a full conversion could be better */ | 1659 | /* a full conversion could be better */ |
| 1656 | c = xs_replace_i(c, "\r", ""); | 1660 | c = xs_replace_i(c, "\r", ""); |
| @@ -1663,12 +1667,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1663 | } | 1667 | } |
| 1664 | 1668 | ||
| 1665 | if (strcmp(type, "Question") == 0) { /** question content **/ | 1669 | if (strcmp(type, "Question") == 0) { /** question content **/ |
| 1666 | xs_list *oo = xs_dict_get(msg, "oneOf"); | 1670 | const xs_list *oo = xs_dict_get(msg, "oneOf"); |
| 1667 | xs_list *ao = xs_dict_get(msg, "anyOf"); | 1671 | const xs_list *ao = xs_dict_get(msg, "anyOf"); |
| 1668 | xs_list *p; | 1672 | const xs_list *p; |
| 1669 | xs_dict *v; | 1673 | xs_dict *v; |
| 1670 | int closed = 0; | 1674 | int closed = 0; |
| 1671 | char *f_closed = NULL; | 1675 | const char *f_closed = NULL; |
| 1672 | 1676 | ||
| 1673 | xs_html *poll = xs_html_tag("div", NULL); | 1677 | xs_html *poll = xs_html_tag("div", NULL); |
| 1674 | 1678 | ||
| @@ -1697,10 +1701,11 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1697 | /* closed poll */ | 1701 | /* closed poll */ |
| 1698 | xs_html *poll_result = xs_html_tag("table", | 1702 | xs_html *poll_result = xs_html_tag("table", |
| 1699 | xs_html_attr("class", "snac-poll-result")); | 1703 | xs_html_attr("class", "snac-poll-result")); |
| 1704 | int c = 0; | ||
| 1700 | 1705 | ||
| 1701 | while (xs_list_iter(&p, &v)) { | 1706 | while (xs_list_next(p, &v, &c)) { |
| 1702 | char *name = xs_dict_get(v, "name"); | 1707 | const char *name = xs_dict_get(v, "name"); |
| 1703 | xs_dict *replies = xs_dict_get(v, "replies"); | 1708 | const xs_dict *replies = xs_dict_get(v, "replies"); |
| 1704 | 1709 | ||
| 1705 | if (name && replies) { | 1710 | if (name && replies) { |
| 1706 | char *ti = (char *)xs_number_str(xs_dict_get(replies, "totalItems")); | 1711 | char *ti = (char *)xs_number_str(xs_dict_get(replies, "totalItems")); |
| @@ -1737,9 +1742,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1737 | xs_html_attr("name", "irt"), | 1742 | xs_html_attr("name", "irt"), |
| 1738 | xs_html_attr("value", id)))); | 1743 | xs_html_attr("value", id)))); |
| 1739 | 1744 | ||
| 1740 | while (xs_list_iter(&p, &v)) { | 1745 | int c = 0; |
| 1741 | char *name = xs_dict_get(v, "name"); | 1746 | while (xs_list_next(p, &v, &c)) { |
| 1742 | xs_dict *replies = xs_dict_get(v, "replies"); | 1747 | const char *name = xs_dict_get(v, "name"); |
| 1748 | const xs_dict *replies = xs_dict_get(v, "replies"); | ||
| 1743 | 1749 | ||
| 1744 | if (name) { | 1750 | if (name) { |
| 1745 | char *ti = (char *)xs_number_str(xs_dict_get(replies, "totalItems")); | 1751 | char *ti = (char *)xs_number_str(xs_dict_get(replies, "totalItems")); |
| @@ -1777,7 +1783,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1777 | } | 1783 | } |
| 1778 | else { | 1784 | else { |
| 1779 | /* show when the poll closes */ | 1785 | /* show when the poll closes */ |
| 1780 | char *end_time = xs_dict_get(msg, "endTime"); | 1786 | const char *end_time = xs_dict_get(msg, "endTime"); |
| 1781 | 1787 | ||
| 1782 | /* Pleroma does not have an endTime field; | 1788 | /* Pleroma does not have an endTime field; |
| 1783 | it has a closed time in the future */ | 1789 | it has a closed time in the future */ |
| @@ -1820,12 +1826,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1820 | xs_html_add(snac_content, | 1826 | xs_html_add(snac_content, |
| 1821 | content_attachments); | 1827 | content_attachments); |
| 1822 | 1828 | ||
| 1823 | xs_list *p = attach; | 1829 | int c = 0; |
| 1824 | 1830 | xs_dict *a; | |
| 1825 | while (xs_list_iter(&p, &v)) { | 1831 | while (xs_list_next(attach, &a, &c)) { |
| 1826 | char *type = xs_dict_get(v, "type"); | 1832 | const char *type = xs_dict_get(a, "type"); |
| 1827 | char *href = xs_dict_get(v, "href"); | 1833 | const char *href = xs_dict_get(a, "href"); |
| 1828 | char *name = xs_dict_get(v, "name"); | 1834 | const char *name = xs_dict_get(a, "name"); |
| 1829 | 1835 | ||
| 1830 | if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) { | 1836 | if (xs_startswith(type, "image/") || strcmp(type, "Image") == 0) { |
| 1831 | xs_html_add(content_attachments, | 1837 | xs_html_add(content_attachments, |
| @@ -1889,7 +1895,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1889 | } | 1895 | } |
| 1890 | 1896 | ||
| 1891 | /* has this message an audience (i.e., comes from a channel or community)? */ | 1897 | /* has this message an audience (i.e., comes from a channel or community)? */ |
| 1892 | char *audience = xs_dict_get(msg, "audience"); | 1898 | const char *audience = xs_dict_get(msg, "audience"); |
| 1893 | if (strcmp(type, "Page") == 0 && !xs_is_null(audience)) { | 1899 | if (strcmp(type, "Page") == 0 && !xs_is_null(audience)) { |
| 1894 | xs_html *au_tag = xs_html_tag("p", | 1900 | xs_html *au_tag = xs_html_tag("p", |
| 1895 | xs_html_text("("), | 1901 | xs_html_text("("), |
| @@ -2023,11 +2029,12 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2023 | 2029 | ||
| 2024 | if (xs_list_len(list) == 1) { | 2030 | if (xs_list_len(list) == 1) { |
| 2025 | /* only one element? pick the description from the source */ | 2031 | /* only one element? pick the description from the source */ |
| 2026 | char *id = xs_list_get(list, 0); | 2032 | const char *id = xs_list_get(list, 0); |
| 2027 | xs *d = NULL; | 2033 | xs *d = NULL; |
| 2028 | object_get_by_md5(id, &d); | 2034 | object_get_by_md5(id, &d); |
| 2029 | if (d && (v = xs_dict_get(d, "sourceContent")) != NULL) | 2035 | const char *sc = xs_dict_get(d, "sourceContent"); |
| 2030 | desc = xs_dup(v); | 2036 | if (d && sc != NULL) |
| 2037 | desc = xs_dup(sc); | ||
| 2031 | 2038 | ||
| 2032 | alternate = xs_dup(xs_dict_get(d, "id")); | 2039 | alternate = xs_dup(xs_dict_get(d, "id")); |
| 2033 | } | 2040 | } |
| @@ -2087,13 +2094,13 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2087 | 2094 | ||
| 2088 | /* is this message a non-public reply? */ | 2095 | /* is this message a non-public reply? */ |
| 2089 | if (user != NULL && !is_msg_public(msg)) { | 2096 | if (user != NULL && !is_msg_public(msg)) { |
| 2090 | char *irt = xs_dict_get(msg, "inReplyTo"); | 2097 | const char *irt = xs_dict_get(msg, "inReplyTo"); |
| 2091 | 2098 | ||
| 2092 | /* is it a reply to something not in the storage? */ | 2099 | /* is it a reply to something not in the storage? */ |
| 2093 | if (!xs_is_null(irt) && !object_here(irt)) { | 2100 | if (!xs_is_null(irt) && !object_here(irt)) { |
| 2094 | /* is it for me? */ | 2101 | /* is it for me? */ |
| 2095 | xs_list *to = xs_dict_get_def(msg, "to", xs_stock(XSTYPE_LIST)); | 2102 | const xs_list *to = xs_dict_get_def(msg, "to", xs_stock(XSTYPE_LIST)); |
| 2096 | xs_list *cc = xs_dict_get_def(msg, "cc", xs_stock(XSTYPE_LIST)); | 2103 | const xs_list *cc = xs_dict_get_def(msg, "cc", xs_stock(XSTYPE_LIST)); |
| 2097 | 2104 | ||
| 2098 | if (xs_list_in(to, user->actor) == -1 && xs_list_in(cc, user->actor) == -1) { | 2105 | if (xs_list_in(to, user->actor) == -1 && xs_list_in(cc, user->actor) == -1) { |
| 2099 | snac_debug(user, 1, xs_fmt("skipping non-public reply to an unknown post %s", v)); | 2106 | snac_debug(user, 1, xs_fmt("skipping non-public reply to an unknown post %s", v)); |
| @@ -2212,7 +2219,7 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t) | |||
| 2212 | html_actor_icon(snac, actor, xs_dict_get(actor, "published"), NULL, NULL, 0, 1))); | 2219 | html_actor_icon(snac, actor, xs_dict_get(actor, "published"), NULL, NULL, 0, 1))); |
| 2213 | 2220 | ||
| 2214 | /* content (user bio) */ | 2221 | /* content (user bio) */ |
| 2215 | char *c = xs_dict_get(actor, "summary"); | 2222 | const char *c = xs_dict_get(actor, "summary"); |
| 2216 | 2223 | ||
| 2217 | if (!xs_is_null(c)) { | 2224 | if (!xs_is_null(c)) { |
| 2218 | xs *sc = sanitize(c); | 2225 | xs *sc = sanitize(c); |
| @@ -2364,10 +2371,10 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2364 | continue; | 2371 | continue; |
| 2365 | 2372 | ||
| 2366 | xs *obj = NULL; | 2373 | xs *obj = NULL; |
| 2367 | char *type = xs_dict_get(noti, "type"); | 2374 | const char *type = xs_dict_get(noti, "type"); |
| 2368 | char *utype = xs_dict_get(noti, "utype"); | 2375 | const char *utype = xs_dict_get(noti, "utype"); |
| 2369 | char *id = xs_dict_get(noti, "objid"); | 2376 | const char *id = xs_dict_get(noti, "objid"); |
| 2370 | char *date = xs_dict_get(noti, "date"); | 2377 | const char *date = xs_dict_get(noti, "date"); |
| 2371 | 2378 | ||
| 2372 | if (xs_is_null(id) || !valid_status(object_get(id, &obj))) | 2379 | if (xs_is_null(id) || !valid_status(object_get(id, &obj))) |
| 2373 | continue; | 2380 | continue; |
| @@ -2375,14 +2382,14 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2375 | if (is_hidden(user, id)) | 2382 | if (is_hidden(user, id)) |
| 2376 | continue; | 2383 | continue; |
| 2377 | 2384 | ||
| 2378 | char *actor_id = xs_dict_get(noti, "actor"); | 2385 | const char *actor_id = xs_dict_get(noti, "actor"); |
| 2379 | xs *actor = NULL; | 2386 | xs *actor = NULL; |
| 2380 | 2387 | ||
| 2381 | if (!valid_status(actor_get(actor_id, &actor))) | 2388 | if (!valid_status(actor_get(actor_id, &actor))) |
| 2382 | continue; | 2389 | continue; |
| 2383 | 2390 | ||
| 2384 | xs *a_name = actor_name(actor); | 2391 | xs *a_name = actor_name(actor); |
| 2385 | char *label = type; | 2392 | const char *label = type; |
| 2386 | 2393 | ||
| 2387 | if (strcmp(type, "Create") == 0) | 2394 | if (strcmp(type, "Create") == 0) |
| 2388 | label = L("Mention"); | 2395 | label = L("Mention"); |
| @@ -2494,14 +2501,14 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2494 | int html_get_handler(const xs_dict *req, const char *q_path, | 2501 | int html_get_handler(const xs_dict *req, const char *q_path, |
| 2495 | char **body, int *b_size, char **ctype, xs_str **etag) | 2502 | char **body, int *b_size, char **ctype, xs_str **etag) |
| 2496 | { | 2503 | { |
| 2497 | char *accept = xs_dict_get(req, "accept"); | 2504 | const char *accept = xs_dict_get(req, "accept"); |
| 2498 | int status = 404; | 2505 | int status = 404; |
| 2499 | snac snac; | 2506 | snac snac; |
| 2500 | xs *uid = NULL; | 2507 | xs *uid = NULL; |
| 2501 | char *p_path; | 2508 | const char *p_path; |
| 2502 | int cache = 1; | 2509 | int cache = 1; |
| 2503 | int save = 1; | 2510 | int save = 1; |
| 2504 | char *v; | 2511 | const char *v; |
| 2505 | 2512 | ||
| 2506 | xs *l = xs_split_n(q_path, "/", 2); | 2513 | xs *l = xs_split_n(q_path, "/", 2); |
| 2507 | v = xs_list_get(l, 1); | 2514 | v = xs_list_get(l, 1); |
| @@ -2540,7 +2547,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2540 | 2547 | ||
| 2541 | int skip = 0; | 2548 | int skip = 0; |
| 2542 | int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); | 2549 | int show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); |
| 2543 | xs_dict *q_vars = xs_dict_get(req, "q_vars"); | 2550 | const xs_dict *q_vars = xs_dict_get(req, "q_vars"); |
| 2544 | if ((v = xs_dict_get(q_vars, "skip")) != NULL) | 2551 | if ((v = xs_dict_get(q_vars, "skip")) != NULL) |
| 2545 | skip = atoi(v), cache = 0, save = 0; | 2552 | skip = atoi(v), cache = 0, save = 0; |
| 2546 | if ((v = xs_dict_get(q_vars, "show")) != NULL) | 2553 | if ((v = xs_dict_get(q_vars, "show")) != NULL) |
| @@ -2585,7 +2592,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2585 | status = 401; | 2592 | status = 401; |
| 2586 | } | 2593 | } |
| 2587 | else { | 2594 | else { |
| 2588 | char *q = xs_dict_get(q_vars, "q"); | 2595 | const char *q = xs_dict_get(q_vars, "q"); |
| 2589 | 2596 | ||
| 2590 | if (q && *q) { | 2597 | if (q && *q) { |
| 2591 | if (*q == '#') { | 2598 | if (*q == '#') { |
| @@ -2669,7 +2676,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2669 | } | 2676 | } |
| 2670 | else { | 2677 | else { |
| 2671 | xs *l = xs_split(p_path, "/"); | 2678 | xs *l = xs_split(p_path, "/"); |
| 2672 | char *md5 = xs_list_get(l, -1); | 2679 | const char *md5 = xs_list_get(l, -1); |
| 2673 | 2680 | ||
| 2674 | if (md5 && *md5 && timeline_here(&snac, md5)) { | 2681 | if (md5 && *md5 && timeline_here(&snac, md5)) { |
| 2675 | xs *list = xs_list_append(xs_list_new(), md5); | 2682 | xs *list = xs_list_append(xs_list_new(), md5); |
| @@ -2728,7 +2735,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2728 | } | 2735 | } |
| 2729 | else { | 2736 | else { |
| 2730 | xs *l = xs_split(p_path, "/"); | 2737 | xs *l = xs_split(p_path, "/"); |
| 2731 | char *lid = xs_list_get(l, -1); | 2738 | const char *lid = xs_list_get(l, -1); |
| 2732 | 2739 | ||
| 2733 | xs *list = list_timeline(&snac, lid, skip, show); | 2740 | xs *list = list_timeline(&snac, lid, skip, show); |
| 2734 | xs *next = list_timeline(&snac, lid, skip + show, 1); | 2741 | xs *next = list_timeline(&snac, lid, skip + show, 1); |
| @@ -2767,7 +2774,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2767 | else | 2774 | else |
| 2768 | if (xs_startswith(p_path, "s/")) { /** a static file **/ | 2775 | if (xs_startswith(p_path, "s/")) { /** a static file **/ |
| 2769 | xs *l = xs_split(p_path, "/"); | 2776 | xs *l = xs_split(p_path, "/"); |
| 2770 | char *id = xs_list_get(l, 1); | 2777 | const char *id = xs_list_get(l, 1); |
| 2771 | int sz; | 2778 | int sz; |
| 2772 | 2779 | ||
| 2773 | if (id && *id) { | 2780 | if (id && *id) { |
| @@ -2788,8 +2795,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 2788 | if (xs_type(xs_dict_get(srv_config, "disable_history")) == XSTYPE_TRUE) | 2795 | if (xs_type(xs_dict_get(srv_config, "disable_history")) == XSTYPE_TRUE) |
| 2789 | return 403; | 2796 | return 403; |
| 2790 | 2797 | ||
| 2791 | xs *l = xs_split(p_path, "/"); | 2798 | xs *l = xs_split(p_path, "/"); |
| 2792 | char *id = xs_list_get(l, 1); | 2799 | const char *id = xs_list_get(l, 1); |
| 2793 | 2800 | ||
| 2794 | if (id && *id) { | 2801 | if (id && *id) { |
| 2795 | if (xs_endswith(id, "timeline.html_")) { | 2802 | if (xs_endswith(id, "timeline.html_")) { |
| @@ -2845,8 +2852,9 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 2845 | 2852 | ||
| 2846 | int status = 0; | 2853 | int status = 0; |
| 2847 | snac snac; | 2854 | snac snac; |
| 2848 | char *uid, *p_path; | 2855 | const char *uid; |
| 2849 | xs_dict *p_vars; | 2856 | const char *p_path; |
| 2857 | const xs_dict *p_vars; | ||
| 2850 | 2858 | ||
| 2851 | xs *l = xs_split_n(q_path, "/", 2); | 2859 | xs *l = xs_split_n(q_path, "/", 2); |
| 2852 | 2860 | ||
| @@ -2874,15 +2882,15 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 2874 | 2882 | ||
| 2875 | if (p_path && strcmp(p_path, "admin/note") == 0) { /** **/ | 2883 | if (p_path && strcmp(p_path, "admin/note") == 0) { /** **/ |
| 2876 | /* post note */ | 2884 | /* post note */ |
| 2877 | xs_str *content = xs_dict_get(p_vars, "content"); | 2885 | const xs_str *content = xs_dict_get(p_vars, "content"); |
| 2878 | xs_str *in_reply_to = xs_dict_get(p_vars, "in_reply_to"); | 2886 | const xs_str *in_reply_to = xs_dict_get(p_vars, "in_reply_to"); |
| 2879 | xs_str *attach_url = xs_dict_get(p_vars, "attach_url"); | 2887 | const xs_str *attach_url = xs_dict_get(p_vars, "attach_url"); |
| 2880 | xs_list *attach_file = xs_dict_get(p_vars, "attach"); | 2888 | const xs_list *attach_file = xs_dict_get(p_vars, "attach"); |
| 2881 | xs_str *to = xs_dict_get(p_vars, "to"); | 2889 | const xs_str *to = xs_dict_get(p_vars, "to"); |
| 2882 | xs_str *sensitive = xs_dict_get(p_vars, "sensitive"); | 2890 | const xs_str *sensitive = xs_dict_get(p_vars, "sensitive"); |
| 2883 | xs_str *summary = xs_dict_get(p_vars, "summary"); | 2891 | const xs_str *summary = xs_dict_get(p_vars, "summary"); |
| 2884 | xs_str *edit_id = xs_dict_get(p_vars, "edit_id"); | 2892 | const xs_str *edit_id = xs_dict_get(p_vars, "edit_id"); |
| 2885 | xs_str *alt_text = xs_dict_get(p_vars, "alt_text"); | 2893 | const xs_str *alt_text = xs_dict_get(p_vars, "alt_text"); |
| 2886 | int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only")); | 2894 | int priv = !xs_is_null(xs_dict_get(p_vars, "mentioned_only")); |
| 2887 | xs *attach_list = xs_list_new(); | 2895 | xs *attach_list = xs_list_new(); |
| 2888 | 2896 | ||
| @@ -2902,7 +2910,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 2902 | 2910 | ||
| 2903 | /* is attach_file set? */ | 2911 | /* is attach_file set? */ |
| 2904 | if (!xs_is_null(attach_file) && xs_type(attach_file) == XSTYPE_LIST) { | 2912 | if (!xs_is_null(attach_file) && xs_type(attach_file) == XSTYPE_LIST) { |
| 2905 | char *fn = xs_list_get(attach_file, 0); | 2913 | const char *fn = xs_list_get(attach_file, 0); |
| 2906 | 2914 | ||
| 2907 | if (*fn != '\0') { | 2915 | if (*fn != '\0') { |
| 2908 | char *ext = strrchr(fn, '.'); | 2916 | char *ext = strrchr(fn, '.'); |
| @@ -2978,7 +2986,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 2978 | int n; | 2986 | int n; |
| 2979 | 2987 | ||
| 2980 | for (n = 0; fields[n]; n++) { | 2988 | for (n = 0; fields[n]; n++) { |
| 2981 | char *v = xs_dict_get(p_msg, fields[n]); | 2989 | const char *v = xs_dict_get(p_msg, fields[n]); |
| 2982 | msg = xs_dict_set(msg, fields[n], v); | 2990 | msg = xs_dict_set(msg, fields[n], v); |
| 2983 | } | 2991 | } |
| 2984 | 2992 | ||
| @@ -3007,10 +3015,10 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3007 | else | 3015 | else |
| 3008 | if (p_path && strcmp(p_path, "admin/action") == 0) { /** **/ | 3016 | if (p_path && strcmp(p_path, "admin/action") == 0) { /** **/ |
| 3009 | /* action on an entry */ | 3017 | /* action on an entry */ |
| 3010 | char *id = xs_dict_get(p_vars, "id"); | 3018 | const char *id = xs_dict_get(p_vars, "id"); |
| 3011 | char *actor = xs_dict_get(p_vars, "actor"); | 3019 | const char *actor = xs_dict_get(p_vars, "actor"); |
| 3012 | char *action = xs_dict_get(p_vars, "action"); | 3020 | const char *action = xs_dict_get(p_vars, "action"); |
| 3013 | char *group = xs_dict_get(p_vars, "group"); | 3021 | const char *group = xs_dict_get(p_vars, "group"); |
| 3014 | 3022 | ||
| 3015 | if (action == NULL) | 3023 | if (action == NULL) |
| 3016 | return 404; | 3024 | return 404; |
| @@ -3134,7 +3142,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3134 | } | 3142 | } |
| 3135 | else | 3143 | else |
| 3136 | if (strcmp(action, L("Delete")) == 0) { /** **/ | 3144 | if (strcmp(action, L("Delete")) == 0) { /** **/ |
| 3137 | char *actor_form = xs_dict_get(p_vars, "actor-form"); | 3145 | const char *actor_form = xs_dict_get(p_vars, "actor-form"); |
| 3138 | if (actor_form != NULL) { | 3146 | if (actor_form != NULL) { |
| 3139 | /* delete follower */ | 3147 | /* delete follower */ |
| 3140 | if (valid_status(follower_del(&snac, actor))) | 3148 | if (valid_status(follower_del(&snac, actor))) |
| @@ -3178,8 +3186,8 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3178 | else | 3186 | else |
| 3179 | if (p_path && strcmp(p_path, "admin/user-setup") == 0) { /** **/ | 3187 | if (p_path && strcmp(p_path, "admin/user-setup") == 0) { /** **/ |
| 3180 | /* change of user data */ | 3188 | /* change of user data */ |
| 3181 | char *v; | 3189 | const char *v; |
| 3182 | char *p1, *p2; | 3190 | const char *p1, *p2; |
| 3183 | 3191 | ||
| 3184 | if ((v = xs_dict_get(p_vars, "name")) != NULL) | 3192 | if ((v = xs_dict_get(p_vars, "name")) != NULL) |
| 3185 | snac.config = xs_dict_set(snac.config, "name", v); | 3193 | snac.config = xs_dict_set(snac.config, "name", v); |
| @@ -3245,7 +3253,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3245 | for (n = 0; uploads[n]; n++) { | 3253 | for (n = 0; uploads[n]; n++) { |
| 3246 | xs *var_name = xs_fmt("%s_file", uploads[n]); | 3254 | xs *var_name = xs_fmt("%s_file", uploads[n]); |
| 3247 | 3255 | ||
| 3248 | xs_list *uploaded_file = xs_dict_get(p_vars, var_name); | 3256 | const xs_list *uploaded_file = xs_dict_get(p_vars, var_name); |
| 3249 | if (xs_type(uploaded_file) == XSTYPE_LIST) { | 3257 | if (xs_type(uploaded_file) == XSTYPE_LIST) { |
| 3250 | const char *fn = xs_list_get(uploaded_file, 0); | 3258 | const char *fn = xs_list_get(uploaded_file, 0); |
| 3251 | 3259 | ||
| @@ -3310,7 +3318,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3310 | } | 3318 | } |
| 3311 | else | 3319 | else |
| 3312 | if (p_path && strcmp(p_path, "admin/vote") == 0) { /** **/ | 3320 | if (p_path && strcmp(p_path, "admin/vote") == 0) { /** **/ |
| 3313 | char *irt = xs_dict_get(p_vars, "irt"); | 3321 | const char *irt = xs_dict_get(p_vars, "irt"); |
| 3314 | const char *opt = xs_dict_get(p_vars, "question"); | 3322 | const char *opt = xs_dict_get(p_vars, "question"); |
| 3315 | const char *actor = xs_dict_get(p_vars, "actor"); | 3323 | const char *actor = xs_dict_get(p_vars, "actor"); |
| 3316 | 3324 | ||
| @@ -3345,7 +3353,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3345 | xs *poll = NULL; | 3353 | xs *poll = NULL; |
| 3346 | 3354 | ||
| 3347 | if (valid_status(object_get(irt, &poll))) { | 3355 | if (valid_status(object_get(irt, &poll))) { |
| 3348 | char *date = xs_dict_get(poll, "endTime"); | 3356 | const char *date = xs_dict_get(poll, "endTime"); |
| 3349 | if (xs_is_null(date)) | 3357 | if (xs_is_null(date)) |
| 3350 | date = xs_dict_get(poll, "closed"); | 3358 | date = xs_dict_get(poll, "closed"); |
| 3351 | 3359 | ||
| @@ -3363,7 +3371,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 3363 | } | 3371 | } |
| 3364 | 3372 | ||
| 3365 | if (status == 303) { | 3373 | if (status == 303) { |
| 3366 | char *redir = xs_dict_get(p_vars, "redir"); | 3374 | const char *redir = xs_dict_get(p_vars, "redir"); |
| 3367 | 3375 | ||
| 3368 | if (xs_is_null(redir)) | 3376 | if (xs_is_null(redir)) |
| 3369 | redir = "top"; | 3377 | redir = "top"; |
| @@ -3411,8 +3419,8 @@ xs_str *timeline_to_rss(snac *user, const xs_list *timeline, char *title, char * | |||
| 3411 | continue; | 3419 | continue; |
| 3412 | } | 3420 | } |
| 3413 | 3421 | ||
| 3414 | char *id = xs_dict_get(msg, "id"); | 3422 | const char *id = xs_dict_get(msg, "id"); |
| 3415 | char *content = xs_dict_get(msg, "content"); | 3423 | const char *content = xs_dict_get(msg, "content"); |
| 3416 | 3424 | ||
| 3417 | if (user && !xs_startswith(id, user->actor)) | 3425 | if (user && !xs_startswith(id, user->actor)) |
| 3418 | continue; | 3426 | continue; |