diff options
| author | 2022-12-02 20:56:51 +0100 | |
|---|---|---|
| committer | 2022-12-02 20:56:51 +0100 | |
| commit | a133427e8dd8533828f7638915d3a0b06a3ed000 (patch) | |
| tree | e94805cd659f510af52be37093bfe8ad7341cce2 /data.c | |
| parent | Renamed timeline_here() to object_here(). (diff) | |
| download | snac2-a133427e8dd8533828f7638915d3a0b06a3ed000.tar.gz snac2-a133427e8dd8533828f7638915d3a0b06a3ed000.tar.xz snac2-a133427e8dd8533828f7638915d3a0b06a3ed000.zip | |
More old code cleaning.
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 57 |
1 files changed, 1 insertions, 56 deletions
| @@ -738,56 +738,11 @@ d_char *follower_list(snac *snac) | |||
| 738 | 738 | ||
| 739 | double timeline_mtime(snac *snac) | 739 | double 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 | ||
| 746 | d_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 | |||
| 770 | d_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 | |||
| 791 | int timeline_del(snac *snac, char *id) | 746 | int 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 | ||
| 803 | d_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 | |||
| 813 | void timeline_update_indexes(snac *snac, const char *id) | 758 | void timeline_update_indexes(snac *snac, const char *id) |
| 814 | /* updates the indexes */ | 759 | /* updates the indexes */ |
| 815 | { | 760 | { |