From 299044f89f0e982beb37152bc23400a727fad27e Mon Sep 17 00:00:00 2001 From: Alvaro <110414366+alvaro-signal@users.noreply.github.com> Date: Fri, 26 Aug 2022 09:02:47 -0600 Subject: [PATCH] Fixed joining ongoing video call by a non-admin on an announcement-only group --- ts/state/ducks/calling.ts | 6 ------ ts/views/conversation_view.tsx | 26 ++++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/ts/state/ducks/calling.ts b/ts/state/ducks/calling.ts index 8c4c28ea3b..d9c0065475 100644 --- a/ts/state/ducks/calling.ts +++ b/ts/state/ducks/calling.ts @@ -570,11 +570,6 @@ type SetOutgoingRingActionType = { payload: boolean; }; -type ShowCallLobbyActionType = { - type: 'calling/START_CALLING_LOBBY'; - payload: StartCallingLobbyPayloadType; -}; - type StartDirectCallActionType = { type: 'calling/START_DIRECT_CALL'; payload: StartDirectCallType; @@ -636,7 +631,6 @@ export type CallingActionType = | SetLocalVideoFulfilledActionType | SetPresentingSourcesActionType | SetOutgoingRingActionType - | ShowCallLobbyActionType | StartDirectCallActionType | ToggleNeedsScreenRecordingPermissionsActionType | ToggleParticipantsActionType diff --git a/ts/views/conversation_view.tsx b/ts/views/conversation_view.tsx index 51c6caec8b..cc5076ccbe 100644 --- a/ts/views/conversation_view.tsx +++ b/ts/views/conversation_view.tsx @@ -113,6 +113,9 @@ import { sendDeleteForEveryoneMessage } from '../util/sendDeleteForEveryoneMessa import { SECOND } from '../util/durations'; import { blockSendUntilConversationsAreVerified } from '../util/blockSendUntilConversationsAreVerified'; import { SafetyNumberChangeSource } from '../components/SafetyNumberChangeDialog'; +import { getOwn } from '../util/getOwn'; +import { CallMode } from '../types/Calling'; +import { isAnybodyElseInGroupCall } from '../state/ducks/calling'; type AttachmentOptions = { messageId: string; @@ -650,9 +653,28 @@ export class ConversationView extends window.Backbone.View { async onOutgoingVideoCallInConversation(): Promise { log.info('onOutgoingVideoCallInConversation: about to start a video call'); + // if it's a group call on an announcementsOnly group + // only allow join if the call has already been started (presumably by the admin) if (this.model.get('announcementsOnly') && !this.model.areWeAdmin()) { - showToast(ToastCannotStartGroupCall); - return; + const call = getOwn( + window.reduxStore.getState().calling.callsByConversation, + this.model.id + ); + + // technically not necessary, but isAnybodyElseInGroupCall requires it + const ourUuid = window.storage.user.getCheckedUuid().toString(); + + const isOngoingGroupCall = + call && + ourUuid && + call.callMode === CallMode.Group && + call.peekInfo && + isAnybodyElseInGroupCall(call.peekInfo, ourUuid); + + if (!isOngoingGroupCall) { + showToast(ToastCannotStartGroupCall); + return; + } } if (await this.isCallSafe()) {