commit c06b74c

default  ·  2023-12-11 09:12:57 +0000 UTC
parent 8d0a69c
Revert "Reverted actor_request() without user."

This reverts commit 8d0a69cd759813b1304605d1676fbca063f0ccdc.
5 files changed,  +16, -16
M http.c
M main.c
M snac.h
+8, -8
 1@@ -115,7 +115,7 @@ int activitypub_request(snac *user, const char *url, xs_dict **data)
 2 }
 3 
 4 
 5-int actor_request(snac *user, const char *actor, xs_dict **data)
 6+int actor_request(const char *actor, xs_dict **data)
 7 /* request an actor */
 8 {
 9     int status, status2;
10@@ -129,7 +129,7 @@ int actor_request(snac *user, const char *actor, xs_dict **data)
11 
12     if (status != 200) {
13         /* actor data non-existent or stale: get from the net */
14-        status2 = activitypub_request(user, actor, &payload);
15+        status2 = activitypub_request(NULL, actor, &payload);
16 
17         if (valid_status(status2)) {
18             /* renew data */
19@@ -207,7 +207,7 @@ int timeline_request(snac *snac, char **id, xs_str **wrk, int level)
20 
21                     /* request (and drop) the actor for this entry */
22                     if (!xs_is_null(actor))
23-                        actor_request(snac, actor, NULL);
24+                        actor_request(actor, NULL);
25 
26                     /* does it have an ancestor? */
27                     char *in_reply_to = xs_dict_get(object, "inReplyTo");
28@@ -331,7 +331,7 @@ xs_str *get_actor_inbox(const char *actor)
29     xs *data = NULL;
30     char *v = NULL;
31 
32-    if (valid_status(actor_request(NULL, actor, &data))) {
33+    if (valid_status(actor_request(actor, &data))) {
34         /* try first endpoints/sharedInbox */
35         if ((v = xs_dict_get(data, "endpoints")))
36             v = xs_dict_get(v, "sharedInbox");
37@@ -1095,7 +1095,7 @@ xs_dict *msg_follow(snac *snac, const char *q)
38     }
39 
40     /* request the actor */
41-    status = actor_request(snac, actor, &actor_o);
42+    status = actor_request(actor, &actor_o);
43 
44     if (valid_status(status)) {
45         /* check if the actor is an alias */
46@@ -1501,7 +1501,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
47         utype = "(null)";
48 
49     /* bring the actor */
50-    a_status = actor_request(snac, actor, &actor_o);
51+    a_status = actor_request(actor, &actor_o);
52 
53     /* do not retry permanent failures */
54     if (a_status == 404 || a_status == 410 || a_status < 0) {
55@@ -1520,7 +1520,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
56     /* check the signature */
57     xs *sig_err = NULL;
58 
59-    if (!check_signature(snac, req, &sig_err)) {
60+    if (!check_signature(req, &sig_err)) {
61         srv_log(xs_fmt("bad signature %s (%s)", actor, sig_err));
62 
63         srv_archive_error("check_signature", sig_err, req, msg);
64@@ -1683,7 +1683,7 @@ int process_input_message(snac *snac, xs_dict *msg, xs_dict *req)
65                     /* bring the actor */
66                     xs *who_o = NULL;
67 
68-                    if (valid_status(actor_request(snac, who, &who_o))) {
69+                    if (valid_status(actor_request(who, &who_o))) {
70                         timeline_admire(snac, object, actor, 0);
71                         snac_log(snac, xs_fmt("new 'Announce' %s %s", actor, object));
72                         do_notify = 1;
M http.c
+2, -2
 1@@ -120,7 +120,7 @@ xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
 2 }
 3 
 4 
 5-int check_signature(snac *user, xs_dict *req, xs_str **err)
 6+int check_signature(xs_dict *req, xs_str **err)
 7 /* check the signature */
 8 {
 9     char *sig_hdr = xs_dict_get(req, "signature");
10@@ -173,7 +173,7 @@ int check_signature(snac *user, xs_dict *req, xs_str **err)
11 
12     xs *actor = NULL;
13 
14-    if (!valid_status(actor_request(user, keyId, &actor))) {
15+    if (!valid_status(actor_request(keyId, &actor))) {
16         *err = xs_fmt("unknown actor %s", keyId);
17         return 0;
18     }
M main.c
+3, -3
 1@@ -184,7 +184,7 @@ int main(int argc, char *argv[])
 2         xs *actor = NULL;
 3         int status;
 4 
 5-        status = actor_request(NULL, user, &actor);
 6+        status = actor_request(user, &actor);
 7 
 8         printf("status: %d\n", status);
 9         if (valid_status(status)) {
10@@ -334,7 +334,7 @@ int main(int argc, char *argv[])
11     if (strcmp(cmd, "ping") == 0) { /** **/
12         xs *actor_o = NULL;
13 
14-        if (valid_status(actor_request(&snac, url, &actor_o))) {
15+        if (valid_status(actor_request(url, &actor_o))) {
16             xs *msg = msg_ping(&snac, url);
17 
18             enqueue_output_by_actor(&snac, msg, url, 0);
19@@ -409,7 +409,7 @@ int main(int argc, char *argv[])
20         int status;
21         xs *data = NULL;
22 
23-        status = actor_request(&snac, url, &data);
24+        status = actor_request(url, &data);
25 
26         printf("status: %d\n", status);
27 
+1, -1
1@@ -1944,7 +1944,7 @@ int mastoapi_get_handler(const xs_dict *req, const char *q_path,
2                     if (valid_status(webfinger_request(q, &actor, &user))) {
3                         xs *actor_o = NULL;
4 
5-                        if (valid_status(actor_request(&snac1, actor, &actor_o))) {
6+                        if (valid_status(actor_request(actor, &actor_o))) {
7                             xs *acct = mastoapi_account(actor_o);
8 
9                             acl = xs_list_append(acl, acct);
M snac.h
+2, -2
 1@@ -212,7 +212,7 @@ xs_dict *http_signed_request(snac *snac, const char *method, const char *url,
 2                             const char *body, int b_size,
 3                             int *status, xs_str **payload, int *p_size,
 4                             int timeout);
 5-int check_signature(snac *user, xs_dict *req, xs_str **err);
 6+int check_signature(xs_dict *req, xs_str **err);
 7 
 8 void httpd(void);
 9 
10@@ -242,7 +242,7 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
11                       const xs_list *opts, int multiple, int end_secs);
12 
13 int activitypub_request(snac *snac, const char *url, xs_dict **data);
14-int actor_request(snac *user, const char *actor, xs_dict **data);
15+int actor_request(const char *actor, xs_dict **data);
16 void timeline_request_replies(snac *user, const char *id);
17 int send_to_inbox_raw(const char *keyid, const char *seckey,
18                   const xs_str *inbox, const xs_dict *msg,