summaryrefslogtreecommitdiff
path: root/activitypub.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-12-10 10:27:45 +0100
committerdefault <nobody@localhost>2023-12-10 10:27:45 +0100
commit90179f84596e7885fade4552cbeac0beb5c53303 (patch)
treeecae50149124ee87fbe91fc6131176bcc28baeb0 /activitypub.c
parent1c194042580249fae3b54ea00517c399d8bc7b77 (diff)
activitypub_request() may have a NULL user.
In the NULL user case, only non-signed requests will be done, but it's probably enough for actor requests in most cases.
Diffstat (limited to 'activitypub.c')
-rw-r--r--activitypub.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/activitypub.c b/activitypub.c
index 0764fa2..a852256 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -60,18 +60,22 @@ const char *default_avatar_base64(void)
}
-int activitypub_request(snac *snac, const char *url, xs_dict **data)
+int activitypub_request(snac *user, const char *url, xs_dict **data)
/* request an object */
{
- int status;
+ int status = 0;
xs *response = NULL;
xs *payload = NULL;
int p_size;
char *ctype;
- /* get from the net */
- response = http_signed_request(snac, "GET", url,
- NULL, NULL, 0, &status, &payload, &p_size, 0);
+ *data = NULL;
+
+ if (user != NULL) {
+ /* get from the net */
+ response = http_signed_request(user, "GET", url,
+ NULL, NULL, 0, &status, &payload, &p_size, 0);
+ }
if (status == 0 || (status >= 500 && status <= 599)) {
/* I found an instance running Misskey that returned
@@ -107,14 +111,11 @@ int activitypub_request(snac *snac, const char *url, xs_dict **data)
status = 500;
}
- if (!valid_status(status))
- *data = NULL;
-
return status;
}
-int actor_request(snac *snac, const char *actor, xs_dict **data)
+int actor_request(snac *user, const char *actor, xs_dict **data)
/* request an actor */
{
int status, status2;
@@ -128,7 +129,7 @@ int actor_request(snac *snac, const char *actor, xs_dict **data)
if (status != 200) {
/* actor data non-existent or stale: get from the net */
- status2 = activitypub_request(snac, actor, &payload);
+ status2 = activitypub_request(user, actor, &payload);
if (valid_status(status2)) {
/* renew data */