Skip to content

Commit

Permalink
Improve check for empty and dormant users (#6073)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jul 19, 2024
1 parent 1787a2e commit 4c7afb8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Changed

- Improve check for empty and dormant users ([#6073](https://github.com/open-chat-labs/open-chat/pull/6073))

## [[2.0.1243](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1243-user)] - 2024-07-17

### Changed
Expand Down
10 changes: 7 additions & 3 deletions backend/canisters/user/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ fn post_upgrade(args: Args) {
info!(version = %args.wasm_version, "Post-upgrade complete");

read_state(|state| {
if state.data.user_created + SIX_MONTHS < state.env.now()
&& state.data.direct_chats.len() <= 1
if state.data.direct_chats.len() <= 1
&& state.data.group_chats.len() == 0
&& state.data.communities.len() == 0
&& state.data.diamond_membership_expires_at.is_none()
&& state.data.unique_person_proof.is_none()
{
ic_cdk_timers::set_timer(Duration::ZERO, mark_user_canister_empty);
let now = state.env.now();
if state.data.user_created + SIX_MONTHS < now && state.data.chit_balance.timestamp + SIX_MONTHS < now {
ic_cdk_timers::set_timer(Duration::ZERO, mark_user_canister_empty);
}
}
});
}
Expand Down

0 comments on commit 4c7afb8

Please sign in to comment.