diff --git a/backend/canisters/user/CHANGELOG.md b/backend/canisters/user/CHANGELOG.md index 6ab2f84ad8..e5293429d8 100644 --- a/backend/canisters/user/CHANGELOG.md +++ b/backend/canisters/user/CHANGELOG.md @@ -17,6 +17,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Disable notifying about empty users until known empty users deleted ([#5996](https://github.com/open-chat-labs/open-chat/pull/5996)) - Delete user accounts that are empty and dormant ([#5985](https://github.com/open-chat-labs/open-chat/pull/5985)) +### Fixed + +- Fix `streak_ends` and notify `user_index` ([#6002](https://github.com/open-chat-labs/open-chat/pull/6002)) + ## [[2.0.1222](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1222-user)] - 2024-07-03 ### Changed diff --git a/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs b/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs index 13d76decda..37b018e6a8 100644 --- a/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs +++ b/backend/canisters/user/impl/src/lifecycle/post_upgrade.rs @@ -64,8 +64,14 @@ fn fix_achievements(state: &mut RuntimeState) { if lifetime_diamond && state.data.award_achievement(Achievement::UpgradedToGoldDiamond, now) { ic_cdk_timers::set_timer(Duration::ZERO, notify_user_index_of_chit); + return; } } + + if state.data.streak.days(now) > 0 { + // Fix the streak_ends for the user record in the user_index + ic_cdk_timers::set_timer(Duration::ZERO, notify_user_index_of_chit); + } } fn notify_user_index_of_chit() { diff --git a/backend/canisters/user/impl/src/model/streak.rs b/backend/canisters/user/impl/src/model/streak.rs index a47458f40e..69bfc9d594 100644 --- a/backend/canisters/user/impl/src/model/streak.rs +++ b/backend/canisters/user/impl/src/model/streak.rs @@ -22,7 +22,7 @@ impl Streak { } pub fn ends(&self) -> TimestampMillis { - Streak::day_to_timestamp(self.end_day + 1) + Streak::day_to_timestamp(self.end_day + 2) } pub fn claim(&mut self, now: TimestampMillis) -> bool {