commit 4971e54

default  ·  2024-11-12 05:11:10 +0000 UTC
parent bbe061c
mastoapi: added some proxy code.
2 files changed,  +7, -5
M data.c
M data.c
+2, -2
 1@@ -3682,10 +3682,10 @@ xs_str *make_url(const char *href, const char *proxy, int by_token)
 2             xs *tks = xs_fmt("%s:%s", xs_dict_get(srv_config, "proxy_token_seed"), proxy);
 3             xs *tk = xs_md5_hex(tks, strlen(tks));
 4 
 5-            p = xs_fmt("y/%s/", tk);
 6+            p = xs_fmt("%s/y/%s/", proxy, tk);
 7         }
 8         else
 9-            p = xs_str_cat(xs_dup(proxy), "/x/");
10+            p = xs_fmt("%s/x/", proxy);
11 
12         url = xs_replace(href, "https:/" "/", p);
13     }
+5, -3
 1@@ -866,11 +866,12 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
 2 
 3         while (xs_list_iter(&p, &v)) {
 4             const char *type = xs_dict_get(v, "type");
 5-            const char *href = xs_dict_get(v, "href");
 6+            const char *o_href = xs_dict_get(v, "href");
 7             const char *name = xs_dict_get(v, "name");
 8 
 9             if (xs_match(type, "image/*|video/*|Image|Video")) { /* */
10                 xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
11+                xs *href = make_url(o_href, snac->actor, 1);
12 
13                 xs *d = xs_dict_new();
14 
15@@ -957,9 +958,10 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
16                 const xs_dict *icon = xs_dict_get(v, "icon");
17 
18                 if (!xs_is_null(name) && !xs_is_null(icon)) {
19-                    const char *url = xs_dict_get(icon, "url");
20+                    const char *o_url = xs_dict_get(icon, "url");
21 
22-                    if (!xs_is_null(url)) {
23+                    if (!xs_is_null(o_url)) {
24+                        xs *url = make_url(o_url, snac->actor, 1);
25                         xs *nm = xs_strip_chars_i(xs_dup(name), ":");
26 
27                         d1 = xs_dict_append(d1, "shortcode", nm);