@wireapp/core 42.14.1 → 42.16.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/Account.test.js +4 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +17 -3
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +32 -6
- package/lib/conversation/ConversationService/ConversationService.test.js +48 -17
- package/lib/notification/NotificationService.d.ts +15 -1
- package/lib/notification/NotificationService.d.ts.map +1 -1
- package/lib/notification/NotificationService.js +7 -7
- 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);
|
package/lib/Account.test.js
CHANGED
|
@@ -220,7 +220,10 @@ describe('Account', () => {
|
|
|
220
220
|
});
|
|
221
221
|
jest.spyOn(apiClient, 'connect').mockImplementation();
|
|
222
222
|
jest.spyOn(account.service.notification, 'handleEvent').mockReturnValue({
|
|
223
|
-
|
|
223
|
+
status: 'handled',
|
|
224
|
+
payload: {
|
|
225
|
+
event: { type: event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD },
|
|
226
|
+
},
|
|
224
227
|
});
|
|
225
228
|
const kill = await account.listen({
|
|
226
229
|
onEvent: ({ event }) => {
|
|
@@ -9,7 +9,8 @@ import { MessageTimer, RemoveUsersParams } from '../../conversation/';
|
|
|
9
9
|
import { MLSService } from '../../messagingProtocols/mls';
|
|
10
10
|
import { ProteusService } from '../../messagingProtocols/proteus';
|
|
11
11
|
import { AddUsersToProteusConversationParams, SendProteusMessageParams } from '../../messagingProtocols/proteus/ProteusService/ProteusService.types';
|
|
12
|
-
import {
|
|
12
|
+
import { HandledEventResult } 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
|
*/
|
|
@@ -148,7 +156,13 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
148
156
|
private recoverMLSConversationFromEpochMismatch;
|
|
149
157
|
private handleMLSWelcomeMessageEvent;
|
|
150
158
|
private handleOtrMessageAddEvent;
|
|
151
|
-
|
|
159
|
+
private isConversationBlacklisted;
|
|
160
|
+
/**
|
|
161
|
+
* Will process one conversation event
|
|
162
|
+
* @param event The backend event to process
|
|
163
|
+
* @return Event handling status (if handled successfully also the decrypted payload and the raw event)
|
|
164
|
+
*/
|
|
165
|
+
handleEvent(event: BackendEvent): Promise<HandledEventResult>;
|
|
152
166
|
}
|
|
153
167
|
export {};
|
|
154
168
|
//# sourceMappingURL=ConversationService.d.ts.map
|
|
@@ -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,
|
|
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,EAAsB,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAC,YAAY,EAA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AC;IAoBhD,oBAAoB,CAAC,cAAc,EAAE,WAAW;IAI7D;;;;;OAKG;IACU,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAmBpE;;;OAGG;IACU,qBAAqB,CAAC,OAAO,EAAE,MAAM;IAIlD;;;;OAIG;IACU,4BAA4B,CAAC,OAAO,EAAE,MAAM;IAI5C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlD,YAAY;IAYb,gCAAgC;IAa7C;;;;;OAKG;YACW,+BAA+B;IA6B7C;;;OAGG;IACG,sBAAsB,CAAC,MAAM,EAAE,WAAW;IAIhD;;;;;;;OAOG;IACH,SAAgB,4BAA4B,YACjC,MAAM,YACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,4BAEvB,QAAQ,eAAe,CAAC,CAoDzB;IAEF;;;;;;;;OAQG;IACU,uBAAuB,CAAC,EACnC,OAAO,EACP,cAAc,EACd,UAAU,EACV,cAAc,GACf,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,WAAW,CAAC;QAC5B,UAAU,EAAE,WAAW,CAAC;QACxB,cAAc,EAAE,WAAW,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC;YA4BH,wBAAwB;YAoBxB,uCAAuC;YAYvC,4BAA4B;YAI5B,wBAAwB;YAIxB,yBAAyB;IAKvC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -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
|
}
|
|
@@ -464,16 +474,32 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
464
474
|
async handleOtrMessageAddEvent(event) {
|
|
465
475
|
return this.proteusService.handleOtrMessageAddEvent(event);
|
|
466
476
|
}
|
|
477
|
+
async isConversationBlacklisted(conversationId) {
|
|
478
|
+
const foundEntry = await this.coreDatabase.get('conversationBlacklist', conversationId);
|
|
479
|
+
return !!foundEntry;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Will process one conversation event
|
|
483
|
+
* @param event The backend event to process
|
|
484
|
+
* @return Event handling status (if handled successfully also the decrypted payload and the raw event)
|
|
485
|
+
*/
|
|
467
486
|
async handleEvent(event) {
|
|
487
|
+
if ('conversation' in event) {
|
|
488
|
+
const isBlacklisted = await this.isConversationBlacklisted(event.conversation);
|
|
489
|
+
if (isBlacklisted) {
|
|
490
|
+
this.logger.info(`Conversation ${event.conversation} is blacklisted, ignoring event ${event.type}`);
|
|
491
|
+
return { status: 'ignored' };
|
|
492
|
+
}
|
|
493
|
+
}
|
|
468
494
|
switch (event.type) {
|
|
469
495
|
case event_1.CONVERSATION_EVENT.MLS_MESSAGE_ADD:
|
|
470
|
-
return this.handleMLSMessageAddEvent(event);
|
|
496
|
+
return { status: 'handled', payload: await this.handleMLSMessageAddEvent(event) };
|
|
471
497
|
case event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE:
|
|
472
|
-
return this.handleMLSWelcomeMessageEvent(event);
|
|
498
|
+
return { status: 'handled', payload: await this.handleMLSWelcomeMessageEvent(event) };
|
|
473
499
|
case event_1.CONVERSATION_EVENT.OTR_MESSAGE_ADD:
|
|
474
|
-
return this.handleOtrMessageAddEvent(event);
|
|
500
|
+
return { status: 'handled', payload: await this.handleOtrMessageAddEvent(event) };
|
|
475
501
|
}
|
|
476
|
-
return
|
|
502
|
+
return { status: 'unhandled' };
|
|
477
503
|
}
|
|
478
504
|
}
|
|
479
505
|
exports.ConversationService = ConversationService;
|
|
@@ -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';
|
|
@@ -17,6 +17,20 @@ export type HandledEventPayload = {
|
|
|
17
17
|
/** in case decryption went wrong, this will contain information about the decryption error */
|
|
18
18
|
decryptionError?: DecryptionError;
|
|
19
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* The result of handling an event
|
|
22
|
+
* - unhandled: The event was not handled by the particular service
|
|
23
|
+
* - ignored: The event was handled, but it got marked as ignored for whatever reason, it will not be emitted
|
|
24
|
+
* - handled: The event was handled and its payload will be emitted
|
|
25
|
+
*/
|
|
26
|
+
export type HandledEventResult = {
|
|
27
|
+
status: 'unhandled';
|
|
28
|
+
} | {
|
|
29
|
+
status: 'ignored';
|
|
30
|
+
} | {
|
|
31
|
+
status: 'handled';
|
|
32
|
+
payload: HandledEventPayload | null;
|
|
33
|
+
};
|
|
20
34
|
declare enum TOPIC {
|
|
21
35
|
NOTIFICATION_ERROR = "NotificationService.TOPIC.NOTIFICATION_ERROR"
|
|
22
36
|
}
|
|
@@ -61,7 +75,7 @@ export declare class NotificationService extends TypedEventEmitter<Events> {
|
|
|
61
75
|
* Will process one event
|
|
62
76
|
* @param event The backend event to process
|
|
63
77
|
* @param dryRun Will not try to decrypt if true
|
|
64
|
-
* @return
|
|
78
|
+
* @return event handling status and if event was handled, the payload
|
|
65
79
|
*/
|
|
66
80
|
private handleEvent;
|
|
67
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationService.d.ts","sourceRoot":"","sources":["../../src/notification/NotificationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAC,YAAY,EAAC,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AAGzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAC,cAAc,EAAC,MAAM,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N,mBAAmB,EAAE,mBAAmB;YAQ7C,mBAAmB;IAKjC,0DAA0D;IAC7C,4BAA4B,IAAI,OAAO,CAAC,MAAM,CAAC;IAO/C,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAKpC,wBAAwB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAI7C,gBAAgB,CAAC,SAAS,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;YAsB/C,qBAAqB;IAItB,yBAAyB,CACpC,mBAAmB,EAAE,mBAAmB,EACxC,qBAAqB,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,EACvD,YAAY,EAAE,YAAY,GACzB,OAAO,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC;IAoC3D;;;;;;;OAOG;IACH,OAAO,CAAC,eAAe;IAYT,kBAAkB,CAC9B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,kBAAkB,EAC1B,MAAM,GAAE,OAAe,GACtB,cAAc,CAAC,mBAAmB,CAAC;IAmCtC;;;;;OAKG;YACW,WAAW;CAc1B"}
|
|
@@ -161,9 +161,9 @@ class NotificationService extends commons_1.TypedEventEmitter {
|
|
|
161
161
|
continue;
|
|
162
162
|
}
|
|
163
163
|
try {
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
yield yield __await(
|
|
164
|
+
const handledEventResult = yield __await(this.handleEvent(event, dryRun));
|
|
165
|
+
if (handledEventResult.status === 'handled' && handledEventResult.payload) {
|
|
166
|
+
yield yield __await(handledEventResult.payload);
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
catch (error) {
|
|
@@ -186,19 +186,19 @@ class NotificationService extends commons_1.TypedEventEmitter {
|
|
|
186
186
|
* Will process one event
|
|
187
187
|
* @param event The backend event to process
|
|
188
188
|
* @param dryRun Will not try to decrypt if true
|
|
189
|
-
* @return
|
|
189
|
+
* @return event handling status and if event was handled, the payload
|
|
190
190
|
*/
|
|
191
191
|
async handleEvent(event, dryRun = false) {
|
|
192
192
|
if (dryRun) {
|
|
193
193
|
// In case of a dry run, we do not want to decrypt messages
|
|
194
194
|
// We just return the raw event to the caller
|
|
195
|
-
return { event };
|
|
195
|
+
return { status: 'handled', payload: { event } };
|
|
196
196
|
}
|
|
197
197
|
const conversationEventResult = await this.conversationService.handleEvent(event);
|
|
198
|
-
if (conversationEventResult) {
|
|
198
|
+
if (conversationEventResult.status !== 'unhandled') {
|
|
199
199
|
return conversationEventResult;
|
|
200
200
|
}
|
|
201
|
-
return { event };
|
|
201
|
+
return { status: 'handled', payload: { event } };
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
exports.NotificationService = NotificationService;
|
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,G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,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAEtD,wBAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAiBlE;AAED,wBAAsB,QAAQ,CAAC,EAAE,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,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.16.0",
|
|
65
|
+
"gitHead": "874c95a4494676bddf4078c46365385b8baf0df5"
|
|
66
66
|
}
|