A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
refactor(app): use account setup checks for calls and voice
Hampus9bb351f948ef
diff --git a/fluxer_app/src/features/channel/components/channel_header_components/CallButtonBlock.ts b/fluxer_app/src/features/channel/components/channel_header_components/CallButtonBlock.tsnew file mode 100644index 000000000..7e1c5b1af--- /dev/null+++ b/fluxer_app/src/features/channel/components/channel_header_components/CallButtonBlock.ts@@ -0,0 +1,35 @@+// SPDX-License-Identifier: AGPL-3.0-or-later++import type {Channel} from '@app/features/channel/models/Channel';+import {isSystemDmChannel} from '@app/features/channel/utils/ChannelUtils';+import Users from '@app/features/user/state/Users';+import {type AccountGateUser, canPerform} from '@app/features/user/utils/AccountGates';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';+import type {TierGateDenial} from '@fluxer/constants/src/AccountTierRules';+import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';++export const CallButtonBlocks = {+ NONE: 'none',+ SYSTEM_DM: 'system_dm',+ ACCOUNT: 'account',+} as const;++export type CallButtonBlockState =+ | {readonly block: typeof CallButtonBlocks.NONE}+ | {readonly block: typeof CallButtonBlocks.SYSTEM_DM}+ | {readonly block: typeof CallButtonBlocks.ACCOUNT; readonly gate: TierGateDenial};++export function resolveCallButtonBlock(+ channel: Channel,+ user: AccountGateUser | null | undefined,+): CallButtonBlockState {+ if (isSystemDmChannel(channel)) return {block: CallButtonBlocks.SYSTEM_DM};+ const action = channel.type === ChannelTypes.DM ? TierGatedActions.CALL : TierGatedActions.GROUP_CALL;+ const gate = canPerform(user, action);+ if (gate.allowed) return {block: CallButtonBlocks.NONE};+ return {block: CallButtonBlocks.ACCOUNT, gate};+}++export function useCallButtonBlock(channel: Channel): CallButtonBlockState {+ return resolveCallButtonBlock(channel, Users.getCurrentUser());+}diff --git a/fluxer_app/src/features/channel/components/channel_header_components/CallButtons.tsx b/fluxer_app/src/features/channel/components/channel_header_components/CallButtons.tsxindex 328874556..88d9024ff 100644--- a/fluxer_app/src/features/channel/components/channel_header_components/CallButtons.tsx+++ b/fluxer_app/src/features/channel/components/channel_header_components/CallButtons.tsx@@ -1,15 +1,17 @@// SPDX-License-Identifier: AGPL-3.0-or-later-import {showChannelErrorModal} from '@app/features/channel/components/alerts/ChannelErrorModalUtils';+import {+ CallButtonBlocks,+ useCallButtonBlock,+} from '@app/features/channel/components/channel_header_components/CallButtonBlock';import {ChannelHeaderIcon} from '@app/features/channel/components/channel_header_components/ChannelHeaderIcon';import type {Channel} from '@app/features/channel/models/Channel';-import {isSystemDmChannel} from '@app/features/channel/utils/ChannelUtils';import {START_VIDEO_CALL_DESCRIPTOR,START_VOICE_CALL_DESCRIPTOR,TURN_OFF_CAMERA_DESCRIPTOR,} from '@app/features/i18n/utils/CommonMessageDescriptors';-import Users from '@app/features/user/state/Users';+import {accountGateReason, openAccountGateFlow} from '@app/features/user/utils/AccountGatePresentation';import * as CallCommands from '@app/features/voice/commands/CallCommands';import MediaEngine from '@app/features/voice/engine/MediaEngineFacade';import CallState from '@app/features/voice/state/CallState';@@ -17,7 +19,6 @@ import LocalVoiceState from '@app/features/voice/state/LocalVoiceState';import VoiceSettings from '@app/features/voice/state/VoiceSettings';import * as CallUtils from '@app/features/voice/utils/CallUtils';import {VOICE_TURN_ON_CAMERA_DESCRIPTOR} from '@app/features/voice/utils/VoiceMessageDescriptors';-import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';import {msg, plural} from '@lingui/core/macro';import {useLingui} from '@lingui/react/macro';import {PhoneIcon, VideoCameraIcon} from '@phosphor-icons/react';@@ -25,20 +26,6 @@ import {observer} from 'mobx-react-lite';import type React from 'react';import {useCallback} from 'react';-const SYSTEM_DMS_CANNOT_HOST_VOICE_CALLS_DESCRIPTOR = msg({- message: 'System DMs cannot host voice calls.',- comment:- 'Tooltip body on the disabled voice call button in a system DM. System DMs are official Fluxer system accounts.',-});-const VOICE_CALL_UNAVAILABLE_DESCRIPTOR = msg({- message: 'Voice call unavailable',- comment: 'Title of the modal shown when the voice call action is blocked.',-});-const CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR = msg({- message: 'Claim your account to start or join 1:1 calls.',- comment:- 'Tooltip body on the disabled voice call button for unclaimed (guest) accounts. Encourages account creation.',-});const SYSTEM_DMS_CANNOT_HOST_VOICE_CALLS_2_DESCRIPTOR = msg({message: 'System DMs cannot host voice calls',comment: 'Short tooltip on the disabled voice call button in a system DM (variant without trailing period).',@@ -51,18 +38,6 @@ const JOIN_VOICE_CALL_DESCRIPTOR = msg({message: 'Join voice call',comment: 'Tooltip on the channel header voice call button when an ongoing voice call exists that the user can join.',});-const CLAIM_YOUR_ACCOUNT_TO_CALL_DESCRIPTOR = msg({- message: 'Claim your account to call',- comment: 'Tooltip on the channel header voice call button for guest accounts. Prompts account claim.',-});-const SYSTEM_DMS_CANNOT_HOST_VIDEO_CALLS_DESCRIPTOR = msg({- message: 'System DMs cannot host video calls.',- comment: 'Tooltip body on the disabled video call button in a system DM.',-});-const VIDEO_CALL_UNAVAILABLE_DESCRIPTOR = msg({- message: 'Video call unavailable',- comment: 'Title of the modal shown when the video call action is blocked.',-});const SYSTEM_DMS_CANNOT_HOST_VIDEO_CALLS_2_DESCRIPTOR = msg({message: 'System DMs cannot host video calls',comment: 'Short tooltip on the disabled video call button in a system DM (variant without trailing period).',@@ -81,28 +56,11 @@ const VoiceCallButton = observer(({channel}: {channel: Channel}) => {const hasActiveCall = CallState.hasActiveCall(channel.id);const participants = call ? CallState.getParticipants(channel.id) : [];const participantCount = participants.length;- const currentUser = Users.getCurrentUser();- const isUnclaimed = !(currentUser?.isClaimed() ?? false);- const is1to1 = channel.type === ChannelTypes.DM;- const systemDmBlock = isSystemDmChannel(channel);- const unclaimedBlock = isUnclaimed && is1to1;- const blocked = systemDmBlock || unclaimedBlock;+ const callBlock = useCallButtonBlock(channel);const handleClick = useCallback(async (event: React.MouseEvent) => {- if (systemDmBlock) {- showChannelErrorModal({- title: i18n._(VOICE_CALL_UNAVAILABLE_DESCRIPTOR),- message: i18n._(SYSTEM_DMS_CANNOT_HOST_VOICE_CALLS_DESCRIPTOR),- dataFlx: 'channel.call-buttons.voice-call.system-dm-blocked.generic-error-modal',- });- return;- }- if (unclaimedBlock) {- showChannelErrorModal({- title: i18n._(CLAIM_YOUR_ACCOUNT_TO_CALL_DESCRIPTOR),- message: i18n._(CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR),- dataFlx: 'channel.call-buttons.voice-call.unclaimed-account-blocked.generic-error-modal',- });+ if (callBlock.block === CallButtonBlocks.ACCOUNT) {+ openAccountGateFlow(i18n, callBlock.gate);return;}if (isInCall) {@@ -117,10 +75,10 @@ const VoiceCallButton = observer(({channel}: {channel: Channel}) => {);}},- [channel.id, hasActiveCall, i18n, isInCall, systemDmBlock, unclaimedBlock],+ [callBlock, channel.id, hasActiveCall, i18n, isInCall],);let label: string;- if (systemDmBlock) {+ if (callBlock.block === CallButtonBlocks.SYSTEM_DM) {label = i18n._(SYSTEM_DMS_CANNOT_HOST_VOICE_CALLS_2_DESCRIPTOR);} else if (participantCount > 0 && hasActiveCall) {if (isInCall) {@@ -128,14 +86,14 @@ const VoiceCallButton = observer(({channel}: {channel: Channel}) => {} else {label = i18n._(JOIN_VOICE_CALL_DESCRIPTOR);}+ } else if (callBlock.block === CallButtonBlocks.ACCOUNT) {+ label = accountGateReason(i18n, callBlock.gate);+ } else if (isInCall) {+ label = i18n._(LEAVE_VOICE_CALL_DESCRIPTOR);+ } else if (hasActiveCall) {+ label = i18n._(JOIN_VOICE_CALL_DESCRIPTOR);} else {- label = blocked- ? i18n._(CLAIM_YOUR_ACCOUNT_TO_CALL_DESCRIPTOR)- : isInCall- ? i18n._(LEAVE_VOICE_CALL_DESCRIPTOR)- : hasActiveCall- ? i18n._(JOIN_VOICE_CALL_DESCRIPTOR)- : i18n._(START_VOICE_CALL_DESCRIPTOR);+ label = i18n._(START_VOICE_CALL_DESCRIPTOR);}return (<ChannelHeaderIcon@@ -143,7 +101,7 @@ const VoiceCallButton = observer(({channel}: {channel: Channel}) => {label={label}isSelected={isInCall}onClick={handleClick}- disabled={blocked}+ disabled={callBlock.block === CallButtonBlocks.SYSTEM_DM}aria-pressed={isInCall}keybindAction="voice_start_dm_call"data-flx="channel.channel-header-components.call-buttons.voice-call-button.channel-header-icon.click"@@ -159,29 +117,12 @@ const VideoCallButton = observer(({channel}: {channel: Channel}) => {const hasActiveCall = CallState.hasActiveCall(channel.id);const participants = call ? CallState.getParticipants(channel.id) : [];const participantCount = participants.length;- const currentUser = Users.getCurrentUser();- const isUnclaimed = !(currentUser?.isClaimed() ?? false);- const is1to1 = channel.type === ChannelTypes.DM;- const systemDmBlock = isSystemDmChannel(channel);- const unclaimedBlock = isUnclaimed && is1to1;- const blocked = systemDmBlock || unclaimedBlock;+ const callBlock = useCallButtonBlock(channel);const selfVideo = isInCall && LocalVoiceState.getSelfVideo();const handleClick = useCallback(async (event: React.MouseEvent) => {- if (systemDmBlock) {- showChannelErrorModal({- title: i18n._(VIDEO_CALL_UNAVAILABLE_DESCRIPTOR),- message: i18n._(SYSTEM_DMS_CANNOT_HOST_VIDEO_CALLS_DESCRIPTOR),- dataFlx: 'channel.call-buttons.video-call.system-dm-blocked.generic-error-modal',- });- return;- }- if (unclaimedBlock) {- showChannelErrorModal({- title: i18n._(CLAIM_YOUR_ACCOUNT_TO_CALL_DESCRIPTOR),- message: i18n._(CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR),- dataFlx: 'channel.call-buttons.video-call.unclaimed-account-blocked.generic-error-modal',- });+ if (callBlock.block === CallButtonBlocks.ACCOUNT) {+ openAccountGateFlow(i18n, callBlock.gate);return;}if (isInCall) {@@ -199,10 +140,10 @@ const VideoCallButton = observer(({channel}: {channel: Channel}) => {);}},- [channel.id, hasActiveCall, i18n, isInCall, systemDmBlock, unclaimedBlock],+ [callBlock, channel.id, hasActiveCall, i18n, isInCall],);let label: string;- if (systemDmBlock) {+ if (callBlock.block === CallButtonBlocks.SYSTEM_DM) {label = i18n._(SYSTEM_DMS_CANNOT_HOST_VIDEO_CALLS_2_DESCRIPTOR);} else if (isInCall) {label = selfVideo ? i18n._(TURN_OFF_CAMERA_DESCRIPTOR) : i18n._(VOICE_TURN_ON_CAMERA_DESCRIPTOR);@@ -214,12 +155,12 @@ const VideoCallButton = observer(({channel}: {channel: Channel}) => {other: 'Join video call (# participants)',},);+ } else if (callBlock.block === CallButtonBlocks.ACCOUNT) {+ label = accountGateReason(i18n, callBlock.gate);+ } else if (hasActiveCall) {+ label = i18n._(JOIN_VIDEO_CALL_DESCRIPTOR);} else {- label = blocked- ? i18n._(CLAIM_YOUR_ACCOUNT_TO_CALL_DESCRIPTOR)- : hasActiveCall- ? i18n._(JOIN_VIDEO_CALL_DESCRIPTOR)- : i18n._(START_VIDEO_CALL_DESCRIPTOR);+ label = i18n._(START_VIDEO_CALL_DESCRIPTOR);}return (<ChannelHeaderIcon@@ -227,7 +168,7 @@ const VideoCallButton = observer(({channel}: {channel: Channel}) => {label={label}isSelected={selfVideo}onClick={handleClick}- disabled={blocked}+ disabled={callBlock.block === CallButtonBlocks.SYSTEM_DM}aria-pressed={selfVideo}data-flx="channel.channel-header-components.call-buttons.video-call-button.channel-header-icon.click"/>diff --git a/fluxer_app/src/features/ui/action_menu/items/VoiceParticipantMenuData.tsx b/fluxer_app/src/features/ui/action_menu/items/VoiceParticipantMenuData.tsxindex 7bb201a5f..2608bb506 100644--- a/fluxer_app/src/features/ui/action_menu/items/VoiceParticipantMenuData.tsx+++ b/fluxer_app/src/features/ui/action_menu/items/VoiceParticipantMenuData.tsx@@ -129,6 +129,7 @@ import {ChangeNicknameModal} from '@app/features/user/components/modals/ChangeNiimport type {User} from '@app/features/user/models/User';import UserSettings from '@app/features/user/state/UserSettings';import Users from '@app/features/user/state/Users';+import {canPerform} from '@app/features/user/utils/AccountGates';import {blockedDmConfirmModal, openDMChannelOrShowError} from '@app/features/user/utils/DMActionUtils';import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';import * as VoiceCallLayoutCommands from '@app/features/voice/commands/VoiceCallLayoutCommands';@@ -163,6 +164,7 @@ import {VOICE_USER_VOLUME_DESCRIPTOR,} from '@app/features/voice/utils/VoiceMessageDescriptors';import {buildVoiceParticipantIdentity} from '@app/features/voice/utils/VoiceParticipantIdentity';+import {TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';import {ChannelTypes, Permissions, TEXT_BASED_CHANNEL_TYPES} from '@fluxer/constants/src/ChannelConstants';import {RelationshipTypes} from '@fluxer/constants/src/UserConstants';import {msg, plural} from '@lingui/core/macro';@@ -318,6 +320,8 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOptconst memberMute = member?.mute ?? false;const memberDeaf = member?.deaf ?? false;const memberTimedOut = member?.isTimedOut() ?? false;+ const directMessagesDisabled = RuntimeConfig.directMessagesDisabled;+ const friendsDisabled = RuntimeConfig.friendsDisabled;const userVoiceStates = useMemo(() => {if (!guildId) return [] as Array<{connectionId: string; voiceState: VoiceState}>;const acc: Array<{connectionId: string; voiceState: VoiceState}> = [];@@ -468,7 +472,10 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOpt: null;const isCameraLive =source.kind === 'camera' && Boolean(connectionParticipant?.isCameraEnabled || connectionVoiceState?.self_video);- const focusSource = source.kind === 'camera' ? (isCameraLive ? 'camera' : undefined) : source.focusSource;+ let focusSource = source.kind === 'camera' ? undefined : source.focusSource;+ if (isCameraLive) {+ focusSource = 'camera';+ }const shouldShowFocus = focusSource !== undefined && (surface === 'call-tile' || surface === 'participant-list');if (shouldShowFocus && connectionId && isTargetInLocalVoiceRoom) {const identity = buildVoiceParticipantIdentity(user.id, connectionId);@@ -512,8 +519,10 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOpt}const popoutChannelId = connectionVoiceState?.channel_id ?? null;const isParticipantPopoutSurface = surface === 'call-tile' || surface === 'call-avatar';- const participantPopoutSource: VoiceTilePopoutSource | null =- isCameraLive && isTargetInLocalVoiceRoom ? 'camera' : isParticipantPopoutSurface ? 'user' : null;+ let participantPopoutSource: VoiceTilePopoutSource | null = isParticipantPopoutSurface ? 'user' : null;+ if (isCameraLive && isTargetInLocalVoiceRoom) {+ participantPopoutSource = 'camera';+ }if (participantPopoutSource && connectionId && popoutChannelId && isVoicePopoutSupported()) {const openParticipantPopout = (): void => {const didOpen = PopoutWindowManager.openTilePopout({@@ -572,7 +581,7 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOpt},});}- if (!isCurrentUser) {+ if (!isCurrentUser && !directMessagesDisabled) {primaryActions.push({icon: (<MessageUserIcon@@ -584,7 +593,7 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOptonClick: isBlocked ? handleOpenBlockedDm : handleMessage,});}- if (!isCurrentUser && relationshipType === RelationshipTypes.FRIEND) {+ if (!isCurrentUser && !friendsDisabled && relationshipType === RelationshipTypes.FRIEND) {relationshipActions.push({icon: (<ChangeNicknameIcon@@ -606,7 +615,7 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOpt},});}- if (!isCurrentUser && !user.bot && !hasActiveDirectCall) {+ if (!isCurrentUser && !user.bot && !hasActiveDirectCall && !directMessagesDisabled) {primaryActions.push({icon: (<VoiceCallIcon size={16} data-flx="ui.action-menu.items.voice-participant-menu-data.groups.voice-call-icon" />@@ -1032,7 +1041,7 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOpt}if (!isCurrentUser) {const nextRelationshipActions: Array<MenuItemType> = [];- if (!RuntimeConfig.directMessagesDisabled) {+ if (!friendsDisabled) {switch (relationshipType) {case RelationshipTypes.FRIEND:nextRelationshipActions.push({@@ -1090,7 +1099,7 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOptcase RelationshipTypes.BLOCKED:break;default:- if (!user.bot && Users.currentUser?.verified !== false) {+ if (!user.bot && canPerform(Users.currentUser, TierGatedActions.FRIEND_REQUEST).allowed) {nextRelationshipActions.push({icon: (<SendFriendRequestIcon@@ -1388,6 +1397,8 @@ export function useVoiceParticipantMenuData(options: VoiceParticipantMenuDataOptmemberMute,memberDeaf,memberTimedOut,+ directMessagesDisabled,+ friendsDisabled,displayName,currentUserVoiceState,currentUserVoiceStateInGuild,diff --git a/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts b/fluxer_app/src/features/voice/engine/MediaEngineFacade.tsindex c95b34ca0..cf48a9213 100644--- a/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts+++ b/fluxer_app/src/features/voice/engine/MediaEngineFacade.ts@@ -2,6 +2,7 @@import assert from 'node:assert/strict';import {showGenericErrorModal} from '@app/features/app/components/alerts/GenericErrorModalCommands';+import RuntimeConfig from '@app/features/app/state/RuntimeConfig';import Authentication from '@app/features/auth/state/Authentication';import type {Channel} from '@app/features/channel/models/Channel';import Channels from '@app/features/channel/state/Channels';@@ -27,6 +28,8 @@ import Idle from '@app/features/ui/state/Idle';import Sound from '@app/features/ui/state/Sound';import {getElectronAPI, isDesktop} from '@app/features/ui/utils/NativeUtils';import Users from '@app/features/user/state/Users';+import {openAccountGateFlow} from '@app/features/user/utils/AccountGatePresentation';+import {canPerform} from '@app/features/user/utils/AccountGates';import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';import {VoiceP2pPeerFailedModal} from '@app/features/voice/components/alerts/VoiceP2pPeerFailedModal';import {getStreamKey, parseStreamKey} from '@app/features/voice/components/StreamKeys';@@ -48,9 +51,6 @@ import {} from '@app/features/voice/engine/MediaEngineFacadeStateMachine';import {AFK_CHECK_INTERVAL_MS,- CLAIM_YOUR_ACCOUNT_TO_JOIN_THIS_VOICE_CHANNEL_DESCRIPTOR,- CLAIM_YOUR_ACCOUNT_TO_JOIN_VOICE_CHANNELS_YOU_DESCRIPTOR,- CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR,DEFERRED_DISCONNECT_TIMEOUT_MS,RECONNECT_SUCCEEDED_PICK_A_SCREEN_AGAIN_IF_YOU_DESCRIPTOR,VOICE_CHANNEL_NO_LONGER_AVAILABLE_DESCRIPTOR,@@ -175,6 +175,8 @@ import {} from '@app/features/voice/utils/VoicePermissionUtils';import {getActiveVoiceProcessingMode} from '@app/features/voice/utils/VoiceProcessingProfile';import type {NativeAudioStartOptions} from '@app/types/electron.d';+import {AccountTiers, type TierGatedAction, TierGatedActions} from '@fluxer/constants/src/AccountTierConstants';+import {resolveVerificationNeed} from '@fluxer/constants/src/AccountTierRules';import {ME} from '@fluxer/constants/src/AppConstants';import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';import {shouldApplyGatewayVoiceStateEcho} from '@fluxer/voice_engine_v2/src/core/reducers/gateway';@@ -208,6 +210,12 @@ import React from 'react';const logger = new Logger('MediaEngineFacade');const VOICE_P2P_PEER_FAILED_MODAL_KEY = 'voice-p2p-peer-failed';+function voiceGateAction(channelType: number | undefined): TierGatedAction {+ if (channelType === ChannelTypes.DM) return TierGatedActions.CALL;+ if (channelType === ChannelTypes.GROUP_DM) return TierGatedActions.GROUP_CALL;+ return TierGatedActions.VOICE;+}+function isCameraPermissionDeniedCommandFailure(error: unknown): boolean {if (!(error instanceof Error)) return false;const code = (error as Error & {code?: unknown}).code;@@ -320,7 +328,7 @@ type TerminalUnloadVoiceDisconnectReason = 'pagehide' | 'beforeunload' | 'unloadtype VoiceMuteReason = 'guild' | 'permission' | 'voice_push_to_talk' | 'self' | null;-export interface VoiceEngineConnectionContext {+interface VoiceEngineConnectionContext {guildId: string | null;channelId: string | null;connectionId: string | null;@@ -1070,6 +1078,21 @@ class MediaEngineFacade extends Store {});}+ private promptAccountForVoice(action: TierGatedAction): void {+ const i18n = this.i18n;+ if (!i18n) return;+ const user = Users.getCurrentUser();+ const need =+ user?.verificationNeed ??+ resolveVerificationNeed({+ tier: AccountTiers.UNCLAIMED,+ identityMode: RuntimeConfig.accountIdentity,+ hasEmail: user?.email != null,+ });+ if (need === null) return;+ openAccountGateFlow(i18n, {action, need});+ }+private showVoiceChannelUnavailableErrorModal(): void {if (!this.i18n) return;this.showVoiceErrorModal(@@ -1130,11 +1153,11 @@ class MediaEngineFacade extends Store {voiceChannel && resolvedGuildId && currentUserId? (GuildMembers.getMember(resolvedGuildId, currentUserId)?.isTimedOut() ?? false): false;- const currentUser = Users.getCurrentUser();- const isUnclaimed = !(currentUser?.isClaimed() ?? false);const guild = resolvedGuildId ? Guilds.getGuild(resolvedGuildId) : null;- const isOwner = guild?.isOwner(currentUserId) ?? false;const channel = voiceChannel ?? Channels.getChannel(channelId);+ const voiceGate = canPerform(Users.getCurrentUser(), voiceGateAction(channel?.type), {+ isGuildOwner: guild?.isOwner(currentUserId) ?? false,+ });const blockedByMatureGate =Boolean(voiceChannel) &&!options.skipChannelGate &&@@ -1145,9 +1168,7 @@ class MediaEngineFacade extends Store {const preflightDecision = selectMediaEngineConnectPreflightDecision({targetAvailable: Boolean(voiceChannel),isTimedOut: Boolean(isTimedOut),- isUnclaimed,- isGuildOwner: resolvedGuildId ? isOwner : true,- isDirectMessage: channel?.type === ChannelTypes.DM,+ accountGateDenied: !voiceGate.allowed,hasGatewaySocket: Boolean(GatewaySessions.foregroundConnection.socket),blockedByMatureGate,channelLimitAllowed: true,@@ -1160,12 +1181,11 @@ class MediaEngineFacade extends Store {if (!this.i18n) {throw new Error('MediaEngineFacade: i18n not initialized');}- const descriptor =- preflightDecision.reason === 'timed-out'- ? YOU_CAN_T_JOIN_WHILE_YOU_RE_ON_DESCRIPTOR- : preflightDecision.reason === 'claim-account-direct'- ? CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR- : CLAIM_YOUR_ACCOUNT_TO_JOIN_VOICE_CHANNELS_YOU_DESCRIPTOR;+ if (preflightDecision.reason === 'account-gate') {+ if (!voiceGate.allowed) openAccountGateFlow(this.i18n, {action: voiceGate.action, need: voiceGate.need});+ return;+ }+ const descriptor = YOU_CAN_T_JOIN_WHILE_YOU_RE_ON_DESCRIPTOR;this.showVoiceErrorModal(descriptor,`voice.media-engine-facade.preflight-${preflightDecision.reason}-error-modal`,@@ -1186,9 +1206,7 @@ class MediaEngineFacade extends Store {const channelLimitDecision = selectMediaEngineConnectPreflightDecision({targetAvailable: true,isTimedOut: false,- isUnclaimed: false,- isGuildOwner: true,- isDirectMessage: false,+ accountGateDenied: false,hasGatewaySocket: true,blockedByMatureGate: false,channelLimitAllowed,@@ -2246,7 +2264,6 @@ class MediaEngineFacade extends Store {async ensureLinuxScreenShareAudioPublication(linuxRule?: NonNullable<NativeAudioStartOptions['linuxRule']>,- options?: {includeSelfWindowAudio?: boolean; replaceExisting?: boolean},): Promise<boolean> {return voiceEngineV2AppScreenShareExecutionAdapter.ensureLinuxScreenShareAudioPublication(this.room,@@ -2641,12 +2658,14 @@ class MediaEngineFacade extends Store {if (!this.i18n) {throw new Error('MediaEngineFacade: i18n not initialized');}+ if (decision.toast === 'unclaimed-account') {+ this.promptAccountForVoice(TierGatedActions.VOICE);+ return;+ }const descriptor =decision.toast === 'timed-out'? YOU_CAN_T_JOIN_WHILE_YOU_RE_ON_DESCRIPTOR- : decision.toast === 'connection-limit'- ? VOICE_CONNECTION_LIMIT_REACHED_DESCRIPTOR- : CLAIM_YOUR_ACCOUNT_TO_JOIN_THIS_VOICE_CHANNEL_DESCRIPTOR;+ : VOICE_CONNECTION_LIMIT_REACHED_DESCRIPTOR;this.showVoiceErrorModal(descriptor, `voice.media-engine-facade.gateway-${decision.toast}-error-modal`);}if (decision.p2pRefusal) {diff --git a/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.ts b/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.tsindex f6e295f71..94e67e6c0 100644--- a/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.ts+++ b/fluxer_app/src/features/voice/engine/MediaEngineFacadeStateMachine.ts@@ -59,9 +59,7 @@ export type MediaEngineFacadeConnectRequestDecision =export interface MediaEngineFacadeConnectPreflightInput {targetAvailable: boolean;isTimedOut: boolean;- isUnclaimed: boolean;- isGuildOwner: boolean;- isDirectMessage: boolean;+ accountGateDenied: boolean;hasGatewaySocket: boolean;blockedByMatureGate: boolean;channelLimitAllowed: boolean;@@ -69,7 +67,7 @@ export interface MediaEngineFacadeConnectPreflightInput {export type MediaEngineFacadeConnectPreflightDecision =| {type: 'cleanup-unavailable-target'; showToast: true}- | {type: 'toast'; reason: 'timed-out' | 'claim-account-guild' | 'claim-account-direct'}+ | {type: 'toast'; reason: 'timed-out' | 'account-gate'}| {type: 'abort'; reason: 'missing-gateway-socket' | 'channel-limit'}| {type: 'navigate-channel-gate'}| {type: 'proceed'};@@ -379,14 +377,8 @@ export function selectMediaEngineConnectPreflightDecision(if (input.isTimedOut) {return {type: 'toast', reason: 'timed-out'};}- if (input.isUnclaimed && input.isDirectMessage) {- return {type: 'toast', reason: 'claim-account-direct'};- }- if (input.isUnclaimed && !input.isGuildOwner) {- return {- type: 'toast',- reason: 'claim-account-guild',- };+ if (input.accountGateDenied) {+ return {type: 'toast', reason: 'account-gate'};}if (!input.hasGatewaySocket) {return {type: 'abort', reason: 'missing-gateway-socket'};@@ -416,6 +408,7 @@ const voiceGatewayErrorCodes = new Set<GatewayErrorCode>([GatewayErrorCodes.VOICE_UNCLAIMED_ACCOUNT,GatewayErrorCodes.VOICE_P2P_CONSENT_REQUIRED,GatewayErrorCodes.VOICE_P2P_UNAVAILABLE,+ GatewayErrorCodes.VOICE_ACCOUNT_VERIFICATION_REQUIRED,]);const unavailableGatewayErrorCodes = new Set<GatewayErrorCode>([@@ -437,6 +430,7 @@ const preConnectAbortGatewayErrorCodes = new Set<GatewayErrorCode>([GatewayErrorCodes.VOICE_UNCLAIMED_ACCOUNT,GatewayErrorCodes.VOICE_P2P_CONSENT_REQUIRED,GatewayErrorCodes.VOICE_P2P_UNAVAILABLE,+ GatewayErrorCodes.VOICE_ACCOUNT_VERIFICATION_REQUIRED,]);const p2pRefusalsByGatewayErrorCode = new Map<GatewayErrorCode, MediaEngineFacadeP2pRefusal>([@@ -482,7 +476,10 @@ export function selectMediaEngineGatewayErrorDecision(toast = 'timed-out';} else if (input.code === GatewayErrorCodes.VOICE_CONNECTION_LIMIT_REACHED) {toast = 'connection-limit';- } else if (input.code === GatewayErrorCodes.VOICE_UNCLAIMED_ACCOUNT) {+ } else if (+ input.code === GatewayErrorCodes.VOICE_UNCLAIMED_ACCOUNT ||+ input.code === GatewayErrorCodes.VOICE_ACCOUNT_VERIFICATION_REQUIRED+ ) {toast = 'unclaimed-account';}diff --git a/fluxer_app/src/features/voice/engine/media_engine_facade/shared.ts b/fluxer_app/src/features/voice/engine/media_engine_facade/shared.tsindex a56dfd01c..20d4a6d2c 100644--- a/fluxer_app/src/features/voice/engine/media_engine_facade/shared.ts+++ b/fluxer_app/src/features/voice/engine/media_engine_facade/shared.ts@@ -6,18 +6,6 @@ export const YOU_CAN_T_JOIN_WHILE_YOU_RE_ON_DESCRIPTOR = msg({message: "You can't join while you're timed out.",comment: 'Toast / error shown when a user tries to join voice while under moderation timeout. Tone stays plain.',});-export const CLAIM_YOUR_ACCOUNT_TO_JOIN_VOICE_CHANNELS_YOU_DESCRIPTOR = msg({- message: "Claim your account to join voice channels you don't own.",- comment: 'Toast / error shown when an unclaimed (guest) account tries to join a voice channel they do not own.',-});-export const CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR = msg({- message: 'Claim your account to start or join 1:1 calls.',- comment: 'Toast / error shown when an unclaimed (guest) account tries to start or join a 1:1 voice call.',-});-export const CLAIM_YOUR_ACCOUNT_TO_JOIN_THIS_VOICE_CHANNEL_DESCRIPTOR = msg({- message: 'Claim your account to join this voice channel.',- comment: 'Toast / error shown when an unclaimed (guest) account tries to join this voice channel.',-});export const RECONNECT_SUCCEEDED_PICK_A_SCREEN_AGAIN_IF_YOU_DESCRIPTOR = msg({message: 'Reconnect succeeded. Pick a screen again if you want to resume your previous stream.',comment: 'Toast shown after a successful voice reconnect when an in-progress screen share could not be auto-resumed.',diff --git a/fluxer_app/src/features/voice/hooks/useVoiceJoinEligibility.ts b/fluxer_app/src/features/voice/hooks/useVoiceJoinEligibility.tsindex 63e3ca366..da4ee156e 100644--- a/fluxer_app/src/features/voice/hooks/useVoiceJoinEligibility.ts+++ b/fluxer_app/src/features/voice/hooks/useVoiceJoinEligibility.ts@@ -2,12 +2,10 @@import Authentication from '@app/features/auth/state/Authentication';import Channels from '@app/features/channel/state/Channels';-import Guilds from '@app/features/guild/state/Guilds';import GuildMembers from '@app/features/member/state/GuildMembers';import Permission from '@app/features/permissions/state/Permission';-import Users from '@app/features/user/state/Users';import MediaEngine, {useMediaEngineVersion} from '@app/features/voice/engine/MediaEngineFacade';-import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants';+import {Permissions} from '@fluxer/constants/src/ChannelConstants';interface VoiceJoinEligibility {canJoin: boolean;@@ -26,22 +24,11 @@ export function useVoiceJoinEligibility({if (!channel) return {canJoin: false};const effectiveGuildId = guildId ?? channel.guildId ?? null;const currentUserId = Authentication.currentUserId;- const currentUser = Users.getCurrentUser();- const isUnclaimed = !(currentUser?.isClaimed() ?? false);if (effectiveGuildId && currentUserId) {const member = GuildMembers.getMember(effectiveGuildId, currentUserId);if (member?.isTimedOut()) return {canJoin: false};}if (effectiveGuildId && !Permission.can(Permissions.CONNECT, channel)) return {canJoin: false};- if (isUnclaimed) {- if (effectiveGuildId) {- const guild = Guilds.getGuild(effectiveGuildId);- const isOwner = guild?.isOwner(currentUserId) ?? false;- if (!isOwner) return {canJoin: false};- } else if (channel.type === ChannelTypes.DM) {- return {canJoin: false};- }- }if (effectiveGuildId && channel.userLimit && channel.userLimit > 0 && currentUserId) {const voiceStates = MediaEngine.getAllVoiceStatesInChannel(effectiveGuildId, channelId);const currentConnectionId = MediaEngine.connectionId;