-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Receive flow for application messages (#326)
This reads in application messages, decrypts them, and stores them in the database. There's still lots of missing pieces here: 1. Sync from last processed payload, rather than syncing all payloads - working on adding the `topic_state` table separately 2. Handle concurrency of syncing 3. Handle payloads coming from yourself (left a comment in the PR body) 4. Better unit tests - we can't decrypt payloads coming from ourselves, so we need to support adding members first 5. This only reads payloads for a group and doesn't return anything - we still need a higher-level method to list all messages in a group by reading from the DB, we also need a higher-level method to read payloads for all groups. There's plenty of space left here also to add in the logic for other message types
- Loading branch information
1 parent
56687a5
commit a9dd41d
Showing
10 changed files
with
221 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use super::hash::sha256; | ||
|
||
pub fn serialize_group_id(group_id: &[u8]) -> String { | ||
// TODO: I wonder if we really want to be base64 encoding this or if we can treat it as a | ||
// slice | ||
hex::encode(group_id) | ||
} | ||
|
||
pub fn get_message_id( | ||
decrypted_message_bytes: &[u8], | ||
group_id: &[u8], | ||
envelope_timestamp_ns: u64, | ||
) -> Vec<u8> { | ||
let mut id_vec = Vec::new(); | ||
id_vec.extend_from_slice(group_id); | ||
id_vec.extend_from_slice(&envelope_timestamp_ns.to_be_bytes()); | ||
id_vec.extend_from_slice(decrypted_message_bytes); | ||
sha256(&id_vec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pub mod hash; | ||
pub mod id; | ||
#[cfg(test)] | ||
pub mod test; | ||
pub mod time; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.