commit 1d82d13

default  ·  2023-02-24 08:00:03 +0000 UTC
parent 1630519
In activitypub_request(), retry failed signed requests as non-signed.
1 files changed,  +13, -3
+13, -3
 1@@ -55,13 +55,23 @@ int activitypub_request(snac *snac, char *url, d_char **data)
 2     int p_size;
 3     char *ctype;
 4 
 5-    /* check if it's an url for this same site */
 6-    /* ... */
 7-
 8     /* get from the net */
 9     response = http_signed_request(snac, "GET", url,
10         NULL, NULL, 0, &status, &payload, &p_size, 0);
11 
12+    if (status == 0 || (status >= 500 && status <= 599)) {
13+        /* I found an instance running Misskey that returned
14+           500 on signed messages but returned the object
15+           perfectly without signing (?), so why not try */
16+        xs_free(response);
17+
18+        xs *hdrs = xs_dict_new();
19+        hdrs = xs_dict_append(hdrs, "accept", "application/activity+json");
20+
21+        response = xs_http_request("GET", url, hdrs,
22+            NULL, 0, &status, &payload, &p_size, 0);
23+    }
24+
25     if (valid_status(status)) {
26         /* ensure it's ActivityPub data */
27         ctype = xs_dict_get(response, "content-type");