Skip to content

Commit

Permalink
fix create group and community (#6576)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Oct 14, 2024
1 parent 1412ed3 commit 7d35ff8
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
5 changes: 5 additions & 0 deletions frontend/openchat-agent/src/services/common/chatMappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,11 @@ export function apiOptional<D, A>(mapper: (d: D) => A, domain: D | undefined): [
return domain !== undefined ? [mapper(domain)] : [];
}

export function apiMaybeAccessGateConfig(domain: AccessGate): [] | [ApiAccessGateConfig] {
const gate = apiMaybeAccessGate(domain);
return gate.length === 0 ? [] : [{ gate: gate[0], expiry: [] }];
}

export function apiMaybeAccessGate(domain: AccessGate): [] | [ApiAccessGate] {
if (domain.kind === "composite_gate") {
return [
Expand Down
36 changes: 18 additions & 18 deletions frontend/openchat-agent/src/services/community/community.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1417,19 +1417,19 @@ export class CommunityClient extends CandidService {
gate === undefined
? "NoChange"
: gate.kind === "no_gate"
? "SetToNone"
: { SetToSome: apiAccessGate(gate) },
? "SetToNone"
: { SetToSome: apiAccessGate(gate) },
gate_config:
gate === undefined
? "NoChange"
: gate.kind === "no_gate"
? "SetToNone"
: {
SetToSome: apiAccessGateConfig({
gate,
expiry: undefined,
}),
},
? "SetToNone"
: {
SetToSome: apiAccessGateConfig({
gate,
expiry: undefined,
}),
},
avatar:
avatar === undefined
? "NoChange"
Expand Down Expand Up @@ -1472,19 +1472,19 @@ export class CommunityClient extends CandidService {
gate === undefined
? "NoChange"
: gate.kind === "no_gate"
? "SetToNone"
: { SetToSome: apiAccessGate(gate) },
? "SetToNone"
: { SetToSome: apiAccessGate(gate) },
gate_config:
gate === undefined
? "NoChange"
: gate.kind === "no_gate"
? "SetToNone"
: {
SetToSome: apiAccessGateConfig({
gate,
expiry: undefined,
}),
},
? "SetToNone"
: {
SetToSome: apiAccessGateConfig({
gate,
expiry: undefined,
}),
},
avatar:
avatar === undefined
? "NoChange"
Expand Down
12 changes: 3 additions & 9 deletions frontend/openchat-agent/src/services/user/user.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ import {
import {
apiCommunityPermissions,
apiGroupPermissions,
apiAccessGate,
apiMaybeAccessGate,
apiMessageContent,
editMessageResponse,
Expand All @@ -152,6 +151,7 @@ import {
cancelP2PSwapResponse,
joinVideoCallResponse,
setPinNumberResponse,
apiMaybeAccessGateConfig,
} from "../common/chatMappers";
import {
apiMessageContent as apiMessageContentV2,
Expand Down Expand Up @@ -303,10 +303,7 @@ export class UserClient extends CandidService {
permissions: [apiCommunityPermissions(community.permissions)],
rules,
gate: apiMaybeAccessGate(community.gate),
gate_config: apiOptional(
(g) => ({ gate: apiAccessGate(g), expiry: [] }),
community.gate,
),
gate_config: apiMaybeAccessGateConfig(community.gate),
default_channels: defaultChannels,
default_channel_rules: [defaultChannelRules],
primary_language: community.primaryLanguage,
Expand Down Expand Up @@ -335,10 +332,7 @@ export class UserClient extends CandidService {
permissions_v2: [apiGroupPermissions(group.permissions)],
rules: group.rules,
gate: apiMaybeAccessGate(group.gate),
gate_config: apiOptional(
(g) => ({ gate: apiAccessGate(g), expiry: [] }),
group.gate,
),
gate_config: apiMaybeAccessGateConfig(group.gate),
events_ttl: apiOptional(identity, group.eventsTTL),
messages_visible_to_non_members: apiOptional(
identity,
Expand Down

0 comments on commit 7d35ff8

Please sign in to comment.