From 928eeecba249456c94a44b157bdfb9f7686ce5ca Mon Sep 17 00:00:00 2001 From: default Date: Wed, 24 Jan 2024 09:28:11 +0100 Subject: [PATCH] Show a handshake emoji for mutual relations (following + follower). --- html.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/html.c b/html.c index e02c62b..5140a11 100644 --- a/html.c +++ b/html.c @@ -108,6 +108,8 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, xs *avatar = NULL; char *v; + int fwing = 0; + int fwer = 0; xs *name = actor_name(actor); @@ -124,9 +126,12 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, xs *href = NULL; if (user) { + fwer = follower_check(user, actor_id); + fwing = following_check(user, actor_id); + /* if this actor is a follower or being followed, create an anchored link to the people page instead of the actor url */ - if (follower_check(user, actor_id) || following_check(user, actor_id)) { + if (fwer || fwing) { xs *md5 = xs_md5_hex(actor_id, strlen(actor_id)); href = xs_fmt("%s/people#%s", user->actor, md5); } @@ -146,6 +151,21 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, xs_html_attr("class", "p-author h-card snac-author"), xs_html_raw(name))); /* name is already html-escaped */ + if (strcmp(xs_dict_get(actor, "type"), "Service") == 0) { + xs_html_add(actor_icon, + xs_html_text(" "), + xs_html_tag("span", + xs_html_attr("title", "bot"), + xs_html_raw("🤖"))); + } + + if (fwing && fwer) { + xs_html_add(actor_icon, + xs_html_text(" "), + xs_html_tag("span", + xs_html_attr("title", "mutual relation"), + xs_html_raw("🤝"))); + } if (!xs_is_null(url)) { xs *md5 = xs_md5_hex(url, strlen(url)); @@ -166,14 +186,6 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, xs_html_raw("🔒"))); } - if (strcmp(xs_dict_get(actor, "type"), "Service") == 0) { - xs_html_add(actor_icon, - xs_html_text(" "), - xs_html_tag("span", - xs_html_attr("title", "bot"), - xs_html_raw("🤖"))); - } - if (xs_is_null(date)) { xs_html_add(actor_icon, xs_html_raw(" "));