From e868ea35df991b80026cb8535586f38c80e4db76 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Tue, 16 Jul 2024 14:50:42 +0100 Subject: [PATCH] Remove deprecated `ChitEarned` event (#6041) --- .../canisters/local_user_index/CHANGELOG.md | 4 +++ .../canisters/local_user_index/api/src/lib.rs | 1 - .../updates/c2c_notify_user_index_events.rs | 11 ------- backend/canisters/user/CHANGELOG.md | 4 +++ backend/canisters/user/api/src/lib.rs | 7 ++-- .../impl/src/updates/c2c_notify_events.rs | 33 +------------------ 6 files changed, 12 insertions(+), 48 deletions(-) diff --git a/backend/canisters/local_user_index/CHANGELOG.md b/backend/canisters/local_user_index/CHANGELOG.md index e2f2d3687c..6f34bfe59c 100644 --- a/backend/canisters/local_user_index/CHANGELOG.md +++ b/backend/canisters/local_user_index/CHANGELOG.md @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Support gates with multiple verifiable credentials ([#6029](https://github.com/open-chat-labs/open-chat/pull/6029)) +### Removed + +- Remove deprecated `ChitEarned` event ([#6041](https://github.com/open-chat-labs/open-chat/pull/6041)) + ## [[2.0.1236](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1236-local_user_index)] - 2024-07-11 ### Changed diff --git a/backend/canisters/local_user_index/api/src/lib.rs b/backend/canisters/local_user_index/api/src/lib.rs index b3daddd17e..3db5858dc1 100644 --- a/backend/canisters/local_user_index/api/src/lib.rs +++ b/backend/canisters/local_user_index/api/src/lib.rs @@ -35,7 +35,6 @@ pub enum Event { UserPrincipalUpdated(UpdateUserPrincipalArgs), DeleteUser(DeleteUser), SecretKeySet(Vec), - ChitEarned(ChitEarned), NotifyUniqueHumanProof(UserId, UniquePersonProof), } diff --git a/backend/canisters/local_user_index/impl/src/updates/c2c_notify_user_index_events.rs b/backend/canisters/local_user_index/impl/src/updates/c2c_notify_user_index_events.rs index bcf873ef8a..00f2f5ae57 100644 --- a/backend/canisters/local_user_index/impl/src/updates/c2c_notify_user_index_events.rs +++ b/backend/canisters/local_user_index/impl/src/updates/c2c_notify_user_index_events.rs @@ -6,7 +6,6 @@ use local_user_index_canister::c2c_notify_user_index_events::{Response::*, *}; use local_user_index_canister::Event; use std::cmp::min; use tracing::info; -use types::ChitEarned; use user_canister::{ DiamondMembershipPaymentReceived, DisplayNameChanged, Event as UserEvent, OpenChatBotMessageV2, PhoneNumberConfirmed, ReferredUserRegistered, StorageUpgraded, UserJoinedCommunityOrChannel, UserJoinedGroup, UserSuspended, UsernameChanged, @@ -180,16 +179,6 @@ fn handle_event(event: Event, state: &mut RuntimeState) { Event::SecretKeySet(sk_der) => { state.data.oc_secret_key_der = Some(sk_der); } - Event::ChitEarned(ev) => { - state.push_event_to_user( - ev.user_id, - UserEvent::ChitEarned(Box::new(ChitEarned { - amount: ev.amount, - timestamp: ev.timestamp, - reason: ev.reason, - })), - ); - } Event::NotifyUniqueHumanProof(user_id, proof) => { state.data.global_users.insert_unique_person_proof(user_id, proof); } diff --git a/backend/canisters/user/CHANGELOG.md b/backend/canisters/user/CHANGELOG.md index c01ab1f18c..d9b887647b 100644 --- a/backend/canisters/user/CHANGELOG.md +++ b/backend/canisters/user/CHANGELOG.md @@ -11,6 +11,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Added lots more achievements to enum ([#6020](https://github.com/open-chat-labs/open-chat/pull/6020)) - Added support for a bunch more achievements ([#6033](https://github.com/open-chat-labs/open-chat/pull/6033)) +### Removed + +- Remove deprecated `ChitEarned` event ([#6041](https://github.com/open-chat-labs/open-chat/pull/6041)) + ## [[2.0.1230](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1230-user)] - 2024-07-08 ### Added diff --git a/backend/canisters/user/api/src/lib.rs b/backend/canisters/user/api/src/lib.rs index 372866291b..2166b3ebfe 100644 --- a/backend/canisters/user/api/src/lib.rs +++ b/backend/canisters/user/api/src/lib.rs @@ -3,9 +3,9 @@ use chat_events::MessageContentInternal; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use types::{ - CanisterId, ChannelId, ChannelLatestMessageIndex, Chat, ChatId, ChitEarned, CommunityId, Cryptocurrency, - DiamondMembershipPlanDuration, EventIndex, MessageContent, MessageContentInitial, MessageId, MessageIndex, Milliseconds, - P2PSwapStatus, PhoneNumber, Reaction, SuspensionDuration, TimestampMillis, User, UserId, + CanisterId, ChannelId, ChannelLatestMessageIndex, Chat, ChatId, CommunityId, Cryptocurrency, DiamondMembershipPlanDuration, + EventIndex, MessageContent, MessageContentInitial, MessageId, MessageIndex, Milliseconds, P2PSwapStatus, PhoneNumber, + Reaction, SuspensionDuration, TimestampMillis, User, UserId, }; mod lifecycle; @@ -97,7 +97,6 @@ pub enum Event { UserJoinedGroup(Box), UserJoinedCommunityOrChannel(Box), DiamondMembershipPaymentReceived(Box), - ChitEarned(Box), } #[derive(Serialize, Deserialize, Clone, Debug)] diff --git a/backend/canisters/user/impl/src/updates/c2c_notify_events.rs b/backend/canisters/user/impl/src/updates/c2c_notify_events.rs index be4fb5facc..df55d40740 100644 --- a/backend/canisters/user/impl/src/updates/c2c_notify_events.rs +++ b/backend/canisters/user/impl/src/updates/c2c_notify_events.rs @@ -2,7 +2,7 @@ use crate::guards::caller_is_local_user_index; use crate::{mutate_state, openchat_bot, RuntimeState}; use canister_api_macros::update_msgpack; use canister_tracing_macros::trace; -use types::{Achievement, ChitEarnedReason, DiamondMembershipPlanDuration, MessageContentInitial, Timestamped}; +use types::{Achievement, DiamondMembershipPlanDuration, MessageContentInitial, Timestamped}; use user_canister::c2c_notify_events::{Response::*, *}; use user_canister::mark_read::ChannelMessagesRead; use user_canister::Event; @@ -102,36 +102,5 @@ fn process_event(event: Event, state: &mut RuntimeState) { ); } } - // TODO: LEGACY - delete this once the website has switched to calling the new user::claim_daily_chit endpoint - Event::ChitEarned(ev) => { - let timestamp = ev.timestamp; - let is_daily_claim = matches!(ev.reason, ChitEarnedReason::DailyClaim); - - state.data.chit_balance = Timestamped::new(state.data.chit_balance.value + ev.amount, now); - - state.data.chit_events.push(*ev); - - if is_daily_claim && state.data.streak.claim(timestamp) { - let streak = state.data.streak.days(timestamp); - - if streak >= 3 { - state.data.award_achievement(Achievement::Streak3, now); - } - - if streak >= 7 { - state.data.award_achievement(Achievement::Streak7, now); - } - - if streak >= 14 { - state.data.award_achievement(Achievement::Streak14, now); - } - - if streak >= 30 { - state.data.award_achievement(Achievement::Streak30, now); - } - } - - state.data.notify_user_index_of_chit(now); - } } }