9c568c58cf
As part of the new Discord <-> Status Community Import functionality, we're adding an API that extracts all discord categories and channels from a previously exported discord export file. These APIs can be used in clients to show the user what categories and channels will be imported later on. There are two APIs: 1. `Messenger.ExtractDiscordCategoriesAndChannels(filesToimport []string) (*MessengerResponse, map[string]*discord.ImportError)` This takes a list of exported discord export (JSON) files (typically one per channel), reads them, and extracts the categories and channels into dedicated data structures (`[]DiscordChannel` and `[]DiscordCategory`) It also returns the oldest message timestamp found in all extracted channels. The API is synchronous and returns the extracted data as a `*MessengerResponse`. This allows to make the API available status-go's RPC interface. The error case is a `map[string]*discord.ImportError` where each key is a file path of a JSON file that we tried to extract data from, and the value a `discord.ImportError` which holds an error message and an error code, allowing for distinguishing between "critical" errors and "non-critical" errors. 2. `Messenger.RequestExtractDiscordCategoriesAndChannels(filesToImport []string)` This is the asynchronous counterpart to `ExtractDiscordCategoriesAndChannels`. The reason this API has been added is because discord servers can have a lot of message and channel data, which causes `ExtractDiscordCategoriesAndChannels` to block the thread for too long, making apps potentially feel like they are stuck. This API runs inside a go routine, eventually calls `ExtractDiscordCategoriesAndChannels`, and then emits a newly introduced `DiscordCategoriesAndChannelsExtractedSignal` that clients can react to. Failure of extraction has to be determined by the `discord.ImportErrors` emitted by the signal. **A note about exported discord history files** We expect users to export their discord histories via the [DiscordChatExporter](https://github.com/Tyrrrz/DiscordChatExporter/wiki/GUI%2C-CLI-and-Formats-explained#exportguild) tool. The tool allows to export the data in different formats, such as JSON, HTML and CSV. We expect users to have their data exported as JSON. Closes: https://github.com/status-im/status-desktop/issues/6690 |
||
---|---|---|
.. | ||
github.com/protocol/encryption | ||
migrations | ||
multidevice | ||
publisher | ||
sharedsecret | ||
README.md | ||
encryption_multi_device_test.go | ||
encryption_test.go | ||
encryptor.go | ||
persistence.go | ||
persistence_keys_storage_test.go | ||
persistence_test.go | ||
protocol.go | ||
protocol_message.pb.go | ||
protocol_message.proto | ||
protocol_test.go | ||
x3dh.go | ||
x3dh_test.go |
README.md
protocol/encryption package
Hash ratchet encryption
encryptor.GenerateHashRatchetKey()
generates a hash ratchet key and stores it in in the DB.
There, 2 new tables are created: hash_ratchet_encryption
and hash_ratchet_encryption_cache
.
Each hash ratchet key is uniquely identified by the (groupId, keyId)
pair, where keyId
is derived from a clock value.
protocol.BuildHashRatchetKeyExchangeMessage
builds an 1-on-1 message containing the hash ratchet key, given it's ID.
protocol.BuildHashRatchetMessage
builds a hash ratchet message with arbitrary payload, given groupId
. It will use the latest hash ratchet key available. encryptor.encryptWithHR
encrypts the payload using Hash Ratchet algorithms. Intermediate hashes are stored in hash_ratchet_encryption_cache
table.
protocol.HandleMessage
uses encryptor.decryptWithHR
fn for decryption.