commit 4a41f3a

default  ·  2022-11-25 13:19:00 +0000 UTC
parent 40a9e6e
New function timeline_object_add().
1 files changed,  +16, -9
M data.c
M data.c
+16, -9
 1@@ -896,6 +896,21 @@ int _timeline_write(snac *snac, char *id, char *msg, char *parent, char *referre
 2 }
 3 
 4 
 5+void timeline_object_add(snac *snac, const char *id, char *msg)
 6+/* adds an object and update the user indexes */
 7+{
 8+    object_add(id, msg);
 9+
10+    xs *idx = xs_fmt("%s/timeline.idx", snac->basedir);
11+    index_add(idx, id);
12+
13+    if (xs_startswith(id, snac->actor)) {
14+        idx = xs_replace_i(idx, "timeline.", "local.");
15+        index_add(idx, id);
16+    }
17+}
18+
19+
20 int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer)
21 /* adds a message to the timeline */
22 {
23@@ -931,15 +946,7 @@ int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer
24     if ((ret = _timeline_write(snac, id, msg, parent, referrer))) {
25         snac_debug(snac, 1, xs_fmt("timeline_add %s", id));
26 
27-        object_add(id, o_msg);
28-
29-        xs *idx = xs_fmt("%s/timeline.idx", snac->basedir);
30-        index_add(idx, id);
31-
32-        if (xs_startswith(id, snac->actor)) {
33-            idx = xs_replace_i(idx, "timeline.", "local.");
34-            index_add(idx, id);
35-        }
36+        timeline_object_add(snac, id, o_msg);
37     }
38 
39     return ret;