reply cache to delete our DM if they delete #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, if we received a notification that someone deleted a toot, we asked our server for our most recent sent toots to see if we could find a reply to the deleted toot. If we found such a reply, we'd delete it (so it's not cluttering the other user's DMs).
Most of the time this does nothing because
Instead of burdening the server to do this unlikely-to-be-useful search, this PR proposes an alternative: we store in memory a cache mapping other people's message IDs to our replies. When we DM someone about missing captions, it creates an entry in the cache. If we get a delete, we check the cache for the deleted message ID and if we find a hit, we delete our message and delete the entry from the cache.
We don't want the cache to grow infinitely so we cap it at some reasonable value (10'000 entries in this PR), and every 12 hours we run a cleanup operation to bring it to that size if it's grown beyond it.
Upsides:
Downsides:
Bonus:
Potential enhancements:
(My overall goal to reduce server load is so we can turn on boost analysis 馃槆)