From 450c0e7aad09491b2abd177e695d3080c352af5e Mon Sep 17 00:00:00 2001 From: default Date: Sat, 1 Oct 2022 19:10:12 +0200 Subject: [PATCH] More snac-origin work. --- html.c | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/html.c b/html.c index 0848b82..d6df61d 100644 --- a/html.c +++ b/html.c @@ -525,16 +525,15 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i } if (level == 0) { - char *referrer; - char *parent; + char *p; s = xs_str_cat(s, "
\n"); /* print the origin of the post, if any */ - if (!xs_is_null(referrer = xs_dict_get(meta, "referrer"))) { + if (!xs_is_null(p = xs_dict_get(meta, "referrer"))) { xs *actor_r = NULL; - if (valid_status(actor_get(snac, referrer, &actor_r))) { + if (valid_status(actor_get(snac, p, &actor_r))) { char *name; if ((name = xs_dict_get(actor_r, "name")) == NULL) @@ -552,12 +551,36 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i } } else - if (!xs_is_null((parent = xs_dict_get(meta, "parent")))) { + if (!xs_is_null((p = xs_dict_get(meta, "parent"))) && *p) { /* this may happen if any of the autor or the parent aren't here */ xs *s1 = xs_fmt( "
%s " "ยป
\n", - L("in reply to"), parent + L("in reply to"), p + ); + + s = xs_str_cat(s, s1); + } + else + if (!xs_is_null((p = xs_dict_get(meta, "announced_by"))) && + xs_list_in(p, snac->actor) != -1) { + /* we boosted this */ + xs *s1 = xs_fmt( + "
" + "%s %s
", + snac->actor, xs_dict_get(snac->config, "name"), L("liked") + ); + + s = xs_str_cat(s, s1); + } + else + if (!xs_is_null((p = xs_dict_get(meta, "liked_by"))) && + xs_list_in(p, snac->actor) != -1) { + /* we liked this */ + xs *s1 = xs_fmt( + "
" + "%s %s
", + snac->actor, xs_dict_get(snac->config, "name"), L("liked") ); s = xs_str_cat(s, s1);