diff options
Diffstat (limited to 'data.c')
| -rw-r--r-- | data.c | 58 |
1 files changed, 54 insertions, 4 deletions
@@ -217,6 +217,7 @@ void user_free(snac *snac) xs_free(snac->key); xs_free(snac->links); xs_free(snac->actor); + xs_free(snac->actor_alt); xs_free(snac->md5); } @@ -1569,6 +1570,37 @@ void timeline_update_indexes(snac *snac, const char *id) else /* also add it to public, it will be discarded later */ object_user_cache_add(snac, id, "public"); + + /* if `keep_replied_posts` is `true` and a local post is a reply to a remote post, add the parent remote post to the public */ + if (xs_is_true(xs_dict_get(srv_config, "keep_replied_posts"))) { + const char *in_reply_to = get_in_reply_to(msg); + + if (xs_is_string(in_reply_to) && *in_reply_to && + !is_msg_mine(snac, in_reply_to)) { + if (object_user_cache_add(snac, in_reply_to, "public") >= 0) { + snac_debug(snac, 1, + xs_fmt("keep_replied_posts: added parent %s to public", in_reply_to)); + } + } + } + } + } + else { + /* if `keep_replied_me` is `true` and a remote post is a reply to one of local posts, add it to public */ + if (xs_is_true(xs_dict_get(srv_config, "keep_replied_me"))) { + xs *msg = NULL; + + if (valid_status(object_get(id, &msg))) { + const char *in_reply_to = get_in_reply_to(msg); + + if (xs_is_string(in_reply_to) && *in_reply_to && + is_msg_mine(snac, in_reply_to)) { + if (object_user_cache_add(snac, id, "public") >= 0) { + snac_debug(snac, 1, + xs_fmt("keep_replied_me: added reply %s to public", id)); + } + } + } } } } @@ -1614,12 +1646,15 @@ int timeline_admire(snac *snac, const char *id, const char *content = xs_dict_get_path(msg, "content"); const char *type = xs_dict_get_path(msg, "type"); - /* if we are admiring this, add to both timelines */ + /* if we are admiring this, add to both timelines, and store for later */ if (!like && strcmp(admirer, snac->actor) == 0) { object_user_cache_add(snac, id, "public"); object_user_cache_add(snac, id, "private"); } + if (strcmp(admirer, snac->actor) == 0) + object_user_cache_add(snac, id, "admire"); + /* use utf <3 as a like, as it is ugly */ if (type && xs_match(type, "Like|EmojiReact|Emoji") && content && strcmp(content, "❤") != 0) { @@ -3311,6 +3346,10 @@ int grave(const char *objid, int op) } break; + + case 2: /** del **/ + unlink(fn); + break; } return ret; @@ -3827,6 +3866,11 @@ void enqueue_close_question(snac *user, const char *id, int end_secs) void enqueue_object_request(snac *user, const char *id, int forward_secs) /* enqueues the request of an object in the future */ { + if (forward_secs < 0) { + /* set it to a somewhat random delay */ + forward_secs = xs_hash_func(user->uid, strlen(user->uid)) % -forward_secs; + } + xs *qmsg = _new_qmsg("object_request", id, 0); xs *ntid = tid(forward_secs); xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); @@ -3855,6 +3899,11 @@ void enqueue_verify_links(snac *user) void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs) /* enqueues an actor refresh */ { + if (forward_secs < 0) { + /* set it to a somewhat random delay */ + forward_secs = xs_hash_func(user->uid, strlen(user->uid)) % -forward_secs; + } + xs *qmsg = _new_qmsg("actor_refresh", "", 0); xs *ntid = tid(forward_secs); xs *fn = xs_fmt("%s/queue/%s.json", user->basedir, ntid); @@ -3864,7 +3913,7 @@ void enqueue_actor_refresh(snac *user, const char *actor, int forward_secs) qmsg = _enqueue_put(fn, qmsg); - snac_debug(user, 1, xs_fmt("enqueue_actor_refresh %s", actor)); + snac_debug(user, 1, xs_fmt("enqueue_actor_refresh %s %d", actor, forward_secs)); } @@ -4419,9 +4468,10 @@ void purge_user(snac *snac) _purge_user_subdir(snac, "pending", priv_days); _purge_user_subdir(snac, "public", pub_days); + _purge_user_subdir(snac, "admire", pub_days); - const char *idxs[] = { "followers.idx", "private.idx", "public.idx", - "pinned.idx", "bookmark.idx", "draft.idx", "sched.idx", NULL }; + const char *idxs[] = { "followers.idx", "private.idx", "public.idx", "pinned.idx", + "bookmark.idx", "draft.idx", "sched.idx", "admire.idx", NULL }; for (n = 0; idxs[n]; n++) { xs *idx = xs_fmt("%s/%s", snac->basedir, idxs[n]); |