Skip to content

feat: improve anonymity by not storing ids in db anymore#182

Draft
drendog wants to merge 10 commits intoUNICT-DMI:mainfrom
drendog:feature/strengthen-anonymity
Draft

feat: improve anonymity by not storing ids in db anymore#182
drendog wants to merge 10 commits intoUNICT-DMI:mainfrom
drendog:feature/strengthen-anonymity

Conversation

@drendog
Copy link
Copy Markdown
Contributor

@drendog drendog commented Feb 8, 2026

Prerequisites

  • I have read and understood the contributing guide.
  • The commit message follows the conventional commits guidelines.
  • Tested the changes locally with a real Telegram bot.
  • Introduced tests for the changes have been added (for bug fixes / features).
  • Docs have been added/updated (for bug fixes / features).
  • I have updated the CHANGELOG.md file with an overview of the changes made.

Description

reworks how the bot handles user id during the pending post lifecycle, applying encrypted in-memory approach to minimize the exposure of user id at every layer.
User/chat id are no longer plaintext written to disk at all (currently encrypted only on the backups), pending posts are held in an ephemeral in-memory encrypted splitted map that exists only for the lifetime of the process.

(If applicable) Issue closed by this PR

Does this PR introduce a breaking change?

  • Yes
  • No

(If yes) What are the changes that might break existing applications?

  • Pending posts table removal
  • Graceful shutdown, that stops accepting new posts, asks to admin to make decision on pending posts by configurable timeout, and cleans pending posts. It is needed because ids will not persist after reboot/update.

Python version you are using

3.14.2

Other information

Remember to set stop_grace_period on the compose file with the same value or more as drain_timeout in settings.yaml, to avoid to kill the bot before cleaning up the pending post

WIP another PR based in this, to add salt on approval/reject buttons in a way to split knowledge about encryption.

WIP another PR based in this, about new post sending flow without storing chat id anywhere, without compromising the user experience too badly, but still keeping the old one

key = self._key
PendingPost._store[key] = self
PendingPost._key_to_user[key] = PendingPost._encrypt_user_id(user_id)
PendingPost._user_to_key[PendingPost._hash_user_id(user_id)] = key
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so you want to keep the pending post in memory? What about if the bot crashes?
and if we restart the docker container for an update?

Is there a persistent cache/storage for it?

@Helias
Copy link
Copy Markdown
Member

Helias commented Feb 8, 2026

merge conflict

@drendog drendog marked this pull request as draft February 8, 2026 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants