diff options
| author | 2025-06-07 07:53:00 +0200 | |
|---|---|---|
| committer | 2025-06-07 07:53:00 +0200 | |
| commit | d5dbdad930d44d9345bec03d0f2ce4076cb028a8 (patch) | |
| tree | 15ec3540abf601860aeebb608d15af2ac49a3ac1 | |
| parent | Always show the 'pending follow confirmations' if there are any. (diff) | |
| download | penes-snac2-d5dbdad930d44d9345bec03d0f2ce4076cb028a8.tar.gz penes-snac2-d5dbdad930d44d9345bec03d0f2ce4076cb028a8.tar.xz penes-snac2-d5dbdad930d44d9345bec03d0f2ce4076cb028a8.zip | |
If a metadata value is an account handle, it's also verified using webfinger.
| -rw-r--r-- | html.c | 13 | ||||
| -rw-r--r-- | utils.c | 16 |
2 files changed, 26 insertions, 3 deletions
| @@ -1077,10 +1077,17 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 1077 | while (xs_dict_next(metadata, &k, &v, &c)) { | 1077 | while (xs_dict_next(metadata, &k, &v, &c)) { |
| 1078 | xs_html *value; | 1078 | xs_html *value; |
| 1079 | 1079 | ||
| 1080 | if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/")) { | 1080 | if (xs_startswith(v, "https:/") || xs_startswith(v, "http:/") || *v == '@') { |
| 1081 | /* is this link validated? */ | 1081 | /* is this link validated? */ |
| 1082 | xs *verified_link = NULL; | 1082 | xs *verified_link = NULL; |
| 1083 | const xs_number *val_time = xs_dict_get(val_links, v); | 1083 | const xs_number *val_time = xs_dict_get(val_links, v); |
| 1084 | const char *url = NULL; | ||
| 1085 | |||
| 1086 | if (xs_is_string(val_time)) { | ||
| 1087 | /* resolve again, as it may be an account handle */ | ||
| 1088 | url = val_time; | ||
| 1089 | val_time = xs_dict_get(val_links, val_time); | ||
| 1090 | } | ||
| 1084 | 1091 | ||
| 1085 | if (xs_type(val_time) == XSTYPE_NUMBER) { | 1092 | if (xs_type(val_time) == XSTYPE_NUMBER) { |
| 1086 | time_t t = xs_number_get(val_time); | 1093 | time_t t = xs_number_get(val_time); |
| @@ -1098,13 +1105,13 @@ static xs_html *html_user_body(snac *user, int read_only) | |||
| 1098 | xs_html_tag("a", | 1105 | xs_html_tag("a", |
| 1099 | xs_html_attr("rel", "me"), | 1106 | xs_html_attr("rel", "me"), |
| 1100 | xs_html_attr("target", "_blank"), | 1107 | xs_html_attr("target", "_blank"), |
| 1101 | xs_html_attr("href", v), | 1108 | xs_html_attr("href", url ? url : v), |
| 1102 | xs_html_text(v))); | 1109 | xs_html_text(v))); |
| 1103 | } | 1110 | } |
| 1104 | else { | 1111 | else { |
| 1105 | value = xs_html_tag("a", | 1112 | value = xs_html_tag("a", |
| 1106 | xs_html_attr("rel", "me"), | 1113 | xs_html_attr("rel", "me"), |
| 1107 | xs_html_attr("href", v), | 1114 | xs_html_attr("href", url ? url : v), |
| 1108 | xs_html_text(v)); | 1115 | xs_html_text(v)); |
| 1109 | } | 1116 | } |
| 1110 | } | 1117 | } |
| @@ -488,6 +488,18 @@ void verify_links(snac *user) | |||
| 488 | 488 | ||
| 489 | int c = 0; | 489 | int c = 0; |
| 490 | while (metadata && xs_dict_next(metadata, &k, &v, &c)) { | 490 | while (metadata && xs_dict_next(metadata, &k, &v, &c)) { |
| 491 | xs *wfinger = NULL; | ||
| 492 | const char *ov = NULL; | ||
| 493 | |||
| 494 | /* is it an account handle? */ | ||
| 495 | if (*v == '@' && strchr(v + 1, '@')) { | ||
| 496 | /* resolve it via webfinger */ | ||
| 497 | if (valid_status(webfinger_request(v, &wfinger, NULL)) && xs_is_string(wfinger)) { | ||
| 498 | ov = v; | ||
| 499 | v = wfinger; | ||
| 500 | } | ||
| 501 | } | ||
| 502 | |||
| 491 | /* not an https link? skip */ | 503 | /* not an https link? skip */ |
| 492 | if (!xs_startswith(v, "https:/" "/")) | 504 | if (!xs_startswith(v, "https:/" "/")) |
| 493 | continue; | 505 | continue; |
| @@ -563,6 +575,10 @@ void verify_links(snac *user) | |||
| 563 | 575 | ||
| 564 | user->links = xs_dict_set(user->links, v, verified_time); | 576 | user->links = xs_dict_set(user->links, v, verified_time); |
| 565 | 577 | ||
| 578 | /* also add the original value if it was 'resolved' */ | ||
| 579 | if (xs_is_string(ov)) | ||
| 580 | user->links = xs_dict_set(user->links, ov, v); | ||
| 581 | |||
| 566 | vfied = 1; | 582 | vfied = 1; |
| 567 | } | 583 | } |
| 568 | else | 584 | else |