Skip to content

Commit

Permalink
Remove code needed to initialise local_user_index_canister_id values (
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 11, 2023
1 parent 6bc3617 commit ac5f7f3
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 565 deletions.
1 change: 1 addition & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Removed

- Removed `local_user_index` endpoint since that is now included in the summary ([#4977](https://github.com/open-chat-labs/open-chat/pull/4977))
- Remove code needed to initialise `local_user_index_canister_id` values ([#4981](https://github.com/open-chat-labs/open-chat/pull/4981))

### Fixed

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

- Removed `local_user_index` endpoint since that is now included in the summary ([#4977](https://github.com/open-chat-labs/open-chat/pull/4977))
- Remove code needed to initialise `local_user_index_canister_id` values ([#4981](https://github.com/open-chat-labs/open-chat/pull/4981))

### Fixed

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

## [unreleased]

### Removed

- Remove code needed to initialise `local_user_index_canister_id` values ([#4981](https://github.com/open-chat-labs/open-chat/pull/4981))

## [[2.0.951](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.951-group_index)] - 2023-11-28

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use candid::CandidType;
use serde::{Deserialize, Serialize};
use types::{local_user_index_canister_id, AccessGate, CanisterId, CommunityId, CommunityPermissions, Document, Rules};
use types::{AccessGate, CanisterId, CommunityId, CommunityPermissions, Document, Rules};

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct Args {
Expand All @@ -27,22 +27,7 @@ pub enum Response {
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
#[serde(from = "SuccessResultPrevious")]
pub struct SuccessResult {
pub community_id: CommunityId,
pub local_user_index_canister_id: CanisterId,
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct SuccessResultPrevious {
pub community_id: CommunityId,
}

impl From<SuccessResultPrevious> for SuccessResult {
fn from(value: SuccessResultPrevious) -> Self {
SuccessResult {
community_id: value.community_id,
local_user_index_canister_id: local_user_index_canister_id(value.community_id.into()),
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use candid::CandidType;
use serde::{Deserialize, Serialize};
use types::{
local_user_index_canister_id, AccessGate, CanisterId, ChatId, Document, GroupPermissions, GroupSubtype, Milliseconds, Rules,
};
use types::{AccessGate, CanisterId, ChatId, Document, GroupPermissions, GroupSubtype, Milliseconds, Rules};

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct Args {
Expand All @@ -28,22 +26,7 @@ pub enum Response {
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
#[serde(from = "SuccessResultPrevious")]
pub struct SuccessResult {
pub chat_id: ChatId,
pub local_user_index_canister_id: CanisterId,
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct SuccessResultPrevious {
pub chat_id: ChatId,
}

impl From<SuccessResultPrevious> for SuccessResult {
fn from(value: SuccessResultPrevious) -> Self {
SuccessResult {
chat_id: value.chat_id,
local_user_index_canister_id: local_user_index_canister_id(value.chat_id.into()),
}
}
}
35 changes: 2 additions & 33 deletions backend/canisters/group_index/impl/src/model/cached_hot_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use tracing::trace;
use types::{
local_user_index_canister_id, AccessGate, CanisterId, ChatId, EventIndex, EventWrapper, Message, MessageIndex,
Milliseconds, PublicGroupSummary, TimestampMillis,
AccessGate, CanisterId, ChatId, EventIndex, EventWrapper, Message, MessageIndex, Milliseconds, PublicGroupSummary,
TimestampMillis,
};

#[derive(Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -37,7 +37,6 @@ impl CachedHotGroups {
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(from = "CachedPublicGroupSummaryPrevious")]
pub struct CachedPublicGroupSummary {
pub chat_id: ChatId,
pub local_user_index_canister_id: CanisterId,
Expand All @@ -51,36 +50,6 @@ pub struct CachedPublicGroupSummary {
pub gate: Option<AccessGate>,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CachedPublicGroupSummaryPrevious {
pub chat_id: ChatId,
pub last_updated: TimestampMillis,
pub latest_message: Option<EventWrapper<Message>>,
pub latest_event_index: EventIndex,
pub latest_message_index: Option<MessageIndex>,
pub participant_count: u32,
pub events_ttl: Option<Milliseconds>,
pub events_ttl_last_updated: TimestampMillis,
pub gate: Option<AccessGate>,
}

impl From<CachedPublicGroupSummaryPrevious> for CachedPublicGroupSummary {
fn from(value: CachedPublicGroupSummaryPrevious) -> Self {
CachedPublicGroupSummary {
chat_id: value.chat_id,
local_user_index_canister_id: local_user_index_canister_id(value.chat_id.into()),
last_updated: value.last_updated,
latest_message: value.latest_message,
latest_event_index: value.latest_event_index,
latest_message_index: value.latest_message_index,
participant_count: value.participant_count,
events_ttl: value.events_ttl,
events_ttl_last_updated: value.events_ttl_last_updated,
gate: value.gate,
}
}
}

impl From<PublicGroupSummary> for CachedPublicGroupSummary {
fn from(summary: PublicGroupSummary) -> Self {
CachedPublicGroupSummary {
Expand Down
4 changes: 4 additions & 0 deletions backend/canisters/local_group_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Removed

- Remove code needed to initialise `local_user_index_canister_id` values ([#4981](https://github.com/open-chat-labs/open-chat/pull/4981))

## [[2.0.954](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.954-local_group_index)] - 2023-12-01

### Changed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use candid::Principal;
use serde::{Deserialize, Serialize};
use types::{
local_user_index_canister_id, AccessGate, CanisterId, CommunityId, CommunityPermissions, Document, Rules, SourceGroup,
UserId,
};
use types::{AccessGate, CanisterId, CommunityId, CommunityPermissions, Document, Rules, SourceGroup, UserId};

#[derive(Serialize, Deserialize, Debug)]
pub struct Args {
Expand Down Expand Up @@ -31,22 +28,7 @@ pub enum Response {
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(from = "SuccessResultPrevious")]
pub struct SuccessResult {
pub community_id: CommunityId,
pub local_user_index_canister_id: CanisterId,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct SuccessResultPrevious {
pub community_id: CommunityId,
}

impl From<SuccessResultPrevious> for SuccessResult {
fn from(value: SuccessResultPrevious) -> Self {
SuccessResult {
community_id: value.community_id,
local_user_index_canister_id: local_user_index_canister_id(value.community_id.into()),
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};
use types::{
local_user_index_canister_id, AccessGate, CanisterId, ChatId, Document, GroupPermissions, GroupSubtype, Milliseconds,
Rules, UserId,
};
use types::{AccessGate, CanisterId, ChatId, Document, GroupPermissions, GroupSubtype, Milliseconds, Rules, UserId};

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct Args {
Expand Down Expand Up @@ -33,17 +30,3 @@ pub struct SuccessResult {
pub chat_id: ChatId,
pub local_user_index_canister_id: CanisterId,
}

#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct SuccessResultPrevious {
pub chat_id: ChatId,
}

impl From<SuccessResultPrevious> for SuccessResult {
fn from(value: SuccessResultPrevious) -> Self {
SuccessResult {
chat_id: value.chat_id,
local_user_index_canister_id: local_user_index_canister_id(value.chat_id.into()),
}
}
}
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 @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [unreleased]

### Removed

- Remove code needed to initialise `local_user_index_canister_id` values ([#4981](https://github.com/open-chat-labs/open-chat/pull/4981))

## [[2.0.959](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.959-local_user_index)] - 2023-12-05

### Added
Expand Down
43 changes: 2 additions & 41 deletions backend/canisters/local_user_index/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use candid::{CandidType, Principal};
use serde::{Deserialize, Serialize};
use types::nns::CryptoAmount;
use types::{
local_user_index_canister_id, CanisterId, ChannelLatestMessageIndex, ChatId, CommunityId, Cryptocurrency,
DiamondMembershipPlanDuration, MessageContent, MessageIndex, PhoneNumber, ReferralType, SuspensionDuration,
TimestampMillis, UserId,
CanisterId, ChannelLatestMessageIndex, ChatId, CommunityId, Cryptocurrency, DiamondMembershipPlanDuration, MessageContent,
MessageIndex, PhoneNumber, ReferralType, SuspensionDuration, TimestampMillis, UserId,
};

mod lifecycle;
Expand Down Expand Up @@ -96,7 +95,6 @@ pub struct UserSuspended {
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(from = "UserJoinedGroupPrevious")]
pub struct UserJoinedGroup {
pub user_id: UserId,
pub chat_id: ChatId,
Expand All @@ -105,50 +103,13 @@ pub struct UserJoinedGroup {
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct UserJoinedGroupPrevious {
pub user_id: UserId,
pub chat_id: ChatId,
pub latest_message_index: Option<MessageIndex>,
}

impl From<UserJoinedGroupPrevious> for UserJoinedGroup {
fn from(value: UserJoinedGroupPrevious) -> Self {
UserJoinedGroup {
user_id: value.user_id,
chat_id: value.chat_id,
local_user_index_canister_id: local_user_index_canister_id(value.chat_id.into()),
latest_message_index: value.latest_message_index,
}
}
}

#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(from = "UserJoinedCommunityOrChannelPrevious")]
pub struct UserJoinedCommunityOrChannel {
pub user_id: UserId,
pub community_id: CommunityId,
pub local_user_index_canister_id: CanisterId,
pub channels: Vec<ChannelLatestMessageIndex>,
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct UserJoinedCommunityOrChannelPrevious {
pub user_id: UserId,
pub community_id: CommunityId,
pub channels: Vec<ChannelLatestMessageIndex>,
}

impl From<UserJoinedCommunityOrChannelPrevious> for UserJoinedCommunityOrChannel {
fn from(value: UserJoinedCommunityOrChannelPrevious) -> Self {
UserJoinedCommunityOrChannel {
user_id: value.user_id,
community_id: value.community_id,
local_user_index_canister_id: local_user_index_canister_id(value.community_id.into()),
channels: value.channels,
}
}
}

#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct DiamondMembershipPaymentReceived {
pub user_id: UserId,
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 @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Log error if any steps during a swap fail ([#4972](https://github.com/open-chat-labs/open-chat/pull/4972))
- Expose logs of swaps ([#4980](https://github.com/open-chat-labs/open-chat/pull/4980))

### Removed

- Remove code needed to initialise `local_user_index_canister_id` values ([#4981](https://github.com/open-chat-labs/open-chat/pull/4981))

## [[2.0.963](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.963-user)] - 2023-12-05

### Changed
Expand Down
38 changes: 2 additions & 36 deletions backend/canisters/user/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use candid::CandidType;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use types::{
local_user_index_canister_id, CanisterId, ChannelId, ChannelLatestMessageIndex, Chat, ChatId, CommunityId, Cryptocurrency,
DiamondMembershipPlanDuration, MessageContent, MessageIndex, PhoneNumber, SuspensionDuration, TimestampMillis, UserId,
CanisterId, ChannelId, ChannelLatestMessageIndex, Chat, ChatId, CommunityId, Cryptocurrency, DiamondMembershipPlanDuration,
MessageContent, MessageIndex, PhoneNumber, SuspensionDuration, TimestampMillis, UserId,
};

mod lifecycle;
Expand Down Expand Up @@ -133,53 +133,19 @@ pub struct UserSuspended {
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
#[serde(from = "UserJoinedGroupPrevious")]
pub struct UserJoinedGroup {
pub chat_id: ChatId,
pub local_user_index_canister_id: CanisterId,
pub latest_message_index: Option<MessageIndex>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct UserJoinedGroupPrevious {
pub chat_id: ChatId,
pub latest_message_index: Option<MessageIndex>,
}

impl From<UserJoinedGroupPrevious> for UserJoinedGroup {
fn from(value: UserJoinedGroupPrevious) -> Self {
UserJoinedGroup {
chat_id: value.chat_id,
local_user_index_canister_id: local_user_index_canister_id(value.chat_id.into()),
latest_message_index: value.latest_message_index,
}
}
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
#[serde(from = "UserJoinedCommunityOrChannelPrevious")]
pub struct UserJoinedCommunityOrChannel {
pub community_id: CommunityId,
pub local_user_index_canister_id: CanisterId,
pub channels: Vec<ChannelLatestMessageIndex>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct UserJoinedCommunityOrChannelPrevious {
pub community_id: CommunityId,
pub channels: Vec<ChannelLatestMessageIndex>,
}

impl From<UserJoinedCommunityOrChannelPrevious> for UserJoinedCommunityOrChannel {
fn from(value: UserJoinedCommunityOrChannelPrevious) -> Self {
UserJoinedCommunityOrChannel {
community_id: value.community_id,
local_user_index_canister_id: local_user_index_canister_id(value.community_id.into()),
channels: value.channels,
}
}
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct DiamondMembershipPaymentReceived {
pub timestamp: TimestampMillis,
Expand Down
Loading

0 comments on commit ac5f7f3

Please sign in to comment.