matrix-org / matrix-appservice-tg

Matrix<->Telegram user-puppeting portal
Apache License 2.0
37 stars 15 forks source link

Mapping Telegram concepts to Matrix concepts #11

Open kaiyou opened 6 years ago

kaiyou commented 6 years ago

I just started thinking about improving this bridge and getting it up to speed with the IRC bridges.

Before I start writing code, I wanted to be certain the concepts were well mapped between the two worlds, so that we do not end up being stuck by a lack of consistency. So first, I believe this bridge should remain a pupetting bridge, and given the current state of Telegram APIs, there is no way we get a full two-way bridges without a bot on the Telegram side.

Inventory

Here are the concepts that I think are interested to map from Telegram:

On the other end, the following concepts should not be mapped:

I am hesitating for the following concepts, still thinking maybe about planning to include them but not short-term:

Registration and authentication

I think the overall process should be self services. It could be made available through a bot, or through a widget, or a combination of the two. I still have to dig into the features widgets provide to see what can be implemented through a widget exactly.

Multi-step authentication should be mapped to a multistep questoin/response on Matrix.

Users

Telegram has a distinction between multiple types of users:

Users can be discovered by username, or by other means (uploaded contact list), in which case they are identified by an integer. Unfortunately, usernames, despite being unique, can vary (a user can switch username). Also, the user integer identifier is unique across all types of users.

Therefore, a suggestion would be to use @prefix_<id> for every user, and have a separate mechanism to discover users by username (bot command, or anything else).

I guess we could implement something for discovering new users based on their phone number, but I do not believe that should be mapped to mxids or room aliases.

Direct chats and group chats

There are two dinstinct kinds of chat on Telegram, that one cannot mix (impossible to invite additional members to a direct chat). Also, both direct chats and group chats are identified by an integer id, only unique in its scope (either the user id, or the room id). Additionally, a direct chat can only be opened once with each user.

There is no strong obligation on using aliases to map these rooms: the appservice should automatically invite the Matrix user to rooms that he is not part of. Leaving a room should leave the actual Telegram room.

Also, to match the distinction between direct chat and group chats, two conditions should be applied:

Channels

Channels are simple group chats with access restrictions. They are identified by name, so one should be able to find them at #prefix_#<name>.

Message edition and deletion

Editing a message on Telegram is only allowed for the latest messages. It could be reflected on Matrix as deleting and posting again until we have proper message edition.

heyakyra commented 6 years ago

Would it be possible to have an option to show Telegram users by their username rather than full name on Matrix?

Or is there another solution to avoid creating IRC nicks with users' full names when bridging a room with Telegram and IRC?