From 8b252dab84e45de924fb55ef9a85131769c477bc Mon Sep 17 00:00:00 2001 From: default Date: Fri, 4 Nov 2022 08:48:15 +0100 Subject: New 'Hide' button. --- data.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'data.c') diff --git a/data.c b/data.c index e8e4f9f..741acc8 100644 --- a/data.c +++ b/data.c @@ -627,6 +627,37 @@ void timeline_admire(snac *snac, char *id, char *admirer, int like) } +int timeline_hide(snac *snac, char *id, int hide) +/* hides/unhides a timeline entry */ +{ + int ret = 0; + xs *fn = _timeline_find_fn(snac, id); + FILE *f; + + if (fn != NULL && (f = fopen(fn, "r")) != NULL) { + xs *s1 = xs_readall(f); + xs *msg = xs_json_loads(s1); + xs *meta = xs_dup(xs_dict_get(msg, "_snac")); + + fclose(f); + + meta = xs_dict_set(meta, "hidden", xs_val_new(hide ? XSTYPE_TRUE : XSTYPE_FALSE)); + msg = xs_dict_set(msg, "_snac", meta); + + if ((f = fopen(fn, "w")) != NULL) { + xs *j1 = xs_json_dumps_pp(msg, 4); + + fwrite(j1, strlen(j1), 1, f); + fclose(f); + + ret = 1; + } + } + + return ret; +} + + d_char *_following_fn(snac *snac, char *actor) { xs *md5 = xs_md5_hex(actor, strlen(actor)); -- cgit v1.2.3