Skip to content

Commit

Permalink
add invited users gate
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs committed Jul 25, 2024
1 parent 25f17db commit 89fa27a
Show file tree
Hide file tree
Showing 38 changed files with 176 additions and 15 deletions.
13 changes: 13 additions & 0 deletions frontend/app/src/components/home/access/AccessGateIcon.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import AccountPlusOutline from "svelte-material-icons/AccountPlusOutline.svelte";
import AccountCheck from "svelte-material-icons/AccountCheck.svelte";
import VectorCombine from "svelte-material-icons/VectorCombine.svelte";
import ShieldLockOpenOutline from "svelte-material-icons/ShieldLockOpenOutline.svelte";
Expand Down Expand Up @@ -116,6 +117,18 @@
</TooltipPopup>
</div>
</TooltipWrapper>
{:else if gate.kind === "invited_gate"}
<TooltipWrapper {position} {align}>
<div slot="target" class="invited">
<AccountPlusOutline size={$iconSize} color={"var(--txt)"} />
</div>
<div let:position let:align slot="tooltip">
<TooltipPopup {position} {align}>
<Translatable
resourceKey={i18nKey("access.invitedGateInfo", undefined, level, true)} />
</TooltipPopup>
</div>
</TooltipWrapper>
{:else if gate.kind === "composite_gate"}
<TooltipWrapper {position} {align}>
<div slot="target" class="composite">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@
<div class="info">
<Translatable resourceKey={i18nKey("access.lockedGateInfo", undefined, level, true)} />
</div>
{:else if gate.kind === "invited_gate"}
<div class="info">
<Translatable resourceKey={i18nKey("access.invitedGateInfo", undefined, level, true)} />
</div>
{:else if gate.kind === "credential_gate"}
<CredentialSelector {editable} bind:valid={credentialIssuerValid} bind:gate />
{/if}
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "门禁",
"gateCheckFailed": "未满足访问门禁",
"gateInvalid": "访问门无效",
"invitedGate": "受邀用户",
"invitedGateInfo": "已明确受邀参加此 {level} 的用户将被允许加入",
"join": "加入",
"lifetimeDiamondGateInfo": "只有终身钻石会员才允许加入",
"lifetimeDiamondGateInfo2": "为了加入这个{level},您需要拥有终身钻石会员资格。",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Zugangstor",
"gateCheckFailed": "Zugangstor nicht erreicht",
"gateInvalid": "Das Zugangstor ist ungültig",
"invitedGate": "Eingeladene Benutzer",
"invitedGateInfo": "Benutzer, die ausdrücklich zu diesem {level} eingeladen wurden, dürfen teilnehmen",
"join": "Verbinden",
"lifetimeDiamondGateInfo": "Nur Benutzer mit lebenslanger Diamond-Mitgliedschaft dürfen teilnehmen",
"lifetimeDiamondGateInfo2": "Um diesem {level} beizutreten, ist eine lebenslange Diamant-Mitgliedschaft erforderlich.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Access gate",
"gateCheckFailed": "Access gate not met",
"gateInvalid": "Access gate is invalid",
"invitedGate": "Invited Users",
"invitedGateInfo": "Users who have been explicitly invited to this {level} will be allowed to join",
"join": "Join",
"lifetimeDiamondGateInfo": "Only users with lifetime Diamond membership will be allowed to join",
"lifetimeDiamondGateInfo2": "In order to join this {level} you are required to have lifetime Diamond membership.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Puerta de acceso",
"gateCheckFailed": "Puerta de acceso no cumplida",
"gateInvalid": "La puerta de acceso no es válida",
"invitedGate": "Usuarios invitados",
"invitedGateInfo": "Los usuarios que hayan sido invitados explícitamente a este {level} podrán unirse",
"join": "Unirse",
"lifetimeDiamondGateInfo": "Solo los usuarios con membresía Diamond vitalicia podrán unirse",
"lifetimeDiamondGateInfo2": "Para unirse a este {level}, debe tener una membresía Diamond de por vida.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Porte d'accès",
"gateCheckFailed": "Porte d'accès non rencontrée",
"gateInvalid": "La porte d'accès n'est pas valide",
"invitedGate": "Utilisateurs invités",
"invitedGateInfo": "Les utilisateurs qui ont été explicitement invités à ce {level} seront autorisés à le rejoindre",
"join": "Rejoindre",
"lifetimeDiamondGateInfo": "Seuls les utilisateurs disposant d'un abonnement Diamond à vie seront autorisés à rejoindre",
"lifetimeDiamondGateInfo2": "Pour rejoindre ce {level}, vous devez être membre Diamond à vie.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "प्रवेश द्वार",
"gateCheckFailed": "प्रवेश द्वार नहीं मिला",
"gateInvalid": "प्रवेश द्वार अमान्य है",
"invitedGate": "आमंत्रित उपयोगकर्ता",
"invitedGateInfo": "जिन उपयोगकर्ताओं को इस {level} में स्पष्ट रूप से आमंत्रित किया गया है, उन्हें इसमें शामिल होने की अनुमति दी जाएगी",
"join": "जोड़ना",
"lifetimeDiamondGateInfo": "केवल आजीवन डायमंड सदस्यता वाले उपयोगकर्ताओं को ही इसमें शामिल होने की अनुमति होगी",
"lifetimeDiamondGateInfo2": "इस {level} में शामिल होने के लिए आपके पास आजीवन डायमंड सदस्यता होना आवश्यक है।",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Cancello di accesso",
"gateCheckFailed": "Cancello di accesso non rispettato",
"gateInvalid": "Il cancello di accesso non è valido",
"invitedGate": "Utenti invitati",
"invitedGateInfo": "Gli utenti che sono stati esplicitamente invitati a questo {level} potranno partecipare",
"join": "Giuntura",
"lifetimeDiamondGateInfo": "Solo gli utenti con abbonamento Diamond a vita potranno iscriversi",
"lifetimeDiamondGateInfo2": "Per iscriverti a questo {level} devi avere un abbonamento Diamond a vita.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/iw.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "שער גישה",
"gateCheckFailed": "שער הגישה לא נפגש",
"gateInvalid": "שער הגישה אינו חוקי",
"invitedGate": "משתמשים מוזמנים",
"invitedGateInfo": "משתמשים שהוזמנו במפורש ל-{level} הזה יורשו להצטרף",
"join": "לְהִצְטַרֵף",
"lifetimeDiamondGateInfo": "רק משתמשים עם חברות Diamond לכל החיים יורשו להצטרף",
"lifetimeDiamondGateInfo2": "על מנת להצטרף ל-{level} הזה, עליך להיות בעל חברות Diamond לכל החיים.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "アクセスゲート",
"gateCheckFailed": "アクセスゲートが満たされていません",
"gateInvalid": "アクセスゲートが無効です",
"invitedGate": "招待されたユーザー",
"invitedGateInfo": "この{level}に明示的に招待されたユーザーは参加できます",
"join": "参加する",
"lifetimeDiamondGateInfo": "生涯ダイヤモンド会員のみ参加できます",
"lifetimeDiamondGateInfo2": "この {level} に参加するには、生涯ダイヤモンド メンバーシップが必要です。",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Brama dostępowa",
"gateCheckFailed": "Brama dostępu nie została spełniona",
"gateInvalid": "Brama dostępu jest nieprawidłowa",
"invitedGate": "Zaproszeni Użytkownicy",
"invitedGateInfo": "Użytkownicy, którzy zostali wyraźnie zaproszeni do tego {level}, będą mogli dołączyć",
"join": "Dołączyć",
"lifetimeDiamondGateInfo": "Tylko użytkownicy z dożywotnim członkostwem Diamentowym będą mogli dołączyć",
"lifetimeDiamondGateInfo2": "Aby dołączyć do tego {level}, musisz mieć dożywotnie członkostwo Diamentowe.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Въездные ворота",
"gateCheckFailed": "Въездные ворота не выполнены",
"gateInvalid": "Ворота доступа недействительны",
"invitedGate": "Приглашенные пользователи",
"invitedGateInfo": "Пользователям, которые были явно приглашены на этот {level}, будет разрешено присоединиться.",
"join": "Присоединиться",
"lifetimeDiamondGateInfo": "Присоединиться смогут только пользователи с пожизненным статусом Diamond.",
"lifetimeDiamondGateInfo2": "Чтобы присоединиться к {level}, вам необходимо иметь пожизненное членство со статусом Diamond.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "Під’їздні ворота",
"gateCheckFailed": "Ворота доступу не зустрічаються",
"gateInvalid": "Ворота доступу недійсні",
"invitedGate": "Запрошені користувачі",
"invitedGateInfo": "Користувачам, яких було явно запрошено до цього {level}, буде дозволено приєднатися",
"join": "Приєднуйтесь",
"lifetimeDiamondGateInfo": "Приєднатися зможуть лише користувачі з довічним членством Diamond",
"lifetimeDiamondGateInfo2": "Щоб приєднатися до цього {level}, ви повинні мати довічне Діамантове членство.",
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/i18n/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
"gate": "cổng ra vào",
"gateCheckFailed": "Cổng truy cập không được đáp ứng",
"gateInvalid": "Cổng truy cập không hợp lệ",
"invitedGate": "Người dùng được mời",
"invitedGateInfo": "Người dùng đã được mời rõ ràng vào {level} này sẽ được phép tham gia",
"join": "Tham gia",
"lifetimeDiamondGateInfo": "Chỉ những người dùng có tư cách thành viên Kim cương trọn đời mới được phép tham gia",
"lifetimeDiamondGateInfo2": "Để tham gia {level} này, bạn bắt buộc phải có tư cách thành viên Kim cương trọn đời.",
Expand Down
9 changes: 9 additions & 0 deletions frontend/app/src/utils/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const gateLabel: Record<AccessGate["kind"], string> = {
token_balance_gate: "access.tokenBalance",
unique_person_gate: "access.uniquePerson",
locked_gate: "access.lockedGate",
invited_gate: "access.invitedGate",
};

export function getGateBindings(): GateBinding[] {
Expand All @@ -40,6 +41,7 @@ export function getGateBindings(): GateBinding[] {
credentialGate,
uniquePersonGate,
lockedGate,
invitedGate,
nftGate,
];
}
Expand Down Expand Up @@ -138,6 +140,13 @@ export const lockedGate: GateBinding = {
enabled: true,
};

export const invitedGate: GateBinding = {
label: "access.invitedGate",
key: "invited_gate",
gate: { kind: "invited_gate" },
enabled: true,
};

export const neuronGateFolder: GateBinding = {
label: "access.neuronHolder",
key: "neuron_gate_folder",
Expand Down
10 changes: 10 additions & 0 deletions frontend/openchat-agent/src/services/common/chatMappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,7 @@ export function apiMaybeAccessGate(domain: AccessGate): [] | [ApiAccessGate] {
if (domain.kind === "nft_gate") return []; // TODO
if (domain.kind === "diamond_gate") return [{ DiamondMember: null }];
if (domain.kind === "locked_gate") return [{ Locked: null }];
if (domain.kind === "invited_gate") return [{ Invited: null }];
if (domain.kind === "credential_gate")
return [
{
Expand Down Expand Up @@ -1666,6 +1667,7 @@ export function apiMaybeAccessGate(domain: AccessGate): [] | [ApiAccessGate] {

export function apiAccessGate(domain: AccessGate): ApiAccessGate {
if (domain.kind === "locked_gate") return { Locked: null };
if (domain.kind === "invited_gate") return { Invited: null };
if (domain.kind === "diamond_gate") return { DiamondMember: null };
if (domain.kind === "lifetime_diamond_gate") return { LifetimeDiamondMember: null };
if (domain.kind === "unique_person_gate") return { UniquePerson: null };
Expand Down Expand Up @@ -1770,6 +1772,11 @@ export function accessGate(candid: ApiAccessGate): AccessGate {
kind: "locked_gate",
};
}
if ("Invited" in candid) {
return {
kind: "invited_gate",
};
}
if ("LifetimeDiamondMember" in candid) {
return {
kind: "lifetime_diamond_gate",
Expand Down Expand Up @@ -2172,6 +2179,9 @@ export function gateCheckFailedReason(candid: ApiGateCheckFailedReason): GateChe
if ("Locked" in candid) {
return "locked";
}
if ("NotInvited" in candid) {
return "not_invited";
}
throw new UnsupportedValueError("Unexpected ApiGateCheckFailedReason type received", candid);
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/openchat-agent/src/services/community/candid/idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const idlFactory = ({ IDL }) => {
});
const GateCheckFailedReason = IDL.Variant({
'NotLifetimeDiamondMember' : IDL.Null,
'NotInvited' : IDL.Null,
'NotDiamondMember' : IDL.Null,
'PaymentFailed' : ICRC2_TransferFromError,
'InsufficientBalance' : IDL.Nat,
Expand Down Expand Up @@ -322,6 +323,7 @@ export const idlFactory = ({ IDL }) => {
});
AccessGate.fill(
IDL.Variant({
'Invited' : IDL.Null,
'UniquePerson' : IDL.Null,
'VerifiedCredential' : VerifiedCredentialGate,
'SnsNeuron' : SnsNeuronGate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export type AcceptP2PSwapResponse = {
{ 'InternalError' : string } |
{ 'InsufficientFunds' : null };
export interface AcceptSwapSuccess { 'token1_txn_in' : bigint }
export type AccessGate = { 'UniquePerson' : null } |
export type AccessGate = { 'Invited' : null } |
{ 'UniquePerson' : null } |
{ 'VerifiedCredential' : VerifiedCredentialGate } |
{ 'SnsNeuron' : SnsNeuronGate } |
{ 'Locked' : null } |
Expand Down Expand Up @@ -925,6 +926,7 @@ export type FrozenGroupUpdate = { 'NoChange' : null } |
{ 'SetToNone' : null } |
{ 'SetToSome' : FrozenGroupInfo };
export type GateCheckFailedReason = { 'NotLifetimeDiamondMember' : null } |
{ 'NotInvited' : null } |
{ 'NotDiamondMember' : null } |
{ 'PaymentFailed' : ICRC2_TransferFromError } |
{ 'InsufficientBalance' : bigint } |
Expand Down Expand Up @@ -2362,6 +2364,7 @@ export type UserId = CanisterId;
export interface UserSummary {
'streak' : number,
'username' : string,
'total_chit_earned' : number,
'diamond_member' : boolean,
'diamond_membership_status' : DiamondMembershipStatus,
'is_unique_person' : boolean,
Expand All @@ -2388,6 +2391,7 @@ export interface UserSummaryV2 {
}
export interface UserSummaryVolatile {
'streak' : number,
'total_chit_earned' : number,
'chit_balance' : number,
}
export interface UsersBlocked {
Expand Down
1 change: 1 addition & 0 deletions frontend/openchat-agent/src/services/group/candid/idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ export const idlFactory = ({ IDL }) => {
});
AccessGate.fill(
IDL.Variant({
'Invited' : IDL.Null,
'UniquePerson' : IDL.Null,
'VerifiedCredential' : VerifiedCredentialGate,
'SnsNeuron' : SnsNeuronGate,
Expand Down
6 changes: 5 additions & 1 deletion frontend/openchat-agent/src/services/group/candid/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export type AcceptP2PSwapResponse = {
{ 'InternalError' : string } |
{ 'InsufficientFunds' : null };
export interface AcceptSwapSuccess { 'token1_txn_in' : bigint }
export type AccessGate = { 'UniquePerson' : null } |
export type AccessGate = { 'Invited' : null } |
{ 'UniquePerson' : null } |
{ 'VerifiedCredential' : VerifiedCredentialGate } |
{ 'SnsNeuron' : SnsNeuronGate } |
{ 'Locked' : null } |
Expand Down Expand Up @@ -778,6 +779,7 @@ export type FrozenGroupUpdate = { 'NoChange' : null } |
{ 'SetToNone' : null } |
{ 'SetToSome' : FrozenGroupInfo };
export type GateCheckFailedReason = { 'NotLifetimeDiamondMember' : null } |
{ 'NotInvited' : null } |
{ 'NotDiamondMember' : null } |
{ 'PaymentFailed' : ICRC2_TransferFromError } |
{ 'InsufficientBalance' : bigint } |
Expand Down Expand Up @@ -2053,6 +2055,7 @@ export type UserId = CanisterId;
export interface UserSummary {
'streak' : number,
'username' : string,
'total_chit_earned' : number,
'diamond_member' : boolean,
'diamond_membership_status' : DiamondMembershipStatus,
'is_unique_person' : boolean,
Expand All @@ -2079,6 +2082,7 @@ export interface UserSummaryV2 {
}
export interface UserSummaryVolatile {
'streak' : number,
'total_chit_earned' : number,
'chit_balance' : number,
}
export interface UsersBlocked {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const idlFactory = ({ IDL }) => {
});
AccessGate.fill(
IDL.Variant({
'Invited' : IDL.Null,
'UniquePerson' : IDL.Null,
'VerifiedCredential' : VerifiedCredentialGate,
'SnsNeuron' : SnsNeuronGate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { ActorMethod } from '@dfinity/agent';
import type { IDL } from '@dfinity/candid';

export interface AcceptSwapSuccess { 'token1_txn_in' : bigint }
export type AccessGate = { 'UniquePerson' : null } |
export type AccessGate = { 'Invited' : null } |
{ 'UniquePerson' : null } |
{ 'VerifiedCredential' : VerifiedCredentialGate } |
{ 'SnsNeuron' : SnsNeuronGate } |
{ 'Locked' : null } |
Expand Down Expand Up @@ -708,6 +709,7 @@ export type FrozenGroupUpdate = { 'NoChange' : null } |
{ 'SetToNone' : null } |
{ 'SetToSome' : FrozenGroupInfo };
export type GateCheckFailedReason = { 'NotLifetimeDiamondMember' : null } |
{ 'NotInvited' : null } |
{ 'NotDiamondMember' : null } |
{ 'PaymentFailed' : ICRC2_TransferFromError } |
{ 'InsufficientBalance' : bigint } |
Expand Down Expand Up @@ -1765,6 +1767,7 @@ export type UserId = CanisterId;
export interface UserSummary {
'streak' : number,
'username' : string,
'total_chit_earned' : number,
'diamond_member' : boolean,
'diamond_membership_status' : DiamondMembershipStatus,
'is_unique_person' : boolean,
Expand All @@ -1791,6 +1794,7 @@ export interface UserSummaryV2 {
}
export interface UserSummaryVolatile {
'streak' : number,
'total_chit_earned' : number,
'chit_balance' : number,
}
export interface UsersBlocked {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export const idlFactory = ({ IDL }) => {
});
AccessGate.fill(
IDL.Variant({
'Invited' : IDL.Null,
'UniquePerson' : IDL.Null,
'VerifiedCredential' : VerifiedCredentialGate,
'SnsNeuron' : SnsNeuronGate,
Expand Down Expand Up @@ -1139,6 +1140,7 @@ export const idlFactory = ({ IDL }) => {
});
const GateCheckFailedReason = IDL.Variant({
'NotLifetimeDiamondMember' : IDL.Null,
'NotInvited' : IDL.Null,
'NotDiamondMember' : IDL.Null,
'PaymentFailed' : ICRC2_TransferFromError,
'InsufficientBalance' : IDL.Nat,
Expand Down
Loading

0 comments on commit 89fa27a

Please sign in to comment.