-
Notifications
You must be signed in to change notification settings - Fork 0
Bridge logic
This document explains how we want the bridge to work, and why we made things how they are.
This section defines how user should be bridge between Discord and matrix.
Due to Discord limitations, we can only show the username and avatar on the webhook that is used to send images.
The avatar should be the avatar used by the user in the room, even if their global avatar is different. Avatars URL should be cached and only uploaded when a change is required.
Matrix does not really have username length limit, so we will need to strip the username (the maximum allowed username size on Discord is 80 characters).
To prevent conflict issues, we should follow Matrix specifications about Calculating the display name for a user.
Because their is a BOT
icon next to the username of a message sent through a webhook, it is not needed to prevent name spoofing against Discord users.
Matrix Appservice can reserve user id range on the homeserver host.
The user id range that will be used is _discord_{id}
.
With this method, each discord user correspond to one matrix user with an easy conversion.
In a given channel, username and avatars on matrix should be based on the display username and avatars on discord for the given bridged channel (which means server specific usernames and avatars for nitro users are supported).
The avatar should always be the display avatar. We should not need to implement a toggle for this features, Discord admins can disable the functionality on Discord.
Usernames on matrix do no need to include the discriminator (for example Wumpus
) (the four digit number which makes username uniques), except when multiple users with the same usernames talk in the same channel.
In this case, we should use the discriminator (for example Wumpus#4455
).
There could be cases where the users shares the same discriminator, if they have different usernames but same discriminator and changed the username on the server. In this case, we should show the default name for both users, to prevent attempts to imitate an other user.
Matrix clients should handle name conflicts on their side so their is no need to do this on our side from Discord to Matrix.
Forwarding power levels from Matrix to Discord is not possible, because webhooks don't provide much freedom about user info. This data could be accessible using a "about" command, which could show various data about a message, including the author.
It should be possible to show basic data about the role of a Discord user to Matrix by associating some permissions like manage messages, kick and ban users to moderator level and administrator role to administrator level. Finer control could be done by associating Discord permissions to Matrix permissions, in order:
Discord Permission | Matrix Permission |
---|---|
Everyone | Remove messages sent by me |
Everyone / Add reactions | Send reactions |
Send messages | Send messages |
Create invitation | Invite users |
Manage messages | Remove messages sent by others |
Mention @everyone, @here and other roles | Notify everyone |
Manage messages | Send m.room.pinned_events events |
Kick members | Remove users |
Ban members | Ban users |
Manage channel | Change room avatar |
Manage channel | Change topic |
Manage channel | Modify widgets |
Manage channel | Change settings |
Manage channel | Change main address of the room |
Manage channel | Change history visibility |
Manage roles | Change permissions |
Will not be supported:
Discord Permission | Matrix Permission |
---|---|
Not bridged | Change server ACLs |
Not bridged | Upgrade the room |
Calls are not supported in text channels on discord | Send org.matrix.msc3401.call events |
Calls are not supported in text channels on discord | Send org.matrix.msc3401.call.members events |
Calls are not supported in text channels on discord | Voice broadcasts |
This is how you choose which power level to assign to a Discord user:
- if the administrator of the bridge chose simple bridging:
- based on the user roles, we assign:
- Owner power level if the user is the owner of the Discord server;
- Administrator power level if the user has the Administrator permission;
- Moderator power level if the user has the Manage Messages, Kick or Ban Members permissions;
- Default role else.
- bridge administrators should be able to edit the permissions and levels above.
- based on the user roles, we assign:
- if the administrator of the bridge chose advanced bridging:
- an administrator on the Matrix side should edit permissions level with different levels for each permissions specified above in the table;
- based on the Discord user roles, we assign:
- the power level corresponding to the highest permission the user has as shown in the table.
- this feature can be disabled.