commit 1a94d7c
default
·
2023-07-10 05:19:51 +0000 UTC
parent 92b3b71
Revert "New server config array "webfinger_domains"." This reverts commit f2e0b7747813445138d5b65363fd3a74c7a2454a.
2 files changed,
+12,
-21
M
snac.h
M
snac.h
+1,
-1
1@@ -203,7 +203,7 @@ void httpd(void);
2
3 int webfinger_request_signed(snac *snac, const char *qs, char **actor, char **user);
4 int webfinger_request(const char *qs, char **actor, char **user);
5-int webfinger_get_handler(const xs_dict *req, const char *q_path,
6+int webfinger_get_handler(xs_dict *req, char *q_path,
7 char **body, int *b_size, char **ctype);
8
9 const char *default_avatar_base64(void);
+11,
-20
1@@ -106,8 +106,8 @@ int webfinger_request(const char *qs, char **actor, char **user)
2 }
3
4
5-int webfinger_get_handler(const xs_dict *req, const char *q_path,
6- char **body, int *b_size, char **ctype)
7+int webfinger_get_handler(d_char *req, char *q_path,
8+ char **body, int *b_size, char **ctype)
9 /* serves webfinger queries */
10 {
11 int status;
12@@ -117,8 +117,8 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
13 if (strcmp(q_path, "/.well-known/webfinger") != 0)
14 return 0;
15
16- const xs_dict *q_vars = xs_dict_get(req, "q_vars");
17- const char *resource = xs_dict_get(q_vars, "resource");
18+ char *q_vars = xs_dict_get(req, "q_vars");
19+ char *resource = xs_dict_get(q_vars, "resource");
20
21 if (resource == NULL)
22 return 400;
23@@ -129,8 +129,7 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
24 if (xs_startswith(resource, "https:/" "/")) {
25 /* actor search: find a user with this actor */
26 xs *list = user_list();
27- xs_list *p;
28- char *uid;
29+ char *p, *uid;
30
31 p = list;
32 while (xs_list_iter(&p, &uid)) {
33@@ -157,22 +156,11 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
34 l = xs_split_n(an, "@", 1);
35
36 if (xs_list_len(l) == 2) {
37- const char *uid = xs_list_get(l, 0);
38- const char *host = xs_list_get(l, 1);
39+ char *uid = xs_list_get(l, 0);
40+ char *host = xs_list_get(l, 1);
41
42 if (strcmp(host, xs_dict_get(srv_config, "host")) == 0)
43 found = user_open(&snac, uid);
44-
45- if (!found) {
46- /* get the list of possible domain aliases */
47- xs_list *domains = xs_dict_get(srv_config, "webfinger_domains");
48- char *v;
49-
50- while (!found && xs_list_iter(&domains, &v)) {
51- if (strcmp(host, v) == 0)
52- found = user_open(&snac, uid);
53- }
54- }
55 }
56 }
57
58@@ -182,6 +170,7 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
59 xs *aaj = xs_dict_new();
60 xs *links = xs_list_new();
61 xs *obj = xs_dict_new();
62+ d_char *j;
63
64 acct = xs_fmt("acct:%s@%s",
65 xs_dict_get(snac.config, "uid"), xs_dict_get(srv_config, "host"));
66@@ -195,10 +184,12 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
67 obj = xs_dict_append(obj, "subject", acct);
68 obj = xs_dict_append(obj, "links", links);
69
70+ j = xs_json_dumps_pp(obj, 4);
71+
72 user_free(&snac);
73
74 status = 200;
75- *body = xs_json_dumps_pp(obj, 4);
76+ *body = j;
77 *ctype = "application/json";
78 }
79 else