crypto: Change the way we check if an user is already tracked.
This commit is contained in:
parent
db553b2040
commit
ac2469d270
4 changed files with 13 additions and 18 deletions
|
@ -1219,7 +1219,7 @@ impl OlmMachine {
|
|||
///
|
||||
/// Returns true if the user was queued up for a key query, false otherwise.
|
||||
pub async fn mark_user_as_changed(&self, user_id: &UserId) -> StoreResult<bool> {
|
||||
if self.store.read().await.tracked_users().contains(user_id) {
|
||||
if self.store.read().await.is_user_tracked(user_id) {
|
||||
self.store
|
||||
.write()
|
||||
.await
|
||||
|
@ -1250,7 +1250,7 @@ impl OlmMachine {
|
|||
I: IntoIterator<Item = &'a UserId>,
|
||||
{
|
||||
for user in users {
|
||||
if self.store.read().await.tracked_users().contains(user) {
|
||||
if self.store.read().await.is_user_tracked(user) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,14 +83,14 @@ impl CryptoStore for MemoryStore {
|
|||
.get(room_id, sender_key, session_id))
|
||||
}
|
||||
|
||||
fn tracked_users(&self) -> &HashSet<UserId> {
|
||||
&self.tracked_users
|
||||
}
|
||||
|
||||
fn users_for_key_query(&self) -> &HashSet<UserId> {
|
||||
&self.users_for_key_query
|
||||
}
|
||||
|
||||
fn is_user_tracked(&self, user_id: &UserId) -> bool {
|
||||
self.tracked_users.contains(user_id)
|
||||
}
|
||||
|
||||
async fn update_tracked_user(&mut self, user: &UserId, dirty: bool) -> Result<bool> {
|
||||
if dirty {
|
||||
self.users_for_key_query.insert(user.clone());
|
||||
|
@ -228,8 +228,6 @@ mod test {
|
|||
.await
|
||||
.unwrap());
|
||||
|
||||
let tracked_users = store.tracked_users();
|
||||
|
||||
let _ = tracked_users.contains(device.user_id());
|
||||
assert!(store.is_user_tracked(device.user_id()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,8 +143,8 @@ pub trait CryptoStore: Debug {
|
|||
session_id: &str,
|
||||
) -> Result<Option<InboundGroupSession>>;
|
||||
|
||||
/// Get the set of tracked users.
|
||||
fn tracked_users(&self) -> &HashSet<UserId>;
|
||||
/// Is the given user already tracked.
|
||||
fn is_user_tracked(&self, user_id: &UserId) -> bool;
|
||||
|
||||
/// Set of users that we need to query keys for. This is a subset of
|
||||
/// the tracked users.
|
||||
|
|
|
@ -818,8 +818,8 @@ impl CryptoStore for SqliteStore {
|
|||
.get(room_id, sender_key, session_id))
|
||||
}
|
||||
|
||||
fn tracked_users(&self) -> &HashSet<UserId> {
|
||||
&self.tracked_users
|
||||
fn is_user_tracked(&self, user_id: &UserId) -> bool {
|
||||
self.tracked_users.contains(user_id)
|
||||
}
|
||||
|
||||
fn users_for_key_query(&self) -> &HashSet<UserId> {
|
||||
|
@ -1200,9 +1200,7 @@ mod test {
|
|||
.await
|
||||
.unwrap());
|
||||
|
||||
let tracked_users = store.tracked_users();
|
||||
|
||||
assert!(tracked_users.contains(device.user_id()));
|
||||
assert!(store.is_user_tracked(device.user_id()));
|
||||
assert!(!store.users_for_key_query().contains(device.user_id()));
|
||||
assert!(!store
|
||||
.update_tracked_user(device.user_id(), true)
|
||||
|
@ -1217,8 +1215,7 @@ mod test {
|
|||
|
||||
store.load_account().await.unwrap();
|
||||
|
||||
let tracked_users = store.tracked_users();
|
||||
assert!(tracked_users.contains(device.user_id()));
|
||||
assert!(store.is_user_tracked(device.user_id()));
|
||||
assert!(store.users_for_key_query().contains(device.user_id()));
|
||||
|
||||
store
|
||||
|
|
Loading…
Reference in a new issue