summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-11-04 08:48:15 +0100
committerdefault <nobody@localhost>2022-11-04 08:48:15 +0100
commit8b252dab84e45de924fb55ef9a85131769c477bc (patch)
tree273501204f5856753769d0337191bc182f492277 /data.c
parentb6a2abede2725b278366313a3649e081b47e51ea (diff)
New 'Hide' button.
Diffstat (limited to 'data.c')
-rw-r--r--data.c31
1 files changed, 31 insertions, 0 deletions
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));