@wireapp/core 42.14.1 → 42.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Account.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +9 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +12 -2
- package/lib/conversation/ConversationService/ConversationService.test.js +48 -17
- package/lib/storage/CoreDB.d.ts +7 -0
- package/lib/storage/CoreDB.d.ts.map +1 -1
- package/lib/storage/CoreDB.js +3 -1
- package/package.json +3 -3
package/lib/Account.js
CHANGED
|
@@ -305,7 +305,7 @@ class Account extends commons_1.TypedEventEmitter {
|
|
|
305
305
|
const connectionService = new connection_1.ConnectionService(this.apiClient);
|
|
306
306
|
const giphyService = new giphy_1.GiphyService(this.apiClient);
|
|
307
307
|
const linkPreviewService = new linkPreview_1.LinkPreviewService(assetService);
|
|
308
|
-
const conversationService = new conversation_1.ConversationService(this.apiClient, proteusService, mlsService);
|
|
308
|
+
const conversationService = new conversation_1.ConversationService(this.apiClient, proteusService, this.db, mlsService);
|
|
309
309
|
const notificationService = new notification_1.NotificationService(this.apiClient, this.storeEngine, conversationService);
|
|
310
310
|
const selfService = new self_1.SelfService(this.apiClient);
|
|
311
311
|
const teamService = new team_1.TeamService(this.apiClient);
|
|
@@ -10,6 +10,7 @@ import { MLSService } from '../../messagingProtocols/mls';
|
|
|
10
10
|
import { ProteusService } from '../../messagingProtocols/proteus';
|
|
11
11
|
import { AddUsersToProteusConversationParams, SendProteusMessageParams } from '../../messagingProtocols/proteus/ProteusService/ProteusService.types';
|
|
12
12
|
import { HandledEventPayload } from '../../notification';
|
|
13
|
+
import { CoreDatabase } from '../../storage/CoreDB';
|
|
13
14
|
import { RemoteData } from '../content';
|
|
14
15
|
type Events = {
|
|
15
16
|
MLSConversationRecovered: {
|
|
@@ -19,10 +20,11 @@ type Events = {
|
|
|
19
20
|
export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
20
21
|
private readonly apiClient;
|
|
21
22
|
private readonly proteusService;
|
|
23
|
+
private readonly coreDatabase;
|
|
22
24
|
private readonly _mlsService?;
|
|
23
25
|
readonly messageTimer: MessageTimer;
|
|
24
26
|
private readonly logger;
|
|
25
|
-
constructor(apiClient: APIClient, proteusService: ProteusService, _mlsService?: MLSService | undefined);
|
|
27
|
+
constructor(apiClient: APIClient, proteusService: ProteusService, coreDatabase: CoreDatabase, _mlsService?: MLSService | undefined);
|
|
26
28
|
get mlsService(): MLSService;
|
|
27
29
|
/**
|
|
28
30
|
* Get a fresh list from backend of clients for all the participants of the conversation.
|
|
@@ -56,6 +58,12 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
56
58
|
send(params: XOR<SendMlsMessageParams, SendProteusMessageParams>): Promise<SendResult>;
|
|
57
59
|
sendTypingStart(conversationId: QualifiedId): Promise<void>;
|
|
58
60
|
sendTypingStop(conversationId: QualifiedId): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Blacklists a conversation.
|
|
63
|
+
* When conversations is blacklisted, it means that it will be completely ignored by a client, even though it does exist on backend and we're the conversation member.
|
|
64
|
+
* @param conversationId id of the conversation to blacklist
|
|
65
|
+
*/
|
|
66
|
+
readonly blacklistConversation: (conversationId: QualifiedId) => Promise<void>;
|
|
59
67
|
/**
|
|
60
68
|
* returns the number of messages that are in the queue expecting to be sent
|
|
61
69
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAuB,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,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AY,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CAYnF"}
|
|
@@ -41,12 +41,21 @@ const util_1 = require("../../util");
|
|
|
41
41
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
42
42
|
const messageSender_1 = require("../message/messageSender");
|
|
43
43
|
class ConversationService extends commons_1.TypedEventEmitter {
|
|
44
|
-
constructor(apiClient, proteusService, _mlsService) {
|
|
44
|
+
constructor(apiClient, proteusService, coreDatabase, _mlsService) {
|
|
45
45
|
super();
|
|
46
46
|
this.apiClient = apiClient;
|
|
47
47
|
this.proteusService = proteusService;
|
|
48
|
+
this.coreDatabase = coreDatabase;
|
|
48
49
|
this._mlsService = _mlsService;
|
|
49
50
|
this.logger = (0, logdown_1.default)('@wireapp/core/ConversationService');
|
|
51
|
+
/**
|
|
52
|
+
* Blacklists a conversation.
|
|
53
|
+
* When conversations is blacklisted, it means that it will be completely ignored by a client, even though it does exist on backend and we're the conversation member.
|
|
54
|
+
* @param conversationId id of the conversation to blacklist
|
|
55
|
+
*/
|
|
56
|
+
this.blacklistConversation = async (conversationId) => {
|
|
57
|
+
await this.coreDatabase.put('conversationBlacklist', conversationId, conversationId.id);
|
|
58
|
+
};
|
|
50
59
|
/**
|
|
51
60
|
* Will try registering mls 1:1 conversation adding the other user.
|
|
52
61
|
* If it fails and the conversation is already established, it will try joining via external commit instead.
|
|
@@ -138,7 +147,8 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
138
147
|
}
|
|
139
148
|
async getConversations(conversationIds) {
|
|
140
149
|
if (!conversationIds) {
|
|
141
|
-
|
|
150
|
+
const conversationIdsToSkip = await this.coreDatabase.getAll('conversationBlacklist');
|
|
151
|
+
return this.apiClient.api.conversation.getConversationList(conversationIdsToSkip);
|
|
142
152
|
}
|
|
143
153
|
return this.apiClient.api.conversation.getConversationsByQualifiedIds(conversationIds);
|
|
144
154
|
}
|
|
@@ -50,6 +50,7 @@ const api_client_1 = require("@wireapp/api-client");
|
|
|
50
50
|
const __1 = require("..");
|
|
51
51
|
const CoreCryptoMLSError_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSError");
|
|
52
52
|
const MessagingProtocols = __importStar(require("../../messagingProtocols/proteus"));
|
|
53
|
+
const CoreDB_1 = require("../../storage/CoreDB");
|
|
53
54
|
const PayloadHelper = __importStar(require("../../test/PayloadHelper"));
|
|
54
55
|
const MessageBuilder = __importStar(require("../message/MessageBuilder"));
|
|
55
56
|
const createMLSMessageAddEventMock = (conversationId) => ({
|
|
@@ -73,7 +74,7 @@ describe('ConversationService', () => {
|
|
|
73
74
|
jest.useFakeTimers();
|
|
74
75
|
jest.setSystemTime(new Date(0));
|
|
75
76
|
});
|
|
76
|
-
function buildConversationService() {
|
|
77
|
+
async function buildConversationService() {
|
|
77
78
|
const client = new api_client_1.APIClient({ urls: api_client_1.APIClient.BACKEND.STAGING });
|
|
78
79
|
jest.spyOn(client.api.conversation, 'postMlsMessage').mockReturnValue(Promise.resolve({
|
|
79
80
|
events: [],
|
|
@@ -110,7 +111,8 @@ describe('ConversationService', () => {
|
|
|
110
111
|
addUsersToExistingConversation: jest.fn(),
|
|
111
112
|
resetKeyMaterialRenewal: jest.fn(),
|
|
112
113
|
};
|
|
113
|
-
const
|
|
114
|
+
const mockedDb = await (0, CoreDB_1.openDB)('core-test-db');
|
|
115
|
+
const conversationService = new __1.ConversationService(client, mockedProteusService, mockedDb, mockedMLSService);
|
|
114
116
|
jest.spyOn(conversationService, 'joinByExternalCommit');
|
|
115
117
|
jest.spyOn(conversationService, 'emit');
|
|
116
118
|
return [conversationService, { apiClient: client, mlsService: mockedMLSService }];
|
|
@@ -126,7 +128,7 @@ describe('ConversationService', () => {
|
|
|
126
128
|
];
|
|
127
129
|
messages.forEach(({ type, message }) => {
|
|
128
130
|
it(`calls callbacks when sending '${type}' message is successful`, async () => {
|
|
129
|
-
const [conversationService] = buildConversationService();
|
|
131
|
+
const [conversationService] = await buildConversationService();
|
|
130
132
|
const sentTime = new Date().toISOString();
|
|
131
133
|
mockedProteusService.sendMessage = jest.fn().mockResolvedValue({ sentAt: sentTime });
|
|
132
134
|
const promise = conversationService.send({
|
|
@@ -152,7 +154,7 @@ describe('ConversationService', () => {
|
|
|
152
154
|
];
|
|
153
155
|
messages.forEach(({ type, message }) => {
|
|
154
156
|
it(`calls callbacks when sending '${type}' message is starting and successful`, async () => {
|
|
155
|
-
const [conversationService] = buildConversationService();
|
|
157
|
+
const [conversationService] = await buildConversationService();
|
|
156
158
|
const promise = conversationService.send({
|
|
157
159
|
protocol: conversation_1.ConversationProtocol.MLS,
|
|
158
160
|
groupId,
|
|
@@ -164,7 +166,7 @@ describe('ConversationService', () => {
|
|
|
164
166
|
});
|
|
165
167
|
});
|
|
166
168
|
it('rejoins a MLS group when failed encrypting MLS message', async () => {
|
|
167
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
169
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
168
170
|
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlamxpbms=';
|
|
169
171
|
const mockConversationId = { id: 'mockConversationId', domain: 'staging.zinfra.io' };
|
|
170
172
|
const mockedMessage = MessageBuilder.buildTextMessage({ text: 'test' });
|
|
@@ -207,7 +209,7 @@ describe('ConversationService', () => {
|
|
|
207
209
|
};
|
|
208
210
|
};
|
|
209
211
|
it('re-joins multiple not-established conversations', async () => {
|
|
210
|
-
const [conversationService, { apiClient }] = buildConversationService();
|
|
212
|
+
const [conversationService, { apiClient }] = await buildConversationService();
|
|
211
213
|
const remoteEpoch = 1;
|
|
212
214
|
const mlsConversation1 = createConversation(remoteEpoch, 'conversation1');
|
|
213
215
|
const mlsConversation2 = createConversation(remoteEpoch, 'conversation2');
|
|
@@ -219,7 +221,7 @@ describe('ConversationService', () => {
|
|
|
219
221
|
expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mlsConversation2.qualified_id);
|
|
220
222
|
});
|
|
221
223
|
it('re-joins multiple conversations when mismatches detected', async () => {
|
|
222
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
224
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
223
225
|
const mlsConversation1 = createConversation(1, 'conversation1');
|
|
224
226
|
const mlsConversation2 = createConversation(1, 'conversation2');
|
|
225
227
|
const mockedDBResponse = [mlsConversation1, mlsConversation2];
|
|
@@ -231,7 +233,7 @@ describe('ConversationService', () => {
|
|
|
231
233
|
expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mlsConversation2.qualified_id);
|
|
232
234
|
});
|
|
233
235
|
it("does not re-join when there's no mismatch", async () => {
|
|
234
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
236
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
235
237
|
const mlsConversation = createConversation(1);
|
|
236
238
|
const mockedDBResponse = [mlsConversation];
|
|
237
239
|
jest.spyOn(apiClient.api.conversation, 'getConversationList').mockResolvedValueOnce({ found: mockedDBResponse });
|
|
@@ -244,7 +246,7 @@ describe('ConversationService', () => {
|
|
|
244
246
|
});
|
|
245
247
|
describe('establishMLS1to1Conversation', () => {
|
|
246
248
|
it('only returns a conversation if a group is already established on backend and locally', async () => {
|
|
247
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
249
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
248
250
|
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
249
251
|
const mockGroupId = 'mock-group-id';
|
|
250
252
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
@@ -262,7 +264,7 @@ describe('ConversationService', () => {
|
|
|
262
264
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
263
265
|
});
|
|
264
266
|
it('joins with an external commit if a group is already established on backend but not established locally', async () => {
|
|
265
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
267
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
266
268
|
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
267
269
|
const mockGroupId = 'mock-group-id';
|
|
268
270
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
@@ -290,7 +292,7 @@ describe('ConversationService', () => {
|
|
|
290
292
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
291
293
|
});
|
|
292
294
|
it('wipes the conversation and registers it if a group is not yet established on backend', async () => {
|
|
293
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
295
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
294
296
|
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
295
297
|
const mockGroupId = 'mock-group-id';
|
|
296
298
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
@@ -319,7 +321,7 @@ describe('ConversationService', () => {
|
|
|
319
321
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
320
322
|
});
|
|
321
323
|
it('retries to register the conversation after it has failed for the first time', async () => {
|
|
322
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
324
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
323
325
|
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
324
326
|
const mockGroupId = 'mock-group-id';
|
|
325
327
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
@@ -358,7 +360,7 @@ describe('ConversationService', () => {
|
|
|
358
360
|
});
|
|
359
361
|
describe('handleEvent', () => {
|
|
360
362
|
it('rejoins a MLS conversation if epoch mismatch detected when decrypting mls message', async () => {
|
|
361
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
363
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
362
364
|
const conversationId = { id: 'conversationId', domain: 'staging.zinfra.io' };
|
|
363
365
|
const mockGroupId = 'mock-group-id';
|
|
364
366
|
const mockMLSMessageAddEvent = createMLSMessageAddEventMock(conversationId);
|
|
@@ -380,9 +382,38 @@ describe('ConversationService', () => {
|
|
|
380
382
|
expect(conversationService.emit).toHaveBeenCalledWith('MLSConversationRecovered', { conversationId });
|
|
381
383
|
});
|
|
382
384
|
});
|
|
385
|
+
describe('getConversations', () => {
|
|
386
|
+
it('returns a list of conversations by conversation ids', async () => {
|
|
387
|
+
var _a;
|
|
388
|
+
const [conversationService, { apiClient }] = await buildConversationService();
|
|
389
|
+
const conversationIds = Array.from({ length: 10 }, () => ({ id: PayloadHelper.getUUID(), domain: 'test.zinfra.io' }));
|
|
390
|
+
jest.spyOn(apiClient.api.conversation, 'getConversationsByQualifiedIds').mockResolvedValueOnce({
|
|
391
|
+
found: conversationIds,
|
|
392
|
+
});
|
|
393
|
+
const conversations = await conversationService.getConversations(conversationIds);
|
|
394
|
+
expect((_a = conversations.found) === null || _a === void 0 ? void 0 : _a.length).toBe(conversationIds.length);
|
|
395
|
+
});
|
|
396
|
+
it('returns a full list of conversations if a list of conversations is not provided', async () => {
|
|
397
|
+
const [conversationService, { apiClient }] = await buildConversationService();
|
|
398
|
+
jest.spyOn(apiClient.api.conversation, 'getConversationList').mockImplementation(jest.fn());
|
|
399
|
+
await conversationService.getConversations();
|
|
400
|
+
expect(apiClient.api.conversation.getConversationList).toHaveBeenCalled();
|
|
401
|
+
});
|
|
402
|
+
it('includes a list of ids to skip if they exist in db store', async () => {
|
|
403
|
+
const [conversationService, { apiClient }] = await buildConversationService();
|
|
404
|
+
const conversationIdsToSkip = Array.from({ length: 2 }, () => ({
|
|
405
|
+
id: PayloadHelper.getUUID(),
|
|
406
|
+
domain: 'test.zinfra.io',
|
|
407
|
+
}));
|
|
408
|
+
conversationIdsToSkip.forEach(conversationService.blacklistConversation);
|
|
409
|
+
jest.spyOn(apiClient.api.conversation, 'getConversationList').mockImplementation(jest.fn());
|
|
410
|
+
await conversationService.getConversations();
|
|
411
|
+
expect(apiClient.api.conversation.getConversationList).toHaveBeenCalledWith(expect.arrayContaining(conversationIdsToSkip));
|
|
412
|
+
});
|
|
413
|
+
});
|
|
383
414
|
describe('fetchAllParticipantsClients', () => {
|
|
384
415
|
it('gives the members and clients of a federated conversation', async () => {
|
|
385
|
-
const [conversationService, { apiClient }] = buildConversationService();
|
|
416
|
+
const [conversationService, { apiClient }] = await buildConversationService();
|
|
386
417
|
jest.spyOn(apiClient.api.conversation, 'getConversation').mockResolvedValue({
|
|
387
418
|
members: {
|
|
388
419
|
others: [
|
|
@@ -408,7 +439,7 @@ describe('ConversationService', () => {
|
|
|
408
439
|
});
|
|
409
440
|
describe('addUsersToMLSConversation', () => {
|
|
410
441
|
it('should claim key packages for all the users and add them to the group', async () => {
|
|
411
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
442
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
412
443
|
const mockGroupId = 'groupId';
|
|
413
444
|
const mockConversationId = { id: PayloadHelper.getUUID(), domain: 'local.wire.com' };
|
|
414
445
|
const otherUsersToAdd = Array(3)
|
|
@@ -438,7 +469,7 @@ describe('ConversationService', () => {
|
|
|
438
469
|
});
|
|
439
470
|
describe('tryEstablishingMLSGroup', () => {
|
|
440
471
|
it('should add all the users to a MLS group after group was established by the self client', async () => {
|
|
441
|
-
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
472
|
+
const [conversationService, { apiClient, mlsService }] = await buildConversationService();
|
|
442
473
|
const selfUserId = { id: 'self-user-id', domain: 'local.wire.com' };
|
|
443
474
|
const mockConversationId = { id: PayloadHelper.getUUID(), domain: 'local.wire.com' };
|
|
444
475
|
const mockGroupId = 'groupId';
|
|
@@ -462,7 +493,7 @@ describe('ConversationService', () => {
|
|
|
462
493
|
});
|
|
463
494
|
});
|
|
464
495
|
it('should not add any users if MLS group was not established by the self client', async () => {
|
|
465
|
-
const [conversationService, { mlsService }] = buildConversationService();
|
|
496
|
+
const [conversationService, { mlsService }] = await buildConversationService();
|
|
466
497
|
const selfUserId = { id: 'self-user-id', domain: 'local.wire.com' };
|
|
467
498
|
const mockConversationId = { id: PayloadHelper.getUUID(), domain: 'local.wire.com' };
|
|
468
499
|
const mockGroupId = 'groupId';
|
package/lib/storage/CoreDB.d.ts
CHANGED
|
@@ -21,6 +21,13 @@ interface CoreDBSchema extends DBSchema {
|
|
|
21
21
|
firingDate: number;
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
|
+
conversationBlacklist: {
|
|
25
|
+
key: string;
|
|
26
|
+
value: {
|
|
27
|
+
id: string;
|
|
28
|
+
domain: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
24
31
|
}
|
|
25
32
|
export type CoreDatabase = IDBPDatabase<CoreDBSchema>;
|
|
26
33
|
export declare function openDB(dbName: string): Promise<CoreDatabase>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreDB.d.ts","sourceRoot":"","sources":["../../src/storage/CoreDB.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,QAAQ,EAA2B,YAAY,EAAsB,MAAM,KAAK,CAAC;AAGzF,UAAU,YAAa,SAAQ,QAAQ;IACrC,OAAO,EAAE;QACP,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAC,CAAC;KAC/C,CAAC;IACF,gBAAgB,EAAE;QAChB,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAC,CAAC;KAC9C,CAAC;IACF,cAAc,EAAE;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE;YAAC,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CAE9D"}
|
package/lib/storage/CoreDB.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.deleteDB = exports.openDB = void 0;
|
|
22
22
|
const idb_1 = require("idb");
|
|
23
|
-
const VERSION =
|
|
23
|
+
const VERSION = 4;
|
|
24
24
|
async function openDB(dbName) {
|
|
25
25
|
const db = await (0, idb_1.openDB)(dbName, VERSION, {
|
|
26
26
|
upgrade: (db, oldVersion) => {
|
|
@@ -32,6 +32,8 @@ async function openDB(dbName) {
|
|
|
32
32
|
db.createObjectStore('pendingProposals');
|
|
33
33
|
case 2:
|
|
34
34
|
db.createObjectStore('recurringTasks');
|
|
35
|
+
case 3:
|
|
36
|
+
db.createObjectStore('conversationBlacklist');
|
|
35
37
|
}
|
|
36
38
|
},
|
|
37
39
|
});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^26.
|
|
14
|
+
"@wireapp/api-client": "^26.4.0",
|
|
15
15
|
"@wireapp/commons": "^5.2.1",
|
|
16
16
|
"@wireapp/core-crypto": "1.0.0-rc.13",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "42.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "42.15.0",
|
|
65
|
+
"gitHead": "ed5b55b51ef156d0e50051c5ba4409e2d9360683"
|
|
66
66
|
}
|