-
Notifications
You must be signed in to change notification settings - Fork 290
Store the timeline in the SledStore #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -22,6 +22,7 @@ use std::{ | |
sync::Arc, | ||
}; | ||
|
||
use api::message::get_message_events::Direction; | ||
use matrix_sdk_common::{ | ||
api::r0 as api, | ||
deserialized_responses::{ | ||
|
@@ -495,20 +496,17 @@ impl BaseClient { | |
}, | ||
|
||
#[cfg(feature = "encryption")] | ||
AnySyncRoomEvent::Message(message) => { | ||
if let AnySyncMessageEvent::RoomEncrypted(encrypted) = message { | ||
if let Some(olm) = self.olm_machine().await { | ||
if let Ok(decrypted) = | ||
olm.decrypt_room_event(encrypted, room_id).await | ||
{ | ||
match decrypted.deserialize() { | ||
Ok(decrypted) => e = decrypted, | ||
Err(e) => { | ||
warn!( | ||
"Error deserializing a decrypted event {:?} ", | ||
e | ||
) | ||
} | ||
AnySyncRoomEvent::Message(AnySyncMessageEvent::RoomEncrypted( | ||
encrypted, | ||
)) => { | ||
if let Some(olm) = self.olm_machine().await { | ||
if let Ok(decrypted) = | ||
olm.decrypt_room_event(encrypted, room_id).await | ||
{ | ||
match decrypted.deserialize() { | ||
Ok(decrypted) => e = decrypted, | ||
Err(e) => { | ||
warn!("Error deserializing a decrypted event {:?} ", e) | ||
} | ||
} | ||
} | ||
|
@@ -529,6 +527,19 @@ impl BaseClient { | |
} | ||
} | ||
|
||
// TODO: | ||
// We wait until after the event has been decrypted? | ||
if let Some(prev) = timeline.prev_batch.as_deref() { | ||
let needed = self | ||
.store | ||
.unknown_timeline_events(room_id, prev, &timeline.events) | ||
.await?; | ||
|
||
if !needed.is_empty() { | ||
changes.handle_sync_timeline(room_id, prev, needed); | ||
} | ||
} | ||
|
||
Ok(timeline) | ||
} | ||
|
||
|
@@ -1046,6 +1057,22 @@ impl BaseClient { | |
}) | ||
} | ||
|
||
/// Receive a successful /messages response. | ||
/// | ||
/// * `response` - The successful response from /messages. | ||
pub async fn receive_messages_response( | ||
&self, | ||
room_id: &RoomId, | ||
dir: Direction, | ||
resp: &api::message::get_message_events::Response, | ||
) -> Result<()> { | ||
let mut changes = StateChanges::default(); | ||
changes.handle_messages_response(room_id, resp, dir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This method will need to decrypt the events as well, but that can be left for later on. |
||
self.store().save_changes(&changes).await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Receive a successful filter upload response, the filter id will be | ||
/// stored under the given name in the store. | ||
/// | ||
|
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry what are you asking here? The block above already makes sure that all events that can be decrypted during this sync are decrypted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I was just making sure that we wanted the events decrypted I figured since the Store can be encrypted that this is Ok but I just wanted to make sure.