diff options
| author | 2023-05-07 07:34:35 +0000 | |
|---|---|---|
| committer | 2023-05-07 07:34:35 +0000 | |
| commit | 14950d6954ea689c1225df8963372d9b5a2ba4ec (patch) | |
| tree | c2484af8006961d95dcf39cf16c3749100a713c9 | |
| parent | Version 2.30 RELEASED. (diff) | |
| parent | Merge pull request 'master' (#1) from grunfink/snac2:master into master (diff) | |
| download | snac2-14950d6954ea689c1225df8963372d9b5a2ba4ec.tar.gz snac2-14950d6954ea689c1225df8963372d9b5a2ba4ec.tar.xz snac2-14950d6954ea689c1225df8963372d9b5a2ba4ec.zip | |
Merge pull request 'Fixed webfinger and curl issues' (#31) from poesty/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/31
| -rw-r--r-- | activitypub.c | 2 | ||||
| -rw-r--r-- | webfinger.c | 3 | ||||
| -rw-r--r-- | xs_curl.h | 5 |
3 files changed, 6 insertions, 4 deletions
diff --git a/activitypub.c b/activitypub.c index 6127dab..9069d03 100644 --- a/activitypub.c +++ b/activitypub.c | |||
| @@ -673,7 +673,7 @@ xs_dict *msg_follow(snac *snac, const char *q) | |||
| 673 | if (xs_startswith(url_or_uid, "https:/")) | 673 | if (xs_startswith(url_or_uid, "https:/")) |
| 674 | actor = xs_dup(url_or_uid); | 674 | actor = xs_dup(url_or_uid); |
| 675 | else | 675 | else |
| 676 | if (!valid_status(webfinger_request(url_or_uid, &actor, NULL))) { | 676 | if (!valid_status(webfinger_request(url_or_uid, &actor, NULL)) || actor == NULL) { |
| 677 | snac_log(snac, xs_fmt("cannot resolve user %s to follow", url_or_uid)); | 677 | snac_log(snac, xs_fmt("cannot resolve user %s to follow", url_or_uid)); |
| 678 | return NULL; | 678 | return NULL; |
| 679 | } | 679 | } |
diff --git a/webfinger.c b/webfinger.c index 765c469..c7b73f7 100644 --- a/webfinger.c +++ b/webfinger.c | |||
| @@ -85,7 +85,8 @@ int webfinger_request(const char *qs, char **actor, char **user) | |||
| 85 | if (xs_type(v) == XSTYPE_DICT) { | 85 | if (xs_type(v) == XSTYPE_DICT) { |
| 86 | char *type = xs_dict_get(v, "type"); | 86 | char *type = xs_dict_get(v, "type"); |
| 87 | 87 | ||
| 88 | if (type && strcmp(type, "application/activity+json") == 0) { | 88 | if (type && (strcmp(type, "application/activity+json") == 0 || |
| 89 | strcmp(type, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") == 0)) { | ||
| 89 | *actor = xs_dup(xs_dict_get(v, "href")); | 90 | *actor = xs_dup(xs_dict_get(v, "href")); |
| 90 | break; | 91 | break; |
| 91 | } | 92 | } |
| @@ -127,14 +127,15 @@ xs_dict *xs_http_request(const char *method, const char *url, | |||
| 127 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback); | 127 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback); |
| 128 | 128 | ||
| 129 | if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) { | 129 | if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) { |
| 130 | curl_easy_setopt(curl, method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD, 1L); | 130 | CURLoption curl_method = method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD; |
| 131 | curl_easy_setopt(curl, curl_method, 1L); | ||
| 131 | 132 | ||
| 132 | if (body != NULL) { | 133 | if (body != NULL) { |
| 133 | if (b_size <= 0) | 134 | if (b_size <= 0) |
| 134 | b_size = xs_size(body); | 135 | b_size = xs_size(body); |
| 135 | 136 | ||
| 136 | /* add the content-length header */ | 137 | /* add the content-length header */ |
| 137 | curl_easy_setopt(curl, CURLOPT_INFILESIZE, b_size); | 138 | curl_easy_setopt(curl, curl_method == CURLOPT_POST ? CURLOPT_POSTFIELDSIZE : CURLOPT_INFILESIZE, b_size); |
| 138 | 139 | ||
| 139 | pd.data = (char *)body; | 140 | pd.data = (char *)body; |
| 140 | pd.size = b_size; | 141 | pd.size = b_size; |