diff options
| author | 2025-09-28 15:46:56 +0200 | |
|---|---|---|
| committer | 2025-09-28 15:46:56 +0200 | |
| commit | ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce (patch) | |
| tree | 868fa6b77c7697f972cb7b9ea8d3ff49ab8652e1 /data.c | |
| parent | Temporary tweak. (diff) | |
| parent | Merge branch 'master' into feature/visibility (diff) | |
| download | snac2-ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce.tar.gz snac2-ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce.tar.xz snac2-ab698c2bd6cbe74b2cca0a17fe210e159a43a2ce.zip | |
Merge pull request 'implementing scopes' (#474) from byte/snac2:feature/visibility into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/474
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -1456,15 +1456,16 @@ void timeline_update_indexes(snac *snac, const char *id) | |||
| 1456 | xs *msg = NULL; | 1456 | xs *msg = NULL; |
| 1457 | 1457 | ||
| 1458 | if (valid_status(object_get(id, &msg))) { | 1458 | if (valid_status(object_get(id, &msg))) { |
| 1459 | const int scope = get_msg_visibility(msg); | ||
| 1459 | /* if its ours and is public, also store in public */ | 1460 | /* if its ours and is public, also store in public */ |
| 1460 | if (is_msg_public(msg)) { | 1461 | if (scope == SCOPE_PUBLIC) { |
| 1461 | if (object_user_cache_add(snac, id, "public") >= 0) { | 1462 | if (object_user_cache_add(snac, id, "public") >= 0) { |
| 1462 | /* also add it to the instance public timeline */ | 1463 | /* also add it to the instance public timeline */ |
| 1463 | xs *ipt = xs_fmt("%s/public.idx", srv_basedir); | 1464 | xs *ipt = xs_fmt("%s/public.idx", srv_basedir); |
| 1464 | index_add(ipt, id); | 1465 | index_add(ipt, id); |
| 1465 | } | 1466 | } |
| 1466 | else | 1467 | else |
| 1467 | srv_debug(1, xs_fmt("Not added to public instance index %s", id)); | 1468 | srv_debug(1, xs_fmt("Not added to public instance index %s, visibility %d", id, scope)); |
| 1468 | } | 1469 | } |
| 1469 | else | 1470 | else |
| 1470 | /* also add it to public, it will be discarded later */ | 1471 | /* also add it to public, it will be discarded later */ |
| @@ -2222,7 +2223,10 @@ void tag_index(const char *id, const xs_dict *obj) | |||
| 2222 | const xs_list *tags = xs_dict_get(obj, "tag"); | 2223 | const xs_list *tags = xs_dict_get(obj, "tag"); |
| 2223 | xs *md5_id = xs_md5_hex(id, strlen(id)); | 2224 | xs *md5_id = xs_md5_hex(id, strlen(id)); |
| 2224 | 2225 | ||
| 2225 | if (is_msg_public(obj) && xs_type(tags) == XSTYPE_LIST && xs_list_len(tags) > 0) { | 2226 | if (get_msg_visibility(obj) != SCOPE_PUBLIC) |
| 2227 | return; | ||
| 2228 | |||
| 2229 | if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags) > 0) { | ||
| 2226 | xs *g_tag_dir = xs_fmt("%s/tag", srv_basedir); | 2230 | xs *g_tag_dir = xs_fmt("%s/tag", srv_basedir); |
| 2227 | 2231 | ||
| 2228 | mkdirx(g_tag_dir); | 2232 | mkdirx(g_tag_dir); |