diff --git a/backend/canisters/user/CHANGELOG.md b/backend/canisters/user/CHANGELOG.md index 368974384c..9d00b748be 100644 --- a/backend/canisters/user/CHANGELOG.md +++ b/backend/canisters/user/CHANGELOG.md @@ -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 diff --git a/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs b/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs index c6306514cd..f48bf922da 100644 --- a/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs +++ b/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs @@ -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); + } } }); }