@wireapp/core 17.27.2 → 17.28.1
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/CHANGELOG.md +38 -0
- package/package.json +3 -3
- package/src/main/conversation/ConversationService.d.ts +39 -14
- package/src/main/conversation/ConversationService.js +65 -27
- package/src/main/conversation/ConversationService.js.map +1 -1
- package/src/main/conversation/ConversationService.test.node.js +98 -51
- package/src/main/conversation/ConversationService.test.node.js.map +1 -1
- package/src/main/conversation/ConversationService.test.node.ts +137 -61
- package/src/main/conversation/ConversationService.ts +108 -33
- package/src/main/conversation/message/MessageService.d.ts +4 -2
- package/src/main/conversation/message/MessageService.js +23 -6
- package/src/main/conversation/message/MessageService.js.map +1 -1
- package/src/main/conversation/message/MessageService.test.node.js +6 -6
- package/src/main/conversation/message/MessageService.test.node.js.map +1 -1
- package/src/main/conversation/message/MessageService.test.node.ts +10 -6
- package/src/main/conversation/message/MessageService.ts +41 -16
|
@@ -41,6 +41,7 @@ import {MessageBuilder} from './MessageBuilder';
|
|
|
41
41
|
import {GenericMessage} from '@wireapp/protocol-messaging';
|
|
42
42
|
import {GenericMessageType} from '..';
|
|
43
43
|
import {flattenUserClients, flattenQualifiedUserClients} from './UserClientsUtil';
|
|
44
|
+
import {isQualifiedIdArray, isStringArray} from '../../util';
|
|
44
45
|
|
|
45
46
|
type ClientMismatchError = AxiosError<ClientMismatch | MessageSendingStatus>;
|
|
46
47
|
|
|
@@ -65,8 +66,9 @@ export class MessageService {
|
|
|
65
66
|
plainText: Uint8Array,
|
|
66
67
|
options: {
|
|
67
68
|
conversationId?: string;
|
|
68
|
-
reportMissing?: boolean;
|
|
69
|
+
reportMissing?: boolean | string[];
|
|
69
70
|
sendAsProtobuf?: boolean;
|
|
71
|
+
nativePush?: boolean;
|
|
70
72
|
onClientMismatch?: (mismatch: ClientMismatch) => void | boolean | Promise<boolean>;
|
|
71
73
|
} = {},
|
|
72
74
|
): Promise<ClientMismatch & {errored?: boolean}> {
|
|
@@ -119,7 +121,8 @@ export class MessageService {
|
|
|
119
121
|
options: {
|
|
120
122
|
assetData?: Uint8Array;
|
|
121
123
|
conversationId?: QualifiedId;
|
|
122
|
-
reportMissing?: boolean;
|
|
124
|
+
reportMissing?: boolean | QualifiedId[];
|
|
125
|
+
nativePush?: boolean;
|
|
123
126
|
onClientMismatch?: (mismatch: MessageSendingStatus) => void | boolean | Promise<boolean>;
|
|
124
127
|
},
|
|
125
128
|
): Promise<MessageSendingStatus & {errored?: boolean}> {
|
|
@@ -146,7 +149,12 @@ export class MessageService {
|
|
|
146
149
|
private async sendFederatedOtrMessage(
|
|
147
150
|
sendingClientId: string,
|
|
148
151
|
recipients: QualifiedOTRRecipients,
|
|
149
|
-
options: {
|
|
152
|
+
options: {
|
|
153
|
+
assetData?: Uint8Array;
|
|
154
|
+
conversationId?: QualifiedId;
|
|
155
|
+
reportMissing?: boolean | QualifiedId[];
|
|
156
|
+
nativePush?: boolean;
|
|
157
|
+
},
|
|
150
158
|
): Promise<MessageSendingStatus> {
|
|
151
159
|
const qualifiedUserEntries = Object.entries(recipients).map<ProtobufOTR.IQualifiedUserEntry>(
|
|
152
160
|
([domain, otrRecipients]) => {
|
|
@@ -177,6 +185,7 @@ export class MessageService {
|
|
|
177
185
|
sender: {
|
|
178
186
|
client: Long.fromString(sendingClientId, 16),
|
|
179
187
|
},
|
|
188
|
+
nativePush: options.nativePush,
|
|
180
189
|
});
|
|
181
190
|
|
|
182
191
|
if (options.assetData) {
|
|
@@ -184,9 +193,13 @@ export class MessageService {
|
|
|
184
193
|
}
|
|
185
194
|
|
|
186
195
|
if (options.reportMissing) {
|
|
187
|
-
|
|
196
|
+
if (isQualifiedIdArray(options.reportMissing)) {
|
|
197
|
+
protoMessage.reportOnly = {userIds: options.reportMissing};
|
|
198
|
+
} else {
|
|
199
|
+
protoMessage.reportAll = true;
|
|
200
|
+
}
|
|
188
201
|
} else {
|
|
189
|
-
protoMessage.ignoreAll =
|
|
202
|
+
protoMessage.ignoreAll = true;
|
|
190
203
|
}
|
|
191
204
|
|
|
192
205
|
if (!options.conversationId) {
|
|
@@ -202,22 +215,28 @@ export class MessageService {
|
|
|
202
215
|
private async sendOTRMessage(
|
|
203
216
|
sendingClientId: string,
|
|
204
217
|
recipients: OTRRecipients<Uint8Array>,
|
|
205
|
-
options: {
|
|
218
|
+
options: {
|
|
219
|
+
conversationId?: string;
|
|
220
|
+
assetData?: Uint8Array;
|
|
221
|
+
reportMissing?: boolean | string[];
|
|
222
|
+
nativePush?: boolean;
|
|
223
|
+
},
|
|
206
224
|
): Promise<ClientMismatch> {
|
|
207
225
|
const message: NewOTRMessage<string> = {
|
|
208
226
|
data: options.assetData ? Encoder.toBase64(options.assetData).asString : undefined,
|
|
209
227
|
recipients: CryptographyService.convertArrayRecipientsToBase64(recipients),
|
|
210
228
|
sender: sendingClientId,
|
|
229
|
+
native_push: options.nativePush,
|
|
211
230
|
};
|
|
212
231
|
|
|
232
|
+
const ignoreMissing = options.reportMissing === true ? false : undefined;
|
|
233
|
+
if (isStringArray(options.reportMissing)) {
|
|
234
|
+
message.report_missing = options.reportMissing;
|
|
235
|
+
}
|
|
236
|
+
|
|
213
237
|
return !options.conversationId
|
|
214
|
-
? this.apiClient.broadcast.api.postBroadcastMessage(sendingClientId, message,
|
|
215
|
-
: this.apiClient.conversation.api.postOTRMessage(
|
|
216
|
-
sendingClientId,
|
|
217
|
-
options.conversationId,
|
|
218
|
-
message,
|
|
219
|
-
!options.reportMissing,
|
|
220
|
-
);
|
|
238
|
+
? this.apiClient.broadcast.api.postBroadcastMessage(sendingClientId, message, ignoreMissing)
|
|
239
|
+
: this.apiClient.conversation.api.postOTRMessage(sendingClientId, options.conversationId, message, ignoreMissing);
|
|
221
240
|
}
|
|
222
241
|
|
|
223
242
|
private async generateExternalPayload(plainText: Uint8Array): Promise<{text: Uint8Array; cipherText: Uint8Array}> {
|
|
@@ -309,7 +328,7 @@ export class MessageService {
|
|
|
309
328
|
private async sendOTRProtobufMessage(
|
|
310
329
|
sendingClientId: string,
|
|
311
330
|
recipients: OTRRecipients<Uint8Array>,
|
|
312
|
-
options: {conversationId?: string; assetData?: Uint8Array; reportMissing?: boolean},
|
|
331
|
+
options: {conversationId?: string; assetData?: Uint8Array; reportMissing?: boolean | string[]},
|
|
313
332
|
): Promise<ClientMismatch> {
|
|
314
333
|
const userEntries: ProtobufOTR.IUserEntry[] = Object.entries(recipients).map(([userId, otrClientMap]) => {
|
|
315
334
|
const clients: ProtobufOTR.IClientEntry[] = Object.entries(otrClientMap).map(([clientId, payload]) => {
|
|
@@ -336,17 +355,23 @@ export class MessageService {
|
|
|
336
355
|
},
|
|
337
356
|
});
|
|
338
357
|
|
|
358
|
+
const ignoreMissing = options.reportMissing === true ? false : undefined;
|
|
359
|
+
if (isStringArray(options.reportMissing)) {
|
|
360
|
+
const encoder = new TextEncoder();
|
|
361
|
+
protoMessage.reportMissing = options.reportMissing.map(userId => ({uuid: encoder.encode(userId)}));
|
|
362
|
+
}
|
|
363
|
+
|
|
339
364
|
if (options.assetData) {
|
|
340
365
|
protoMessage.blob = options.assetData;
|
|
341
366
|
}
|
|
342
367
|
|
|
343
368
|
return !options.conversationId
|
|
344
|
-
? this.apiClient.broadcast.api.postBroadcastProtobufMessage(sendingClientId, protoMessage,
|
|
369
|
+
? this.apiClient.broadcast.api.postBroadcastProtobufMessage(sendingClientId, protoMessage, ignoreMissing)
|
|
345
370
|
: this.apiClient.conversation.api.postOTRProtobufMessage(
|
|
346
371
|
sendingClientId,
|
|
347
372
|
options.conversationId,
|
|
348
373
|
protoMessage,
|
|
349
|
-
|
|
374
|
+
ignoreMissing,
|
|
350
375
|
);
|
|
351
376
|
}
|
|
352
377
|
}
|