From f82124a705d9c5350b92fba6a03c556c1fd5b2b0 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 2 Oct 2022 18:16:58 +0200 Subject: [PATCH] The history is shown at the bottom of the local timeline. --- data.c | 31 +++++++++++++++++++++++++++++++ html.c | 29 +++++++++++++++++++++++++++++ snac.h | 1 + 3 files changed, 61 insertions(+) diff --git a/data.c b/data.c index 5de26c1..8c07a7b 100644 --- a/data.c +++ b/data.c @@ -914,6 +914,37 @@ int history_del(snac *snac, char *id) } +d_char *history_list(snac *snac) +{ + d_char *list; + xs *spec; + glob_t globbuf; + + list = xs_list_new(); + spec = xs_fmt("%s/history/" "*.html", snac->basedir); + + if (glob(spec, 0, NULL, &globbuf) == 0) { + int n; + char *fn; + + for (n = 0; (fn = globbuf.gl_pathv[n]) != NULL; n++) { + char *p; + + if ((p = strrchr(fn, '/')) != NULL) { + *p++ = '\0'; + + if (*p != '_') + list = xs_list_append(list, p); + } + } + } + + globfree(&globbuf); + + return list; +} + + void enqueue_input(snac *snac, char *msg, char *req, int retries) /* enqueues an input message */ { diff --git a/html.c b/html.c index ad867af..f36bcfb 100644 --- a/html.c +++ b/html.c @@ -483,6 +483,10 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i xs *actor_o = NULL; char *actor; + /* 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; @@ -720,6 +724,31 @@ d_char *html_timeline(snac *snac, char *list, int local) s = xs_str_cat(s, "\n"); + if (local) { + xs *s1 = xs_fmt( + "
\n" + "

%s

\n"); + } + s = html_user_footer(snac, s); { diff --git a/snac.h b/snac.h index 7d07da0..a9809bf 100644 --- a/snac.h +++ b/snac.h @@ -86,6 +86,7 @@ double history_mtime(snac *snac, char *id); void history_add(snac *snac, char *id, char *content, int size); d_char *history_get(snac *snac, char *id); int history_del(snac *snac, char *id); +d_char *history_list(snac *snac); void enqueue_input(snac *snac, char *msg, char *req, int retries); void enqueue_output(snac *snac, char *msg, char *actor, int retries);