Skip to content

Commit

Permalink
Fixed joining ongoing video call by a non-admin on an announcement-on…
Browse files Browse the repository at this point in the history
…ly group
  • Loading branch information
alvaro-signal committed Aug 26, 2022
1 parent 07ab071 commit 299044f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
6 changes: 0 additions & 6 deletions ts/state/ducks/calling.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -636,7 +631,6 @@ export type CallingActionType =
| SetLocalVideoFulfilledActionType
| SetPresentingSourcesActionType
| SetOutgoingRingActionType
| ShowCallLobbyActionType
| StartDirectCallActionType
| ToggleNeedsScreenRecordingPermissionsActionType
| ToggleParticipantsActionType
Expand Down
26 changes: 24 additions & 2 deletions ts/views/conversation_view.tsx
Expand Up @@ -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;
Expand Down Expand Up @@ -650,9 +653,28 @@ export class ConversationView extends window.Backbone.View<ConversationModel> {
async onOutgoingVideoCallInConversation(): Promise<void> {
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()) {
Expand Down

0 comments on commit 299044f

Please sign in to comment.