codingteam / emulsion

XMPP ↔ Telegram bridge
MIT License
33 stars 3 forks source link

HTTP redirector service for Telegram content #147

Closed ForNeVeR closed 2 years ago

ForNeVeR commented 2 years ago

As the first minimally viable step of #102, I propose us to do the following:

  1. Add database support to Emulsion (should be optional: I host a plenty of Emulsion instances already, and not every one of them demands a separate database).
  2. We should store the correspondence between Telegram message/content ids and our internal ones in said database.
  3. Every content id gets a nanoid.
  4. Every content-rich message gets that nanoid included instead of the current message link (like https://codingteam.org.ru/tg/<nanoid> instead of https://t.me/<tgid>).
  5. Create a HTTP service which will serve requests to https://codingteam.org.ru/tg/<nanoid>, and just redirect them to the corresponding https://t.me/<tgid> instead.

    This will require us to store both Telegram message id and content id together. Collisions are possible if there are several messages with the same content id (not sure how, but technically possible). In such cases, just generate several entries (for each content id + message id pair).

    At a later point, we may migrate and renormalize the database if we decide that the message ids aren't required.