diff --git a/html.c b/html.c index fe14ab3..9b5cbf2 100644 --- a/html.c +++ b/html.c @@ -135,12 +135,37 @@ xs_str *html_actor_icon(xs_str *os, char *actor, } xs *s1 = xs_fmt( - "
\n\n", + "\n\n", date_title, date_label); s = xs_str_cat(s, s1); } + { + char *username, *id; + xs *s1; + + if (xs_is_null(username = xs_dict_get(actor, "preferredUsername")) || *username == '\0') { + /* This should never be reached */ + username = "anonymous"; + } + + if (xs_is_null(id = xs_dict_get(actor, "id")) || *id == '\0') { + /* This should never be reached */ + id = "https://social.example.org/anonymous"; + } + + /* "LIKE AN ANIMAL" */ + xs *domain = xs_split(id, "/"); + xs *user = xs_fmt("@%s@%s", username, xs_list_get(domain, 2)); + + s1 = xs_fmt( + "
%s", + xs_dict_get(actor, "id"), user); + + s = xs_str_cat(s, s1); + } + return xs_str_cat(os, s); }