Skip to content

Commit

Permalink
Merge branch 'master' into invites
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Jul 25, 2024
2 parents accffd9 + b2f2968 commit 1f1bbc4
Show file tree
Hide file tree
Showing 14 changed files with 13 additions and 27 deletions.
1 change: 0 additions & 1 deletion backend/canisters/community/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))
- Add `Invited` gate ([#6106](https://github.com/open-chat-labs/open-chat/pull/6106))

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use community_canister::add_members_to_channel::{Response::*, *};
use gated_groups::{check_if_passes_gate, CheckGateArgs, CheckIfPassesGateResult};
use group_chat_core::AddResult;
use ic_cdk::update;
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::iter::zip;
use types::{
AccessGate, AddedToChannelNotification, CanisterId, ChannelId, EventIndex, MembersAdded, MessageIndex, Notification,
Expand Down Expand Up @@ -57,7 +57,6 @@ async fn add_members_to_channel(args: Args) -> Response {
this_canister: prepare_result.this_canister,
unique_person_proof: None,
verified_credential_args: None,
is_user_invited: prepare_result.invited.contains(user_id),
now: prepare_result.now_nanos,
},
)
Expand Down Expand Up @@ -107,7 +106,6 @@ struct PrepareResult {
member_display_name: Option<String>,
this_canister: CanisterId,
now_nanos: TimestampNanos,
invited: HashSet<UserId>,
}

#[allow(clippy::result_large_err)]
Expand Down Expand Up @@ -150,7 +148,6 @@ fn prepare(args: &Args, state: &RuntimeState) -> Result<PrepareResult, Response>
member_display_name: member.display_name().value.clone(),
this_canister: state.env.canister_id(),
now_nanos: state.env.now_nanos(),
invited: channel.chat.invited_users.users().into_iter().collect(),
})
} else {
Err(UserNotInChannel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ fn is_permitted_to_join(
ii_canister_id: state.data.internet_identity_canister_id,
ii_origin: vc.ii_origin,
}),
is_user_invited: channel.chat.invited_users.contains(&member.user_id),
now: state.env.now(),
},
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ fn is_permitted_to_join(args: &Args, state: &RuntimeState) -> Result<Option<(Acc
ii_origin: vc.ii_origin.clone(),
}
}),
is_user_invited: state.data.invited_users.contains(&args.user_id),
now: state.env.now(),
},
)
Expand Down
1 change: 0 additions & 1 deletion backend/canisters/group/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))
- Add `Invited` gate ([#6106](https://github.com/open-chat-labs/open-chat/pull/6106))

### Changed

Expand Down
1 change: 0 additions & 1 deletion backend/canisters/group/impl/src/updates/c2c_join_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ fn is_permitted_to_join(args: &Args, state: &RuntimeState) -> Result<Option<(Acc
ii_origin: vc.ii_origin.clone(),
}
}),
is_user_invited: state.data.chat.invited_users.contains(&args.user_id),
now: state.env.now(),
},
)
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 `Invited` gate ([#6112](https://github.com/open-chat-labs/open-chat/pull/6112))

## [[2.0.1253](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1253-group_index)] - 2024-07-25

### Added
Expand Down
3 changes: 0 additions & 3 deletions backend/canisters/group_index/impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,6 @@ pub struct AccessGateMetrics {
pub composite: u32,
#[serde(default)]
pub locked: u32,
#[serde(default)]
pub invited: u32,
}

impl AccessGateMetrics {
Expand All @@ -398,7 +396,6 @@ impl AccessGateMetrics {
AccessGate::TokenBalance(_) => self.token_balance += 1,
AccessGate::Composite(_) => self.composite += 1,
AccessGate::Locked => self.locked += 1,
AccessGate::Invited => self.invited += 1,
}
}
}
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 `Invited` gate ([#6112](https://github.com/open-chat-labs/open-chat/pull/6112))

## [[2.0.1254](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1254-local_group_index)] - 2024-07-25

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

## [unreleased]

### Removed

- Remove `Invited` gate ([#6112](https://github.com/open-chat-labs/open-chat/pull/6112))

## [[2.0.1256](https://github.com/open-chat-labs/open-chat/releases/tag/v2.0.1256-local_user_index)] - 2024-07-25

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

- Add `Locked` gate ([#6095](https://github.com/open-chat-labs/open-chat/pull/6095))
- Add `Invited` gate ([#6106](https://github.com/open-chat-labs/open-chat/pull/6106))

### Changed

Expand Down
9 changes: 0 additions & 9 deletions backend/libraries/gated_groups/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub struct CheckGateArgs {
pub this_canister: CanisterId,
pub unique_person_proof: Option<UniquePersonProof>,
pub verified_credential_args: Option<CheckVerifiedCredentialGateArgs>,
pub is_user_invited: bool,
pub now: TimestampMillis,
}

Expand Down Expand Up @@ -69,14 +68,6 @@ async fn check_non_composite_gate(gate: AccessGate, args: CheckGateArgs) -> Chec
AccessGate::TokenBalance(g) => check_token_balance_gate(&g, args.user_id).await,
AccessGate::Composite(_) => unreachable!(),
AccessGate::Locked => CheckIfPassesGateResult::Failed(GateCheckFailedReason::Locked),
AccessGate::Invited => check_invited_gate(args.is_user_invited),
}
}

fn check_invited_gate(is_user_invited: bool) -> CheckIfPassesGateResult {
match is_user_invited {
true => CheckIfPassesGateResult::Success,
false => CheckIfPassesGateResult::Failed(GateCheckFailedReason::NotInvited),
}
}

Expand Down
2 changes: 0 additions & 2 deletions backend/libraries/types/can.did
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,6 @@ type AccessGate = variant {
and : bool;
};
Locked;
Invited;
};

type AccessGateUpdate = variant {
Expand Down Expand Up @@ -1581,7 +1580,6 @@ type GateCheckFailedReason = variant {
InsufficientBalance : nat;
FailedVerifiedCredentialCheck : text;
Locked;
NotInvited;
};

type VerifiedCredentialGateArgs = record {
Expand Down
3 changes: 0 additions & 3 deletions backend/libraries/types/src/gated_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub enum AccessGate {
TokenBalance(TokenBalanceGate),
Composite(CompositeGate),
Locked,
Invited,
}

impl AccessGate {
Expand Down Expand Up @@ -48,7 +47,6 @@ impl AccessGate {
AccessGate::TokenBalance(_) => "token_balance",
AccessGate::Composite(_) => "composite",
AccessGate::Locked => "locked",
AccessGate::Invited => "invited",
}
}
}
Expand Down Expand Up @@ -106,7 +104,6 @@ pub enum GateCheckFailedReason {
InsufficientBalance(u128),
FailedVerifiedCredentialCheck(String),
Locked,
NotInvited,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug)]
Expand Down

0 comments on commit 1f1bbc4

Please sign in to comment.