feat(telegram): opt-in auto-purge of chat messages after N hours#1512
Open
anikinsasha wants to merge 1 commit into
Open
feat(telegram): opt-in auto-purge of chat messages after N hours#1512anikinsasha wants to merge 1 commit into
anikinsasha wants to merge 1 commit into
Conversation
OFF by default (purge_enabled). Deletes the visible Telegram messages (both sides) after purge_hours, for privacy; the bot's memory lives server-side in the SessionStore, so the visible copies can be purged without losing context. - Durable ledger records (chat, message_id, ts) via an incoming middleware + an outgoing api.config transformer (captures every send centrally). - 30-min loop + boot sweep delete anything aged into [purge_hours, 48h); bounded by the Bot API's 48h deleteMessage ceiling. - No-op and unscheduled when disabled — zero change for existing installs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
An opt-in privacy feature for the Telegram module: automatically delete the visible chat messages (both the user's and the bot's) after a configurable number of hours. OFF by default — existing installs are unchanged.
Why
The bot's real memory lives server-side in the
SessionStore(and the conversation store), never in the Telegram chat history. The visible Telegram messages are just a UI surface, so for privacy many users will want them not to linger. This deletes them afterpurge_hourswhile losing zero context.How
state/telegram/purge-ledger.json) records(chat, message_id, ts)as messages flow: an incomingbot.usemiddleware for the user's messages, and abot.api.config.usetransformer that captures themessage_idof every outgoing send (reply, voice, photo) centrally.[purge_hours, ~48h)and drops messages past that window. Bounded by the Bot API's hard 48hdeleteMessageceiling.purge_enabled:recordPurgeMsg/runPurgeare no-ops when off and the loop isn't scheduled. Zero behavior change for existing installs.Notes
purge_enabled = true, purge_hours = 24on a live install; verified end-to-end (a planted 25h-aged message is deleted on the next sweep).curlto the Bot API) aren't recorded, so they aren't purged. All normal in-bot sends are captured via the transformer.