Skip to content

Commit

Permalink
Ensure user has never joined a group or community before marking empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Aug 2, 2024
1 parent 936748a commit 32ea3b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/canisters/user/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ fn post_upgrade(args: Args) {
&& state.data.communities.len() == 0
&& state.data.diamond_membership_expires_at.is_none()
&& state.data.unique_person_proof.is_none()
&& state.data.group_chats.removed_len() == 0
&& state.data.communities.removed_len() == 0
{
let now = state.env.now();
if state.data.user_created + SIX_MONTHS < now && state.data.chit_events.last_updated() + SIX_MONTHS < now {
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user/impl/src/model/communities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ impl Communities {
self.communities.len()
}

pub fn removed_len(&self) -> usize {
self.removed.len()
}

fn next_index(&self) -> u32 {
self.communities.values().map(|c| c.index.value).max().unwrap_or_default() + 1
}
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user/impl/src/model/group_chats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ impl GroupChats {
self.group_chats.len()
}

pub fn removed_len(&self) -> usize {
self.removed.len()
}

pub fn pin(&mut self, chat_id: ChatId, now: TimestampMillis) {
if !self.pinned.value.contains(&chat_id) {
self.pinned.timestamp = now;
Expand Down

0 comments on commit 32ea3b9

Please sign in to comment.