summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordefault <nobody@localhost>2022-12-02 21:16:34 +0100
committerdefault <nobody@localhost>2022-12-02 21:16:34 +0100
commit908e068e36966b3d96a6a61bce4548fdc32cb5c7 (patch)
treea1097728438cd830682c6c46712931466480d53f
parenta133427e8dd8533828f7638915d3a0b06a3ed000 (diff)
New function object_parent().
-rw-r--r--data.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/data.c b/data.c
index aee03e2..122021e 100644
--- a/data.c
+++ b/data.c
@@ -605,6 +605,15 @@ d_char *object_announces(const char *id)
}
+int object_parent(const char *id, char *buf, int size)
+/* returns the object parent, if any */
+{
+ xs *fn = _object_fn_by_md5(id);
+ fn = xs_replace_i(fn, ".json", "_p.idx");
+ return index_first(fn, buf, size);
+}
+
+
int object_admire(const char *id, const char *actor, int like)
/* actor likes or announces this object */
{
@@ -804,11 +813,9 @@ d_char *timeline_top_level(d_char *list)
for (;;) {
char line2[256];
- xs *fn = _object_fn_by_md5(line);
- fn = xs_replace_i(fn, ".json", "_p.idx");
/* if it doesn't have a parent, use this */
- if (index_first(fn, line2, sizeof(line2)) == 0)
+ if (!object_parent(line, line2, sizeof(line2)))
break;
xs *pfn = _object_fn_by_md5(line2);