summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2023-05-07 07:34:35 +0000
committergrunfink <grunfink@noreply.codeberg.org>2023-05-07 07:34:35 +0000
commit14950d6954ea689c1225df8963372d9b5a2ba4ec (patch)
treec2484af8006961d95dcf39cf16c3749100a713c9
parent6a1cc55676eaf18ecadb42b86474aaef73cf9805 (diff)
parente65760a349112abce39404ca50f6bc2f1301bed9 (diff)
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.c2
-rw-r--r--webfinger.c3
-rw-r--r--xs_curl.h5
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)
if (xs_startswith(url_or_uid, "https:/"))
actor = xs_dup(url_or_uid);
else
- if (!valid_status(webfinger_request(url_or_uid, &actor, NULL))) {
+ if (!valid_status(webfinger_request(url_or_uid, &actor, NULL)) || actor == NULL) {
snac_log(snac, xs_fmt("cannot resolve user %s to follow", url_or_uid));
return NULL;
}
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)
if (xs_type(v) == XSTYPE_DICT) {
char *type = xs_dict_get(v, "type");
- if (type && strcmp(type, "application/activity+json") == 0) {
+ if (type && (strcmp(type, "application/activity+json") == 0 ||
+ strcmp(type, "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") == 0)) {
*actor = xs_dup(xs_dict_get(v, "href"));
break;
}
diff --git a/xs_curl.h b/xs_curl.h
index ca90f92..d19d6e5 100644
--- a/xs_curl.h
+++ b/xs_curl.h
@@ -127,14 +127,15 @@ xs_dict *xs_http_request(const char *method, const char *url,
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback);
if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) {
- curl_easy_setopt(curl, method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD, 1L);
+ CURLoption curl_method = method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD;
+ curl_easy_setopt(curl, curl_method, 1L);
if (body != NULL) {
if (b_size <= 0)
b_size = xs_size(body);
/* add the content-length header */
- curl_easy_setopt(curl, CURLOPT_INFILESIZE, b_size);
+ curl_easy_setopt(curl, curl_method == CURLOPT_POST ? CURLOPT_POSTFIELDSIZE : CURLOPT_INFILESIZE, b_size);
pd.data = (char *)body;
pd.size = b_size;