diff --git a/backend/canisters/community/impl/src/lib.rs b/backend/canisters/community/impl/src/lib.rs index 56ff187857..6191904f57 100644 --- a/backend/canisters/community/impl/src/lib.rs +++ b/backend/canisters/community/impl/src/lib.rs @@ -332,9 +332,9 @@ struct Data { description: Timestamped, #[serde(deserialize_with = "deserialize_maybe_timestamped")] rules: Timestamped, - #[serde(deserialize_with = "deserialize_maybe_timestamped")] + #[serde(deserialize_with = "deserialize_optional_document")] avatar: Timestamped>, - #[serde(deserialize_with = "deserialize_maybe_timestamped")] + #[serde(deserialize_with = "deserialize_optional_document")] banner: Timestamped>, #[serde(deserialize_with = "deserialize_maybe_timestamped")] permissions: Timestamped, @@ -965,3 +965,8 @@ pub struct AddUsersToChannelResult { pub users_already_in_channel: Vec, pub users_limit_reached: Vec, } + +fn deserialize_optional_document<'de, D: Deserializer<'de>>(d: D) -> Result>, D::Error> { + let document = Option::deserialize(d)?; + Ok(Timestamped::new(document, now_millis())) +} diff --git a/backend/integration_tests/src/communities/delete_channel_tests.rs b/backend/integration_tests/src/communities/delete_channel_tests.rs index 1393f7dc5f..ceed82ff09 100644 --- a/backend/integration_tests/src/communities/delete_channel_tests.rs +++ b/backend/integration_tests/src/communities/delete_channel_tests.rs @@ -94,7 +94,7 @@ fn stable_memory_garbage_collected_after_deleting_channel() { assert_eq!( get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(), - 87 + 88 ); client::community::happy_path::delete_channel(env, user1.principal, community_id, channel_id2); @@ -102,7 +102,7 @@ fn stable_memory_garbage_collected_after_deleting_channel() { env.advance_time(Duration::from_secs(60)); env.tick(); - assert_eq!(get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(), 3); + assert_eq!(get_stable_memory_map(env, community_id, STABLE_MEMORY_MAP_MEMORY_ID).len(), 4); } fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Principal) -> TestData {