summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2024-04-29 09:50:22 +0200
committerdefault <nobody@localhost>2024-04-29 09:50:22 +0200
commit7f322302e5b5cf0345de110afe78767bfb03ae51 (patch)
tree32c2e4a11f43665519c9fddbbd207572e3d3015b /data.c
parent29fb43079761796e34209611ec93bd651b871cab (diff)
New function list_distribute().
Diffstat (limited to 'data.c')
-rw-r--r--data.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/data.c b/data.c
index ed65d32..07b38ec 100644
--- a/data.c
+++ b/data.c
@@ -1154,6 +1154,8 @@ int timeline_add(snac *snac, const char *id, const xs_dict *o_msg)
tag_index(id, o_msg);
+ list_distribute(snac, o_msg);
+
snac_debug(snac, 1, xs_fmt("timeline_add %s", id));
return ret;
@@ -1859,6 +1861,32 @@ xs_val *list_content(snac *user, const char *list, const char *actor_md5, int op
}
+void list_distribute(snac *user, const xs_dict *post)
+/* distributes the post to all appropriate lists */
+{
+ char *atto = get_atto(post);
+ char *id = xs_dict_get(post, "id");
+
+ if (xs_type(atto) == XSTYPE_STRING && xs_type(id) == XSTYPE_STRING) {
+ xs *a_md5 = xs_md5_hex(atto, strlen(atto));
+ xs *i_md5 = xs_md5_hex(id, strlen(id));
+ xs *spec = xs_fmt("%s/list/" "*.lst", user->basedir);
+ xs *ls = xs_glob(spec, 0, 0);
+ int c = 0;
+ char *v;
+
+ while (xs_list_next(ls, &v, &c)) {
+ /* is the actor in this list? */
+ if (index_in_md5(v, a_md5)) {
+ /* it is; add post md5 to its timeline */
+ xs *idx = xs_replace(v, ".lst", ".idx");
+ index_add(idx, i_md5);
+ }
+ }
+ }
+}
+
+
/** static data **/
static int _load_raw_file(const char *fn, xs_val **data, int *size,