summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2022-12-02 20:56:51 +0100
committerGravatar default2022-12-02 20:56:51 +0100
commita133427e8dd8533828f7638915d3a0b06a3ed000 (patch)
treee94805cd659f510af52be37093bfe8ad7341cce2 /data.c
parentRenamed timeline_here() to object_here(). (diff)
downloadsnac2-a133427e8dd8533828f7638915d3a0b06a3ed000.tar.gz
snac2-a133427e8dd8533828f7638915d3a0b06a3ed000.tar.xz
snac2-a133427e8dd8533828f7638915d3a0b06a3ed000.zip
More old code cleaning.
Diffstat (limited to 'data.c')
-rw-r--r--data.c57
1 files changed, 1 insertions, 56 deletions
diff --git a/data.c b/data.c
index a530f22..aee03e2 100644
--- a/data.c
+++ b/data.c
@@ -738,56 +738,11 @@ d_char *follower_list(snac *snac)
738 738
739double timeline_mtime(snac *snac) 739double timeline_mtime(snac *snac)
740{ 740{
741 xs *fn = xs_fmt("%s/timeline", snac->basedir); 741 xs *fn = xs_fmt("%s/private.idx", snac->basedir);
742 return mtime(fn); 742 return mtime(fn);
743} 743}
744 744
745 745
746d_char *_timeline_find_fn(snac *snac, char *id)
747/* returns the file name of a timeline entry by its id */
748{
749 xs *md5 = xs_md5_hex(id, strlen(id));
750 xs *spec = xs_fmt("%s/timeline/" "*-%s.json", snac->basedir, md5);
751 xs *list = NULL;
752 d_char *fn = NULL;
753 int l;
754
755 list = xs_glob(spec, 0, 0);
756 l = xs_list_len(list);
757
758 /* if there is something, get the first one */
759 if (l > 0) {
760 fn = xs_str_new(xs_list_get(list, 0));
761
762 if (l > 1)
763 snac_log(snac, xs_fmt("**ALERT** _timeline_find_fn %d > 1", l));
764 }
765
766 return fn;
767}
768
769
770d_char *timeline_find(snac *snac, char *id)
771/* gets a message from the timeline by id */
772{
773 xs *fn = _timeline_find_fn(snac, id);
774 d_char *msg = NULL;
775
776 if (fn != NULL) {
777 FILE *f;
778
779 if ((f = fopen(fn, "r")) != NULL) {
780 xs *j = xs_readall(f);
781
782 msg = xs_json_loads(j);
783 fclose(f);
784 }
785 }
786
787 return msg;
788}
789
790
791int timeline_del(snac *snac, char *id) 746int timeline_del(snac *snac, char *id)
792/* deletes a message from the timeline */ 747/* deletes a message from the timeline */
793{ 748{
@@ -800,16 +755,6 @@ int timeline_del(snac *snac, char *id)
800} 755}
801 756
802 757
803d_char *_timeline_new_fn(snac *snac, char *id)
804/* creates a new filename */
805{
806 xs *ntid = tid(0);
807 xs *md5 = xs_md5_hex(id, strlen(id));
808
809 return xs_fmt("%s/timeline/%s-%s.json", snac->basedir, ntid, md5);
810}
811
812
813void timeline_update_indexes(snac *snac, const char *id) 758void timeline_update_indexes(snac *snac, const char *id)
814/* updates the indexes */ 759/* updates the indexes */
815{ 760{