1.8 KiB
1.8 KiB
d2m
Remember that a discord message may be transformed to multiple matrix messages.
A database will be used to store the discord id to matrix event id mapping. Table columns:
- discord id
- matrix id
- the "type" of the matrix id, used to update things properly next time. for example, whether it is the message text or an attachment
There needs to be a way to easily manually trigger something later. For example, it should be easy to manually retry sending a message, or check all members for changes, etc.
Transforming content
- Upload attachments to mxc if they are small enough.
- Convert discord message text and embeds to matrix event.
- Convert discord mentions, names, channel links, message links, and emojis to intermediate formats.
- Convert discord text to body.
- Convert discord text to formatted_body using custom discord-markdown npm module.
- Convert discord embeds to quotes.
- Gather relevant reply data.
- Send reply+message.
- Send attachments.
- Store in database.
Message sent
- Transform content.
- Send to matrix.
Message deleted
- Look up equivalents on matrix.
- Delete on matrix.
Message edited / embeds added
- Look up equivalents on matrix.
- Replace content on matrix.
Reaction added
- Add reaction on matrix.
Reaction removed
- Remove reaction on matrix.
Member data changed
- Compare current member against cached version in database.
- Update member on matrix.
- Update cached version in database.
Channel created / updated
(but I should be able to manually call this function at any time to run the same code on any given channel)
- Compare current channel against cached version in database.
- If channel does not yet exist in database:
- Create the corresponding room.
- Add to database.
- Update room details to match.
- Add to space.