@wireapp/core 32.0.4 → 32.0.6
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 +3 -3
- package/src/main/Account.js +1 -0
- package/src/main/conversation/ConversationMapper/ConversationMapper.js +1 -1
- package/src/main/conversation/ConversationService/ConversationService.d.ts +16 -37
- package/src/main/conversation/ConversationService/ConversationService.js +26 -115
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +5 -17
- package/src/main/conversation/message/CompositeContentBuilder.js +1 -1
- package/src/main/conversation/message/MessageBuilder.d.ts +25 -96
- package/src/main/conversation/message/MessageBuilder.js +272 -100
- package/src/main/conversation/message/MessageService.d.ts +1 -1
- package/src/main/conversation/message/MessageService.js +3 -3
- package/src/main/conversation/message/MessageToProtoMapper.d.ts +1 -1
- package/src/main/conversation/message/MessageToProtoMapper.js +1 -1
- package/src/main/conversation/message/TextContentBuilder.d.ts +10 -11
- package/src/main/conversation/message/TextContentBuilder.js +3 -5
- package/src/main/conversation/message/messageSender.d.ts +1 -0
- package/src/main/conversation/message/messageSender.js +5 -1
- package/src/main/index.d.ts +7 -17
- package/src/main/index.js +12 -16
- package/src/main/user/UserMapper.js +4 -4
- package/src/main/user/UserService.js +3 -1
- package/src/main/account/AccountService.js.map +0 -1
- package/src/main/account/AccountService.ts +0 -31
- package/src/main/account/index.js.map +0 -1
- package/src/main/account/index.ts +0 -20
- package/src/main/conversation/ConversationService/messageGenerator.d.ts +0 -9
- package/src/main/conversation/ConversationService/messageGenerator.js +0 -313
package/package.json
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"!src/main/**/*test*.ts"
|
|
66
66
|
],
|
|
67
67
|
"license": "GPL-3.0",
|
|
68
|
-
"main": "src/main/
|
|
68
|
+
"main": "src/main/index",
|
|
69
69
|
"name": "@wireapp/core",
|
|
70
70
|
"repository": "https://github.com/wireapp/wire-web-packages/tree/main/packages/core",
|
|
71
71
|
"scripts": {
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
"test": "jest",
|
|
82
82
|
"watch": "tsc ---watch"
|
|
83
83
|
},
|
|
84
|
-
"version": "32.0.
|
|
85
|
-
"gitHead": "
|
|
84
|
+
"version": "32.0.6",
|
|
85
|
+
"gitHead": "b7e78c5c3923cd10386056cdeff94c74a56030a2"
|
|
86
86
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -442,6 +442,7 @@ class Account extends events_1.EventEmitter {
|
|
|
442
442
|
this.apiClient.transport.ws.unlock();
|
|
443
443
|
// We need to wait for the notification stream to be fully handled before releasing the message sending queue.
|
|
444
444
|
// This is due to the nature of how message are encrypted, any change in mls epoch needs to happen before we start encrypting any kind of messages
|
|
445
|
+
this.logger.log(`resume message sending. ${(0, messageSender_1.getQueueLength)()} messages to be sent`);
|
|
445
446
|
(0, messageSender_1.resumeMessageSending)();
|
|
446
447
|
onConnectionStateChanged(ConnectionState.LIVE);
|
|
447
448
|
};
|
|
@@ -30,7 +30,7 @@ class ConversationMapper {
|
|
|
30
30
|
qualifiedConversation: event.qualified_conversation,
|
|
31
31
|
qualifiedFrom: event.qualified_from,
|
|
32
32
|
from: event.from,
|
|
33
|
-
id: MessageBuilder_1.
|
|
33
|
+
id: (0, MessageBuilder_1.createId)(),
|
|
34
34
|
messageTimer: 0,
|
|
35
35
|
source,
|
|
36
36
|
state: PayloadBundle_1.PayloadBundleState.INCOMING,
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { APIClient } from '@wireapp/api-client';
|
|
2
|
-
import {
|
|
2
|
+
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation';
|
|
3
3
|
import { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
|
|
4
4
|
import { QualifiedId, UserPreKeyBundleMap } from '@wireapp/api-client/src/user';
|
|
5
|
-
import { MessageTimer, RemoveUsersParams } from '../../conversation/';
|
|
5
|
+
import { MessageTimer, PayloadBundleState, RemoveUsersParams } from '../../conversation/';
|
|
6
6
|
import { RemoteData } from '../content';
|
|
7
7
|
import { CryptographyService } from '../../cryptography/';
|
|
8
8
|
import { MLSService } from '../../mls';
|
|
9
9
|
import { NotificationService } from '../../notification';
|
|
10
|
-
import { ClearConversationMessage, OtrMessage } from '../message/OtrMessage';
|
|
11
10
|
import { XOR } from '@wireapp/commons/src/main/util/TypeUtil';
|
|
12
|
-
import { AddUsersParams,
|
|
11
|
+
import { AddUsersParams, MLSReturnType, SendMlsMessageParams, SendProteusMessageParams } from './ConversationService.types';
|
|
12
|
+
declare type SendResult = {
|
|
13
|
+
/** The id of the message sent */
|
|
14
|
+
id: string;
|
|
15
|
+
/** the ISO formatted date at which the message was received by the backend */
|
|
16
|
+
sentAt: string;
|
|
17
|
+
/** The sending state of the payload (has the payload been succesfully sent or canceled) */
|
|
18
|
+
state: PayloadBundleState;
|
|
19
|
+
};
|
|
13
20
|
export declare class ConversationService {
|
|
14
21
|
private readonly apiClient;
|
|
15
22
|
private readonly config;
|
|
@@ -17,7 +24,6 @@ export declare class ConversationService {
|
|
|
17
24
|
private readonly mlsService;
|
|
18
25
|
readonly messageTimer: MessageTimer;
|
|
19
26
|
private readonly messageService;
|
|
20
|
-
private selfConversationId?;
|
|
21
27
|
constructor(apiClient: APIClient, cryptographyService: CryptographyService, config: {
|
|
22
28
|
useQualifiedIds?: boolean;
|
|
23
29
|
}, notificationService: NotificationService, mlsService: MLSService);
|
|
@@ -31,8 +37,7 @@ export declare class ConversationService {
|
|
|
31
37
|
* @returns {Promise<QualifiedUserPreKeyBundleMap}
|
|
32
38
|
*/
|
|
33
39
|
private getQualifiedPreKeyBundle;
|
|
34
|
-
getPreKeyBundleMap(conversationId:
|
|
35
|
-
private getSelfConversationId;
|
|
40
|
+
getPreKeyBundleMap(conversationId: QualifiedId, userIds?: string[] | UserClients): Promise<UserPreKeyBundleMap>;
|
|
36
41
|
private getQualifiedRecipientsForConversation;
|
|
37
42
|
private getRecipientsForConversation;
|
|
38
43
|
/**
|
|
@@ -46,33 +51,6 @@ export declare class ConversationService {
|
|
|
46
51
|
private sendGenericMessage;
|
|
47
52
|
private extractUserIds;
|
|
48
53
|
private extractQualifiedUserIds;
|
|
49
|
-
clearConversation(conversationId: string, timestamp?: number | Date, messageId?: string, sendAsProtobuf?: boolean): Promise<ClearConversationMessage>;
|
|
50
|
-
/**
|
|
51
|
-
* Sends a LastRead message to the current user's self conversation.
|
|
52
|
-
* This will allow all the user's devices to compute which messages are unread
|
|
53
|
-
*
|
|
54
|
-
* @param conversationId The conversation which has been read
|
|
55
|
-
* @param lastReadTimestamp The timestamp at which the conversation was read
|
|
56
|
-
* @param sendingOptions?
|
|
57
|
-
* @return Resolves when the message has been sent
|
|
58
|
-
*/
|
|
59
|
-
sendLastRead(conversationId: string, lastReadTimestamp: number, sendingOptions?: MessageSendingOptions): Promise<(MessageSendingStatus & {
|
|
60
|
-
errored?: boolean | undefined;
|
|
61
|
-
}) | (ClientMismatch & {
|
|
62
|
-
errored?: boolean | undefined;
|
|
63
|
-
})>;
|
|
64
|
-
/**
|
|
65
|
-
* Syncs all self user's devices with the countly id
|
|
66
|
-
*
|
|
67
|
-
* @param countlyId The countly id of the current device
|
|
68
|
-
* @param sendingOptions?
|
|
69
|
-
* @return Resolves when the message has been sent
|
|
70
|
-
*/
|
|
71
|
-
sendCountlySync(countlyId: string, sendingOptions: MessageSendingOptions): Promise<(MessageSendingStatus & {
|
|
72
|
-
errored?: boolean | undefined;
|
|
73
|
-
}) | (ClientMismatch & {
|
|
74
|
-
errored?: boolean | undefined;
|
|
75
|
-
})>;
|
|
76
54
|
/**
|
|
77
55
|
* Get a fresh list from backend of clients for all the participants of the conversation.
|
|
78
56
|
* This is a hacky way of getting all the clients for a conversation.
|
|
@@ -83,7 +61,7 @@ export declare class ConversationService {
|
|
|
83
61
|
* @param {string} conversationId
|
|
84
62
|
* @param {string} conversationDomain? - If given will send the message to the new qualified endpoint
|
|
85
63
|
*/
|
|
86
|
-
getAllParticipantsClients(conversationId:
|
|
64
|
+
getAllParticipantsClients(conversationId: QualifiedId): Promise<UserClients | QualifiedUserClients>;
|
|
87
65
|
/**
|
|
88
66
|
* Get a fresh list from backend of clients for all the participants of the conversation.
|
|
89
67
|
* @fixme there are some case where this method is not enough to detect removed devices
|
|
@@ -118,9 +96,9 @@ export declare class ConversationService {
|
|
|
118
96
|
private sendProteusMessage;
|
|
119
97
|
/**
|
|
120
98
|
* Sends a message to a conversation
|
|
121
|
-
* @return resolves with the
|
|
99
|
+
* @return resolves with the sending status
|
|
122
100
|
*/
|
|
123
|
-
send
|
|
101
|
+
send(params: XOR<SendMlsMessageParams, SendProteusMessageParams>): Promise<SendResult>;
|
|
124
102
|
sendTypingStart(conversationId: string): Promise<void>;
|
|
125
103
|
sendTypingStop(conversationId: string): Promise<void>;
|
|
126
104
|
setConversationMutedStatus(conversationId: string, status: MutedStatus, muteTimestamp: number | Date): Promise<void>;
|
|
@@ -147,3 +125,4 @@ export declare class ConversationService {
|
|
|
147
125
|
isMLSConversationEstablished(conversationGroupId: string): Promise<boolean>;
|
|
148
126
|
wipeMLSConversation(conversationId: Uint8Array): Promise<void>;
|
|
149
127
|
}
|
|
128
|
+
export {};
|
|
@@ -26,14 +26,12 @@ const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
|
26
26
|
const conversation_2 = require("../../conversation/");
|
|
27
27
|
const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
|
|
28
28
|
const TypePredicateUtil_1 = require("../../util/TypePredicateUtil");
|
|
29
|
-
const MessageBuilder_1 = require("../message/MessageBuilder");
|
|
30
29
|
const MessageService_1 = require("../message/MessageService");
|
|
31
30
|
const ConversationService_types_1 = require("./ConversationService.types");
|
|
32
31
|
const bazinga64_1 = require("bazinga64");
|
|
33
32
|
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
34
33
|
const mls_1 = require("../../mls");
|
|
35
34
|
const messageSender_1 = require("../message/messageSender");
|
|
36
|
-
const messageGenerator_1 = require("./messageGenerator");
|
|
37
35
|
class ConversationService {
|
|
38
36
|
constructor(apiClient, cryptographyService, config, notificationService, mlsService) {
|
|
39
37
|
this.apiClient = apiClient;
|
|
@@ -125,15 +123,6 @@ class ConversationService {
|
|
|
125
123
|
return bundleMap;
|
|
126
124
|
}, {});
|
|
127
125
|
}
|
|
128
|
-
async getSelfConversationId() {
|
|
129
|
-
if (!this.selfConversationId) {
|
|
130
|
-
const { userId } = this.apiClient.context;
|
|
131
|
-
const { qualified_id, id } = await this.apiClient.api.conversation.getConversation(userId);
|
|
132
|
-
const domain = this.config.useQualifiedIds ? qualified_id.domain : '';
|
|
133
|
-
this.selfConversationId = { id, domain };
|
|
134
|
-
}
|
|
135
|
-
return this.selfConversationId;
|
|
136
|
-
}
|
|
137
126
|
async getQualifiedRecipientsForConversation(conversationId, userIds) {
|
|
138
127
|
if ((0, TypePredicateUtil_1.isQualifiedUserClients)(userIds)) {
|
|
139
128
|
return userIds;
|
|
@@ -155,16 +144,16 @@ class ConversationService {
|
|
|
155
144
|
* @param genericMessage The payload of the message to send
|
|
156
145
|
* @return Resolves with the message sending status from backend
|
|
157
146
|
*/
|
|
158
|
-
async sendGenericMessage(
|
|
147
|
+
async sendGenericMessage(conversationId, sendingClientId, genericMessage, { userIds, nativePush, sendAsProtobuf, onClientMismatch, targetMode = ConversationService_types_1.MessageTargetMode.NONE, } = {}) {
|
|
159
148
|
const plainText = protocol_messaging_1.GenericMessage.encode(genericMessage).finish();
|
|
160
149
|
if (targetMode !== ConversationService_types_1.MessageTargetMode.NONE && !userIds) {
|
|
161
150
|
throw new Error('Cannot send targetted message when no userIds are given');
|
|
162
151
|
}
|
|
163
|
-
if (
|
|
152
|
+
if (conversationId.domain && this.config.useQualifiedIds) {
|
|
164
153
|
if ((0, TypePredicateUtil_1.isStringArray)(userIds) || (0, TypePredicateUtil_1.isUserClients)(userIds)) {
|
|
165
154
|
throw new Error('Invalid userIds option for sending to federated backend');
|
|
166
155
|
}
|
|
167
|
-
const recipients = await this.getQualifiedRecipientsForConversation(
|
|
156
|
+
const recipients = await this.getQualifiedRecipientsForConversation(conversationId, userIds);
|
|
168
157
|
let reportMissing;
|
|
169
158
|
if (targetMode === ConversationService_types_1.MessageTargetMode.NONE) {
|
|
170
159
|
reportMissing = (0, TypePredicateUtil_1.isQualifiedUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
|
|
@@ -177,7 +166,7 @@ class ConversationService {
|
|
|
177
166
|
reportMissing = false;
|
|
178
167
|
}
|
|
179
168
|
return this.messageService.sendFederatedMessage(sendingClientId, recipients, plainText, {
|
|
180
|
-
conversationId
|
|
169
|
+
conversationId,
|
|
181
170
|
nativePush,
|
|
182
171
|
reportMissing,
|
|
183
172
|
onClientMismatch: mismatch => onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(mismatch, false),
|
|
@@ -220,77 +209,6 @@ class ConversationService {
|
|
|
220
209
|
}
|
|
221
210
|
return userIds;
|
|
222
211
|
}
|
|
223
|
-
async clearConversation(conversationId, timestamp = new Date(), messageId = MessageBuilder_1.MessageBuilder.createId(), sendAsProtobuf) {
|
|
224
|
-
if (timestamp instanceof Date) {
|
|
225
|
-
timestamp = timestamp.getTime();
|
|
226
|
-
}
|
|
227
|
-
const content = {
|
|
228
|
-
clearedTimestamp: timestamp,
|
|
229
|
-
conversationId,
|
|
230
|
-
};
|
|
231
|
-
const clearedMessage = protocol_messaging_1.Cleared.create(content);
|
|
232
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
233
|
-
[conversation_2.GenericMessageType.CLEARED]: clearedMessage,
|
|
234
|
-
messageId,
|
|
235
|
-
});
|
|
236
|
-
const { id: selfConversationId, domain } = await this.getSelfConversationId();
|
|
237
|
-
await this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
|
|
238
|
-
conversationDomain: domain,
|
|
239
|
-
sendAsProtobuf,
|
|
240
|
-
});
|
|
241
|
-
return {
|
|
242
|
-
content,
|
|
243
|
-
conversation: conversationId,
|
|
244
|
-
from: this.apiClient.context.userId,
|
|
245
|
-
id: messageId,
|
|
246
|
-
messageTimer: 0,
|
|
247
|
-
source: conversation_2.PayloadBundleSource.LOCAL,
|
|
248
|
-
state: conversation_2.PayloadBundleState.OUTGOING_SENT,
|
|
249
|
-
timestamp: Date.now(),
|
|
250
|
-
type: conversation_2.PayloadBundleType.CONVERSATION_CLEAR,
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Sends a LastRead message to the current user's self conversation.
|
|
255
|
-
* This will allow all the user's devices to compute which messages are unread
|
|
256
|
-
*
|
|
257
|
-
* @param conversationId The conversation which has been read
|
|
258
|
-
* @param lastReadTimestamp The timestamp at which the conversation was read
|
|
259
|
-
* @param sendingOptions?
|
|
260
|
-
* @return Resolves when the message has been sent
|
|
261
|
-
*/
|
|
262
|
-
async sendLastRead(conversationId, lastReadTimestamp, sendingOptions) {
|
|
263
|
-
const lastRead = new protocol_messaging_1.LastRead({
|
|
264
|
-
conversationId,
|
|
265
|
-
lastReadTimestamp,
|
|
266
|
-
});
|
|
267
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
268
|
-
[conversation_2.GenericMessageType.LAST_READ]: lastRead,
|
|
269
|
-
messageId: MessageBuilder_1.MessageBuilder.createId(),
|
|
270
|
-
});
|
|
271
|
-
const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
|
|
272
|
-
return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, Object.assign({ conversationDomain: selfConversationDomain }, sendingOptions));
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Syncs all self user's devices with the countly id
|
|
276
|
-
*
|
|
277
|
-
* @param countlyId The countly id of the current device
|
|
278
|
-
* @param sendingOptions?
|
|
279
|
-
* @return Resolves when the message has been sent
|
|
280
|
-
*/
|
|
281
|
-
async sendCountlySync(countlyId, sendingOptions) {
|
|
282
|
-
const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
|
|
283
|
-
const dataTransfer = new protocol_messaging_1.DataTransfer({
|
|
284
|
-
trackingIdentifier: {
|
|
285
|
-
identifier: countlyId,
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
const genericMessage = new protocol_messaging_1.GenericMessage({
|
|
289
|
-
[conversation_2.GenericMessageType.DATA_TRANSFER]: dataTransfer,
|
|
290
|
-
messageId: MessageBuilder_1.MessageBuilder.createId(),
|
|
291
|
-
});
|
|
292
|
-
return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, Object.assign({ conversationDomain: selfConversationDomain }, sendingOptions));
|
|
293
|
-
}
|
|
294
212
|
/**
|
|
295
213
|
* Get a fresh list from backend of clients for all the participants of the conversation.
|
|
296
214
|
* This is a hacky way of getting all the clients for a conversation.
|
|
@@ -301,7 +219,7 @@ class ConversationService {
|
|
|
301
219
|
* @param {string} conversationId
|
|
302
220
|
* @param {string} conversationDomain? - If given will send the message to the new qualified endpoint
|
|
303
221
|
*/
|
|
304
|
-
getAllParticipantsClients(conversationId
|
|
222
|
+
getAllParticipantsClients(conversationId) {
|
|
305
223
|
const sendingClientId = this.apiClient.validatedClientId;
|
|
306
224
|
const recipients = {};
|
|
307
225
|
const text = new Uint8Array();
|
|
@@ -311,9 +229,9 @@ class ConversationService {
|
|
|
311
229
|
// When the mismatch happens, we ask the messageService to cancel the sending
|
|
312
230
|
return false;
|
|
313
231
|
};
|
|
314
|
-
if (
|
|
232
|
+
if (conversationId.domain && this.config.useQualifiedIds) {
|
|
315
233
|
await this.messageService.sendFederatedMessage(sendingClientId, recipients, text, {
|
|
316
|
-
conversationId
|
|
234
|
+
conversationId,
|
|
317
235
|
onClientMismatch,
|
|
318
236
|
reportMissing: true,
|
|
319
237
|
});
|
|
@@ -385,13 +303,10 @@ class ConversationService {
|
|
|
385
303
|
async removeUserFromConversation(conversationId, userId) {
|
|
386
304
|
return this.apiClient.api.conversation.deleteMember(conversationId, userId);
|
|
387
305
|
}
|
|
388
|
-
async sendProteusMessage(
|
|
389
|
-
|
|
390
|
-
const { userIds, sendAsProtobuf, conversationDomain, nativePush, targetMode, payload, onClientMismatch, onSuccess } = params;
|
|
391
|
-
const response = await this.sendGenericMessage(this.apiClient.validatedClientId, payload.conversation, genericMessage, {
|
|
306
|
+
async sendProteusMessage({ userIds, sendAsProtobuf, conversationId, nativePush, targetMode, payload, onClientMismatch, }) {
|
|
307
|
+
const response = await this.sendGenericMessage(conversationId, this.apiClient.validatedClientId, payload, {
|
|
392
308
|
userIds,
|
|
393
309
|
sendAsProtobuf,
|
|
394
|
-
conversationDomain,
|
|
395
310
|
nativePush,
|
|
396
311
|
targetMode,
|
|
397
312
|
onClientMismatch,
|
|
@@ -401,27 +316,22 @@ class ConversationService {
|
|
|
401
316
|
// We warn the consumer that there is a mismatch that did not prevent message sending
|
|
402
317
|
await (onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(response, true));
|
|
403
318
|
}
|
|
404
|
-
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(genericMessage, response.time);
|
|
405
319
|
}
|
|
406
|
-
return
|
|
320
|
+
return {
|
|
321
|
+
id: payload.messageId,
|
|
322
|
+
sentAt: response.time,
|
|
323
|
+
state: response.errored ? conversation_2.PayloadBundleState.CANCELLED : conversation_2.PayloadBundleState.OUTGOING_SENT,
|
|
324
|
+
};
|
|
407
325
|
}
|
|
408
326
|
/**
|
|
409
327
|
* Sends a message to a conversation
|
|
410
|
-
* @return resolves with the
|
|
328
|
+
* @return resolves with the sending status
|
|
411
329
|
*/
|
|
412
330
|
async send(params) {
|
|
413
331
|
function isMLS(params) {
|
|
414
332
|
return params.protocol === conversation_1.ConversationProtocol.MLS;
|
|
415
333
|
}
|
|
416
|
-
|
|
417
|
-
const { genericMessage, content } = (0, messageGenerator_1.generateGenericMessage)(payload, this.messageTimer);
|
|
418
|
-
if ((await (onStart === null || onStart === void 0 ? void 0 : onStart(genericMessage))) === false) {
|
|
419
|
-
// If the onStart call returns false, it means the consumer wants to cancel the message sending
|
|
420
|
-
return Object.assign(Object.assign({}, payload), { state: conversation_2.PayloadBundleState.CANCELLED });
|
|
421
|
-
}
|
|
422
|
-
return (0, messageSender_1.sendMessage)(() => isMLS(params)
|
|
423
|
-
? this.sendMLSMessage(params, genericMessage, content)
|
|
424
|
-
: this.sendProteusMessage(params, genericMessage, content));
|
|
334
|
+
return (0, messageSender_1.sendMessage)(() => (isMLS(params) ? this.sendMLSMessage(params) : this.sendProteusMessage(params)));
|
|
425
335
|
}
|
|
426
336
|
sendTypingStart(conversationId) {
|
|
427
337
|
return this.apiClient.api.conversation.postTyping(conversationId, { status: data_1.CONVERSATION_TYPING.STARTED });
|
|
@@ -518,21 +428,22 @@ class ConversationService {
|
|
|
518
428
|
conversation,
|
|
519
429
|
};
|
|
520
430
|
}
|
|
521
|
-
async sendMLSMessage(
|
|
522
|
-
var _a, _b;
|
|
523
|
-
const { groupId, onSuccess, payload } = params;
|
|
431
|
+
async sendMLSMessage({ payload, groupId }) {
|
|
524
432
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
525
433
|
// immediately execute pending commits before sending the message
|
|
526
434
|
await this.notificationService.commitPendingProposals({ groupId });
|
|
527
|
-
const encrypted = await this.mlsService.encryptMessage(groupIdBytes, protocol_messaging_1.GenericMessage.encode(
|
|
435
|
+
const encrypted = await this.mlsService.encryptMessage(groupIdBytes, protocol_messaging_1.GenericMessage.encode(payload).finish());
|
|
436
|
+
let sentAt = '';
|
|
528
437
|
try {
|
|
529
438
|
const { time = '' } = await this.apiClient.api.conversation.postMlsMessage(encrypted);
|
|
530
|
-
|
|
531
|
-
return Object.assign(Object.assign({}, payload), { content, messageTimer: ((_a = genericMessage.ephemeral) === null || _a === void 0 ? void 0 : _a.expireAfterMillis) || 0, state: conversation_2.PayloadBundleState.OUTGOING_SENT });
|
|
532
|
-
}
|
|
533
|
-
catch (_c) {
|
|
534
|
-
return Object.assign(Object.assign({}, payload), { content, messageTimer: ((_b = genericMessage.ephemeral) === null || _b === void 0 ? void 0 : _b.expireAfterMillis) || 0, state: conversation_2.PayloadBundleState.CANCELLED });
|
|
439
|
+
sentAt = (time === null || time === void 0 ? void 0 : time.length) > 0 ? time : new Date().toISOString();
|
|
535
440
|
}
|
|
441
|
+
catch (_a) { }
|
|
442
|
+
return {
|
|
443
|
+
id: payload.messageId,
|
|
444
|
+
sentAt,
|
|
445
|
+
state: sentAt ? conversation_2.PayloadBundleState.OUTGOING_SENT : conversation_2.PayloadBundleState.CANCELLED,
|
|
446
|
+
};
|
|
536
447
|
}
|
|
537
448
|
async addUsersToMLSConversation({ qualifiedUserIds, groupId, conversationId, }) {
|
|
538
449
|
const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
@@ -8,10 +8,6 @@ export declare enum MessageTargetMode {
|
|
|
8
8
|
USERS_CLIENTS = 2
|
|
9
9
|
}
|
|
10
10
|
export interface MessageSendingOptions {
|
|
11
|
-
/**
|
|
12
|
-
* The federated domain the server runs on. Should only be set for federation enabled envs
|
|
13
|
-
*/
|
|
14
|
-
conversationDomain?: string;
|
|
15
11
|
/**
|
|
16
12
|
* can be either a QualifiedId[] or QualfiedUserClients or undefined. The type has some effect on the behavior of the method.
|
|
17
13
|
* When given undefined the method will fetch both the members of the conversations and their devices. No ClientMismatch can happen in that case
|
|
@@ -37,13 +33,6 @@ export interface MessageSendingOptions {
|
|
|
37
33
|
targetMode?: MessageTargetMode;
|
|
38
34
|
}
|
|
39
35
|
export interface MessageSendingCallbacks {
|
|
40
|
-
/**
|
|
41
|
-
* Will be called before a message is actually sent. Returning 'false' will prevent the message from being sent
|
|
42
|
-
* @param message The message being sent
|
|
43
|
-
* @return true or undefined if the message should be sent, false if the message sending should be cancelled
|
|
44
|
-
*/
|
|
45
|
-
onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
|
|
46
|
-
onSuccess?: (message: GenericMessage, sentTime?: string) => void;
|
|
47
36
|
/**
|
|
48
37
|
* Called whenever there is a clientmismatch returned from the server. Will also indicate the sending status of the message (if it was already sent or not)
|
|
49
38
|
*
|
|
@@ -67,12 +56,11 @@ export declare type ProtocolParam = {
|
|
|
67
56
|
/**
|
|
68
57
|
* The message to send to the conversation
|
|
69
58
|
*/
|
|
70
|
-
export declare type SendCommonParams
|
|
71
|
-
payload:
|
|
72
|
-
onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
|
|
73
|
-
onSuccess?: (message: GenericMessage, sentTime?: string) => void;
|
|
59
|
+
export declare type SendCommonParams = ProtocolParam & {
|
|
60
|
+
payload: GenericMessage;
|
|
74
61
|
};
|
|
75
|
-
export declare type SendProteusMessageParams
|
|
62
|
+
export declare type SendProteusMessageParams = SendCommonParams & MessageSendingOptions & {
|
|
63
|
+
conversationId: QualifiedId;
|
|
76
64
|
/**
|
|
77
65
|
* Can be either a QualifiedId[], string[], UserClients or QualfiedUserClients. The type has some effect on the behavior of the method. (Needed only for Proteus)
|
|
78
66
|
* When given a QualifiedId[] or string[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
|
|
@@ -84,7 +72,7 @@ export declare type SendProteusMessageParams<T> = SendCommonParams<T> & MessageS
|
|
|
84
72
|
onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
85
73
|
protocol: ConversationProtocol.PROTEUS;
|
|
86
74
|
};
|
|
87
|
-
export declare type SendMlsMessageParams
|
|
75
|
+
export declare type SendMlsMessageParams = SendCommonParams & {
|
|
88
76
|
/**
|
|
89
77
|
* The groupId of the conversation to send the message to (Needed only for MLS)
|
|
90
78
|
*/
|
|
@@ -45,7 +45,7 @@ class CompositeContentBuilder {
|
|
|
45
45
|
this.items.push(protocol_messaging_1.Composite.Item.create({ text }));
|
|
46
46
|
return this;
|
|
47
47
|
}
|
|
48
|
-
addButton(buttonText, id = MessageBuilder_1.
|
|
48
|
+
addButton(buttonText, id = (0, MessageBuilder_1.createId)()) {
|
|
49
49
|
this.items.push(protocol_messaging_1.Composite.Item.create({ button: protocol_messaging_1.Button.create({ id, text: buttonText }) }));
|
|
50
50
|
return this;
|
|
51
51
|
}
|
|
@@ -1,96 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
interface CreateFileOptions extends BaseOptions {
|
|
27
|
-
expectsReadConfirmation?: boolean;
|
|
28
|
-
asset: EncryptedAssetUploaded;
|
|
29
|
-
file: FileContent;
|
|
30
|
-
legalHoldStatus?: LegalHoldStatus;
|
|
31
|
-
originalMessageId: string;
|
|
32
|
-
}
|
|
33
|
-
interface CreateEditedTextOptions extends BaseOptions {
|
|
34
|
-
newMessageText: string;
|
|
35
|
-
originalMessageId: string;
|
|
36
|
-
}
|
|
37
|
-
interface CreateFileMetadataOptions extends BaseOptions {
|
|
38
|
-
expectsReadConfirmation?: boolean;
|
|
39
|
-
legalHoldStatus?: LegalHoldStatus;
|
|
40
|
-
metaData: FileMetaDataContent;
|
|
41
|
-
}
|
|
42
|
-
interface CreateFileAbortOptions {
|
|
43
|
-
conversationId: string;
|
|
44
|
-
expectsReadConfirmation?: boolean;
|
|
45
|
-
from: string;
|
|
46
|
-
legalHoldStatus?: LegalHoldStatus;
|
|
47
|
-
originalMessageId: string;
|
|
48
|
-
reason: AbortReason;
|
|
49
|
-
}
|
|
50
|
-
interface CreateLocationOptions extends BaseOptions {
|
|
51
|
-
location: LocationContent;
|
|
52
|
-
}
|
|
53
|
-
interface CreateCallOptions extends BaseOptions {
|
|
54
|
-
content: CallingContent;
|
|
55
|
-
}
|
|
56
|
-
interface CreateReactionOptions extends BaseOptions {
|
|
57
|
-
reaction: ReactionContent;
|
|
58
|
-
}
|
|
59
|
-
interface CreateTextOptions extends BaseOptions {
|
|
60
|
-
text: string;
|
|
61
|
-
}
|
|
62
|
-
interface CreateConfirmationOptions extends BaseOptions {
|
|
63
|
-
firstMessageId: string;
|
|
64
|
-
moreMessageIds?: string[];
|
|
65
|
-
type: Confirmation.Type;
|
|
66
|
-
}
|
|
67
|
-
interface CreatePingOptions extends BaseOptions {
|
|
68
|
-
ping?: KnockContent;
|
|
69
|
-
}
|
|
70
|
-
interface CreateButtonActionConfirmationOptions extends BaseOptions {
|
|
71
|
-
content: ButtonActionConfirmationContent;
|
|
72
|
-
}
|
|
73
|
-
interface CreateActionMessageOptions extends BaseOptions {
|
|
74
|
-
content: ButtonActionContent;
|
|
75
|
-
}
|
|
76
|
-
export declare class MessageBuilder {
|
|
77
|
-
static createEditedText(payload: CreateEditedTextOptions): TextContentBuilder;
|
|
78
|
-
static createFileData(payload: CreateFileOptions): FileAssetMessage;
|
|
79
|
-
static createMessageDelete(payload: CreateMessageDeleteOption): DeleteMessage;
|
|
80
|
-
static createMessageHide(payload: CreateMessageHideOption): HideMessage;
|
|
81
|
-
static createFileMetadata(payload: CreateFileMetadataOptions): FileAssetMetaDataMessage;
|
|
82
|
-
static createFileAbort(payload: CreateFileAbortOptions): FileAssetAbortMessage;
|
|
83
|
-
static createImage(payload: CreateImageOptions): ImageAssetMessageOutgoing;
|
|
84
|
-
static createLocation(payload: CreateLocationOptions): LocationMessage;
|
|
85
|
-
static createCall(payload: CreateCallOptions): CallMessage;
|
|
86
|
-
static createReaction(payload: CreateReactionOptions): ReactionMessage;
|
|
87
|
-
static createText(payload: CreateTextOptions): TextContentBuilder;
|
|
88
|
-
static createConfirmation(payload: CreateConfirmationOptions): ConfirmationMessage;
|
|
89
|
-
static createButtonActionMessage(payload: CreateActionMessageOptions): ButtonActionMessage;
|
|
90
|
-
static createButtonActionConfirmationMessage(payload: CreateButtonActionConfirmationOptions): ButtonActionConfirmationMessage;
|
|
91
|
-
static createComposite(payload: BaseOptions): CompositeContentBuilder;
|
|
92
|
-
static createPing(payload: CreatePingOptions): PingMessage;
|
|
93
|
-
static createSessionReset(payload: BaseOptions): ResetSessionMessage;
|
|
94
|
-
static createId(): string;
|
|
95
|
-
}
|
|
96
|
-
export {};
|
|
1
|
+
import { ButtonActionConfirmationMessage, ButtonActionMessage, CallMessage, ConfirmationMessage, DeleteMessage, EditedTextMessage, FileAssetAbortMessage, FileAssetMessage, FileAssetMetaDataMessage, HideMessage, ImageAssetMessageOutgoing, LocationMessage, PingMessage, ReactionMessage, TextMessage } from './OtrMessage';
|
|
2
|
+
import { IComposite, GenericMessage } from '@wireapp/protocol-messaging';
|
|
3
|
+
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
4
|
+
export declare function createId(): string;
|
|
5
|
+
export declare function buildButtonActionMessage(payloadBundle: ButtonActionMessage['content']): GenericMessage;
|
|
6
|
+
export declare function buildButtonActionConfirmationMessage(payloadBundle: ButtonActionConfirmationMessage['content']): GenericMessage;
|
|
7
|
+
export declare function buildCompositeMessage(payload: IComposite): GenericMessage;
|
|
8
|
+
export declare function buildConfirmationMessage(payloadBundle: ConfirmationMessage['content']): GenericMessage;
|
|
9
|
+
export declare function buildEditedTextMessage(payloadBundle: EditedTextMessage['content'], messageId?: string): GenericMessage;
|
|
10
|
+
export declare function buildFileDataMessage(payloadBundle: FileAssetMessage['content'], messageId?: string): GenericMessage;
|
|
11
|
+
export declare function buildFileMetaDataMessage(payloadBundle: FileAssetMetaDataMessage['content']): GenericMessage;
|
|
12
|
+
export declare function buildFileAbortMessage(payloadBundle: FileAssetAbortMessage['content'], messageId?: string): GenericMessage;
|
|
13
|
+
export declare function buildLastReadMessage(conversationId: QualifiedId, lastReadTimestamp: number): GenericMessage;
|
|
14
|
+
export declare function buildDataTransferMessage(identifier: string): GenericMessage;
|
|
15
|
+
export declare function buildClearedMessage(conversationId: QualifiedId, timestamp?: number): GenericMessage;
|
|
16
|
+
export declare function buildImageMessage(payloadBundle: ImageAssetMessageOutgoing['content'], messageId?: string): GenericMessage;
|
|
17
|
+
export declare function buildLocationMessage(payloadBundle: LocationMessage['content']): GenericMessage;
|
|
18
|
+
export declare function buildPingMessage(payloadBundle: PingMessage['content']): GenericMessage;
|
|
19
|
+
export declare function buildReactionMessage(payloadBundle: ReactionMessage['content']): GenericMessage;
|
|
20
|
+
export declare function buildSessionResetMessage(): GenericMessage;
|
|
21
|
+
export declare function buildCallMessage(payloadBundle: CallMessage['content']): GenericMessage;
|
|
22
|
+
export declare function buildDeleteMessage(payload: DeleteMessage['content']): GenericMessage;
|
|
23
|
+
export declare function buildHideMessage(payload: HideMessage['content']): GenericMessage;
|
|
24
|
+
export declare function buildTextMessage(payloadBundle: TextMessage['content'], messageId?: string): GenericMessage;
|
|
25
|
+
export declare function wrapInEphemeral(originalGenericMessage: GenericMessage, expireAfterMillis: number): GenericMessage;
|