Skip to content

Commit

Permalink
runfix: treat 1:1 calls as conference calls (#17759)
Browse files Browse the repository at this point in the history
* runfix: use mls conference subconversation for 1:1 calls

* chore: feature flag todo

* runfix: add env feature flag

* runfix: remove feature flag

* runfix: conference calls for proteus 1:1 if flag is enabled

* docs: add fixme comment

* chore: set flag to false for the tests to pass

* runfix: use feature flag from backend

* refactor: apply cr suggestions

* runfix: temporarily hardcode sft for 1:1 flag
  • Loading branch information
PatrykBuniX authored Jul 26, 2024
1 parent c6e496a commit 3b8cd98
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 29 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@lexical/react": "0.12.5",
"@wireapp/avs": "9.6.12",
"@wireapp/commons": "5.2.7",
"@wireapp/core": "46.0.16-hotfix-1.0",
"@wireapp/core": "46.0.17-hotfix-1.1",
"@wireapp/react-ui-kit": "9.16.4",
"@wireapp/store-engine-dexie": "2.1.8",
"@wireapp/webapp-events": "0.20.1",
Expand Down Expand Up @@ -212,7 +212,7 @@
"translate:merge": "formatjs extract --format './bin/translations_extract_formatter.js' --out-file './src/i18n/en-US.json' './src/script/strings.ts'"
},
"resolutions": {
"@wireapp/api-client": "27.0.9-hotfix.2",
"@wireapp/api-client": "27.1.0-hotfix-1.0",
"libsodium": "0.7.10",
"xml2js": "0.5.0",
"@stablelib/utf8": "1.0.2",
Expand Down
9 changes: 6 additions & 3 deletions src/script/calling/CallingRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ describe('CallingRepository', () => {
});

describe('startCall', () => {
it.each([ConversationProtocol.PROTEUS, ConversationProtocol.MLS])(
//FIXME: Unskip after hardcoded value is removed from CallingRepository.ts
it.skip.each([ConversationProtocol.PROTEUS, ConversationProtocol.MLS])(
'starts a ONEONONE call for proteus or MLS 1:1 conversation',
async protocol => {
const conversation = createConversation(CONVERSATION_TYPE.ONE_TO_ONE, protocol);
Expand Down Expand Up @@ -296,7 +297,8 @@ describe('CallingRepository', () => {
);
});

it('does not subscribe to epoch updates after initiating a call in 1:1 mls conversation', async () => {
//FIXME: Unskip after hardcoded value is removed from CallingRepository.ts
it.skip('does not subscribe to epoch updates after initiating a call in 1:1 mls conversation', async () => {
const conversationId = {domain: 'example.com', id: 'conversation1'};

const groupId = 'groupId';
Expand Down Expand Up @@ -351,7 +353,8 @@ describe('CallingRepository', () => {
);
});

it('does not subscribe to epoch updates after answering a call in mls 1:1 conversation', async () => {
//FIXME: Unskip after hardcoded value is removed from CallingRepository.ts
it.skip('does not subscribe to epoch updates after answering a call in mls 1:1 conversation', async () => {
const conversationId = {domain: 'example.com', id: 'conversation2'};
const selfParticipant = createSelfParticipant();
const userId = {domain: '', id: ''};
Expand Down
38 changes: 24 additions & 14 deletions src/script/calling/CallingRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ import {ClientId, Participant, UserId} from './Participant';

import {PrimaryModal} from '../components/Modals/PrimaryModal';
import {Config} from '../Config';
import {isGroupMLSConversation, isMLSConversation, MLSConversation} from '../conversation/ConversationSelectors';
import {isMLSConversation, MLSConversation} from '../conversation/ConversationSelectors';
import {ConversationState} from '../conversation/ConversationState';
import {ConversationVerificationState} from '../conversation/ConversationVerificationState';
import {EventBuilder} from '../conversation/EventBuilder';
Expand Down Expand Up @@ -369,6 +369,10 @@ export class CallingRepository {
activeCall?.muteState(isMuted ? this.nextMuteState : MuteState.NOT_MUTED);
};

private readonly isMLSConference = (conversation: Conversation): conversation is MLSConversation => {
return isMLSConversation(conversation) && this.getConversationType(conversation) === CONV_TYPE.CONFERENCE_MLS;
};

public async pushClients(call: Call | undefined = this.callState.joinedCall(), checkMismatch?: boolean) {
if (!call) {
return false;
Expand All @@ -382,7 +386,7 @@ export class CallingRepository {
}
const allClients = await this.core.service!.conversation.fetchAllParticipantsClients(call.conversationId);

if (!isGroupMLSConversation(conversation)) {
if (!this.isMLSConference(conversation)) {
const qualifiedClients = flattenUserMap(allClients);

const clients: Clients = flatten(
Expand Down Expand Up @@ -740,7 +744,7 @@ export class CallingRepository {
this.serializeQualifiedId(conversation.qualifiedId),
this.serializeQualifiedId(userId),
conversation && isMLSConversation(conversation) ? senderClientId : clientId,
conversation && isGroupMLSConversation(conversation) ? CONV_TYPE.CONFERENCE_MLS : CONV_TYPE.CONFERENCE,
conversation && this.getConversationType(conversation),
);

if (res !== 0) {
Expand All @@ -762,14 +766,20 @@ export class CallingRepository {
//##############################################################################

private getConversationType(conversation: Conversation): CONV_TYPE {
if (!conversation.isGroup()) {
return CONV_TYPE.ONEONONE;
}
//FIXME: Remove this line when the feature flag is available on backend
const useSFTForOneToOneCalls = true;
// const useSFTForOneToOneCalls =
// this.teamState.teamFeatures()?.[FEATURE_KEY.CONFERENCE_CALLING]?.config?.useSFTForOneToOneCalls;

if (conversation.isGroup() || useSFTForOneToOneCalls) {
if (isMLSConversation(conversation)) {
return CONV_TYPE.CONFERENCE_MLS;
}

if (isGroupMLSConversation(conversation)) {
return CONV_TYPE.CONFERENCE_MLS;
return this.supportsConferenceCalling ? CONV_TYPE.CONFERENCE : CONV_TYPE.GROUP;
}
return this.supportsConferenceCalling ? CONV_TYPE.CONFERENCE : CONV_TYPE.GROUP;

return CONV_TYPE.ONEONONE;
}

async startCall(conversation: Conversation, callType: CALL_TYPE): Promise<void | Call> {
Expand Down Expand Up @@ -826,7 +836,7 @@ export class CallingRepository {
this.removeCall(call);
}

if (isGroupMLSConversation(conversation)) {
if (this.isMLSConference(conversation)) {
await this.joinMlsConferenceSubconversation(conversation);
}

Expand Down Expand Up @@ -958,7 +968,7 @@ export class CallingRepository {
[Segmentation.CALL.DIRECTION]: this.getCallDirection(call),
});

if (!conversation || !isGroupMLSConversation(conversation)) {
if (!conversation || !this.isMLSConference(conversation)) {
return;
}

Expand Down Expand Up @@ -993,7 +1003,7 @@ export class CallingRepository {

private readonly updateConferenceSubconversationEpoch = async (conversationId: QualifiedId) => {
const conversation = this.getConversationById(conversationId);
if (!conversation || !isGroupMLSConversation(conversation)) {
if (!conversation || !this.isMLSConference(conversation)) {
return;
}

Expand All @@ -1012,7 +1022,7 @@ export class CallingRepository {

private readonly handleCallParticipantChange = (conversationId: QualifiedId, members: QualifiedWcallMember[]) => {
const conversation = this.getConversationById(conversationId);
if (!conversation || !isGroupMLSConversation(conversation)) {
if (!conversation || !this.isMLSConference(conversation)) {
return;
}

Expand Down Expand Up @@ -1672,7 +1682,7 @@ export class CallingRepository {

const conversation = this.getConversationById(call.conversationId);

if (conversation && isGroupMLSConversation(conversation)) {
if (conversation && this.isMLSConference(conversation)) {
const subconversationEpochInfo = await this.subconversationService.getSubconversationEpochInfo(
conversation.qualifiedId,
conversation.groupId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('FeatureConfigChangeNotifier', () => {
config: {enforcedTimeoutSeconds: 0},
},
[FEATURE_KEY.CONFERENCE_CALLING]: {
config: {useSFTForOneToOneCalls: false},
status: FeatureStatus.DISABLED,
},
[FEATURE_KEY.CONVERSATION_GUEST_LINKS]: {
Expand Down
1 change: 1 addition & 0 deletions src/script/team/TeamService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export class TeamService {
status: FeatureStatus.DISABLED,
},
[FEATURE_KEY.CONFERENCE_CALLING]: {
config: {useSFTForOneToOneCalls: false},
status: FeatureStatus.ENABLED,
},
[FEATURE_KEY.DIGITAL_SIGNATURES]: {
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4693,9 +4693,9 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/api-client@npm:27.0.9-hotfix.2":
version: 27.0.9-hotfix.2
resolution: "@wireapp/api-client@npm:27.0.9-hotfix.2"
"@wireapp/api-client@npm:27.1.0-hotfix-1.0":
version: 27.1.0-hotfix-1.0
resolution: "@wireapp/api-client@npm:27.1.0-hotfix-1.0"
dependencies:
"@wireapp/commons": ^5.2.8
"@wireapp/priority-queue": ^2.1.6
Expand All @@ -4710,7 +4710,7 @@ __metadata:
tough-cookie: 4.1.4
ws: 8.17.1
zod: 3.23.8
checksum: fa33b277c45295135d4ea8e063474d4d01261d7d254609427f5fa467d6107e91c1f0a89946bbad7e02f1fb1a4836142b07db68d7a104f9ff65f9c79251952393
checksum: dc119718f533ffc1e62b2eba4953ad87ab16937dc1703ad6d01e100702014ef9d0319fc3fa5600307a81bc60e1d136436ed0061d3f4ae62106c783882424634f
languageName: node
linkType: hard

Expand Down Expand Up @@ -4775,11 +4775,11 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core@npm:46.0.16-hotfix-1.0":
version: 46.0.16-hotfix-1.0
resolution: "@wireapp/core@npm:46.0.16-hotfix-1.0"
"@wireapp/core@npm:46.0.17-hotfix-1.1":
version: 46.0.17-hotfix-1.1
resolution: "@wireapp/core@npm:46.0.17-hotfix-1.1"
dependencies:
"@wireapp/api-client": ^27.0.9-hotfix.2
"@wireapp/api-client": ^27.1.0-hotfix-1.0
"@wireapp/commons": ^5.2.8
"@wireapp/core-crypto": 1.0.0-rc.60
"@wireapp/cryptobox": 12.8.0
Expand All @@ -4797,7 +4797,7 @@ __metadata:
long: ^5.2.0
uuid: 9.0.1
zod: 3.23.8
checksum: f7d2553f307fb9a273fd7c1bc8a6e886c37a55649d45c247dac1145f1cd43597ba1050ebafea867c258ebeb6626f84bbab4ecc5b1edf7f98dbfa41d0c1ee31bf
checksum: e345882a734ea8d37c800f360fa4777389a63249ac532c3c5f1eb5c51ca618155f5e9138c0c7cb1e582d5a8947c515073d24c8e1b2ec2df4de3f7e60c88e31be
languageName: node
linkType: hard

Expand Down Expand Up @@ -17508,7 +17508,7 @@ __metadata:
"@wireapp/avs": 9.6.12
"@wireapp/commons": 5.2.7
"@wireapp/copy-config": 2.1.14
"@wireapp/core": 46.0.16-hotfix-1.0
"@wireapp/core": 46.0.17-hotfix-1.1
"@wireapp/eslint-config": 3.0.5
"@wireapp/prettier-config": 0.6.3
"@wireapp/react-ui-kit": 9.16.4
Expand Down

0 comments on commit 3b8cd98

Please sign in to comment.