From c00e3afcdc8cf1503439a174621090b133ad329f Mon Sep 17 00:00:00 2001 From: default Date: Fri, 2 Dec 2022 19:14:59 +0100 Subject: Big data storage change. --- html.c | 142 ++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 75 insertions(+), 67 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index 63b54c3..4c1ca79 100644 --- a/html.c +++ b/html.c @@ -386,7 +386,8 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) { char *id = xs_dict_get(msg, "id"); char *actor = xs_dict_get(msg, "attributedTo"); - char *meta = xs_dict_get(msg, "_snac"); + xs *likes = object_likes(id); + xs *boosts = object_announces(id); xs *s = xs_str_new(NULL); xs *md5 = xs_md5_hex(id, strlen(id)); @@ -407,20 +408,14 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) s = xs_str_cat(s, s1); } - { - char *l; - - l = xs_dict_get(meta, "liked_by"); - if (xs_list_in(l, snac->actor) == -1) { - /* not already liked; add button */ - s = html_button(s, "like", L("Like")); - } + if (xs_list_in(likes, snac->md5) == -1) { + /* not already liked; add button */ + s = html_button(s, "like", L("Like")); + } - l = xs_dict_get(meta, "announced_by"); - if (strcmp(actor, snac->actor) == 0 || xs_list_in(l, snac->actor) == -1) { - /* not already boosted or us; add button */ - s = html_button(s, "boost", L("Boost")); - } + if (strcmp(actor, snac->actor) == 0 || xs_list_in(boosts, snac->md5) == -1) { + /* not already boosted or us; add button */ + s = html_button(s, "boost", L("Boost")); } if (strcmp(actor, snac->actor) != 0) { @@ -477,23 +472,20 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) } -d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, int level, int *num) +d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int *num) { char *id = xs_dict_get(msg, "id"); char *type = xs_dict_get(msg, "type"); - char *meta = xs_dict_get(msg, "_snac"); char *actor; int sensitive = 0; char *v; + xs *likes = NULL; + xs *boosts = NULL; /* do not show non-public messages in the public timeline */ if (local && !is_msg_public(snac, msg)) return os; - /* return if already seen */ - if (xs_set_add(seen, id) == 0) - return os; - xs *s = xs_str_new(NULL); /* top wrap */ @@ -522,6 +514,14 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i return xs_str_cat(os, s); } + else + if (strcmp(type, "Note") != 0) { + s = xs_str_cat(s, "
%s
\n", type); + + return xs_str_cat(os, s); + } /* bring the main actor */ if ((actor = xs_dict_get(msg, "attributedTo")) == NULL) @@ -536,14 +536,14 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i /* if this is our post, add the score */ if (xs_startswith(id, snac->actor)) { - int likes = xs_list_len(xs_dict_get(meta, "liked_by")); - int boosts = xs_list_len(xs_dict_get(meta, "announced_by")); + likes = object_likes(id); + boosts = object_announces(id); /* alternate emojis: %d 👍 %d 🔁 */ xs *s1 = xs_fmt( "