commit d5dbdad
grunfink
·
2025-06-07 05:53:00 +0000 UTC
parent c9c1323
If a metadata value is an account handle, it's also verified using webfinger.
M
html.c
+10,
-3
1@@ -1077,10 +1077,17 @@ static xs_html *html_user_body(snac *user, int read_only)
2 while (xs_dict_next(metadata, &k, &v, &c)) {
3 xs_html *value;
4
5- if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/")) {
6+ if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/") || *v == '@') {
7 /* is this link validated? */
8 xs *verified_link = NULL;
9 const xs_number *val_time = xs_dict_get(val_links, v);
10+ const char *url = NULL;
11+
12+ if (xs_is_string(val_time)) {
13+ /* resolve again, as it may be an account handle */
14+ url = val_time;
15+ val_time = xs_dict_get(val_links, val_time);
16+ }
17
18 if (xs_type(val_time) == XSTYPE_NUMBER) {
19 time_t t = xs_number_get(val_time);
20@@ -1098,13 +1105,13 @@ static xs_html *html_user_body(snac *user, int read_only)
21 xs_html_tag("a",
22 xs_html_attr("rel", "me"),
23 xs_html_attr("target", "_blank"),
24- xs_html_attr("href", v),
25+ xs_html_attr("href", url ? url : v),
26 xs_html_text(v)));
27 }
28 else {
29 value = xs_html_tag("a",
30 xs_html_attr("rel", "me"),
31- xs_html_attr("href", v),
32+ xs_html_attr("href", url ? url : v),
33 xs_html_text(v));
34 }
35 }
M
utils.c
+16,
-0
1@@ -488,6 +488,18 @@ void verify_links(snac *user)
2
3 int c = 0;
4 while (metadata && xs_dict_next(metadata, &k, &v, &c)) {
5+ xs *wfinger = NULL;
6+ const char *ov = NULL;
7+
8+ /* is it an account handle? */
9+ if (*v == '@' && strchr(v + 1, '@')) {
10+ /* resolve it via webfinger */
11+ if (valid_status(webfinger_request(v, &wfinger, NULL)) && xs_is_string(wfinger)) {
12+ ov = v;
13+ v = wfinger;
14+ }
15+ }
16+
17 /* not an https link? skip */
18 if (!xs_startswith(v, "https:/" "/"))
19 continue;
20@@ -563,6 +575,10 @@ void verify_links(snac *user)
21
22 user->links = xs_dict_set(user->links, v, verified_time);
23
24+ /* also add the original value if it was 'resolved' */
25+ if (xs_is_string(ov))
26+ user->links = xs_dict_set(user->links, ov, v);
27+
28 vfied = 1;
29 }
30 else