aboutsummaryrefslogtreecommitdiff
path: root/webfinger.c
diff options
context:
space:
mode:
authorgrunfink <grunfink@noreply.codeberg.org>2026-03-20 16:19:25 +0100
committergrunfink <grunfink@noreply.codeberg.org>2026-03-20 16:19:25 +0100
commit373acdc002c19afedd7d53c578c87db7769c4b7a (patch)
treea8a9afd3cb6cba17d282daa39737b2357a566804 /webfinger.c
parent81e0683e9ce779d4f9935f8471f514cbc22e0e03 (diff)
parent7da3f49ba23c2469a4830f8963f188744d9eea5e (diff)
Merge pull request 'Implemented tootfinder.ch compatibility mimic Mastodon behaviour' (#587) from rgiuse/snac2:tootfinder-patch into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/587
Diffstat (limited to 'webfinger.c')
-rw-r--r--webfinger.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/webfinger.c b/webfinger.c
index 264cb85..921a848 100644
--- a/webfinger.c
+++ b/webfinger.c
@@ -182,10 +182,14 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
found = user_open(&snac, uid);
}
else
- if (xs_startswith(resource, "acct:")) {
- /* it's an account name */
- xs *an = xs_replace_n(resource, "acct:", "", 1);
- xs *l = NULL;
+ {
+ xs *an = xs_fmt("%s", resource);
+ xs *l = NULL;
+
+ if (xs_startswith(resource, "acct:")) {
+ /* it's an account name */
+ an = xs_replace_n(resource, "acct:", "", 1);
+ }
/* strip a possible leading @ */
if (xs_startswith(an, "@"))
@@ -205,17 +209,18 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
if (found) {
/* build the object */
xs *acct;
- xs *aaj = xs_dict_new();
- xs *prof = xs_dict_new();
- xs *links = xs_list_new();
- xs *obj = xs_dict_new();
+ xs *aaj = xs_dict_new();
+ xs *prof = xs_dict_new();
+ xs *links = xs_list_new();
+ xs *aliases = xs_list_new();
+ xs *obj = xs_dict_new();
acct = xs_fmt("acct:%s@%s",
xs_dict_get(snac.config, "uid"), xs_dict_get(srv_config, "host"));
aaj = xs_dict_append(aaj, "rel", "self");
aaj = xs_dict_append(aaj, "type", "application/activity+json");
- aaj = xs_dict_append(aaj, "href", snac.actor);
+ aaj = xs_dict_append(aaj, "href", snac.actor_alt);
links = xs_list_append(links, aaj);
@@ -242,7 +247,12 @@ int webfinger_get_handler(const xs_dict *req, const char *q_path,
links = xs_list_append(links, d);
}
+ aliases = xs_list_append(aliases, snac.actor);
+ aliases = xs_list_append(aliases, snac.actor_alt);
+
+
obj = xs_dict_append(obj, "subject", acct);
+ obj = xs_dict_append(obj, "aliases", aliases);
obj = xs_dict_append(obj, "links", links);
xs_str *j = xs_json_dumps(obj, 4);