Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated ChitEarned event #6041

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion backend/canisters/local_user_index/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ pub enum Event {
UserPrincipalUpdated(UpdateUserPrincipalArgs),
DeleteUser(DeleteUser),
SecretKeySet(Vec<u8>),
ChitEarned(ChitEarned),
NotifyUniqueHumanProof(UserId, UniquePersonProof),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions backend/canisters/user/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -97,7 +97,6 @@ pub enum Event {
UserJoinedGroup(Box<UserJoinedGroup>),
UserJoinedCommunityOrChannel(Box<UserJoinedCommunityOrChannel>),
DiamondMembershipPaymentReceived(Box<DiamondMembershipPaymentReceived>),
ChitEarned(Box<ChitEarned>),
}

#[derive(Serialize, Deserialize, Clone, Debug)]
Expand Down
33 changes: 1 addition & 32 deletions backend/canisters/user/impl/src/updates/c2c_notify_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Loading