summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar grunfink2025-09-03 19:36:33 +0200
committerGravatar grunfink2025-09-03 19:36:33 +0200
commit0c3665fc49064f1fd5a04f2427056f9ea37f8d70 (patch)
treea27bb3c1066eb2f31cad936413dc4cff5ac012e6 /data.c
parentMerge branch 'master' of grunfink-codeberg:grunfink/snac2 (diff)
downloadsnac2-0c3665fc49064f1fd5a04f2427056f9ea37f8d70.tar.gz
snac2-0c3665fc49064f1fd5a04f2427056f9ea37f8d70.tar.xz
snac2-0c3665fc49064f1fd5a04f2427056f9ea37f8d70.zip
Also keep a 'personal' folder for better organization.
Diffstat (limited to 'data.c')
-rw-r--r--data.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/data.c b/data.c
index 7e90a06..1caaabe 100644
--- a/data.c
+++ b/data.c
@@ -1383,8 +1383,13 @@ xs_str *timeline_fn_by_md5(snac *snac, const char *md5)
1383 fn = xs_free(fn); 1383 fn = xs_free(fn);
1384 fn = xs_fmt("%s/public/%s.json", snac->basedir, md5); 1384 fn = xs_fmt("%s/public/%s.json", snac->basedir, md5);
1385 1385
1386 if (mtime(fn) == 0.0) 1386 if (mtime(fn) == 0.0) {
1387 fn = xs_free(fn); 1387 fn = xs_free(fn);
1388 fn = xs_fmt("%s/personal/%s.json", snac->basedir, md5);
1389
1390 if (mtime(fn) == 0.0)
1391 fn = xs_free(fn);
1392 }
1388 } 1393 }
1389 } 1394 }
1390 1395
@@ -1463,6 +1468,8 @@ void timeline_update_indexes(snac *snac, const char *id)
1463 else 1468 else
1464 srv_debug(1, xs_fmt("Not added to public instance index %s", id)); 1469 srv_debug(1, xs_fmt("Not added to public instance index %s", id));
1465 } 1470 }
1471 else
1472 object_user_cache_add(snac, id, "personal");
1466 } 1473 }
1467 } 1474 }
1468} 1475}
@@ -3877,14 +3884,14 @@ void purge_server(void)
3877} 3884}
3878 3885
3879 3886
3880void delete_purged_posts(snac *user, int days) 3887void delete_purged_posts(snac *user, const char *subdir, int days)
3881/* enqueues Delete activities for local purged messages */ 3888/* enqueues Delete activities for local purged messages */
3882{ 3889{
3883 if (days == 0) 3890 if (days == 0)
3884 return; 3891 return;
3885 3892
3886 time_t mt = time(NULL) - days * 24 * 3600; 3893 time_t mt = time(NULL) - days * 24 * 3600;
3887 xs *spec = xs_fmt("%s/public/" "*.json", user->basedir); 3894 xs *spec = xs_fmt("%s/%s/" "*.json", user->basedir, subdir);
3888 xs *list = xs_glob(spec, 0, 0); 3895 xs *list = xs_glob(spec, 0, 0);
3889 const char *v; 3896 const char *v;
3890 3897
@@ -3937,15 +3944,18 @@ void purge_user(snac *snac)
3937 pub_days = user_days; 3944 pub_days = user_days;
3938 } 3945 }
3939 3946
3940 if (xs_is_true(xs_dict_get(srv_config, "propagate_local_purge"))) 3947 if (xs_is_true(xs_dict_get(srv_config, "propagate_local_purge"))) {
3941 delete_purged_posts(snac, pub_days); 3948 delete_purged_posts(snac, "public", pub_days);
3949 delete_purged_posts(snac, "personal", pub_days);
3950 }
3942 3951
3943 _purge_user_subdir(snac, "hidden", priv_days); 3952 _purge_user_subdir(snac, "hidden", priv_days);
3944 _purge_user_subdir(snac, "private", priv_days); 3953 _purge_user_subdir(snac, "private", priv_days);
3945 3954
3946 _purge_user_subdir(snac, "public", pub_days); 3955 _purge_user_subdir(snac, "public", pub_days);
3956 _purge_user_subdir(snac, "personal", pub_days);
3947 3957
3948 const char *idxs[] = { "followers.idx", "private.idx", "public.idx", 3958 const char *idxs[] = { "followers.idx", "private.idx", "public.idx", "personal.idx",
3949 "pinned.idx", "bookmark.idx", "draft.idx", "sched.idx", NULL }; 3959 "pinned.idx", "bookmark.idx", "draft.idx", "sched.idx", NULL };
3950 3960
3951 for (n = 0; idxs[n]; n++) { 3961 for (n = 0; idxs[n]; n++) {