diff options
| author | 2022-12-02 21:16:34 +0100 | |
|---|---|---|
| committer | 2022-12-02 21:16:34 +0100 | |
| commit | 908e068e36966b3d96a6a61bce4548fdc32cb5c7 (patch) | |
| tree | a1097728438cd830682c6c46712931466480d53f /data.c | |
| parent | More old code cleaning. (diff) | |
| download | snac2-908e068e36966b3d96a6a61bce4548fdc32cb5c7.tar.gz snac2-908e068e36966b3d96a6a61bce4548fdc32cb5c7.tar.xz snac2-908e068e36966b3d96a6a61bce4548fdc32cb5c7.zip | |
New function object_parent().
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 13 |
1 files changed, 10 insertions, 3 deletions
| @@ -605,6 +605,15 @@ d_char *object_announces(const char *id) | |||
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | 607 | ||
| 608 | int object_parent(const char *id, char *buf, int size) | ||
| 609 | /* returns the object parent, if any */ | ||
| 610 | { | ||
| 611 | xs *fn = _object_fn_by_md5(id); | ||
| 612 | fn = xs_replace_i(fn, ".json", "_p.idx"); | ||
| 613 | return index_first(fn, buf, size); | ||
| 614 | } | ||
| 615 | |||
| 616 | |||
| 608 | int object_admire(const char *id, const char *actor, int like) | 617 | int object_admire(const char *id, const char *actor, int like) |
| 609 | /* actor likes or announces this object */ | 618 | /* actor likes or announces this object */ |
| 610 | { | 619 | { |
| @@ -804,11 +813,9 @@ d_char *timeline_top_level(d_char *list) | |||
| 804 | 813 | ||
| 805 | for (;;) { | 814 | for (;;) { |
| 806 | char line2[256]; | 815 | char line2[256]; |
| 807 | xs *fn = _object_fn_by_md5(line); | ||
| 808 | fn = xs_replace_i(fn, ".json", "_p.idx"); | ||
| 809 | 816 | ||
| 810 | /* if it doesn't have a parent, use this */ | 817 | /* if it doesn't have a parent, use this */ |
| 811 | if (index_first(fn, line2, sizeof(line2)) == 0) | 818 | if (!object_parent(line, line2, sizeof(line2))) |
| 812 | break; | 819 | break; |
| 813 | 820 | ||
| 814 | xs *pfn = _object_fn_by_md5(line2); | 821 | xs *pfn = _object_fn_by_md5(line2); |