commit a133427

default  ·  2022-12-02 19:56:51 +0000 UTC
parent 3e2891b
More old code cleaning.
3 files changed,  +4, -61
M data.c
M snac.h
+3, -3
 1@@ -399,7 +399,7 @@ d_char *msg_admiration(snac *snac, char *object, char *type)
 2     /* call the object */
 3     timeline_request(snac, object, snac->actor);
 4 
 5-    if ((a_msg = timeline_find(snac, object)) != NULL) {
 6+    if (valid_status(object_get(object, &a_msg, NULL))) {
 7         xs *rcpts = xs_list_new();
 8 
 9         msg = msg_base(snac, type, "@dummy", snac->actor, "@now", object);
10@@ -592,7 +592,7 @@ d_char *msg_note(snac *snac, char *content, char *rcpts, char *in_reply_to, char
11         /* demand this thing */
12         timeline_request(snac, in_reply_to, NULL);
13 
14-        if ((p_msg = timeline_find(snac, in_reply_to)) != NULL) {
15+        if (valid_status(object_get(in_reply_to, &p_msg, NULL))) {
16             /* add this author as recipient */
17             char *a, *v;
18 
19@@ -892,7 +892,7 @@ int process_message(snac *snac, char *msg, char *req)
20 
21         timeline_request(snac, object, actor);
22 
23-        if ((a_msg = timeline_find(snac, object)) != NULL) {
24+        if (valid_status(object_get(object, &a_msg, NULL))) {
25             char *who = xs_dict_get(a_msg, "attributedTo");
26 
27             if (who && !is_muted(snac, who)) {
M data.c
+1, -56
 1@@ -738,56 +738,11 @@ d_char *follower_list(snac *snac)
 2 
 3 double timeline_mtime(snac *snac)
 4 {
 5-    xs *fn = xs_fmt("%s/timeline", snac->basedir);
 6+    xs *fn = xs_fmt("%s/private.idx", snac->basedir);
 7     return mtime(fn);
 8 }
 9 
10 
11-d_char *_timeline_find_fn(snac *snac, char *id)
12-/* returns the file name of a timeline entry by its id */
13-{
14-    xs *md5  = xs_md5_hex(id, strlen(id));
15-    xs *spec = xs_fmt("%s/timeline/" "*-%s.json", snac->basedir, md5);
16-    xs *list = NULL;
17-    d_char *fn = NULL;
18-    int l;
19-
20-    list = xs_glob(spec, 0, 0);
21-    l = xs_list_len(list);
22-
23-    /* if there is something, get the first one */
24-    if (l > 0) {
25-        fn = xs_str_new(xs_list_get(list, 0));
26-
27-        if (l > 1)
28-            snac_log(snac, xs_fmt("**ALERT** _timeline_find_fn %d > 1", l));
29-    }
30-
31-    return fn;
32-}
33-
34-
35-d_char *timeline_find(snac *snac, char *id)
36-/* gets a message from the timeline by id */
37-{
38-    xs *fn      = _timeline_find_fn(snac, id);
39-    d_char *msg = NULL;
40-
41-    if (fn != NULL) {
42-        FILE *f;
43-
44-        if ((f = fopen(fn, "r")) != NULL) {
45-            xs *j = xs_readall(f);
46-
47-            msg = xs_json_loads(j);
48-            fclose(f);
49-        }
50-    }
51-
52-    return msg;
53-}
54-
55-
56 int timeline_del(snac *snac, char *id)
57 /* deletes a message from the timeline */
58 {
59@@ -800,16 +755,6 @@ int timeline_del(snac *snac, char *id)
60 }
61 
62 
63-d_char *_timeline_new_fn(snac *snac, char *id)
64-/* creates a new filename */
65-{
66-    xs *ntid = tid(0);
67-    xs *md5  = xs_md5_hex(id, strlen(id));
68-
69-    return xs_fmt("%s/timeline/%s-%s.json", snac->basedir, ntid, md5);
70-}
71-
72-
73 void timeline_update_indexes(snac *snac, const char *id)
74 /* updates the indexes */
75 {
M snac.h
+0, -2
1@@ -76,8 +76,6 @@ int follower_check(snac *snac, const char *actor);
2 d_char *follower_list(snac *snac);
3 
4 double timeline_mtime(snac *snac);
5-d_char *_timeline_find_fn(snac *snac, char *id);
6-d_char *timeline_find(snac *snac, char *id);
7 int timeline_del(snac *snac, char *id);
8 d_char *timeline_list(snac *snac, const char *idx_name, int max);
9 int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);