@wireapp/core 46.0.16 → 46.0.18
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 +43 -56
- package/lib/account/AccountService.js +1 -0
- package/lib/broadcast/BroadcastService.js +3 -0
- package/lib/client/ClientBackendRepository.js +1 -0
- package/lib/client/ClientDatabaseRepository.js +16 -7
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +14 -13
- package/lib/connection/ConnectionService.js +1 -0
- package/lib/conversation/AssetService/AssetService.d.ts +0 -1
- package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.js +13 -6
- package/lib/conversation/AssetService/AssetService.test.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +90 -80
- package/lib/conversation/ConversationService/ConversationService.test.js +12 -5
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
- package/lib/conversation/MessageTimer/MessageTimer.js +2 -0
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +23 -17
- package/lib/conversation/content/AssetContent.d.ts +0 -1
- package/lib/conversation/content/AssetContent.d.ts.map +1 -1
- package/lib/conversation/content/ContentType.js +18 -19
- package/lib/conversation/content/FileContent.d.ts +0 -1
- package/lib/conversation/content/FileContent.d.ts.map +1 -1
- package/lib/conversation/content/ImageContent.d.ts +0 -1
- package/lib/conversation/content/ImageContent.d.ts.map +1 -1
- package/lib/conversation/message/MessageBuilder.js +22 -23
- package/lib/conversation/message/MessageService.js +5 -4
- package/lib/conversation/message/MessageService.test.js +20 -9
- package/lib/conversation/message/MessageToProtoMapper.js +2 -2
- package/lib/conversation/message/RecipientsHelper.js +1 -2
- package/lib/conversation/message/TextContentBuilder.js +3 -2
- package/lib/conversation/message/UserClientsUtil.js +2 -3
- package/lib/conversation/message/messageSender.js +5 -6
- package/lib/cryptography/AssetCryptography/AssetCryptography.d.ts.map +1 -1
- package/lib/cryptography/GenericMessageMapper.js +74 -22
- package/lib/cryptography/MessageHashService.d.ts +0 -1
- package/lib/cryptography/MessageHashService.d.ts.map +1 -1
- package/lib/cryptography/MessageHashService.js +2 -0
- package/lib/errors/DecryptionError.js +2 -0
- package/lib/errors/FederatedBackendsError.js +3 -2
- package/lib/giphy/GiphyService.js +1 -0
- package/lib/linkPreview/LinkPreviewService.js +2 -12
- package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.d.ts +4 -4
- package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.js +9 -8
- package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/schema.d.ts +8 -8
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +33 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +11 -11
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +15 -5
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Account.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Account.js +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.d.ts +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.js +2 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Certificate.js +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.js +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.js +1 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.schema.d.ts +4 -4
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +7 -3
- package/lib/messagingProtocols/mls/MLSService/ClientMLSError.js +1 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +109 -114
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +28 -9
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.js +1 -2
- package/lib/messagingProtocols/mls/conversationRejoinQueue.js +3 -4
- package/lib/messagingProtocols/mls/utils/MLSId.js +2 -3
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +6 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.js +3 -0
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.js +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +5 -4
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +1 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +20 -16
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +4 -7
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +15 -15
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.js +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.js +1 -2
- package/lib/messagingProtocols/proteus/ProteusService/sessionIdMigrator.js +2 -3
- package/lib/messagingProtocols/proteus/ProteusService/userDomainFilters.js +1 -2
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +14 -14
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +5 -2
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/notification/NotificationBackendRepository.d.ts +1 -1
- package/lib/notification/NotificationBackendRepository.js +1 -0
- package/lib/notification/NotificationDatabaseRepository.js +1 -0
- package/lib/notification/NotificationService.js +38 -49
- package/lib/secretStore/encryptedStore.js +10 -22
- package/lib/secretStore/secretKeyGenerator.js +2 -2
- package/lib/secretStore/secretKeyGenerator.test.js +1 -1
- package/lib/self/SelfService.js +2 -1
- package/lib/storage/CoreDB.js +2 -3
- package/lib/team/TeamService.js +1 -0
- package/lib/test/PayloadHelper.js +3 -4
- package/lib/testUtils/index.js +2 -3
- package/lib/user/UserService.d.ts +2 -2
- package/lib/user/UserService.js +1 -0
- package/lib/util/LocalStorageStore/index.d.ts.map +1 -1
- package/lib/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +4 -6
- package/lib/util/RecurringTaskScheduler/RecurringTaskScheduler.d.ts.map +1 -1
- package/lib/util/RecurringTaskScheduler/RecurringTaskScheduler.js +34 -33
- package/lib/util/TaskScheduler/TaskScheduler.d.ts +1 -1
- package/lib/util/TaskScheduler/TaskScheduler.d.ts.map +1 -1
- package/lib/util/TypePredicateUtil.js +7 -10
- package/lib/util/fullyQualifiedClientIdUtils.js +1 -2
- package/package.json +3 -3
|
@@ -38,6 +38,14 @@ const util_1 = require("../../util");
|
|
|
38
38
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
39
39
|
const messageSender_1 = require("../message/messageSender");
|
|
40
40
|
class ConversationService extends commons_1.TypedEventEmitter {
|
|
41
|
+
apiClient;
|
|
42
|
+
proteusService;
|
|
43
|
+
coreDatabase;
|
|
44
|
+
groupIdFromConversationId;
|
|
45
|
+
subconversationService;
|
|
46
|
+
_mlsService;
|
|
47
|
+
messageTimer;
|
|
48
|
+
logger = (0, logdown_1.default)('@wireapp/core/ConversationService');
|
|
41
49
|
constructor(apiClient, proteusService, coreDatabase, groupIdFromConversationId, subconversationService, _mlsService) {
|
|
42
50
|
super();
|
|
43
51
|
this.apiClient = apiClient;
|
|
@@ -46,67 +54,6 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
46
54
|
this.groupIdFromConversationId = groupIdFromConversationId;
|
|
47
55
|
this.subconversationService = subconversationService;
|
|
48
56
|
this._mlsService = _mlsService;
|
|
49
|
-
this.logger = (0, logdown_1.default)('@wireapp/core/ConversationService');
|
|
50
|
-
/**
|
|
51
|
-
* Blacklists a conversation.
|
|
52
|
-
* 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.
|
|
53
|
-
* @param conversationId id of the conversation to blacklist
|
|
54
|
-
*/
|
|
55
|
-
this.blacklistConversation = async (conversationId) => {
|
|
56
|
-
await this.coreDatabase.put('conversationBlacklist', conversationId, conversationId.id);
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Removes a conversation from the blacklists.
|
|
60
|
-
* @param conversationId id of the conversation to remove from the blacklist
|
|
61
|
-
*/
|
|
62
|
-
this.removeConversationFromBlacklist = async (conversationId) => {
|
|
63
|
-
await this.coreDatabase.delete('conversationBlacklist', conversationId.id);
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Will try registering mls 1:1 conversation adding the other user.
|
|
67
|
-
* If it fails and the conversation is already established, it will try joining via external commit instead.
|
|
68
|
-
*
|
|
69
|
-
* @param mlsConversation - mls 1:1 conversation
|
|
70
|
-
* @param selfUser - user and client ids of the self user
|
|
71
|
-
* @param otherUserId - id of the other user
|
|
72
|
-
*/
|
|
73
|
-
this.establishMLS1to1Conversation = async (groupId, selfUser, otherUserId, shouldRetry = true) => {
|
|
74
|
-
this.logger.info(`Trying to establish a MLS 1:1 conversation with user ${otherUserId.id}...`);
|
|
75
|
-
// Before trying to register a group, check if the group is already established o backend.
|
|
76
|
-
// If remote epoch is higher than 0, it means that the group was already established.
|
|
77
|
-
// It's possible that we've already received a welcome message.
|
|
78
|
-
const mlsConversation = await this.getMLS1to1Conversation(otherUserId);
|
|
79
|
-
if (mlsConversation.epoch > 0) {
|
|
80
|
-
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is already established on backend, checking the local epoch...`);
|
|
81
|
-
const isMLSGroupEstablishedLocally = await this.isMLSGroupEstablishedLocally(groupId);
|
|
82
|
-
// If group is already established locally, there's nothing more to do
|
|
83
|
-
if (isMLSGroupEstablishedLocally) {
|
|
84
|
-
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is already established locally.`);
|
|
85
|
-
return mlsConversation;
|
|
86
|
-
}
|
|
87
|
-
// If local epoch is 0 it means that we've not received a welcome message
|
|
88
|
-
// We try joining via external commit.
|
|
89
|
-
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is not yet established locally, joining via external commit...`);
|
|
90
|
-
await this.joinByExternalCommit(mlsConversation.qualified_id);
|
|
91
|
-
return this.getMLS1to1Conversation(otherUserId);
|
|
92
|
-
}
|
|
93
|
-
// If group is not established on backend,
|
|
94
|
-
// we wipe the it locally (in case it exsits in the local store) and try to register it.
|
|
95
|
-
await this.mlsService.wipeConversation(groupId);
|
|
96
|
-
try {
|
|
97
|
-
await this.mlsService.register1to1Conversation(groupId, otherUserId, selfUser);
|
|
98
|
-
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) established successfully.`);
|
|
99
|
-
return this.getMLS1to1Conversation(otherUserId);
|
|
100
|
-
}
|
|
101
|
-
catch (error) {
|
|
102
|
-
this.logger.info(`Could not register MLS group with id ${groupId}: `, error);
|
|
103
|
-
if (!shouldRetry) {
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is not established, retrying to establish it`);
|
|
107
|
-
return this.establishMLS1to1Conversation(groupId, selfUser, otherUserId, false);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
57
|
this.messageTimer = new conversation_2.MessageTimer();
|
|
111
58
|
}
|
|
112
59
|
get mlsService() {
|
|
@@ -129,7 +76,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
129
76
|
const allClients = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedMembers });
|
|
130
77
|
const qualifiedUserClients = {};
|
|
131
78
|
Object.entries(allClients.qualified_user_map).map(([domain, userClientMap]) => Object.entries(userClientMap).map(async ([userId, clients]) => {
|
|
132
|
-
qualifiedUserClients[domain]
|
|
79
|
+
qualifiedUserClients[domain] ||= {};
|
|
133
80
|
qualifiedUserClients[domain][userId] = clients.map(client => client.id);
|
|
134
81
|
}));
|
|
135
82
|
return qualifiedUserClients;
|
|
@@ -183,6 +130,21 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
183
130
|
sendTypingStop(conversationId) {
|
|
184
131
|
return this.apiClient.api.conversation.postTyping(conversationId, { status: data_1.CONVERSATION_TYPING.STOPPED });
|
|
185
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Blacklists a conversation.
|
|
135
|
+
* 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.
|
|
136
|
+
* @param conversationId id of the conversation to blacklist
|
|
137
|
+
*/
|
|
138
|
+
blacklistConversation = async (conversationId) => {
|
|
139
|
+
await this.coreDatabase.put('conversationBlacklist', conversationId, conversationId.id);
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Removes a conversation from the blacklists.
|
|
143
|
+
* @param conversationId id of the conversation to remove from the blacklist
|
|
144
|
+
*/
|
|
145
|
+
removeConversationFromBlacklist = async (conversationId) => {
|
|
146
|
+
await this.coreDatabase.delete('conversationBlacklist', conversationId.id);
|
|
147
|
+
};
|
|
186
148
|
/**
|
|
187
149
|
* returns the number of messages that are in the queue expecting to be sent
|
|
188
150
|
*/
|
|
@@ -230,7 +192,11 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
230
192
|
* field must be empty as backend is not aware which users
|
|
231
193
|
* are in a MLS conversation because of the MLS architecture.
|
|
232
194
|
*/
|
|
233
|
-
const newConversation = await this.apiClient.api.conversation.postConversation(
|
|
195
|
+
const newConversation = await this.apiClient.api.conversation.postConversation({
|
|
196
|
+
...conversationData,
|
|
197
|
+
users: undefined,
|
|
198
|
+
qualified_users: undefined,
|
|
199
|
+
});
|
|
234
200
|
const { group_id: groupId, qualified_id: qualifiedId } = newConversation;
|
|
235
201
|
if (!groupId) {
|
|
236
202
|
throw new Error('No group_id found in response which is required for creating MLS conversations.');
|
|
@@ -250,7 +216,6 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
250
216
|
};
|
|
251
217
|
}
|
|
252
218
|
async sendMLSMessage(params, shouldRetry = true) {
|
|
253
|
-
var _a, _b;
|
|
254
219
|
const { payload, groupId, conversationId } = params;
|
|
255
220
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
256
221
|
// immediately execute pending commits before sending the message
|
|
@@ -260,7 +225,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
260
225
|
let sentAt = '';
|
|
261
226
|
try {
|
|
262
227
|
response = await this.apiClient.api.conversation.postMlsMessage(encrypted);
|
|
263
|
-
sentAt =
|
|
228
|
+
sentAt = response.time?.length > 0 ? response.time : new Date().toISOString();
|
|
264
229
|
}
|
|
265
230
|
catch (error) {
|
|
266
231
|
const isMLSStaleMessageError = error instanceof http_1.BackendError && error.label === http_1.BackendErrorLabel.MLS_STALE_MESSAGE;
|
|
@@ -272,10 +237,10 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
272
237
|
}
|
|
273
238
|
throw error;
|
|
274
239
|
}
|
|
275
|
-
const failedToSend =
|
|
240
|
+
const failedToSend = response?.failed || (response?.failed_to_send ?? []).length > 0
|
|
276
241
|
? {
|
|
277
|
-
queued: response
|
|
278
|
-
failed: response
|
|
242
|
+
queued: response?.failed_to_send,
|
|
243
|
+
failed: response?.failed,
|
|
279
244
|
}
|
|
280
245
|
: undefined;
|
|
281
246
|
return {
|
|
@@ -341,12 +306,12 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
341
306
|
}
|
|
342
307
|
async matchesEpoch(groupId, backendEpoch) {
|
|
343
308
|
const localEpoch = await this.mlsService.getEpoch(groupId);
|
|
344
|
-
this.logger.
|
|
309
|
+
this.logger.debug(`Comparing conversation's (group_id: ${groupId}) local and backend epoch number: {local: ${String(localEpoch)}, backend: ${backendEpoch}}`);
|
|
345
310
|
//corecrypto stores epoch number as BigInt, we're mapping both values to be sure comparison is valid
|
|
346
311
|
return BigInt(localEpoch) === BigInt(backendEpoch);
|
|
347
312
|
}
|
|
348
313
|
async handleConversationsEpochMismatch() {
|
|
349
|
-
this.logger.
|
|
314
|
+
this.logger.warn(`There were some missed messages, handling possible epoch mismatch in MLS conversations.`);
|
|
350
315
|
//fetch all the mls conversations from backend
|
|
351
316
|
const conversations = await this.apiClient.api.conversation.getConversationList();
|
|
352
317
|
const foundConversations = conversations.found || [];
|
|
@@ -363,7 +328,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
363
328
|
async handleSubconversationEpochMismatch(subconversation, parentGroupId) {
|
|
364
329
|
const { parent_qualified_id: parentConversationId, group_id: groupId, epoch, subconv_id: subconversationId, } = subconversation;
|
|
365
330
|
if (await this.hasEpochMismatch(groupId, epoch)) {
|
|
366
|
-
this.logger.
|
|
331
|
+
this.logger.warn(`Subconversation "${subconversationId}" (parent id: ${parentConversationId.id}) was not established or its epoch number was out of date, joining via external commit`);
|
|
367
332
|
// We only support conference subconversations for now
|
|
368
333
|
if (subconversationId !== conversation_1.SUBCONVERSATION_ID.CONFERENCE) {
|
|
369
334
|
throw new Error('Unexpected subconversation id');
|
|
@@ -384,10 +349,10 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
384
349
|
async handleConversationEpochMismatch(remoteMlsConversation, onSuccessfulRejoin) {
|
|
385
350
|
const { qualified_id: qualifiedId, group_id: groupId, epoch } = remoteMlsConversation;
|
|
386
351
|
if (await this.hasEpochMismatch(groupId, epoch)) {
|
|
387
|
-
this.logger.
|
|
352
|
+
this.logger.warn(`Conversation (id ${qualifiedId.id}) was not established or it's epoch number was out of date, joining via external commit`);
|
|
388
353
|
try {
|
|
389
354
|
await this.joinByExternalCommit(qualifiedId);
|
|
390
|
-
onSuccessfulRejoin
|
|
355
|
+
onSuccessfulRejoin?.();
|
|
391
356
|
}
|
|
392
357
|
catch (error) {
|
|
393
358
|
const message = `There was an error while handling epoch mismatch in MLS conversation (id: ${qualifiedId.id}):`;
|
|
@@ -416,6 +381,51 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
416
381
|
async getMLS1to1Conversation(userId) {
|
|
417
382
|
return this.apiClient.api.conversation.getMLS1to1Conversation(userId);
|
|
418
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Will try registering mls 1:1 conversation adding the other user.
|
|
386
|
+
* If it fails and the conversation is already established, it will try joining via external commit instead.
|
|
387
|
+
*
|
|
388
|
+
* @param mlsConversation - mls 1:1 conversation
|
|
389
|
+
* @param selfUser - user and client ids of the self user
|
|
390
|
+
* @param otherUserId - id of the other user
|
|
391
|
+
*/
|
|
392
|
+
establishMLS1to1Conversation = async (groupId, selfUser, otherUserId, shouldRetry = true) => {
|
|
393
|
+
this.logger.debug(`Trying to establish a MLS 1:1 conversation with user ${otherUserId.id}...`);
|
|
394
|
+
// Before trying to register a group, check if the group is already established o backend.
|
|
395
|
+
// If remote epoch is higher than 0, it means that the group was already established.
|
|
396
|
+
// It's possible that we've already received a welcome message.
|
|
397
|
+
const mlsConversation = await this.getMLS1to1Conversation(otherUserId);
|
|
398
|
+
if (mlsConversation.epoch > 0) {
|
|
399
|
+
this.logger.debug(`Conversation (id ${mlsConversation.qualified_id.id}) is already established on backend, checking the local epoch...`);
|
|
400
|
+
const isMLSGroupEstablishedLocally = await this.isMLSGroupEstablishedLocally(groupId);
|
|
401
|
+
// If group is already established locally, there's nothing more to do
|
|
402
|
+
if (isMLSGroupEstablishedLocally) {
|
|
403
|
+
this.logger.debug(`Conversation (id ${mlsConversation.qualified_id.id}) is already established locally.`);
|
|
404
|
+
return mlsConversation;
|
|
405
|
+
}
|
|
406
|
+
// If local epoch is 0 it means that we've not received a welcome message
|
|
407
|
+
// We try joining via external commit.
|
|
408
|
+
this.logger.debug(`Conversation (id ${mlsConversation.qualified_id.id}) is not yet established locally, joining via external commit...`);
|
|
409
|
+
await this.joinByExternalCommit(mlsConversation.qualified_id);
|
|
410
|
+
return this.getMLS1to1Conversation(otherUserId);
|
|
411
|
+
}
|
|
412
|
+
// If group is not established on backend,
|
|
413
|
+
// we wipe the it locally (in case it exsits in the local store) and try to register it.
|
|
414
|
+
await this.mlsService.wipeConversation(groupId);
|
|
415
|
+
try {
|
|
416
|
+
await this.mlsService.register1to1Conversation(groupId, otherUserId, selfUser);
|
|
417
|
+
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) established successfully.`);
|
|
418
|
+
return this.getMLS1to1Conversation(otherUserId);
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
if (!shouldRetry) {
|
|
422
|
+
this.logger.error(`Could not register MLS group with id ${groupId}: `, error);
|
|
423
|
+
throw error;
|
|
424
|
+
}
|
|
425
|
+
this.logger.error(`Conversation (id ${mlsConversation.qualified_id.id}) is not established, retrying to establish it`);
|
|
426
|
+
return this.establishMLS1to1Conversation(groupId, selfUser, otherUserId, false);
|
|
427
|
+
}
|
|
428
|
+
};
|
|
419
429
|
/**
|
|
420
430
|
* Will try to register mls group by sending an empty commit to establish it.
|
|
421
431
|
* After group was successfully established, it will try to add other users to the group.
|
|
@@ -428,13 +438,13 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
428
438
|
async tryEstablishingMLSGroup({ groupId, conversationId, selfUserId, qualifiedUsers, }) {
|
|
429
439
|
const wasGroupEstablishedBySelfClient = await this.mlsService.tryEstablishingMLSGroup(groupId);
|
|
430
440
|
if (!wasGroupEstablishedBySelfClient) {
|
|
431
|
-
this.logger.
|
|
441
|
+
this.logger.debug('Group was not established by self client, skipping adding users to the group.');
|
|
432
442
|
return;
|
|
433
443
|
}
|
|
434
|
-
this.logger.
|
|
444
|
+
this.logger.debug('Group was established by self client, adding other users to the group...');
|
|
435
445
|
const usersToAdd = [
|
|
436
446
|
...qualifiedUsers,
|
|
437
|
-
|
|
447
|
+
{ ...selfUserId, skipOwnClientId: this.apiClient.validatedClientId },
|
|
438
448
|
];
|
|
439
449
|
const { conversation } = await this.addUsersToMLSConversation({
|
|
440
450
|
conversationId,
|
|
@@ -443,10 +453,10 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
443
453
|
});
|
|
444
454
|
const addedUsers = conversation.members.others;
|
|
445
455
|
if (addedUsers.length > 0) {
|
|
446
|
-
this.logger.
|
|
456
|
+
this.logger.debug(`Successfully added ${addedUsers} users to the group.`);
|
|
447
457
|
}
|
|
448
458
|
else {
|
|
449
|
-
this.logger.
|
|
459
|
+
this.logger.debug('No other users were added to the group.');
|
|
450
460
|
}
|
|
451
461
|
}
|
|
452
462
|
async handleMLSMessageAddEvent(event) {
|
|
@@ -455,7 +465,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
455
465
|
}
|
|
456
466
|
catch (error) {
|
|
457
467
|
if ((0, CoreCryptoMLSError_1.isCoreCryptoMLSWrongEpochError)(error)) {
|
|
458
|
-
this.logger.
|
|
468
|
+
this.logger.warn(`Received message for the wrong epoch in conversation ${event.conversation}, handling epoch mismatch...`);
|
|
459
469
|
const { qualified_conversation: conversationId, subconv } = event;
|
|
460
470
|
if (!conversationId) {
|
|
461
471
|
throw new Error('Qualified conversation id is missing in the event');
|
|
@@ -493,7 +503,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
493
503
|
if (!conversationId) {
|
|
494
504
|
throw new Error('Qualified conversation id is missing in the event');
|
|
495
505
|
}
|
|
496
|
-
this.logger.
|
|
506
|
+
this.logger.warn(`Received an orphan welcome message, joining the conversation (${conversationId.id}) via external commit...`);
|
|
497
507
|
void (0, conversationRejoinQueue_1.queueConversationRejoin)(conversationId.id, () => this.joinByExternalCommit(conversationId));
|
|
498
508
|
return null;
|
|
499
509
|
}
|
|
@@ -71,9 +71,17 @@ const createMLSWelcomeMessageEventMock = (conversationId) => ({
|
|
|
71
71
|
type: event_1.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE,
|
|
72
72
|
time: '2023-08-21T06:47:43.387Z',
|
|
73
73
|
});
|
|
74
|
-
jest.mock('../../messagingProtocols/proteus', () => (
|
|
74
|
+
jest.mock('../../messagingProtocols/proteus', () => ({
|
|
75
|
+
...jest.requireActual('../../messagingProtocols/proteus'),
|
|
76
|
+
getGenericMessageParams: jest.fn(),
|
|
77
|
+
getRecipientsForConversation: jest.fn(),
|
|
78
|
+
getConversationQualifiedMembers: jest.fn(),
|
|
79
|
+
}));
|
|
75
80
|
const MockedMessagingProtocols = MessagingProtocols;
|
|
76
|
-
jest.mock('../message/messageSender', () => (
|
|
81
|
+
jest.mock('../message/messageSender', () => ({
|
|
82
|
+
...jest.requireActual('../message/messageSender'),
|
|
83
|
+
sendMessage: jest.fn().mockImplementation(fn => fn()),
|
|
84
|
+
}));
|
|
77
85
|
const mockedProteusService = {
|
|
78
86
|
encryptGenericMessage: () => Promise.resolve(),
|
|
79
87
|
sendProteusMessage: () => Promise.resolve({ sentAt: new Date() }),
|
|
@@ -438,14 +446,13 @@ describe('ConversationService', () => {
|
|
|
438
446
|
});
|
|
439
447
|
describe('getConversations', () => {
|
|
440
448
|
it('returns a list of conversations by conversation ids', async () => {
|
|
441
|
-
var _a;
|
|
442
449
|
const [conversationService, { apiClient }] = await buildConversationService();
|
|
443
450
|
const conversationIds = Array.from({ length: 10 }, () => ({ id: PayloadHelper.getUUID(), domain: 'test.zinfra.io' }));
|
|
444
451
|
jest.spyOn(apiClient.api.conversation, 'getConversationsByQualifiedIds').mockResolvedValueOnce({
|
|
445
452
|
found: conversationIds,
|
|
446
453
|
});
|
|
447
454
|
const conversations = await conversationService.getConversations(conversationIds);
|
|
448
|
-
expect(
|
|
455
|
+
expect(conversations.found?.length).toBe(conversationIds.length);
|
|
449
456
|
});
|
|
450
457
|
it('returns a full list of conversations if a list of conversations is not provided', async () => {
|
|
451
458
|
const [conversationService, { apiClient }] = await buildConversationService();
|
|
@@ -578,7 +585,7 @@ describe('ConversationService', () => {
|
|
|
578
585
|
expect(conversationService.addUsersToMLSConversation).toHaveBeenCalledWith({
|
|
579
586
|
conversationId: mockConversationId,
|
|
580
587
|
groupId: mockGroupId,
|
|
581
|
-
qualifiedUsers: [...otherUsersToAdd,
|
|
588
|
+
qualifiedUsers: [...otherUsersToAdd, { ...selfUserId, skipOwnClientId: apiClient.clientId }],
|
|
582
589
|
});
|
|
583
590
|
});
|
|
584
591
|
it('should not add any users if MLS group was not established by the self client', async () => {
|
package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConversationQualifiedMembers.d.ts","sourceRoot":"","sources":["../../../../src/conversation/ConversationService/Utility/getConversationQualifiedMembers.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,UAAU,MAAM;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;CAC7B;AACD,QAAA,MAAM,+BAA+B,kCAAuC,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"getConversationQualifiedMembers.d.ts","sourceRoot":"","sources":["../../../../src/conversation/ConversationService/Utility/getConversationQualifiedMembers.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,UAAU,MAAM;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;CAC7B;AACD,QAAA,MAAM,+BAA+B,kCAAuC,MAAM,KAAG,OAAO,CAAC,WAAW,EAAE,CAWzG,CAAC;AAEF,OAAO,EAAC,+BAA+B,EAAC,CAAC"}
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.MessageTimer = void 0;
|
|
22
22
|
class MessageTimer {
|
|
23
|
+
conversationLevelTimers;
|
|
24
|
+
messageLevelTimers;
|
|
23
25
|
constructor() {
|
|
24
26
|
this.conversationLevelTimers = new Map();
|
|
25
27
|
this.messageLevelTimers = new Map();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAkB,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,qBAAa,sBAAuB,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAIjE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;gBAGvD,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"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"}
|
|
@@ -30,27 +30,15 @@ const subconversationUtil_1 = require("./subconversationUtil");
|
|
|
30
30
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
31
31
|
const MLS_CONVERSATION_KEY_LENGTH = 32;
|
|
32
32
|
class SubconversationService extends commons_1.TypedEventEmitter {
|
|
33
|
+
apiClient;
|
|
34
|
+
coreDatabase;
|
|
35
|
+
_mlsService;
|
|
36
|
+
logger = (0, logdown_1.default)('@wireapp/core/SubconversationService');
|
|
33
37
|
constructor(apiClient, coreDatabase, _mlsService) {
|
|
34
38
|
super();
|
|
35
39
|
this.apiClient = apiClient;
|
|
36
40
|
this.coreDatabase = coreDatabase;
|
|
37
41
|
this._mlsService = _mlsService;
|
|
38
|
-
this.logger = (0, logdown_1.default)('@wireapp/core/SubconversationService');
|
|
39
|
-
this.getSubconversationGroupId = async (parentConversationId, subconversationId) => {
|
|
40
|
-
const foundSubconversation = await this.coreDatabase.get('subconversations', (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
41
|
-
return foundSubconversation === null || foundSubconversation === void 0 ? void 0 : foundSubconversation.groupId;
|
|
42
|
-
};
|
|
43
|
-
this.getAllGroupIdsBySubconversationId = async (subconversationId) => {
|
|
44
|
-
const allSubconversations = await this.coreDatabase.getAll('subconversations');
|
|
45
|
-
const foundSubconversations = allSubconversations.filter(subconversation => subconversation.subconversationId === subconversationId);
|
|
46
|
-
return foundSubconversations;
|
|
47
|
-
};
|
|
48
|
-
this.saveSubconversationGroupId = async (parentConversationId, subconversationId, groupId) => {
|
|
49
|
-
return this.coreDatabase.put('subconversations', { parentConversationId, subconversationId, groupId }, (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
50
|
-
};
|
|
51
|
-
this.clearSubconversationGroupId = async (parentConversationId, subconversationId) => {
|
|
52
|
-
return this.coreDatabase.delete('subconversations', (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
53
|
-
};
|
|
54
42
|
}
|
|
55
43
|
get mlsService() {
|
|
56
44
|
if (!this._mlsService) {
|
|
@@ -173,7 +161,10 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
173
161
|
return;
|
|
174
162
|
}
|
|
175
163
|
const newSubconversationEpoch = Number(await this.mlsService.getEpoch(subconversationGroupId));
|
|
176
|
-
return onEpochUpdate(
|
|
164
|
+
return onEpochUpdate({
|
|
165
|
+
...subconversationEpochInfo,
|
|
166
|
+
epoch: newSubconversationEpoch,
|
|
167
|
+
});
|
|
177
168
|
};
|
|
178
169
|
this.mlsService.on('newEpoch', forwardNewEpoch);
|
|
179
170
|
await forwardNewEpoch({ groupId: subconversationGroupId, epoch: initialEpoch });
|
|
@@ -221,5 +212,20 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
221
212
|
};
|
|
222
213
|
});
|
|
223
214
|
}
|
|
215
|
+
getSubconversationGroupId = async (parentConversationId, subconversationId) => {
|
|
216
|
+
const foundSubconversation = await this.coreDatabase.get('subconversations', (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
217
|
+
return foundSubconversation?.groupId;
|
|
218
|
+
};
|
|
219
|
+
getAllGroupIdsBySubconversationId = async (subconversationId) => {
|
|
220
|
+
const allSubconversations = await this.coreDatabase.getAll('subconversations');
|
|
221
|
+
const foundSubconversations = allSubconversations.filter(subconversation => subconversation.subconversationId === subconversationId);
|
|
222
|
+
return foundSubconversations;
|
|
223
|
+
};
|
|
224
|
+
saveSubconversationGroupId = async (parentConversationId, subconversationId, groupId) => {
|
|
225
|
+
return this.coreDatabase.put('subconversations', { parentConversationId, subconversationId, groupId }, (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
226
|
+
};
|
|
227
|
+
clearSubconversationGroupId = async (parentConversationId, subconversationId) => {
|
|
228
|
+
return this.coreDatabase.delete('subconversations', (0, subconversationUtil_1.generateSubconversationStoreKey)(parentConversationId, subconversationId));
|
|
229
|
+
};
|
|
224
230
|
}
|
|
225
231
|
exports.SubconversationService = SubconversationService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetContent.d.ts","sourceRoot":"","sources":["../../../src/conversation/content/AssetContent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssetContent.d.ts","sourceRoot":"","sources":["../../../src/conversation/content/AssetContent.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,KAAK,EAAC,MAAM,6BAA6B,CAAC;AAElD,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,IAAI,CAAC;AACnD,OAAO,EAAC,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAE,eAAe,EAAC,MAAM,GAAG,CAAC;AAElF,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC;AACjD,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC;AACjD,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC;AACrC,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC;AAEvC,MAAM,WAAW,SAAS;IACxB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAGD,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,UAAW,SAAQ,KAAK,CAAC,WAAW;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5B,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC;IACrF,kBAAkB,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,iBAAkB,SAAQ,SAAS;IAClD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,KAAK,EAAE,YAAY,CAAC;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,KAAK,EAAE,sBAAsB,CAAC;IAC9B,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,wBAAyB,SAAQ,SAAS;IACzD,QAAQ,EAAE,mBAAmB,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAsB,SAAQ,SAAS;IACtD,MAAM,EAAE,WAAW,CAAC;CACrB"}
|
|
@@ -18,76 +18,75 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
21
|
+
exports.isAbortedAssetContent = isAbortedAssetContent;
|
|
22
|
+
exports.isAssetContent = isAssetContent;
|
|
23
|
+
exports.isClearedContent = isClearedContent;
|
|
24
|
+
exports.isClientActionContent = isClientActionContent;
|
|
25
|
+
exports.isClientActionType = isClientActionType;
|
|
26
|
+
exports.isConfirmationContent = isConfirmationContent;
|
|
27
|
+
exports.isConnection = isConnection;
|
|
28
|
+
exports.isDeletedContent = isDeletedContent;
|
|
29
|
+
exports.isEditedTextContent = isEditedTextContent;
|
|
30
|
+
exports.isFileAssetAbortContent = isFileAssetAbortContent;
|
|
31
|
+
exports.isFileAssetContent = isFileAssetContent;
|
|
32
|
+
exports.isFileAssetMetaDataContent = isFileAssetMetaDataContent;
|
|
33
|
+
exports.isHiddenContent = isHiddenContent;
|
|
34
|
+
exports.isImageAssetContent = isImageAssetContent;
|
|
35
|
+
exports.isImageContent = isImageContent;
|
|
36
|
+
exports.isLocationContent = isLocationContent;
|
|
37
|
+
exports.isReactionContent = isReactionContent;
|
|
38
|
+
exports.isTextContent = isTextContent;
|
|
22
39
|
function isAbortedAssetContent(content) {
|
|
23
40
|
return !!content.abortReason;
|
|
24
41
|
}
|
|
25
|
-
exports.isAbortedAssetContent = isAbortedAssetContent;
|
|
26
42
|
function isAssetContent(content) {
|
|
27
43
|
return !!(content.uploaded || content.preview);
|
|
28
44
|
}
|
|
29
|
-
exports.isAssetContent = isAssetContent;
|
|
30
45
|
function isClearedContent(content) {
|
|
31
46
|
return !!content.clearedTimestamp;
|
|
32
47
|
}
|
|
33
|
-
exports.isClearedContent = isClearedContent;
|
|
34
48
|
function isClientActionContent(content) {
|
|
35
49
|
return !!content.clientAction;
|
|
36
50
|
}
|
|
37
|
-
exports.isClientActionContent = isClientActionContent;
|
|
38
51
|
function isClientActionType(content) {
|
|
39
52
|
return typeof content === 'number';
|
|
40
53
|
}
|
|
41
|
-
exports.isClientActionType = isClientActionType;
|
|
42
54
|
function isConfirmationContent(content) {
|
|
43
55
|
return !!content.firstMessageId;
|
|
44
56
|
}
|
|
45
|
-
exports.isConfirmationContent = isConfirmationContent;
|
|
46
57
|
function isConnection(content) {
|
|
47
58
|
return !!content.from && !!content.to;
|
|
48
59
|
}
|
|
49
|
-
exports.isConnection = isConnection;
|
|
50
60
|
function isDeletedContent(content) {
|
|
51
61
|
return !!content.messageId && !content.text;
|
|
52
62
|
}
|
|
53
|
-
exports.isDeletedContent = isDeletedContent;
|
|
54
63
|
function isEditedTextContent(content) {
|
|
55
64
|
return !!content.text && !!content.originalMessageId;
|
|
56
65
|
}
|
|
57
|
-
exports.isEditedTextContent = isEditedTextContent;
|
|
58
66
|
function isFileAssetAbortContent(content) {
|
|
59
67
|
return !!content.reason;
|
|
60
68
|
}
|
|
61
|
-
exports.isFileAssetAbortContent = isFileAssetAbortContent;
|
|
62
69
|
function isFileAssetContent(content) {
|
|
63
70
|
return !!content.asset && !!content.file;
|
|
64
71
|
}
|
|
65
|
-
exports.isFileAssetContent = isFileAssetContent;
|
|
66
72
|
function isFileAssetMetaDataContent(content) {
|
|
67
73
|
return !!content.metaData;
|
|
68
74
|
}
|
|
69
|
-
exports.isFileAssetMetaDataContent = isFileAssetMetaDataContent;
|
|
70
75
|
function isHiddenContent(content) {
|
|
71
76
|
return !!content.conversationId;
|
|
72
77
|
}
|
|
73
|
-
exports.isHiddenContent = isHiddenContent;
|
|
74
78
|
function isImageAssetContent(content) {
|
|
75
79
|
return !!content.asset && !!content.image;
|
|
76
80
|
}
|
|
77
|
-
exports.isImageAssetContent = isImageAssetContent;
|
|
78
81
|
function isImageContent(content) {
|
|
79
82
|
return !!content.data && !!content.type;
|
|
80
83
|
}
|
|
81
|
-
exports.isImageContent = isImageContent;
|
|
82
84
|
function isLocationContent(content) {
|
|
83
85
|
return !!content.latitude && !!content.longitude;
|
|
84
86
|
}
|
|
85
|
-
exports.isLocationContent = isLocationContent;
|
|
86
87
|
function isReactionContent(content) {
|
|
87
88
|
return !!content.type && !!content.originalMessageId;
|
|
88
89
|
}
|
|
89
|
-
exports.isReactionContent = isReactionContent;
|
|
90
90
|
function isTextContent(content) {
|
|
91
91
|
return !!content.text;
|
|
92
92
|
}
|
|
93
|
-
exports.isTextContent = isTextContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileContent.d.ts","sourceRoot":"","sources":["../../../src/conversation/content/FileContent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileContent.d.ts","sourceRoot":"","sources":["../../../src/conversation/content/FileContent.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,aAAa,EAAE,aAAa,EAAE,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageContent.d.ts","sourceRoot":"","sources":["../../../src/conversation/content/ImageContent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageContent.d.ts","sourceRoot":"","sources":["../../../src/conversation/content/ImageContent.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf"}
|