summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
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)
627} 627}
628 628
629 629
630int timeline_hide(snac *snac, char *id, int hide)
631/* hides/unhides a timeline entry */
632{
633 int ret = 0;
634 xs *fn = _timeline_find_fn(snac, id);
635 FILE *f;
636
637 if (fn != NULL && (f = fopen(fn, "r")) != NULL) {
638 xs *s1 = xs_readall(f);
639 xs *msg = xs_json_loads(s1);
640 xs *meta = xs_dup(xs_dict_get(msg, "_snac"));
641
642 fclose(f);
643
644 meta = xs_dict_set(meta, "hidden", xs_val_new(hide ? XSTYPE_TRUE : XSTYPE_FALSE));
645 msg = xs_dict_set(msg, "_snac", meta);
646
647 if ((f = fopen(fn, "w")) != NULL) {
648 xs *j1 = xs_json_dumps_pp(msg, 4);
649
650 fwrite(j1, strlen(j1), 1, f);
651 fclose(f);
652
653 ret = 1;
654 }
655 }
656
657 return ret;
658}
659
660
630d_char *_following_fn(snac *snac, char *actor) 661d_char *_following_fn(snac *snac, char *actor)
631{ 662{
632 xs *md5 = xs_md5_hex(actor, strlen(actor)); 663 xs *md5 = xs_md5_hex(actor, strlen(actor));