diff --git a/presage-store-sled/src/lib.rs b/presage-store-sled/src/lib.rs
index d603d17aa..b51ff2f2d 100644
--- a/presage-store-sled/src/lib.rs
+++ b/presage-store-sled/src/lib.rs
@@ -27,7 +27,7 @@ use presage::libsignal_service::{
Profile, ServiceAddress,
};
use presage::store::{ContentExt, ContentsStore, StateStore, Store, Thread};
-use presage::{manager::RegistrationData, proto::verified};
+use presage::{manager::RegistrationData, proto::verified, AvatarBytes};
use prost::Message;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use sha2::{Digest, Sha256};
@@ -42,6 +42,7 @@ pub use error::SledStoreError;
const SLED_TREE_CONTACTS: &str = "contacts";
const SLED_TREE_GROUPS: &str = "groups";
+const SLED_TREE_GROUP_AVATARS: &str = "group_avatars";
const SLED_TREE_IDENTITIES: &str = "identities";
const SLED_TREE_PRE_KEYS: &str = "pre_keys";
const SLED_TREE_SENDER_KEYS: &str = "sender_keys";
@@ -51,6 +52,7 @@ const SLED_TREE_KYBER_PRE_KEYS: &str = "kyber_pre_keys";
const SLED_TREE_STATE: &str = "state";
const SLED_TREE_THREADS_PREFIX: &str = "threads";
const SLED_TREE_PROFILES: &str = "profiles";
+const SLED_TREE_PROFILE_AVATARS: &str = "profile_avatars";
const SLED_TREE_PROFILE_KEYS: &str = "profile_keys";
const SLED_KEY_NEXT_SIGNED_PRE_KEY_ID: &str = "next_signed_pre_key_id";
@@ -93,11 +95,13 @@ pub enum SchemaVersion {
V1 = 1,
V2 = 2,
V3 = 3,
+ // Introduction of avatars, requires dropping all profiles from the cache
+ V4 = 4,
}
impl SchemaVersion {
fn current() -> SchemaVersion {
- Self::V3
+ Self::V4
}
/// return an iterator on all the necessary migration steps from another version
@@ -110,6 +114,7 @@ impl SchemaVersion {
1 => SchemaVersion::V1,
2 => SchemaVersion::V2,
3 => SchemaVersion::V3,
+ 4 => SchemaVersion::V4,
_ => unreachable!("oops, this not supposed to happen!"),
})
}
@@ -347,6 +352,12 @@ fn migrate(
db.drop_tree(SLED_TREE_GROUPS)?;
db.flush()?;
}
+ SchemaVersion::V4 => {
+ debug!("migrating from schema v3 to v4: dropping profile cache");
+ let db = store.write();
+ db.drop_tree(SLED_TREE_PROFILES)?;
+ db.flush()?;
+ }
_ => return Err(SledStoreError::MigrationConflict),
}
@@ -482,6 +493,22 @@ impl ContentsStore for SledStore {
Ok(())
}
+ fn group_avatar(
+ &self,
+ master_key_bytes: GroupMasterKeyBytes,
+ ) -> Result