@wireapp/core 30.12.0 → 31.0.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/package.json +28 -22
- package/src/main/Account.d.ts +11 -3
- package/src/main/Account.js +11 -0
- package/src/main/CoreError.d.ts +1 -1
- package/src/main/account/AccountService.d.ts +2 -2
- package/src/main/account/AccountService.ts +2 -2
- package/src/main/auth/LoginSanitizer.d.ts +1 -1
- package/src/main/broadcast/AvailabilityType.d.ts +1 -1
- package/src/main/broadcast/BroadcastService.d.ts +3 -3
- package/src/main/client/ClientBackendRepository.d.ts +2 -2
- package/src/main/client/ClientDatabaseRepository.d.ts +3 -3
- package/src/main/client/ClientInfo.d.ts +1 -1
- package/src/main/client/ClientService.d.ts +4 -4
- package/src/main/connection/ConnectionService.d.ts +1 -1
- package/src/main/conversation/AbortReason.d.ts +1 -1
- package/src/main/conversation/AssetService/AssetService.d.ts +4 -4
- package/src/main/conversation/ConversationService/ConversationService.d.ts +9 -28
- package/src/main/conversation/ConversationService/ConversationService.js +4 -312
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +2 -0
- package/src/main/conversation/ConversationService/messageGenerator.d.ts +9 -0
- package/src/main/conversation/ConversationService/messageGenerator.js +301 -0
- package/src/main/conversation/message/CompositeContentBuilder.d.ts +1 -1
- package/src/main/conversation/message/Message.d.ts +3 -3
- package/src/main/conversation/message/MessageBuilder.d.ts +6 -2
- package/src/main/conversation/message/MessageBuilder.js +3 -0
- package/src/main/conversation/message/MessageToProtoMapper.d.ts +2 -2
- package/src/main/conversation/message/OtrMessage.d.ts +2 -2
- package/src/main/conversation/message/PayloadBundle.d.ts +3 -3
- package/src/main/conversation/message/TeamMessage.d.ts +2 -2
- package/src/main/conversation/message/TextContentBuilder.d.ts +1 -1
- package/src/main/conversation/message/UserMessage.d.ts +2 -2
- package/src/main/cryptography/AssetCryptography/index.d.ts +1 -1
- package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +1 -1
- package/src/main/cryptography/CryptographyService.d.ts +7 -7
- package/src/main/cryptography/GenericMessageMapper.d.ts +1 -1
- package/src/main/giphy/GiphyService.d.ts +2 -2
- package/src/main/mls/MLSService/MLSService.d.ts +5 -3
- package/src/main/mls/MLSService/MLSService.js +35 -10
- package/src/main/mls/types.d.ts +11 -0
- package/src/main/notification/NotificationBackendRepository.d.ts +2 -2
- package/src/main/notification/NotificationDatabaseRepository.d.ts +4 -7
- package/src/main/notification/NotificationDatabaseRepository.js +0 -10
- package/src/main/notification/NotificationService.d.ts +6 -17
- package/src/main/notification/NotificationService.js +15 -27
- package/src/main/notification/types.d.ts +0 -4
- package/src/main/self/SelfService.d.ts +2 -2
- package/src/main/team/TeamService.d.ts +2 -2
- package/src/main/test/CryptographyHelper.d.ts +1 -1
- package/src/main/user/UserService.d.ts +3 -3
- package/src/main/util/TypePredicateUtil.d.ts +2 -2
- package/src/main/util/{mapQualifiedUserClientIdsToFullyQualifiedClientIds.d.ts → fullyQualifiedClientIdUtils.d.ts} +5 -0
- package/src/main/util/{mapQualifiedUserClientIdsToFullyQualifiedClientIds.js → fullyQualifiedClientIdUtils.js} +12 -2
- package/CHANGELOG.md +0 -12408
|
@@ -28,12 +28,12 @@ const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
|
|
|
28
28
|
const TypePredicateUtil_1 = require("../../util/TypePredicateUtil");
|
|
29
29
|
const MessageBuilder_1 = require("../message/MessageBuilder");
|
|
30
30
|
const MessageService_1 = require("../message/MessageService");
|
|
31
|
-
const MessageToProtoMapper_1 = require("../message/MessageToProtoMapper");
|
|
32
31
|
const ConversationService_types_1 = require("./ConversationService.types");
|
|
33
32
|
const bazinga64_1 = require("bazinga64");
|
|
34
|
-
const
|
|
33
|
+
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
35
34
|
const mls_1 = require("../../mls");
|
|
36
35
|
const messageSender_1 = require("../message/messageSender");
|
|
36
|
+
const messageGenerator_1 = require("./messageGenerator");
|
|
37
37
|
class ConversationService {
|
|
38
38
|
constructor(apiClient, cryptographyService, config, notificationService, mlsService) {
|
|
39
39
|
this.apiClient = apiClient;
|
|
@@ -43,17 +43,6 @@ class ConversationService {
|
|
|
43
43
|
this.messageTimer = new conversation_2.MessageTimer();
|
|
44
44
|
this.messageService = new MessageService_1.MessageService(this.apiClient, cryptographyService);
|
|
45
45
|
}
|
|
46
|
-
createEphemeral(originalGenericMessage, expireAfterMillis) {
|
|
47
|
-
const ephemeralMessage = protocol_messaging_1.Ephemeral.create({
|
|
48
|
-
expireAfterMillis,
|
|
49
|
-
[originalGenericMessage.content]: originalGenericMessage[originalGenericMessage.content],
|
|
50
|
-
});
|
|
51
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
52
|
-
[conversation_2.GenericMessageType.EPHEMERAL]: ephemeralMessage,
|
|
53
|
-
messageId: originalGenericMessage.messageId,
|
|
54
|
-
});
|
|
55
|
-
return genericMessage;
|
|
56
|
-
}
|
|
57
46
|
async getConversationQualifiedMembers(conversationId) {
|
|
58
47
|
const conversation = await this.apiClient.api.conversation.getConversation(conversationId);
|
|
59
48
|
/*
|
|
@@ -231,214 +220,6 @@ class ConversationService {
|
|
|
231
220
|
}
|
|
232
221
|
return userIds;
|
|
233
222
|
}
|
|
234
|
-
generateButtonActionGenericMessage(payloadBundle) {
|
|
235
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
236
|
-
[conversation_2.GenericMessageType.BUTTON_ACTION]: protocol_messaging_1.ButtonAction.create(payloadBundle.content),
|
|
237
|
-
messageId: payloadBundle.id,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
generateButtonActionConfirmationGenericMessage(payloadBundle) {
|
|
241
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
242
|
-
[conversation_2.GenericMessageType.BUTTON_ACTION_CONFIRMATION]: protocol_messaging_1.ButtonActionConfirmation.create(payloadBundle.content),
|
|
243
|
-
messageId: payloadBundle.id,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
generateCompositeGenericMessage(payloadBundle) {
|
|
247
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
248
|
-
[conversation_2.GenericMessageType.COMPOSITE]: protocol_messaging_1.Composite.create(payloadBundle.content),
|
|
249
|
-
messageId: payloadBundle.id,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
generateConfirmationGenericMessage(payloadBundle) {
|
|
253
|
-
const content = protocol_messaging_1.Confirmation.create(payloadBundle.content);
|
|
254
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
255
|
-
[conversation_2.GenericMessageType.CONFIRMATION]: content,
|
|
256
|
-
messageId: payloadBundle.id,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
generateEditedTextGenericMessage(payloadBundle) {
|
|
260
|
-
const editedMessage = protocol_messaging_1.MessageEdit.create({
|
|
261
|
-
replacingMessageId: payloadBundle.content.originalMessageId,
|
|
262
|
-
text: MessageToProtoMapper_1.MessageToProtoMapper.mapText(payloadBundle),
|
|
263
|
-
});
|
|
264
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
265
|
-
[conversation_2.GenericMessageType.EDITED]: editedMessage,
|
|
266
|
-
messageId: payloadBundle.id,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
generateFileDataGenericMessage(payloadBundle) {
|
|
270
|
-
if (!payloadBundle.content) {
|
|
271
|
-
throw new Error('No content for sendFileData provided.');
|
|
272
|
-
}
|
|
273
|
-
const { asset, expectsReadConfirmation, legalHoldStatus } = payloadBundle.content;
|
|
274
|
-
const remoteData = protocol_messaging_1.Asset.RemoteData.create({
|
|
275
|
-
assetId: asset.key,
|
|
276
|
-
assetToken: asset.token,
|
|
277
|
-
otrKey: asset.keyBytes,
|
|
278
|
-
sha256: asset.sha256,
|
|
279
|
-
assetDomain: asset.domain,
|
|
280
|
-
});
|
|
281
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
282
|
-
expectsReadConfirmation,
|
|
283
|
-
legalHoldStatus,
|
|
284
|
-
uploaded: remoteData,
|
|
285
|
-
});
|
|
286
|
-
assetMessage.status = conversation_2.AssetTransferState.UPLOADED;
|
|
287
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
288
|
-
[conversation_2.GenericMessageType.ASSET]: assetMessage,
|
|
289
|
-
messageId: payloadBundle.id,
|
|
290
|
-
});
|
|
291
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
292
|
-
return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
293
|
-
}
|
|
294
|
-
generateFileMetaDataGenericMessage(payloadBundle) {
|
|
295
|
-
if (!payloadBundle.content) {
|
|
296
|
-
throw new Error('No content for sendFileMetaData provided.');
|
|
297
|
-
}
|
|
298
|
-
const { expectsReadConfirmation, legalHoldStatus, metaData } = payloadBundle.content;
|
|
299
|
-
const original = protocol_messaging_1.Asset.Original.create({
|
|
300
|
-
audio: metaData.audio,
|
|
301
|
-
mimeType: metaData.type,
|
|
302
|
-
name: metaData.name,
|
|
303
|
-
size: metaData.length,
|
|
304
|
-
video: metaData.video,
|
|
305
|
-
image: metaData.image,
|
|
306
|
-
});
|
|
307
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
308
|
-
expectsReadConfirmation,
|
|
309
|
-
legalHoldStatus,
|
|
310
|
-
original,
|
|
311
|
-
});
|
|
312
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
313
|
-
[conversation_2.GenericMessageType.ASSET]: assetMessage,
|
|
314
|
-
messageId: payloadBundle.id,
|
|
315
|
-
});
|
|
316
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
317
|
-
return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
318
|
-
}
|
|
319
|
-
generateFileAbortGenericMessage(payloadBundle) {
|
|
320
|
-
if (!payloadBundle.content) {
|
|
321
|
-
throw new Error('No content for sendFileAbort provided.');
|
|
322
|
-
}
|
|
323
|
-
const { expectsReadConfirmation, legalHoldStatus, reason } = payloadBundle.content;
|
|
324
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
325
|
-
expectsReadConfirmation,
|
|
326
|
-
legalHoldStatus,
|
|
327
|
-
notUploaded: reason,
|
|
328
|
-
});
|
|
329
|
-
assetMessage.status = conversation_2.AssetTransferState.NOT_UPLOADED;
|
|
330
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
331
|
-
[conversation_2.GenericMessageType.ASSET]: assetMessage,
|
|
332
|
-
messageId: payloadBundle.id,
|
|
333
|
-
});
|
|
334
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
335
|
-
return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
336
|
-
}
|
|
337
|
-
generateAsset(payloadBundle) {
|
|
338
|
-
if (!payloadBundle.content) {
|
|
339
|
-
throw new Error('No content for sendImage provided.');
|
|
340
|
-
}
|
|
341
|
-
const { asset, expectsReadConfirmation, image, legalHoldStatus } = payloadBundle.content;
|
|
342
|
-
const imageMetadata = protocol_messaging_1.Asset.ImageMetaData.create({
|
|
343
|
-
height: image.height,
|
|
344
|
-
width: image.width,
|
|
345
|
-
});
|
|
346
|
-
const original = protocol_messaging_1.Asset.Original.create({
|
|
347
|
-
[conversation_2.GenericMessageType.IMAGE]: imageMetadata,
|
|
348
|
-
mimeType: image.type,
|
|
349
|
-
name: null,
|
|
350
|
-
size: image.data.length,
|
|
351
|
-
});
|
|
352
|
-
const remoteData = protocol_messaging_1.Asset.RemoteData.create({
|
|
353
|
-
assetId: asset.key,
|
|
354
|
-
assetToken: asset.token,
|
|
355
|
-
assetDomain: asset.domain,
|
|
356
|
-
otrKey: asset.keyBytes,
|
|
357
|
-
sha256: asset.sha256,
|
|
358
|
-
});
|
|
359
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
360
|
-
expectsReadConfirmation,
|
|
361
|
-
legalHoldStatus,
|
|
362
|
-
original,
|
|
363
|
-
uploaded: remoteData,
|
|
364
|
-
});
|
|
365
|
-
assetMessage.status = conversation_2.AssetTransferState.UPLOADED;
|
|
366
|
-
return assetMessage;
|
|
367
|
-
}
|
|
368
|
-
generateImageGenericMessage(payloadBundle) {
|
|
369
|
-
const imageAsset = this.generateAsset(payloadBundle);
|
|
370
|
-
let genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
371
|
-
[conversation_2.GenericMessageType.ASSET]: imageAsset,
|
|
372
|
-
messageId: payloadBundle.id,
|
|
373
|
-
});
|
|
374
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
375
|
-
if (expireAfterMillis) {
|
|
376
|
-
genericMessage = this.createEphemeral(genericMessage, expireAfterMillis);
|
|
377
|
-
}
|
|
378
|
-
return { genericMessage, content: imageAsset };
|
|
379
|
-
}
|
|
380
|
-
generateLocationGenericMessage(payloadBundle) {
|
|
381
|
-
const { expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom } = payloadBundle.content;
|
|
382
|
-
const locationMessage = protocol_messaging_1.Location.create({
|
|
383
|
-
expectsReadConfirmation,
|
|
384
|
-
latitude,
|
|
385
|
-
legalHoldStatus,
|
|
386
|
-
longitude,
|
|
387
|
-
name,
|
|
388
|
-
zoom,
|
|
389
|
-
});
|
|
390
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
391
|
-
[conversation_2.GenericMessageType.LOCATION]: locationMessage,
|
|
392
|
-
messageId: payloadBundle.id,
|
|
393
|
-
});
|
|
394
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
395
|
-
return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
396
|
-
}
|
|
397
|
-
generatePingGenericMessage(payloadBundle) {
|
|
398
|
-
const content = protocol_messaging_1.Knock.create(payloadBundle.content);
|
|
399
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
400
|
-
[conversation_2.GenericMessageType.KNOCK]: content,
|
|
401
|
-
messageId: payloadBundle.id,
|
|
402
|
-
});
|
|
403
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
404
|
-
return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
405
|
-
}
|
|
406
|
-
generateReactionGenericMessage(payloadBundle) {
|
|
407
|
-
const { legalHoldStatus, originalMessageId, type } = payloadBundle.content;
|
|
408
|
-
const reaction = protocol_messaging_1.Reaction.create({
|
|
409
|
-
emoji: type,
|
|
410
|
-
legalHoldStatus,
|
|
411
|
-
messageId: originalMessageId,
|
|
412
|
-
});
|
|
413
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
414
|
-
[conversation_2.GenericMessageType.REACTION]: reaction,
|
|
415
|
-
messageId: payloadBundle.id,
|
|
416
|
-
});
|
|
417
|
-
return genericMessage;
|
|
418
|
-
}
|
|
419
|
-
generateSessionResetGenericMessage(payloadBundle) {
|
|
420
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
421
|
-
[conversation_2.GenericMessageType.CLIENT_ACTION]: protocol_messaging_1.ClientAction.RESET_SESSION,
|
|
422
|
-
messageId: payloadBundle.id,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
generateCallGenericMessage(payloadBundle) {
|
|
426
|
-
const callMessage = protocol_messaging_1.Calling.create({
|
|
427
|
-
content: payloadBundle.content,
|
|
428
|
-
});
|
|
429
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
430
|
-
[conversation_2.GenericMessageType.CALLING]: callMessage,
|
|
431
|
-
messageId: payloadBundle.id,
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
generateTextGenericMessage(payloadBundle) {
|
|
435
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
436
|
-
messageId: payloadBundle.id,
|
|
437
|
-
[conversation_2.GenericMessageType.TEXT]: MessageToProtoMapper_1.MessageToProtoMapper.mapText(payloadBundle),
|
|
438
|
-
});
|
|
439
|
-
const expireAfterMillis = this.messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
440
|
-
return expireAfterMillis > 0 ? this.createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
441
|
-
}
|
|
442
223
|
async clearConversation(conversationId, timestamp = new Date(), messageId = MessageBuilder_1.MessageBuilder.createId(), sendAsProtobuf) {
|
|
443
224
|
if (timestamp instanceof Date) {
|
|
444
225
|
timestamp = timestamp.getTime();
|
|
@@ -588,35 +369,6 @@ class ConversationService {
|
|
|
588
369
|
type: conversation_2.PayloadBundleType.MESSAGE_HIDE,
|
|
589
370
|
};
|
|
590
371
|
}
|
|
591
|
-
async deleteMessageEveryone(conversationId, messageIdToDelete, userIds, sendAsProtobuf, conversationDomain, callbacks) {
|
|
592
|
-
var _a, _b;
|
|
593
|
-
const messageId = MessageBuilder_1.MessageBuilder.createId();
|
|
594
|
-
const content = protocol_messaging_1.MessageDelete.create({
|
|
595
|
-
messageId: messageIdToDelete,
|
|
596
|
-
});
|
|
597
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
598
|
-
[conversation_2.GenericMessageType.DELETED]: content,
|
|
599
|
-
messageId,
|
|
600
|
-
});
|
|
601
|
-
(_a = callbacks === null || callbacks === void 0 ? void 0 : callbacks.onStart) === null || _a === void 0 ? void 0 : _a.call(callbacks, genericMessage);
|
|
602
|
-
const response = await this.sendGenericMessage(this.apiClient.validatedClientId, conversationId, genericMessage, {
|
|
603
|
-
userIds,
|
|
604
|
-
sendAsProtobuf,
|
|
605
|
-
conversationDomain,
|
|
606
|
-
});
|
|
607
|
-
(_b = callbacks === null || callbacks === void 0 ? void 0 : callbacks.onSuccess) === null || _b === void 0 ? void 0 : _b.call(callbacks, genericMessage, response === null || response === void 0 ? void 0 : response.time);
|
|
608
|
-
return {
|
|
609
|
-
content,
|
|
610
|
-
conversation: conversationId,
|
|
611
|
-
from: this.apiClient.context.userId,
|
|
612
|
-
id: messageId,
|
|
613
|
-
messageTimer: this.messageTimer.getMessageTimer(conversationId),
|
|
614
|
-
source: conversation_2.PayloadBundleSource.LOCAL,
|
|
615
|
-
state: conversation_2.PayloadBundleState.OUTGOING_SENT,
|
|
616
|
-
timestamp: Date.now(),
|
|
617
|
-
type: conversation_2.PayloadBundleType.MESSAGE_DELETE,
|
|
618
|
-
};
|
|
619
|
-
}
|
|
620
372
|
createProteusConversation(conversationData, otherUserIds) {
|
|
621
373
|
let payload;
|
|
622
374
|
if (typeof conversationData === 'string') {
|
|
@@ -689,7 +441,7 @@ class ConversationService {
|
|
|
689
441
|
return params.protocol === conversation_1.ConversationProtocol.MLS;
|
|
690
442
|
}
|
|
691
443
|
const { payload, onStart } = params;
|
|
692
|
-
const { genericMessage, content } =
|
|
444
|
+
const { genericMessage, content } = (0, messageGenerator_1.generateGenericMessage)(payload, this.messageTimer);
|
|
693
445
|
if ((await (onStart === null || onStart === void 0 ? void 0 : onStart(genericMessage))) === false) {
|
|
694
446
|
// If the onStart call returns false, it means the consumer wants to cancel the message sending
|
|
695
447
|
return Object.assign(Object.assign({}, payload), { state: conversation_2.PayloadBundleState.CANCELLED });
|
|
@@ -736,65 +488,6 @@ class ConversationService {
|
|
|
736
488
|
const hasFailed = Object.keys(mismatch.failed_to_send || {}).length > 0;
|
|
737
489
|
return !hasMissing && !hasDeleted && !hasRedundant && !hasFailed;
|
|
738
490
|
}
|
|
739
|
-
generateGenericMessage(payload) {
|
|
740
|
-
let genericMessage;
|
|
741
|
-
const content = payload.content;
|
|
742
|
-
switch (payload.type) {
|
|
743
|
-
case conversation_2.PayloadBundleType.ASSET:
|
|
744
|
-
genericMessage = this.generateFileDataGenericMessage(payload);
|
|
745
|
-
return { genericMessage, content };
|
|
746
|
-
case conversation_2.PayloadBundleType.ASSET_ABORT:
|
|
747
|
-
genericMessage = this.generateFileAbortGenericMessage(payload);
|
|
748
|
-
return { genericMessage, content };
|
|
749
|
-
case conversation_2.PayloadBundleType.ASSET_META:
|
|
750
|
-
genericMessage = this.generateFileMetaDataGenericMessage(payload);
|
|
751
|
-
return { genericMessage, content };
|
|
752
|
-
case conversation_2.PayloadBundleType.ASSET_IMAGE:
|
|
753
|
-
return this.generateImageGenericMessage(payload);
|
|
754
|
-
case conversation_2.PayloadBundleType.BUTTON_ACTION:
|
|
755
|
-
genericMessage = this.generateButtonActionGenericMessage(payload);
|
|
756
|
-
return { genericMessage, content };
|
|
757
|
-
case conversation_2.PayloadBundleType.BUTTON_ACTION_CONFIRMATION:
|
|
758
|
-
genericMessage = this.generateButtonActionConfirmationGenericMessage(payload);
|
|
759
|
-
return { genericMessage, content };
|
|
760
|
-
case conversation_2.PayloadBundleType.CALL:
|
|
761
|
-
genericMessage = this.generateCallGenericMessage(payload);
|
|
762
|
-
return { genericMessage, content };
|
|
763
|
-
case conversation_2.PayloadBundleType.CLIENT_ACTION: {
|
|
764
|
-
if (payload.content.clientAction !== protocol_messaging_1.ClientAction.RESET_SESSION) {
|
|
765
|
-
throw new Error(`No send method implemented for "${payload.type}" and ClientAction "${payload.content}".`);
|
|
766
|
-
}
|
|
767
|
-
genericMessage = this.generateSessionResetGenericMessage(payload);
|
|
768
|
-
return { genericMessage, content };
|
|
769
|
-
}
|
|
770
|
-
case conversation_2.PayloadBundleType.COMPOSITE:
|
|
771
|
-
genericMessage = this.generateCompositeGenericMessage(payload);
|
|
772
|
-
return { genericMessage, content };
|
|
773
|
-
case conversation_2.PayloadBundleType.CONFIRMATION:
|
|
774
|
-
genericMessage = this.generateConfirmationGenericMessage(payload);
|
|
775
|
-
return { genericMessage, content };
|
|
776
|
-
case conversation_2.PayloadBundleType.LOCATION:
|
|
777
|
-
genericMessage = this.generateLocationGenericMessage(payload);
|
|
778
|
-
return { genericMessage, content };
|
|
779
|
-
case conversation_2.PayloadBundleType.MESSAGE_EDIT:
|
|
780
|
-
genericMessage = this.generateEditedTextGenericMessage(payload);
|
|
781
|
-
return { genericMessage, content };
|
|
782
|
-
case conversation_2.PayloadBundleType.PING:
|
|
783
|
-
genericMessage = this.generatePingGenericMessage(payload);
|
|
784
|
-
return { genericMessage, content };
|
|
785
|
-
case conversation_2.PayloadBundleType.REACTION:
|
|
786
|
-
genericMessage = this.generateReactionGenericMessage(payload);
|
|
787
|
-
return { genericMessage, content };
|
|
788
|
-
case conversation_2.PayloadBundleType.TEXT:
|
|
789
|
-
genericMessage = this.generateTextGenericMessage(payload);
|
|
790
|
-
return { genericMessage, content };
|
|
791
|
-
/**
|
|
792
|
-
* ToDo: Create Generic implementation for everything else
|
|
793
|
-
*/
|
|
794
|
-
default:
|
|
795
|
-
throw new Error(`No send method implemented for "${payload['type']}".`);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
491
|
/**
|
|
799
492
|
* ###############################################
|
|
800
493
|
* ################ MLS Functions ################
|
|
@@ -830,7 +523,6 @@ class ConversationService {
|
|
|
830
523
|
...qualifiedUsers,
|
|
831
524
|
]);
|
|
832
525
|
const response = await this.mlsService.addUsersToExistingConversation(groupIdDecodedFromBase64, coreCryptoKeyPackagesPayload);
|
|
833
|
-
await this.notificationService.saveConversationGroupId(newConversation);
|
|
834
526
|
//We store the info when conversation (along with key material) was created, so we will know when to renew it
|
|
835
527
|
const groupCreationTimeStamp = new Date().getTime();
|
|
836
528
|
await this.notificationService.storeLastKeyMaterialUpdateDate({
|
|
@@ -877,7 +569,7 @@ class ConversationService {
|
|
|
877
569
|
async removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }) {
|
|
878
570
|
const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
879
571
|
const clientsToRemove = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedUserIds });
|
|
880
|
-
const fullyQualifiedClientIds = (0,
|
|
572
|
+
const fullyQualifiedClientIds = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(clientsToRemove.qualified_user_map);
|
|
881
573
|
const messageResponse = await this.mlsService.removeClientsFromConversation(groupIdDecodedFromBase64, fullyQualifiedClientIds);
|
|
882
574
|
//key material gets updated after removing a user from the group, so we can reset last key update time value in the store
|
|
883
575
|
await this.storeLastKeyMaterialUpdateDateWithCurrentTime(groupId);
|
|
@@ -82,12 +82,14 @@ export declare type SendProteusMessageParams<T> = SendCommonParams<T> & MessageS
|
|
|
82
82
|
*/
|
|
83
83
|
userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients;
|
|
84
84
|
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
85
|
+
protocol: ConversationProtocol.PROTEUS;
|
|
85
86
|
};
|
|
86
87
|
export declare type SendMlsMessageParams<T> = SendCommonParams<T> & {
|
|
87
88
|
/**
|
|
88
89
|
* The groupId of the conversation to send the message to (Needed only for MLS)
|
|
89
90
|
*/
|
|
90
91
|
groupId: string;
|
|
92
|
+
protocol: ConversationProtocol.MLS;
|
|
91
93
|
};
|
|
92
94
|
export declare type QualifiedUsers = QualifiedId & {
|
|
93
95
|
skipOwn?: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OtrMessage } from '../message/OtrMessage';
|
|
2
|
+
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
3
|
+
import { MessageTimer } from '../MessageTimer';
|
|
4
|
+
interface GeneratedMessage<T extends OtrMessage> {
|
|
5
|
+
genericMessage: GenericMessage;
|
|
6
|
+
content: T['content'];
|
|
7
|
+
}
|
|
8
|
+
export declare function generateGenericMessage<T extends OtrMessage>(payload: T, messageTimer: MessageTimer): GeneratedMessage<T>;
|
|
9
|
+
export {};
|