diff options
| author | 2024-11-07 17:27:11 +0100 | |
|---|---|---|
| committer | 2024-11-07 17:27:11 +0100 | |
| commit | 484dd127d6e9da8813faa29d88cc8eecd158d163 (patch) | |
| tree | 6fc5f09f8cd9a89485dbb1fe9be0461d67be775d /html.c | |
| parent | New function make_url(), that takes 'proxy_media' into account. (diff) | |
| download | snac2-484dd127d6e9da8813faa29d88cc8eecd158d163.tar.gz snac2-484dd127d6e9da8813faa29d88cc8eecd158d163.tar.xz snac2-484dd127d6e9da8813faa29d88cc8eecd158d163.zip | |
More proxy_media work.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 25 |
1 files changed, 16 insertions, 9 deletions
| @@ -120,7 +120,7 @@ xs_str *actor_name(xs_dict *actor) | |||
| 120 | 120 | ||
| 121 | 121 | ||
| 122 | xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | 122 | xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, |
| 123 | const char *udate, const char *url, int priv, int in_people) | 123 | const char *udate, const char *url, int priv, int in_people, int proxy) |
| 124 | { | 124 | { |
| 125 | xs_html *actor_icon = xs_html_tag("p", NULL); | 125 | xs_html *actor_icon = xs_html_tag("p", NULL); |
| 126 | 126 | ||
| @@ -138,7 +138,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 138 | v = xs_list_get(v, 0); | 138 | v = xs_list_get(v, 0); |
| 139 | 139 | ||
| 140 | if ((v = xs_dict_get(v, "url")) != NULL) | 140 | if ((v = xs_dict_get(v, "url")) != NULL) |
| 141 | avatar = xs_dup(v); | 141 | avatar = make_url(user, proxy, v); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | if (avatar == NULL) | 144 | if (avatar == NULL) |
| @@ -263,7 +263,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | 265 | ||
| 266 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg) | 266 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, int proxy) |
| 267 | { | 267 | { |
| 268 | xs *actor = NULL; | 268 | xs *actor = NULL; |
| 269 | xs_html *actor_icon = NULL; | 269 | xs_html *actor_icon = NULL; |
| @@ -283,7 +283,7 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg) | |||
| 283 | date = xs_dict_get(msg, "published"); | 283 | date = xs_dict_get(msg, "published"); |
| 284 | udate = xs_dict_get(msg, "updated"); | 284 | udate = xs_dict_get(msg, "updated"); |
| 285 | 285 | ||
| 286 | actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0); | 286 | actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy); |
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | return actor_icon; | 289 | return actor_icon; |
| @@ -1515,7 +1515,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1515 | xs_html_tag("div", | 1515 | xs_html_tag("div", |
| 1516 | xs_html_attr("class", "snac-origin"), | 1516 | xs_html_attr("class", "snac-origin"), |
| 1517 | xs_html_text(L("follows you"))), | 1517 | xs_html_text(L("follows you"))), |
| 1518 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg))); | 1518 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy_media))); |
| 1519 | } | 1519 | } |
| 1520 | else | 1520 | else |
| 1521 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { | 1521 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| @@ -1694,7 +1694,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1694 | } | 1694 | } |
| 1695 | 1695 | ||
| 1696 | xs_html_add(post_header, | 1696 | xs_html_add(post_header, |
| 1697 | html_msg_icon(read_only ? NULL : user, actor, msg)); | 1697 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy_media)); |
| 1698 | 1698 | ||
| 1699 | /** post content **/ | 1699 | /** post content **/ |
| 1700 | 1700 | ||
| @@ -2435,6 +2435,8 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2435 | 2435 | ||
| 2436 | xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t) | 2436 | xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t) |
| 2437 | { | 2437 | { |
| 2438 | int proxy_media = xs_is_true(xs_dict_get(srv_config, "proxy_media")); | ||
| 2439 | |||
| 2438 | xs_html *snac_posts; | 2440 | xs_html *snac_posts; |
| 2439 | xs_html *people = xs_html_tag("div", | 2441 | xs_html *people = xs_html_tag("div", |
| 2440 | xs_html_tag("h2", | 2442 | xs_html_tag("h2", |
| @@ -2459,7 +2461,8 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t) | |||
| 2459 | xs_html_attr("name", md5)), | 2461 | xs_html_attr("name", md5)), |
| 2460 | xs_html_tag("div", | 2462 | xs_html_tag("div", |
| 2461 | xs_html_attr("class", "snac-post-header"), | 2463 | xs_html_attr("class", "snac-post-header"), |
| 2462 | html_actor_icon(snac, actor, xs_dict_get(actor, "published"), NULL, NULL, 0, 1))); | 2464 | html_actor_icon(snac, actor, xs_dict_get(actor, "published"), |
| 2465 | NULL, NULL, 0, 1, proxy_media))); | ||
| 2463 | 2466 | ||
| 2464 | /* content (user bio) */ | 2467 | /* content (user bio) */ |
| 2465 | const char *c = xs_dict_get(actor, "summary"); | 2468 | const char *c = xs_dict_get(actor, "summary"); |
| @@ -2580,6 +2583,8 @@ xs_str *html_people(snac *user) | |||
| 2580 | 2583 | ||
| 2581 | xs_str *html_notifications(snac *user, int skip, int show) | 2584 | xs_str *html_notifications(snac *user, int skip, int show) |
| 2582 | { | 2585 | { |
| 2586 | int proxy_media = xs_is_true(xs_dict_get(srv_config, "proxy_media")); | ||
| 2587 | |||
| 2583 | xs *n_list = notify_list(user, skip, show); | 2588 | xs *n_list = notify_list(user, skip, show); |
| 2584 | xs *n_time = notify_check_time(user, 0); | 2589 | xs *n_time = notify_check_time(user, 0); |
| 2585 | 2590 | ||
| @@ -2680,7 +2685,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2680 | xs_html_add(entry, | 2685 | xs_html_add(entry, |
| 2681 | xs_html_tag("div", | 2686 | xs_html_tag("div", |
| 2682 | xs_html_attr("class", "snac-post"), | 2687 | xs_html_attr("class", "snac-post"), |
| 2683 | html_actor_icon(user, actor, NULL, NULL, NULL, 0, 0))); | 2688 | html_actor_icon(user, actor, NULL, NULL, NULL, 0, 0, proxy_media))); |
| 2684 | } | 2689 | } |
| 2685 | else | 2690 | else |
| 2686 | if (strcmp(type, "Move") == 0) { | 2691 | if (strcmp(type, "Move") == 0) { |
| @@ -2694,7 +2699,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 2694 | xs_html_add(entry, | 2699 | xs_html_add(entry, |
| 2695 | xs_html_tag("div", | 2700 | xs_html_tag("div", |
| 2696 | xs_html_attr("class", "snac-post"), | 2701 | xs_html_attr("class", "snac-post"), |
| 2697 | html_actor_icon(user, old_actor, NULL, NULL, NULL, 0, 0))); | 2702 | html_actor_icon(user, old_actor, NULL, NULL, NULL, 0, 0, proxy_media))); |
| 2698 | } | 2703 | } |
| 2699 | } | 2704 | } |
| 2700 | } | 2705 | } |
| @@ -3196,6 +3201,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3196 | xs *url = xs_replace(p_path, "proxy/", "https:/" "/"); | 3201 | xs *url = xs_replace(p_path, "proxy/", "https:/" "/"); |
| 3197 | xs *hdrs = xs_dict_new(); | 3202 | xs *hdrs = xs_dict_new(); |
| 3198 | 3203 | ||
| 3204 | hdrs = xs_dict_append(hdrs, "user-agent", USER_AGENT); | ||
| 3205 | |||
| 3199 | xs *rsp = xs_http_request("GET", url, hdrs, | 3206 | xs *rsp = xs_http_request("GET", url, hdrs, |
| 3200 | NULL, 0, &status, body, b_size, 0); | 3207 | NULL, 0, &status, body, b_size, 0); |
| 3201 | 3208 | ||