Skip to content

Commit 934ee92

Browse files
authored
feat: Implement breaking changes of api V10 & V11 [WPB-19039] (#19329)
* feat: Implement breaking changes of api V10 & V11 [WPB-19039] * remove getRedirectUrl * bump core * fix broken tests * fix broken tests
1 parent 2d54b43 commit 934ee92

File tree

10 files changed

+39
-56
lines changed

10 files changed

+39
-56
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@wireapp/avs": "10.0.46",
1717
"@wireapp/avs-debugger": "0.0.7",
1818
"@wireapp/commons": "5.4.3",
19-
"@wireapp/core": "46.32.4",
19+
"@wireapp/core": "46.33.0",
2020
"@wireapp/kalium-backup": "0.0.4",
2121
"@wireapp/react-ui-kit": "9.63.0",
2222
"@wireapp/store-engine-dexie": "2.1.15",

src/script/Config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*
1818
*/
1919

20+
import {MINIMUM_API_VERSION} from '@wireapp/api-client/lib/Config';
21+
2022
import {Runtime} from '@wireapp/commons';
2123

2224
import {createUuid} from 'Util/uuid';
@@ -84,7 +86,7 @@ const config = {
8486
ALLOWED_IMAGE_TYPES: ['image/bmp', 'image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/webp'],
8587

8688
/** Which min and max version of the backend api do we support */
87-
SUPPORTED_API_RANGE: [9, 9],
89+
SUPPORTED_API_RANGE: [MINIMUM_API_VERSION, 11],
8890

8991
/** DataDog client api keys access */
9092
dataDog: {

src/script/auth/hooks/useEnterpriseLoginV2.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {APIClient} from '../../service/APIClientSingleton';
2929
import {actionRoot as ROOT_ACTIONS} from '../module/action/';
3030
import {RegistrationDataState} from '../module/reducer/authReducer';
3131
import {ROUTE} from '../route';
32-
import {getRedirectURL} from '../util/configUtil';
3332

3433
export const useEnterpriseLoginV2 = ({
3534
loginWithSSO,
@@ -73,7 +72,7 @@ export const useEnterpriseLoginV2 = ({
7372
}
7473

7574
case DomainRedirect.BACKEND: {
76-
const url = await getRedirectURL(response.backend_url);
75+
const url = response.backend.webapp_url;
7776
updateRegistrationData({
7877
customBackendURL: url,
7978
});

src/script/auth/util/configUtil.ts

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/script/error/BaseError.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class BaseError extends Error {
3737
return {
3838
INVALID_PARAMETER: 'Invalid parameter passed',
3939
MISSING_PARAMETER: 'Required parameter is not defined',
40+
MISSING_QUALIFIED_ID: 'Required qualified ID is not defined',
4041
UNKNOWN: 'Unknown',
4142
};
4243
}

src/script/repositories/conversation/ConversationMapper.test.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ describe('ConversationMapper', () => {
354354
ephemeral_timer: null,
355355
global_message_timer: null,
356356
id: conversationId,
357+
domain: 'wire.com',
357358
is_guest: false,
358359
last_event_timestamp: 1545058511982,
359360
last_read_timestamp: 1545058511982,
@@ -373,7 +374,7 @@ describe('ConversationMapper', () => {
373374
access: [CONVERSATION_ACCESS.INVITE, CONVERSATION_ACCESS.CODE],
374375
access_role: CONVERSATION_LEGACY_ACCESS_ROLE.NON_ACTIVATED,
375376
creator: conversationCreatorId,
376-
id: conversationId,
377+
qualified_id: {domain: 'wire.com', id: conversationId},
377378
last_event_timestamp: new Date('1970-01-01T00:00:00.000Z').getTime(),
378379
members: {
379380
others: [
@@ -408,7 +409,7 @@ describe('ConversationMapper', () => {
408409
const remoteData: Partial<ConversationBackendData> = {
409410
access: [CONVERSATION_ACCESS.PRIVATE],
410411
creator: '532af01e-1e24-4366-aacf-33b67d4ee376',
411-
id: 'de7466b0-985c-4dc3-ad57-17877db45b4c',
412+
qualified_id: {domain: 'wire.com', id: 'de7466b0-985c-4dc3-ad57-17877db45b4c'},
412413
members: {
413414
others: [{id: '532af01e-1e24-4366-aacf-33b67d4ee376', status: 0}],
414415
self: {
@@ -436,6 +437,7 @@ describe('ConversationMapper', () => {
436437
cleared_timestamp: 0,
437438
ephemeral_timer: 0,
438439
id: 'de7466b0-985c-4dc3-ad57-17877db45b4c',
440+
domain: 'wire.com',
439441
last_event_timestamp: 1488387380633,
440442
last_read_timestamp: 1488387380633,
441443
muted_state: NOTIFICATION_STATE.EVERYTHING,
@@ -450,7 +452,7 @@ describe('ConversationMapper', () => {
450452

451453
expect(mergedConversation.creator).toBe(remoteData.creator);
452454
expect(mergedConversation.name).toBe(remoteData.name);
453-
expect(mergedConversation.others[0]).toBe(remoteData.members.others[0].id);
455+
expect(mergedConversation.others[0]).toBe(remoteData.members?.others[0].id);
454456
expect(mergedConversation.team_id).toBe(remoteData.team);
455457
expect(mergedConversation.type).toBe(remoteData.type);
456458

@@ -477,7 +479,7 @@ describe('ConversationMapper', () => {
477479
};
478480

479481
const remoteData2: ConversationBackendData = JSON.parse(JSON.stringify(remoteData));
480-
remoteData2.id = createUuid();
482+
remoteData2.qualified_id = {domain: 'wire.com', id: createUuid()};
481483

482484
const [merged_conversation, merged_conversation_2] = ConversationMapper.mergeConversations(
483485
[localData] as ConversationDatabaseData[],
@@ -486,7 +488,7 @@ describe('ConversationMapper', () => {
486488

487489
expect(merged_conversation.creator).toBe(remoteData.creator);
488490
expect(merged_conversation.name).toBe(remoteData.name);
489-
expect(merged_conversation.others[0]).toBe(remoteData.members.others[0].id);
491+
expect(merged_conversation.others[0]).toBe(remoteData.members?.others[0].id);
490492
expect(merged_conversation.type).toBe(remoteData.type);
491493

492494
expect(merged_conversation.cleared_timestamp).toBe(localData.cleared_timestamp);
@@ -514,6 +516,7 @@ describe('ConversationMapper', () => {
514516
it('updates local message timer if present on the remote', () => {
515517
const baseConversation: Partial<ConversationDatabaseData> = {
516518
id: 'd5a39ffb-6ce3-4cc8-9048-0123456789abc',
519+
qualified_id: {domain: 'wire.com', id: 'd5a39ffb-6ce3-4cc8-9048-0123456789abc'},
517520
members: {others: [], self: {} as any},
518521
};
519522
[
@@ -578,7 +581,6 @@ describe('ConversationMapper', () => {
578581
archived_state: false,
579582
archived_timestamp: 1487239601118,
580583
creator: '532af01e-1e24-4366-aacf-33b67d4ee376',
581-
id: 'de7466b0-985c-4dc3-ad57-17877db45b4c',
582584
last_event_timestamp: 1,
583585
last_server_timestamp: 1,
584586
muted_state: 0,
@@ -588,6 +590,8 @@ describe('ConversationMapper', () => {
588590
roles: {},
589591
team_id: '5316fe03-24ee-4b19-b789-6d026bd3ce5f',
590592
type: 2,
593+
domain: 'wire.com',
594+
id: 'de7466b0-985c-4dc3-ad57-17877db45b4c',
591595
};
592596

593597
expect(merged_conversation).toEqual(mergedConversation);

src/script/repositories/conversation/ConversationMapper.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ export class ConversationMapper {
246246
throw new ConversationError(BASE_ERROR_TYPE.INVALID_PARAMETER, BaseError.MESSAGE.INVALID_PARAMETER);
247247
}
248248

249+
// Ensure that conversationData has a qualified_id or id
250+
if (!conversationData.qualified_id && !conversationData.id) {
251+
throw new ConversationError(BASE_ERROR_TYPE.MISSING_PARAMETER, BaseError.MESSAGE.MISSING_QUALIFIED_ID);
252+
}
253+
254+
// since api V10 /get or /post conversation does not return id in conversation data
255+
const conversationIdFromQualifiedId = conversationData?.qualified_id?.id;
256+
if (conversationIdFromQualifiedId) {
257+
conversationData.id = conversationIdFromQualifiedId;
258+
}
259+
249260
const {
250261
creator,
251262
id,
@@ -367,7 +378,7 @@ export class ConversationMapper {
367378

368379
for (let i = 0; i < foundRemoteConversations.length; i++) {
369380
const remoteConversation = foundRemoteConversations[i];
370-
const conversationId = remoteConversation.qualified_id?.id || remoteConversation.id;
381+
const conversationId = remoteConversation.qualified_id?.id;
371382
const localConversation = conversationsMap.get(conversationId);
372383

373384
if (localConversation) {

src/script/repositories/conversation/ConversationRepository.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,6 @@ describe('ConversationRepository', () => {
18201820
access_role_v2: [],
18211821
cells_state: CONVERSATION_CELLS_STATE.DISABLED,
18221822
creator: 'c472ba79-0bca-4a74-aaa3-a559a16705d3',
1823-
id: 'c9405f98-e25a-4b1f-ade7-227ea765dff7',
18241823
last_event: '0.0',
18251824
last_event_time: '1970-01-01T00:00:00.000Z',
18261825
members: {

test/helper/ConversationGenerator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export function generateAPIConversation({
5959
name,
6060
type: type,
6161
protocol: protocol,
62-
qualified_id: id,
62+
qualified_id: overwites.id && overwites.domain ? {id: overwites.id, domain: overwites.domain} : id,
6363
access: [],
6464
verification_state: ConversationVerificationState.UNVERIFIED,
6565
mlsVerificationState: ConversationVerificationState.UNVERIFIED,

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8094,9 +8094,9 @@ __metadata:
80948094
languageName: node
80958095
linkType: hard
80968096

8097-
"@wireapp/api-client@npm:^27.73.2":
8098-
version: 27.73.2
8099-
resolution: "@wireapp/api-client@npm:27.73.2"
8097+
"@wireapp/api-client@npm:^27.74.0":
8098+
version: 27.74.0
8099+
resolution: "@wireapp/api-client@npm:27.74.0"
81008100
dependencies:
81018101
"@aws-sdk/client-s3": "npm:3.864.0"
81028102
"@aws-sdk/lib-storage": "npm:3.864.0"
@@ -8115,7 +8115,7 @@ __metadata:
81158115
uuid: "npm:11.1.0"
81168116
ws: "npm:8.18.1"
81178117
zod: "npm:3.24.2"
8118-
checksum: 10/b3f4fb4991b1ea20db6c106b505d934282a7794b5389b08d9e4d2c0e044fc8e966461476a8ea9f0ffd9b940fecce846d6b2d0d1de95fc3c092ff95fc98ffbae6
8118+
checksum: 10/e257ac14c6bd575f2cb9699ccdaace2583e4dbb63dd5f2219375d449fe69f69bcc75c38bb76a1e99e488006db452b2b76840b3075402ad9eb3ec2d344b07d23c
81198119
languageName: node
81208120
linkType: hard
81218121

@@ -8192,11 +8192,11 @@ __metadata:
81928192
languageName: node
81938193
linkType: hard
81948194

8195-
"@wireapp/core@npm:46.32.4":
8196-
version: 46.32.4
8197-
resolution: "@wireapp/core@npm:46.32.4"
8195+
"@wireapp/core@npm:46.33.0":
8196+
version: 46.33.0
8197+
resolution: "@wireapp/core@npm:46.33.0"
81988198
dependencies:
8199-
"@wireapp/api-client": "npm:^27.73.2"
8199+
"@wireapp/api-client": "npm:^27.74.0"
82008200
"@wireapp/commons": "npm:^5.4.4"
82018201
"@wireapp/core-crypto": "npm:7.0.2"
82028202
"@wireapp/cryptobox": "npm:12.8.0"
@@ -8214,7 +8214,7 @@ __metadata:
82148214
long: "npm:^5.2.0"
82158215
uuid: "npm:9.0.1"
82168216
zod: "npm:3.24.2"
8217-
checksum: 10/ba2ceb080b468817b8ebe61d711d6d2fd2d71ee164919a73d13b77d733c7b05887a4b3cee7f80b54838664f52bd28b079ffff2288ce20ea792cb2e7d800f323f
8217+
checksum: 10/ed49aee978368d8981ed623c0ffb92035d5e0eb3fd567fd800976cfab6576980817acd47caefed1b708b5a77935339a4aa104500a9aafac45f9058d6afd16079
82188218
languageName: node
82198219
linkType: hard
82208220

@@ -21879,7 +21879,7 @@ __metadata:
2187921879
"@wireapp/avs-debugger": "npm:0.0.7"
2188021880
"@wireapp/commons": "npm:5.4.3"
2188121881
"@wireapp/copy-config": "npm:2.3.1"
21882-
"@wireapp/core": "npm:46.32.4"
21882+
"@wireapp/core": "npm:46.33.0"
2188321883
"@wireapp/eslint-config": "npm:3.0.7"
2188421884
"@wireapp/kalium-backup": "npm:0.0.4"
2188521885
"@wireapp/prettier-config": "npm:0.6.4"

0 commit comments

Comments
 (0)