Skip to content

Commit

Permalink
Update canisters post release (#6527)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Oct 8, 2024
1 parent deaa889 commit 8585e6e
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 71 deletions.
2 changes: 2 additions & 0 deletions backend/canisters/identity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1373](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1373-identity)] - 2024-10-07

### Changed

- Increase max stable memory read / write buffer size ([#6440](https://github.com/open-chat-labs/open-chat/pull/6440))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::{read_state, Data};
use crate::Data;
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use ic_cdk::post_upgrade;
Expand All @@ -24,9 +24,4 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

info!(version = %args.wasm_version, "Post-upgrade complete");

read_state(|state| {
let missing_principal_links = state.data.user_principals.count_missing_principal_links();
info!("Missing principal links: {missing_principal_links}");
})
}
12 changes: 0 additions & 12 deletions backend/canisters/identity/impl/src/model/user_principals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,6 @@ struct AuthPrincipalInternal {
}

impl UserPrincipals {
pub fn count_missing_principal_links(&self) -> u32 {
let mut count = 0;
for (principal, details) in self.auth_principals.iter() {
if let Some(user_principal) = self.user_principals.get(details.user_principal_index as usize) {
if !user_principal.auth_principals.contains(principal) {
count += 1;
}
}
}
count
}

pub fn push(
&mut self,
index: u32,
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1372](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1372-local_user_index)] - 2024-10-07

### Changed

- Add `CanisterWasmBytes` to reduce duplication ([#6480](https://github.com/open-chat-labs/open-chat/pull/6480))
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/proposal_validation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1375](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1375-proposal_validation)] - 2024-10-07

## [[2.0.1123](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1123-proposal_validation)] - 2024-03-27

### Added
Expand Down
2 changes: 2 additions & 0 deletions backend/canisters/user/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1374](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1374-user)] - 2024-10-07

### Added

- Allow changing PIN number if signed in within last 5 minutes ([#6459](https://github.com/open-chat-labs/open-chat/pull/6459))
Expand Down
21 changes: 1 addition & 20 deletions backend/canisters/user/impl/src/lifecycle/post_upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use crate::lifecycle::{init_env, init_state};
use crate::memory::get_upgrades_memory;
use crate::{mutate_state, Data};
use candid::Principal;
use crate::Data;
use canister_logger::LogEntry;
use canister_tracing_macros::trace;
use chat_events::OPENCHAT_BOT_USER_ID;
use ic_cdk::post_upgrade;
use stable_memory::get_reader;
use tracing::info;
Expand All @@ -24,21 +22,4 @@ fn post_upgrade(args: Args) {
init_state(env, data, args.wasm_version);

info!(version = %args.wasm_version, "Post-upgrade complete");

let oc_controlled_bots = [
OPENCHAT_BOT_USER_ID, // OC Bot
Principal::from_text("62rh2-kiaaa-aaaaf-bmy5q-cai").unwrap().into(), // AirdropBot
Principal::from_text("iywa7-ayaaa-aaaaf-aemga-cai").unwrap().into(), // ProposalsBot
];

mutate_state(|state| {
for chat in state.data.direct_chats.iter_mut() {
chat.events.populate_search_index();
}

state
.data
.direct_chats
.set_user_type_for_oc_controlled_bots(&oc_controlled_bots);
});
}
4 changes: 0 additions & 4 deletions backend/canisters/user/impl/src/model/direct_chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ pub struct DirectChat {
}

impl DirectChat {
pub fn set_user_as_ic_controlled_bot(&mut self) {
self.user_type = UserType::OcControlledBot;
}

pub fn new(
them: UserId,
user_type: UserType,
Expand Down
8 changes: 0 additions & 8 deletions backend/canisters/user/impl/src/model/direct_chats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ pub struct DirectChats {
}

impl DirectChats {
pub fn set_user_type_for_oc_controlled_bots(&mut self, oc_controlled_bots: &[UserId]) {
for user_id in oc_controlled_bots {
if let Some(chat) = self.direct_chats.get_mut(&ChatId::from(*user_id)) {
chat.set_user_as_ic_controlled_bot();
}
}
}

pub fn get(&self, chat_id: &ChatId) -> Option<&DirectChat> {
self.direct_chats.get(chat_id)
}
Expand Down
10 changes: 0 additions & 10 deletions backend/canisters/user/impl/src/token_swaps/swap_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,7 @@ pub trait SwapClient {
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(from = "u128")]
pub struct SwapSuccess {
pub amount_out: u128,
pub withdrawal_success: Option<bool>,
}

impl From<u128> for SwapSuccess {
fn from(value: u128) -> Self {
SwapSuccess {
amount_out: value,
withdrawal_success: None,
}
}
}
2 changes: 2 additions & 0 deletions backend/canisters/user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

## [[2.0.1371](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1371-user_index)] - 2024-10-07

### Changed

- Clear wasm chunks once new wasm version has been set ([#6524](https://github.com/open-chat-labs/open-chat/pull/6524))
Expand Down
11 changes: 0 additions & 11 deletions backend/libraries/chat_events/src/chat_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,6 @@ pub struct ChatEvents {
}

impl ChatEvents {
// TODO remove this
pub fn populate_search_index(&mut self) {
for event in self.main.iter(None, true, EventIndex::default()) {
if let EventOrExpiredRangeInternal::Event(e) = event {
if let ChatEventInternal::Message(m) = &e.event {
self.search_index.push(m.message_index, m.sender, Document::from(&m.content));
}
}
}
}

pub fn new_direct_chat(
them: UserId,
events_ttl: Option<Milliseconds>,
Expand Down

0 comments on commit 8585e6e

Please sign in to comment.