More snac-origin work.

This commit is contained in:
default 2022-10-01 19:10:12 +02:00
parent bd0bc09912
commit 450c0e7aad

35
html.c
View file

@ -525,16 +525,15 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i
} }
if (level == 0) { if (level == 0) {
char *referrer; char *p;
char *parent;
s = xs_str_cat(s, "<div class=\"snac-post\">\n"); s = xs_str_cat(s, "<div class=\"snac-post\">\n");
/* print the origin of the post, if any */ /* 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; xs *actor_r = NULL;
if (valid_status(actor_get(snac, referrer, &actor_r))) { if (valid_status(actor_get(snac, p, &actor_r))) {
char *name; char *name;
if ((name = xs_dict_get(actor_r, "name")) == NULL) 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 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 */ /* this may happen if any of the autor or the parent aren't here */
xs *s1 = xs_fmt( xs *s1 = xs_fmt(
"<div class=\"snac-origin\">%s " "<div class=\"snac-origin\">%s "
"<a href=\"%s\">»</a></div>\n", "<a href=\"%s\">»</a></div>\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(
"<div class=\"snac-origin\">"
"<a href=\"%s\">%s</a> %s</a></div>",
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(
"<div class=\"snac-origin\">"
"<a href=\"%s\">%s</a> %s</a></div>",
snac->actor, xs_dict_get(snac->config, "name"), L("liked")
); );
s = xs_str_cat(s, s1); s = xs_str_cat(s, s1);