diff options
| author | default <nobody@localhost> | 2024-05-31 11:11:25 +0200 |
|---|---|---|
| committer | default <nobody@localhost> | 2024-05-31 11:11:25 +0200 |
| commit | f1712dbe5d73bb75df1c3d332ca57ebc430ceda3 (patch) | |
| tree | 3ac1edc07d1a482d212d349a348a82ad2666edfd /html.c | |
| parent | c80a30e228777637773012f0b886858494782f7a (diff) | |
| parent | fe52b7612e4a96d491f925dfcbbbaa6251654ca4 (diff) | |
Merge branch 'master' of grunfink-codeberg:grunfink/snac2
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -786,6 +786,24 @@ static xs_html *html_user_body(snac *user, int read_only) xs_html_attr("class", "snac-top-user-id"), xs_html_text(handle))); + /** instance announcement **/ + + double la = 0.0; + xs *user_la = xs_dup(xs_dict_get(user->config, "last_announcement")); + if (user_la != NULL) + la = xs_number_get(user_la); + + const t_announcement *an = announcement(la); + if (an != NULL && (an->text != NULL)) { + xs_html_add(top_user, xs_html_tag("div", + xs_html_attr("class", "snac-announcement"), + xs_html_text(an->text), + xs_html_text(" "), + xs_html_sctag("a", + xs_html_attr("href", xs_dup(xs_fmt("?da=%.0f", an->timestamp)))), + xs_html_text("Dismiss"))); + } + if (read_only) { xs *es1 = encode_html(xs_dict_get(user->config, "bio")); xs *bio1 = not_really_markdown(es1, NULL, NULL); @@ -2606,6 +2624,16 @@ int html_get_handler(const xs_dict *req, const char *q_path, skip = atoi(v), cache = 0, save = 0; if ((v = xs_dict_get(q_vars, "show")) != NULL) show = atoi(v), cache = 0, save = 0; + if ((v = xs_dict_get(q_vars, "da")) != NULL) { + /* user dismissed an announcement */ + if (login(&snac, req)) { + double ts = atof(v); + xs *timestamp = xs_number_new(ts); + srv_log(xs_fmt("user dismissed announcements until %d", ts)); + snac.config = xs_dict_set(snac.config, "last_announcement", timestamp); + user_persist(&snac); + } + } if (p_path == NULL) { /** public timeline **/ xs *h = xs_str_localtime(0, "%Y-%m.html"); |