commit 908e068

default  ·  2022-12-02 20:16:34 +0000 UTC
parent a133427
New function object_parent().
1 files changed,  +10, -3
M data.c
M data.c
+10, -3
 1@@ -605,6 +605,15 @@ d_char *object_announces(const char *id)
 2 }
 3 
 4 
 5+int object_parent(const char *id, char *buf, int size)
 6+/* returns the object parent, if any */
 7+{
 8+    xs *fn = _object_fn_by_md5(id);
 9+    fn = xs_replace_i(fn, ".json", "_p.idx");
10+    return index_first(fn, buf, size);
11+}
12+
13+
14 int object_admire(const char *id, const char *actor, int like)
15 /* actor likes or announces this object */
16 {
17@@ -804,11 +813,9 @@ d_char *timeline_top_level(d_char *list)
18 
19         for (;;) {
20             char line2[256];
21-            xs *fn = _object_fn_by_md5(line);
22-            fn     = xs_replace_i(fn, ".json", "_p.idx");
23 
24             /* if it doesn't have a parent, use this */
25-            if (index_first(fn, line2, sizeof(line2)) == 0)
26+            if (!object_parent(line, line2, sizeof(line2)))
27                 break;
28 
29             xs *pfn = _object_fn_by_md5(line2);