mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-14 17:45:04 +00:00
mastoapi: added some proxy code.
This commit is contained in:
parent
bbe061ca19
commit
4971e54e56
2 changed files with 7 additions and 5 deletions
4
data.c
4
data.c
|
@ -3682,10 +3682,10 @@ xs_str *make_url(const char *href, const char *proxy, int by_token)
|
|||
xs *tks = xs_fmt("%s:%s", xs_dict_get(srv_config, "proxy_token_seed"), proxy);
|
||||
xs *tk = xs_md5_hex(tks, strlen(tks));
|
||||
|
||||
p = xs_fmt("y/%s/", tk);
|
||||
p = xs_fmt("%s/y/%s/", proxy, tk);
|
||||
}
|
||||
else
|
||||
p = xs_str_cat(xs_dup(proxy), "/x/");
|
||||
p = xs_fmt("%s/x/", proxy);
|
||||
|
||||
url = xs_replace(href, "https:/" "/", p);
|
||||
}
|
||||
|
|
|
@ -866,11 +866,12 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
|
|||
|
||||
while (xs_list_iter(&p, &v)) {
|
||||
const char *type = xs_dict_get(v, "type");
|
||||
const char *href = xs_dict_get(v, "href");
|
||||
const char *o_href = xs_dict_get(v, "href");
|
||||
const char *name = xs_dict_get(v, "name");
|
||||
|
||||
if (xs_match(type, "image/*|video/*|Image|Video")) { /* */
|
||||
xs *matteid = xs_fmt("%s_%d", id, xs_list_len(matt));
|
||||
xs *href = make_url(o_href, snac->actor, 1);
|
||||
|
||||
xs *d = xs_dict_new();
|
||||
|
||||
|
@ -957,9 +958,10 @@ xs_dict *mastoapi_status(snac *snac, const xs_dict *msg)
|
|||
const xs_dict *icon = xs_dict_get(v, "icon");
|
||||
|
||||
if (!xs_is_null(name) && !xs_is_null(icon)) {
|
||||
const char *url = xs_dict_get(icon, "url");
|
||||
const char *o_url = xs_dict_get(icon, "url");
|
||||
|
||||
if (!xs_is_null(url)) {
|
||||
if (!xs_is_null(o_url)) {
|
||||
xs *url = make_url(o_url, snac->actor, 1);
|
||||
xs *nm = xs_strip_chars_i(xs_dup(name), ":");
|
||||
|
||||
d1 = xs_dict_append(d1, "shortcode", nm);
|
||||
|
|
Loading…
Reference in a new issue