summaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
Diffstat (limited to 'webfinger.c')
-rw-r--r--webfinger.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/webfinger.c b/webfinger.c
index 46867e9..13a6e6c 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -4,6 +4,7 @@
4#include "xs.h" 4#include "xs.h"
5#include "xs_json.h" 5#include "xs_json.h"
6#include "xs_curl.h" 6#include "xs_curl.h"
7#include "xs_mime.h"
7 8
8#include "snac.h" 9#include "snac.h"
9 10
@@ -128,20 +129,11 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
128 129
129 if (xs_startswith(resource, "https:/" "/")) { 130 if (xs_startswith(resource, "https:/" "/")) {
130 /* actor search: find a user with this actor */ 131 /* actor search: find a user with this actor */
131 xs *list = user_list(); 132 xs *l = xs_split(resource, "/");
132 char *p, *uid; 133 char *uid = xs_list_get(l, -1);
133
134 p = list;
135 while (xs_list_iter(&p, &uid)) {
136 if (user_open(&snac, uid)) {
137 if (strcmp(snac.actor, resource) == 0) {
138 found = 1;
139 break;
140 }
141 134
142 user_free(&snac); 135 if (uid)
143 } 136 found = user_open(&snac, uid);
144 }
145 } 137 }
146 else 138 else
147 if (xs_startswith(resource, "acct:")) { 139 if (xs_startswith(resource, "acct:")) {
@@ -180,6 +172,17 @@ int webfinger_get_handler(xs_dict *req, char *q_path,
180 172
181 links = xs_list_append(links, aaj); 173 links = xs_list_append(links, aaj);
182 174
175 char *avatar = xs_dict_get(snac.config, "avatar");
176 if (!xs_is_null(avatar) && *avatar) {
177 xs *d = xs_dict_new();
178
179 d = xs_dict_append(d, "rel", "http:/" "/webfinger.net/rel/avatar");
180 d = xs_dict_append(d, "type", xs_mime_by_ext(avatar));
181 d = xs_dict_append(d, "href", avatar);
182
183 links = xs_list_append(links, d);
184 }
185
183 obj = xs_dict_append(obj, "subject", acct); 186 obj = xs_dict_append(obj, "subject", acct);
184 obj = xs_dict_append(obj, "links", links); 187 obj = xs_dict_append(obj, "links", links);
185 188