Skip to content

Remove legacy group membership fields from backend #8508

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Support muting of @everyone notifications ([#8496](https://github.com/open-chat-labs/open-chat/pull/8496))
- Support muted=false && @everyone_muted=true ([#8502](https://github.com/open-chat-labs/open-chat/pull/8502))
- Remove legacy group membership fields from backend ([#8508](https://github.com/open-chat-labs/open-chat/pull/8508))

### 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 @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Support muting of @everyone notifications ([#8496](https://github.com/open-chat-labs/open-chat/pull/8496))
- Support muted=false && @everyone_muted=true ([#8502](https://github.com/open-chat-labs/open-chat/pull/8502))
- Remove legacy group membership fields from backend ([#8508](https://github.com/open-chat-labs/open-chat/pull/8508))

### Fixed

Expand Down
7 changes: 0 additions & 7 deletions backend/canisters/group/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,15 @@ impl RuntimeState {
latest_message: main_events_reader.latest_message_event(Some(member.user_id())),
latest_event_index: main_events_reader.latest_event_index().unwrap_or_default(),
latest_message_index: main_events_reader.latest_message_index(),
joined: membership.joined,
participant_count: chat.members.len(),
role: membership.role,
mentions: membership.mentions.clone(),
permissions_v2: chat.permissions.value.clone(),
notifications_muted: membership.notifications_muted,
metrics: chat.events.metrics().hydrate(),
my_metrics: membership.my_metrics.clone(),
latest_threads: membership.latest_threads.clone(),
frozen: self.data.frozen.value.clone(),
wasm_version: BuildVersion::default(),
date_last_pinned: chat.date_last_pinned,
events_ttl: events_ttl.value,
events_ttl_last_updated: events_ttl.timestamp,
gate_config: chat.gate_config.value.clone().map(|gc| gc.into()),
rules_accepted: membership.rules_accepted,
membership: Some(membership),
video_call_in_progress: chat.events.video_call_in_progress(Some(member.user_id())),
verified: self.data.verified.value,
Expand Down
7 changes: 0 additions & 7 deletions backend/canisters/group/impl/src/queries/summary_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,11 @@ fn summary_updates_impl(updates_since: TimestampMillis, on_behalf_of: Option<Pri
latest_event_index: updates.latest_event_index,
latest_message_index: updates.latest_message_index,
participant_count: updates.member_count,
role: membership.role,
mentions: membership.mentions.clone(),
permissions_v2: updates.permissions,
updated_events: updates.updated_events,
metrics: Some(chat.events.metrics().hydrate()),
my_metrics: membership.my_metrics.clone(),
is_public: updates.is_public,
messages_visible_to_non_members: updates.messages_visible_to_non_members,
latest_threads: membership.latest_threads.clone(),
unfollowed_threads: membership.unfollowed_threads.clone(),
notifications_muted: membership.notifications_muted,
frozen: state
.data
.frozen
Expand All @@ -106,7 +100,6 @@ fn summary_updates_impl(updates_since: TimestampMillis, on_behalf_of: Option<Pri
events_ttl: updates.events_ttl,
events_ttl_last_updated: updates.events_ttl_last_updated,
gate_config: updates.gate_config,
rules_accepted: membership.rules_accepted,
membership: Some(membership),
video_call_in_progress: updates.video_call_in_progress,
any_updates_missed: updates.any_updates_missed,
Expand Down
1 change: 1 addition & 0 deletions backend/canisters/local_user_index/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Temporarily remove check that user has recently signed in ([#8497](https://github.com/open-chat-labs/open-chat/pull/8497))
- Support muting of @everyone notifications ([#8502](https://github.com/open-chat-labs/open-chat/pull/8502))
- Remove legacy group membership fields from backend ([#8508](https://github.com/open-chat-labs/open-chat/pull/8508))

## [[2.0.1862](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1862-local_user_index)] - 2025-08-12

Expand Down
11 changes: 2 additions & 9 deletions backend/canisters/user/api/src/queries/initial_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use candid::CandidType;
use serde::{Deserialize, Serialize};
use ts_export::ts_export;
use types::{
CanisterId, Chat, ChatId, ChitEvent, DirectChatSummary, Empty, GroupChatSummary, InstalledBotDetails, PinNumberSettings,
StreakInsurance, TimestampMillis, UserId,
CanisterId, Chat, ChatId, ChitEvent, DirectChatSummary, Empty, InstalledBotDetails, PinNumberSettings, StreakInsurance,
TimestampMillis, UserId,
};

pub type Args = Empty;
Expand Down Expand Up @@ -61,13 +61,6 @@ pub struct GroupChatsInitial {
pub pinned: Vec<ChatId>,
}

#[ts_export(user, initial_state)]
#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct CachedGroupChatSummaries {
pub summaries: Vec<GroupChatSummary>,
pub timestamp: TimestampMillis,
}

#[ts_export(user, initial_state)]
#[derive(CandidType, Serialize, Deserialize, Debug)]
pub struct CommunitiesInitial {
Expand Down
4 changes: 2 additions & 2 deletions backend/integration_tests/src/change_group_role_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ fn owner_can_promote_to_and_demote_from_owner() {
client::group::happy_path::change_role(env, user1.principal, group_id, user2.user_id, GroupRole::Owner);

let summary1 = client::group::happy_path::summary(env, user2.principal, group_id);
assert!(matches!(summary1.role, GroupRole::Owner));
assert!(matches!(summary1.membership.unwrap().role, GroupRole::Owner));

client::group::happy_path::change_role(env, user1.principal, group_id, user2.user_id, GroupRole::Admin);

let summary1 = client::group::happy_path::summary(env, user2.principal, group_id);
assert!(matches!(summary1.role, GroupRole::Admin));
assert!(matches!(summary1.membership.unwrap().role, GroupRole::Admin));
}

fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Principal) -> TestData {
Expand Down
22 changes: 13 additions & 9 deletions backend/integration_tests/src/mentions_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ fn mention_users_succeeds(mention_everyone: bool) {
));

let user2_summary = client::group::happy_path::summary(env, user2.principal, group_id);
assert_eq!(user2_summary.mentions.len(), 1);
let mention = user2_summary.mentions.first().unwrap();
let membership = user2_summary.membership.unwrap();
assert_eq!(membership.mentions.len(), 1);
let mention = membership.mentions.first().unwrap();
assert_eq!(mention.message_index, 0.into());
assert_eq!(mention.message_id, message_id);

let user3_summary = client::group::happy_path::summary(env, user3.principal, group_id);
assert_eq!(user3_summary.mentions.len(), 1);
let mention = user3_summary.mentions.first().unwrap();
let membership = user3_summary.membership.unwrap();
assert_eq!(membership.mentions.len(), 1);
let mention = membership.mentions.first().unwrap();
assert_eq!(mention.message_index, 0.into());
assert_eq!(mention.message_id, message_id);
}
Expand Down Expand Up @@ -134,14 +136,15 @@ fn mention_everyone_only_succeeds_if_authorized(authorized: bool) {
));

let user1_summary = client::group::happy_path::summary(env, user1.principal, group_id);
let membership = user1_summary.membership.unwrap();

if authorized {
assert_eq!(user1_summary.mentions.len(), 1);
let mention = user1_summary.mentions.first().unwrap();
assert_eq!(membership.mentions.len(), 1);
let mention = membership.mentions.first().unwrap();
assert_eq!(mention.message_index, 0.into());
assert_eq!(mention.message_id, message_id);
} else {
assert!(user1_summary.mentions.is_empty())
assert!(membership.mentions.is_empty())
}
}

Expand Down Expand Up @@ -191,8 +194,9 @@ fn mentioned_in_thread_adds_user_as_follower() {
);

let summary = client::group::happy_path::summary(env, user2.principal, group_id);
assert_eq!(summary.mentions.len(), 1);
assert_eq!(summary.latest_threads.len(), 1);
let membership = summary.membership.unwrap();
assert_eq!(membership.mentions.len(), 1);
assert_eq!(membership.latest_threads.len(), 1);
}

fn init_test_data(env: &mut PocketIc, canister_ids: &CanisterIds, controller: Principal) -> TestData {
Expand Down
55 changes: 0 additions & 55 deletions backend/libraries/types/src/chat_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,6 @@ pub struct DirectChatSummary {
pub video_call_in_progress: Option<VideoCall>,
}

#[ts_export]
#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct GroupChatSummary {
pub chat_id: ChatId,
pub local_user_index_canister_id: CanisterId,
pub last_updated: TimestampMillis,
pub name: String,
pub description: String,
pub subtype: Option<GroupSubtype>,
pub avatar_id: Option<u128>,
pub is_public: bool,
pub history_visible_to_new_joiners: bool,
pub messages_visible_to_non_members: bool,
pub min_visible_event_index: EventIndex,
pub min_visible_message_index: MessageIndex,
#[ts(as = "Option<crate::EventWrapperMessage>")]
pub latest_message: Option<EventWrapper<Message>>,
pub latest_event_index: EventIndex,
pub latest_message_index: Option<MessageIndex>,
pub joined: TimestampMillis,
pub read_by_me_up_to: Option<MessageIndex>,
pub notifications_muted: bool,
pub participant_count: u32,
pub role: GroupRole,
pub mentions: Vec<HydratedMention>,
pub wasm_version: BuildVersion,
pub permissions_v2: GroupPermissions,
pub metrics: ChatMetrics,
pub my_metrics: ChatMetrics,
pub latest_threads: Vec<ThreadSyncDetails>,
pub archived: bool,
pub frozen: Option<FrozenGroupInfo>,
pub date_last_pinned: Option<TimestampMillis>,
pub date_read_pinned: Option<TimestampMillis>,
pub events_ttl: Option<Milliseconds>,
pub events_ttl_last_updated: TimestampMillis,
pub gate_config: Option<AccessGateConfig>,
pub rules_accepted: bool,
pub video_call_in_progress: Option<VideoCall>,
}

#[ts_export]
#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
pub struct DirectChatSummaryUpdates {
Expand Down Expand Up @@ -141,22 +100,15 @@ pub struct GroupCanisterGroupChatSummary {
pub latest_message: Option<EventWrapper<Message>>,
pub latest_event_index: EventIndex,
pub latest_message_index: Option<MessageIndex>,
pub joined: TimestampMillis,
pub participant_count: u32,
pub role: GroupRole,
pub mentions: Vec<HydratedMention>,
pub wasm_version: BuildVersion,
pub permissions_v2: GroupPermissions,
pub notifications_muted: bool,
pub metrics: ChatMetrics,
pub my_metrics: ChatMetrics,
pub latest_threads: Vec<GroupCanisterThreadDetails>,
pub frozen: Option<FrozenGroupInfo>,
pub date_last_pinned: Option<TimestampMillis>,
pub events_ttl: Option<Milliseconds>,
pub events_ttl_last_updated: TimestampMillis,
pub gate_config: Option<AccessGateConfig>,
pub rules_accepted: bool,
pub membership: Option<GroupMembership>,
pub video_call_in_progress: Option<VideoCall>,
pub verified: bool,
Expand All @@ -178,18 +130,12 @@ pub struct GroupCanisterGroupChatSummaryUpdates {
pub latest_event_index: Option<EventIndex>,
pub latest_message_index: Option<MessageIndex>,
pub participant_count: Option<u32>,
pub role: Option<GroupRole>,
pub mentions: Vec<HydratedMention>,
pub wasm_version: Option<BuildVersion>,
pub permissions_v2: Option<GroupPermissions>,
pub updated_events: Vec<(Option<MessageIndex>, EventIndex, TimestampMillis)>, // (Thread root message index, event index, timestamp)
pub metrics: Option<ChatMetrics>,
pub my_metrics: Option<ChatMetrics>,
pub is_public: Option<bool>,
pub messages_visible_to_non_members: Option<bool>,
pub latest_threads: Vec<GroupCanisterThreadDetails>,
pub unfollowed_threads: Vec<MessageIndex>,
pub notifications_muted: Option<bool>,
#[ts(as = "crate::OptionUpdateFrozenGroupInfo")]
pub frozen: OptionUpdate<FrozenGroupInfo>,
pub date_last_pinned: Option<TimestampMillis>,
Expand All @@ -198,7 +144,6 @@ pub struct GroupCanisterGroupChatSummaryUpdates {
pub events_ttl_last_updated: Option<TimestampMillis>,
#[ts(as = "crate::OptionUpdateAccessGateConfig")]
pub gate_config: OptionUpdate<AccessGateConfig>,
pub rules_accepted: Option<bool>,
pub membership: Option<GroupMembershipUpdates>,
#[ts(as = "crate::OptionUpdateVideoCall")]
pub video_call_in_progress: OptionUpdate<VideoCall>,
Expand Down
Loading