mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 21:45:31 +09:00
refactor(voice): remove the unused voice state ack (#2716)
This commit is contained in:
1 parent
3e79530389
commit
e1bc6c2f7e
16 files changed
+21
-581
No files matched your search
@@ -36,7 +36,6 @@ import {
|
||||
selectMediaEngineGatewayErrorDecision,
|
||||
shouldCancelMediaEngineReconnectForServerVoiceStateRemoval,
|
||||
shouldImmediatelyDisconnectMediaEngineForServerVoiceStateRemoval,
|
||||
shouldNotifyCameraUserLimitRejection,
|
||||
shouldRunMediaEngineDeferredDisconnect,
|
||||
transitionMediaEngineFacadeSnapshot,
|
||||
} from '@app/features/voice/engine/MediaEngineFacadeStateMachine';
|
||||
@@ -47,7 +46,6 @@ import {
|
||||
CLAIM_YOUR_ACCOUNT_TO_START_OR_JOIN_1_DESCRIPTOR,
|
||||
DEFERRED_DISCONNECT_TIMEOUT_MS,
|
||||
RECONNECT_SUCCEEDED_PICK_A_SCREEN_AGAIN_IF_YOU_DESCRIPTOR,
|
||||
VOICE_CAMERA_USER_LIMIT_REACHED_DESCRIPTOR,
|
||||
VOICE_CHANNEL_NO_LONGER_AVAILABLE_DESCRIPTOR,
|
||||
VOICE_CONNECTION_FAILED_DESCRIPTOR,
|
||||
VOICE_CONNECTION_LIMIT_REACHED_DESCRIPTOR,
|
||||
@@ -136,7 +134,6 @@ import {VoiceEngineV2AppStatsHostAdapter} from '@app/features/voice/engine/v2/Vo
|
||||
import VoiceEngineV2AppSubscriptionAdapter from '@app/features/voice/engine/v2/VoiceEngineV2AppSubscriptionAdapter';
|
||||
import voiceEngineV2AppVoiceStateAdapter from '@app/features/voice/engine/v2/VoiceEngineV2AppVoiceStateAdapter';
|
||||
import type {DisplayScreenShareCaptureContext} from '@app/features/voice/engine/voice_screen_share_manager/shared';
|
||||
import type {VoiceStateAckPayload} from '@app/features/voice/events/VoiceStateAck';
|
||||
import CallMediaPrefs from '@app/features/voice/state/CallMediaPrefs';
|
||||
import {type ChannelE2EEStatus, computeChannelE2EEStatus} from '@app/features/voice/state/ChannelE2EEStatus';
|
||||
import LocalVoiceState from '@app/features/voice/state/LocalVoiceState';
|
||||
@@ -156,7 +153,6 @@ import {getActiveVoiceProcessingMode} from '@app/features/voice/utils/VoiceProce
|
||||
import type {NativeAudioStartOptions} from '@app/types/electron.d';
|
||||
import {ME} from '@fluxer/constants/src/AppConstants';
|
||||
import {ChannelTypes} from '@fluxer/constants/src/ChannelConstants';
|
||||
import {VOICE_CHANNEL_CAMERA_USER_LIMIT} from '@fluxer/constants/src/LimitConstants';
|
||||
import type {
|
||||
VoiceEngineV2AudioMode,
|
||||
VoiceEngineV2CameraOptions,
|
||||
@@ -1925,41 +1921,6 @@ class MediaEngineFacade extends Store {
|
||||
return voiceEngineV2AppVoiceStateAdapter.getAllVoiceStates();
|
||||
}
|
||||
|
||||
handleGatewayVoiceStateAck(data: VoiceStateAckPayload): void {
|
||||
if (shouldNotifyCameraUserLimitRejection({status: data.status, errorCode: data.error_code})) {
|
||||
this.handleCameraUserLimitRejection();
|
||||
}
|
||||
const canonicalState = data.canonical_state;
|
||||
if (!canonicalState?.channel_id || !canonicalState.connection_id) {
|
||||
logger.debug('Ignoring voice state ack without canonical connection state', {
|
||||
mutationId: data.mutation_id,
|
||||
status: data.status,
|
||||
guildId: data.guild_id,
|
||||
channelId: data.channel_id,
|
||||
connectionId: data.connection_id,
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.applyEngineGatewayEcho(
|
||||
this.toEngineGatewayVoiceState(canonicalState, canonicalState.guild_id ?? data.guild_id ?? null),
|
||||
);
|
||||
}
|
||||
|
||||
private handleCameraUserLimitRejection(): void {
|
||||
logger.warn('Camera enable rejected by the gateway camera user limit', {
|
||||
limit: VOICE_CHANNEL_CAMERA_USER_LIMIT,
|
||||
});
|
||||
void this.setCameraEnabled(false, {sendUpdate: false}).catch((error) => {
|
||||
logger.warn('Failed to turn the camera back off after a camera user limit rejection', {error});
|
||||
});
|
||||
if (!this.i18n) return;
|
||||
this.showVoiceErrorModal(
|
||||
VOICE_CAMERA_USER_LIMIT_REACHED_DESCRIPTOR,
|
||||
'voice.media-engine-facade.camera-user-limit-error-modal',
|
||||
{voiceChannelCameraUserLimit: VOICE_CHANNEL_CAMERA_USER_LIMIT},
|
||||
);
|
||||
}
|
||||
|
||||
private toEngineGatewayVoiceState(
|
||||
source: {
|
||||
guild_id?: string | null;
|
||||
|
||||
@@ -10,10 +10,8 @@ import {
|
||||
selectMediaEngineGatewayErrorDecision,
|
||||
shouldCancelMediaEngineReconnectForServerVoiceStateRemoval,
|
||||
shouldImmediatelyDisconnectMediaEngineForServerVoiceStateRemoval,
|
||||
shouldNotifyCameraUserLimitRejection,
|
||||
shouldRunMediaEngineDeferredDisconnect,
|
||||
transitionMediaEngineFacadeSnapshot,
|
||||
VOICE_CAMERA_USER_LIMIT_ERROR_CODE,
|
||||
} from './MediaEngineFacadeStateMachine';
|
||||
|
||||
function connected(guildId: string | null = 'guild-1', channelId = 'channel-1') {
|
||||
@@ -434,27 +432,4 @@ describe('MediaEngineFacadeStateMachine', () => {
|
||||
}),
|
||||
).toEqual({type: 'navigate-channel-gate'});
|
||||
});
|
||||
|
||||
it('notifies only for rejected voice state acks carrying the camera user limit error code', () => {
|
||||
expect(
|
||||
shouldNotifyCameraUserLimitRejection({
|
||||
status: 'rejected',
|
||||
errorCode: VOICE_CAMERA_USER_LIMIT_ERROR_CODE,
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldNotifyCameraUserLimitRejection({
|
||||
status: 'applied',
|
||||
errorCode: VOICE_CAMERA_USER_LIMIT_ERROR_CODE,
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
shouldNotifyCameraUserLimitRejection({
|
||||
status: 'rejected',
|
||||
errorCode: 'VOICE_PERMISSION_DENIED',
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(shouldNotifyCameraUserLimitRejection({})).toBe(false);
|
||||
expect(shouldNotifyCameraUserLimitRejection({status: 'rejected'})).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -84,18 +84,6 @@ export interface MediaEngineFacadeGatewayErrorInput {
|
||||
channelId: string | null;
|
||||
}
|
||||
|
||||
export const VOICE_CAMERA_USER_LIMIT_ERROR_CODE = 'VOICE_CAMERA_USER_LIMIT';
|
||||
|
||||
export interface MediaEngineFacadeVoiceStateAckRejectionInput {
|
||||
status?: string;
|
||||
errorCode?: string;
|
||||
}
|
||||
|
||||
export function shouldNotifyCameraUserLimitRejection(input: MediaEngineFacadeVoiceStateAckRejectionInput): boolean {
|
||||
if (input.status !== 'rejected') return false;
|
||||
return input.errorCode === VOICE_CAMERA_USER_LIMIT_ERROR_CODE;
|
||||
}
|
||||
|
||||
export type MediaEngineFacadeGatewayErrorDecision =
|
||||
| {type: 'ignore'}
|
||||
| {
|
||||
|
||||
Reference in new issue
Block a user