commit 7d3a909
poesty
·
2023-05-07 05:42:47 +0000 UTC
parent fbd30cf
Fixed webfinger and curl issues
3 files changed,
+6,
-4
+1,
-1
1@@ -672,7 +672,7 @@ xs_dict *msg_follow(snac *snac, const char *q)
2 if (xs_startswith(url_or_uid, "https:/"))
3 actor = xs_dup(url_or_uid);
4 else
5- if (!valid_status(webfinger_request(url_or_uid, &actor, NULL))) {
6+ if (!valid_status(webfinger_request(url_or_uid, &actor, NULL)) || actor == NULL) {
7 snac_log(snac, xs_fmt("cannot resolve user %s to follow", url_or_uid));
8 return NULL;
9 }
+2,
-1
1@@ -85,7 +85,8 @@ int webfinger_request(const char *qs, char **actor, char **user)
2 if (xs_type(v) == XSTYPE_DICT) {
3 char *type = xs_dict_get(v, "type");
4
5- if (type && strcmp(type, "application/activity+json") == 0) {
6+ if (type && (strcmp(type, "application/activity+json") == 0 ||
7+ strcmp(type, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") == 0)) {
8 *actor = xs_dup(xs_dict_get(v, "href"));
9 break;
10 }
+3,
-2
1@@ -127,14 +127,15 @@ xs_dict *xs_http_request(const char *method, const char *url,
2 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback);
3
4 if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) {
5- curl_easy_setopt(curl, method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD, 1L);
6+ CURLoption curl_method = method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD;
7+ curl_easy_setopt(curl, curl_method, 1L);
8
9 if (body != NULL) {
10 if (b_size <= 0)
11 b_size = xs_size(body);
12
13 /* add the content-length header */
14- curl_easy_setopt(curl, CURLOPT_INFILESIZE, b_size);
15+ curl_easy_setopt(curl, curl_method == CURLOPT_POST ? CURLOPT_POSTFIELDSIZE : CURLOPT_INFILESIZE, b_size);
16
17 pd.data = (char *)body;
18 pd.size = b_size;