@wireapp/core 17.31.0 → 17.31.4
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 +35 -0
- package/package.json +9 -9
- package/src/main/Account.js.map +0 -1
- package/src/main/Account.test.browser.js +0 -114
- package/src/main/Account.test.node.d.ts +0 -1
- package/src/main/Account.test.node.js +0 -214
- package/src/main/Account.test.node.js.map +0 -1
- package/src/main/Account.test.node.ts +0 -236
- package/src/main/Account.ts +0 -401
- package/src/main/CoreError.js.map +0 -1
- package/src/main/CoreError.ts +0 -30
- package/src/main/auth/LoginSanitizer.js.map +0 -1
- package/src/main/auth/LoginSanitizer.test.node.d.ts +0 -1
- package/src/main/auth/LoginSanitizer.test.node.js +0 -56
- package/src/main/auth/LoginSanitizer.test.node.js.map +0 -1
- package/src/main/auth/LoginSanitizer.test.node.ts +0 -68
- package/src/main/auth/LoginSanitizer.ts +0 -44
- package/src/main/auth/index.js.map +0 -1
- package/src/main/auth/index.ts +0 -20
- package/src/main/broadcast/AvailabilityType.js.map +0 -1
- package/src/main/broadcast/AvailabilityType.ts +0 -22
- package/src/main/broadcast/BroadcastService.js.map +0 -1
- package/src/main/broadcast/BroadcastService.ts +0 -66
- package/src/main/broadcast/index.js.map +0 -1
- package/src/main/broadcast/index.ts +0 -21
- package/src/main/client/ClientBackendRepository.js.map +0 -1
- package/src/main/client/ClientBackendRepository.ts +0 -33
- package/src/main/client/ClientDatabaseRepository.js.map +0 -1
- package/src/main/client/ClientDatabaseRepository.ts +0 -130
- package/src/main/client/ClientInfo.js.map +0 -1
- package/src/main/client/ClientInfo.ts +0 -28
- package/src/main/client/ClientService.js.map +0 -1
- package/src/main/client/ClientService.ts +0 -116
- package/src/main/client/index.js.map +0 -1
- package/src/main/client/index.ts +0 -23
- package/src/main/connection/ConnectionService.js.map +0 -1
- package/src/main/connection/ConnectionService.ts +0 -49
- package/src/main/connection/index.js.map +0 -1
- package/src/main/connection/index.ts +0 -20
- package/src/main/conversation/AbortReason.js.map +0 -1
- package/src/main/conversation/AbortReason.ts +0 -22
- package/src/main/conversation/AssetService.js.map +0 -1
- package/src/main/conversation/AssetService.test.node.d.ts +0 -1
- package/src/main/conversation/AssetService.test.node.js +0 -61
- package/src/main/conversation/AssetService.test.node.js.map +0 -1
- package/src/main/conversation/AssetService.test.node.ts +0 -65
- package/src/main/conversation/AssetService.ts +0 -60
- package/src/main/conversation/AssetTransferState.js.map +0 -1
- package/src/main/conversation/AssetTransferState.ts +0 -23
- package/src/main/conversation/ClientActionType.js.map +0 -1
- package/src/main/conversation/ClientActionType.ts +0 -20
- package/src/main/conversation/ConversationMapper.js.map +0 -1
- package/src/main/conversation/ConversationMapper.test.node.d.ts +0 -1
- package/src/main/conversation/ConversationMapper.test.node.js +0 -111
- package/src/main/conversation/ConversationMapper.test.node.js.map +0 -1
- package/src/main/conversation/ConversationMapper.test.node.ts +0 -154
- package/src/main/conversation/ConversationMapper.ts +0 -56
- package/src/main/conversation/ConversationService.js.map +0 -1
- package/src/main/conversation/ConversationService.test.node.d.ts +0 -1
- package/src/main/conversation/ConversationService.test.node.js +0 -344
- package/src/main/conversation/ConversationService.test.node.js.map +0 -1
- package/src/main/conversation/ConversationService.test.node.ts +0 -416
- package/src/main/conversation/ConversationService.ts +0 -1024
- package/src/main/conversation/GenericMessageType.js.map +0 -1
- package/src/main/conversation/GenericMessageType.ts +0 -44
- package/src/main/conversation/MessageTimer.js.map +0 -1
- package/src/main/conversation/MessageTimer.test.node.d.ts +0 -1
- package/src/main/conversation/MessageTimer.test.node.js +0 -88
- package/src/main/conversation/MessageTimer.test.node.js.map +0 -1
- package/src/main/conversation/MessageTimer.test.node.ts +0 -103
- package/src/main/conversation/MessageTimer.ts +0 -56
- package/src/main/conversation/ReactionType.js.map +0 -1
- package/src/main/conversation/ReactionType.ts +0 -23
- package/src/main/conversation/content/AssetContent.js.map +0 -1
- package/src/main/conversation/content/AssetContent.ts +0 -71
- package/src/main/conversation/content/ButtonActionConfirmationContent.js.map +0 -1
- package/src/main/conversation/content/ButtonActionConfirmationContent.ts +0 -21
- package/src/main/conversation/content/ButtonActionContent.js.map +0 -1
- package/src/main/conversation/content/ButtonActionContent.ts +0 -21
- package/src/main/conversation/content/CallingContent.js.map +0 -1
- package/src/main/conversation/content/CallingContent.ts +0 -20
- package/src/main/conversation/content/ClearedContent.js.map +0 -1
- package/src/main/conversation/content/ClearedContent.ts +0 -21
- package/src/main/conversation/content/ClientActionContent.js.map +0 -1
- package/src/main/conversation/content/ClientActionContent.ts +0 -22
- package/src/main/conversation/content/ClientAddContent.js.map +0 -1
- package/src/main/conversation/content/ClientAddContent.ts +0 -24
- package/src/main/conversation/content/ClientRemoveContent.js.map +0 -1
- package/src/main/conversation/content/ClientRemoveContent.ts +0 -25
- package/src/main/conversation/content/CompositeContent.js.map +0 -1
- package/src/main/conversation/content/CompositeContent.ts +0 -21
- package/src/main/conversation/content/ConfirmationContent.js.map +0 -1
- package/src/main/conversation/content/ConfirmationContent.ts +0 -21
- package/src/main/conversation/content/ContentType.js.map +0 -1
- package/src/main/conversation/content/ContentType.ts +0 -112
- package/src/main/conversation/content/ConversationContent.js.map +0 -1
- package/src/main/conversation/content/ConversationContent.ts +0 -71
- package/src/main/conversation/content/DeletedContent.js.map +0 -1
- package/src/main/conversation/content/DeletedContent.ts +0 -21
- package/src/main/conversation/content/EditedTextContent.js.map +0 -1
- package/src/main/conversation/content/EditedTextContent.ts +0 -31
- package/src/main/conversation/content/FileContent.js.map +0 -1
- package/src/main/conversation/content/FileContent.ts +0 -32
- package/src/main/conversation/content/HiddenContent.js.map +0 -1
- package/src/main/conversation/content/HiddenContent.ts +0 -21
- package/src/main/conversation/content/ImageContent.js.map +0 -1
- package/src/main/conversation/content/ImageContent.ts +0 -25
- package/src/main/conversation/content/KnockContent.js.map +0 -1
- package/src/main/conversation/content/KnockContent.ts +0 -21
- package/src/main/conversation/content/LinkPreviewContent.js.map +0 -1
- package/src/main/conversation/content/LinkPreviewContent.ts +0 -32
- package/src/main/conversation/content/LocationContent.js.map +0 -1
- package/src/main/conversation/content/LocationContent.ts +0 -29
- package/src/main/conversation/content/MentionContent.js.map +0 -1
- package/src/main/conversation/content/MentionContent.ts +0 -21
- package/src/main/conversation/content/QuoteContent.js.map +0 -1
- package/src/main/conversation/content/QuoteContent.ts +0 -29
- package/src/main/conversation/content/ReactionContent.js.map +0 -1
- package/src/main/conversation/content/ReactionContent.ts +0 -27
- package/src/main/conversation/content/TextContent.js.map +0 -1
- package/src/main/conversation/content/TextContent.ts +0 -29
- package/src/main/conversation/content/TweetContent.js.map +0 -1
- package/src/main/conversation/content/TweetContent.ts +0 -21
- package/src/main/conversation/content/index.js.map +0 -1
- package/src/main/conversation/content/index.ts +0 -49
- package/src/main/conversation/index.js.map +0 -1
- package/src/main/conversation/index.ts +0 -28
- package/src/main/conversation/message/CompositeContentBuilder.js.map +0 -1
- package/src/main/conversation/message/CompositeContentBuilder.ts +0 -60
- package/src/main/conversation/message/Message.js.map +0 -1
- package/src/main/conversation/message/Message.ts +0 -24
- package/src/main/conversation/message/MessageBuilder.js.map +0 -1
- package/src/main/conversation/message/MessageBuilder.test.browser.js +0 -27
- package/src/main/conversation/message/MessageBuilder.ts +0 -488
- package/src/main/conversation/message/MessageService.js.map +0 -1
- package/src/main/conversation/message/MessageService.test.node.d.ts +0 -1
- package/src/main/conversation/message/MessageService.test.node.js +0 -308
- package/src/main/conversation/message/MessageService.test.node.js.map +0 -1
- package/src/main/conversation/message/MessageService.test.node.ts +0 -398
- package/src/main/conversation/message/MessageService.ts +0 -383
- package/src/main/conversation/message/MessageToProtoMapper.js.map +0 -1
- package/src/main/conversation/message/MessageToProtoMapper.ts +0 -114
- package/src/main/conversation/message/OtrMessage.js.map +0 -1
- package/src/main/conversation/message/OtrMessage.ts +0 -160
- package/src/main/conversation/message/PayloadBundle.js.map +0 -1
- package/src/main/conversation/message/PayloadBundle.ts +0 -101
- package/src/main/conversation/message/TeamMessage.js.map +0 -1
- package/src/main/conversation/message/TeamMessage.ts +0 -72
- package/src/main/conversation/message/TextContentBuilder.js.map +0 -1
- package/src/main/conversation/message/TextContentBuilder.ts +0 -88
- package/src/main/conversation/message/UserClientsUtil.js.map +0 -1
- package/src/main/conversation/message/UserClientsUtil.ts +0 -44
- package/src/main/conversation/message/UserClientsUtils.test.node.d.ts +0 -1
- package/src/main/conversation/message/UserClientsUtils.test.node.js +0 -42
- package/src/main/conversation/message/UserClientsUtils.test.node.js.map +0 -1
- package/src/main/conversation/message/UserClientsUtils.test.node.ts +0 -44
- package/src/main/conversation/message/UserMessage.js.map +0 -1
- package/src/main/conversation/message/UserMessage.ts +0 -95
- package/src/main/cryptography/AssetCryptography.browser.js.map +0 -1
- package/src/main/cryptography/AssetCryptography.browser.ts +0 -76
- package/src/main/cryptography/AssetCryptography.node.js.map +0 -1
- package/src/main/cryptography/AssetCryptography.node.ts +0 -85
- package/src/main/cryptography/CryptographyDatabaseRepository.js.map +0 -1
- package/src/main/cryptography/CryptographyDatabaseRepository.ts +0 -44
- package/src/main/cryptography/CryptographyService.js.map +0 -1
- package/src/main/cryptography/CryptographyService.test.browser.js +0 -195
- package/src/main/cryptography/CryptographyService.test.node.d.ts +0 -1
- package/src/main/cryptography/CryptographyService.test.node.js +0 -228
- package/src/main/cryptography/CryptographyService.test.node.js.map +0 -1
- package/src/main/cryptography/CryptographyService.test.node.ts +0 -246
- package/src/main/cryptography/CryptographyService.ts +0 -246
- package/src/main/cryptography/EncryptedAsset.js.map +0 -1
- package/src/main/cryptography/EncryptedAsset.ts +0 -30
- package/src/main/cryptography/GenericMessageMapper.js.map +0 -1
- package/src/main/cryptography/GenericMessageMapper.ts +0 -274
- package/src/main/cryptography/MessageHashService.js.map +0 -1
- package/src/main/cryptography/MessageHashService.test.browser.js +0 -176
- package/src/main/cryptography/MessageHashService.test.node.d.ts +0 -1
- package/src/main/cryptography/MessageHashService.test.node.js +0 -138
- package/src/main/cryptography/MessageHashService.test.node.js.map +0 -1
- package/src/main/cryptography/MessageHashService.test.node.ts +0 -176
- package/src/main/cryptography/MessageHashService.ts +0 -109
- package/src/main/cryptography/SessionPayloadBundle.js.map +0 -1
- package/src/main/cryptography/SessionPayloadBundle.ts +0 -23
- package/src/main/cryptography/index.js.map +0 -1
- package/src/main/cryptography/index.ts +0 -23
- package/src/main/giphy/GiphyService.js.map +0 -1
- package/src/main/giphy/GiphyService.ts +0 -37
- package/src/main/giphy/index.js.map +0 -1
- package/src/main/giphy/index.ts +0 -20
- package/src/main/index.js.map +0 -1
- package/src/main/index.test.browser.js +0 -22
- package/src/main/index.ts +0 -34
- package/src/main/notification/NotificationBackendRepository.js.map +0 -1
- package/src/main/notification/NotificationBackendRepository.ts +0 -33
- package/src/main/notification/NotificationDatabaseRepository.js.map +0 -1
- package/src/main/notification/NotificationDatabaseRepository.ts +0 -74
- package/src/main/notification/NotificationService.js.map +0 -1
- package/src/main/notification/NotificationService.test.browser.js +0 -179
- package/src/main/notification/NotificationService.test.node.d.ts +0 -1
- package/src/main/notification/NotificationService.test.node.js +0 -99
- package/src/main/notification/NotificationService.test.node.js.map +0 -1
- package/src/main/notification/NotificationService.test.node.ts +0 -124
- package/src/main/notification/NotificationService.ts +0 -260
- package/src/main/notification/index.js.map +0 -1
- package/src/main/notification/index.ts +0 -20
- package/src/main/self/SelfService.js.map +0 -1
- package/src/main/self/SelfService.ts +0 -59
- package/src/main/self/index.js.map +0 -1
- package/src/main/self/index.ts +0 -20
- package/src/main/team/TeamService.js.map +0 -1
- package/src/main/team/TeamService.ts +0 -68
- package/src/main/team/index.js.map +0 -1
- package/src/main/team/index.ts +0 -20
- package/src/main/test/CryptographyHelper.js.map +0 -1
- package/src/main/test/CryptographyHelper.ts +0 -57
- package/src/main/test/PayloadHelper.js.map +0 -1
- package/src/main/test/PayloadHelper.ts +0 -60
- package/src/main/user/UserMapper.js.map +0 -1
- package/src/main/user/UserMapper.test.node.d.ts +0 -1
- package/src/main/user/UserMapper.test.node.js +0 -55
- package/src/main/user/UserMapper.test.node.js.map +0 -1
- package/src/main/user/UserMapper.test.node.ts +0 -63
- package/src/main/user/UserMapper.ts +0 -92
- package/src/main/user/UserService.js.map +0 -1
- package/src/main/user/UserService.test.node.js +0 -141
- package/src/main/user/UserService.ts +0 -98
- package/src/main/user/index.js.map +0 -1
- package/src/main/user/index.ts +0 -20
- package/src/main/util/TypePredicateUtil.js.map +0 -1
- package/src/main/util/TypePredicateUtil.test.node.d.ts +0 -1
- package/src/main/util/TypePredicateUtil.test.node.js +0 -42
- package/src/main/util/TypePredicateUtil.test.node.js.map +0 -1
- package/src/main/util/TypePredicateUtil.test.node.ts +0 -44
- package/src/main/util/TypePredicateUtil.ts +0 -52
- package/src/main/util/index.js.map +0 -1
- package/src/main/util/index.ts +0 -20
|
@@ -1,416 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2018 Wire Swiss GmbH
|
|
4
|
-
*
|
|
5
|
-
* This program is free software: you can redistribute it and/or modify
|
|
6
|
-
* it under the terms of the GNU General Public License as published by
|
|
7
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
8
|
-
* (at your option) any later version.
|
|
9
|
-
*
|
|
10
|
-
* This program is distributed in the hope that it will be useful,
|
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
* GNU General Public License for more details.
|
|
14
|
-
*
|
|
15
|
-
* You should have received a copy of the GNU General Public License
|
|
16
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import {APIClient} from '@wireapp/api-client';
|
|
21
|
-
import {ClientType} from '@wireapp/api-client/src/client';
|
|
22
|
-
import {LegalHoldStatus} from '@wireapp/protocol-messaging';
|
|
23
|
-
import {MemoryEngine} from '@wireapp/store-engine';
|
|
24
|
-
import {MessageTargetMode, PayloadBundleSource, PayloadBundleState, PayloadBundleType} from '.';
|
|
25
|
-
|
|
26
|
-
import {Account} from '../Account';
|
|
27
|
-
import * as PayloadHelper from '../test/PayloadHelper';
|
|
28
|
-
import {MentionContent, QuoteContent} from './content';
|
|
29
|
-
import {OtrMessage} from './message/OtrMessage';
|
|
30
|
-
|
|
31
|
-
describe('ConversationService', () => {
|
|
32
|
-
let account: Account;
|
|
33
|
-
|
|
34
|
-
beforeAll(async () => {
|
|
35
|
-
const client = new APIClient({urls: APIClient.BACKEND.STAGING});
|
|
36
|
-
account = new Account(client);
|
|
37
|
-
await account.initServices(new MemoryEngine());
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
beforeEach(() => {
|
|
41
|
-
account['apiClient'].context = {
|
|
42
|
-
clientType: ClientType.NONE,
|
|
43
|
-
userId: PayloadHelper.getUUID(),
|
|
44
|
-
clientId: PayloadHelper.getUUID(),
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('"send"', () => {
|
|
49
|
-
const baseMessage = {
|
|
50
|
-
conversation: PayloadHelper.getUUID(),
|
|
51
|
-
from: PayloadHelper.getUUID(),
|
|
52
|
-
id: PayloadHelper.getUUID(),
|
|
53
|
-
timestamp: 0,
|
|
54
|
-
source: PayloadBundleSource.LOCAL,
|
|
55
|
-
state: PayloadBundleState.OUTGOING_UNSENT,
|
|
56
|
-
};
|
|
57
|
-
const messages: OtrMessage[] = [
|
|
58
|
-
{...baseMessage, type: PayloadBundleType.TEXT, content: {text: 'test'}},
|
|
59
|
-
{
|
|
60
|
-
...baseMessage,
|
|
61
|
-
type: PayloadBundleType.CONFIRMATION,
|
|
62
|
-
content: {type: 1, firstMessageId: PayloadHelper.getUUID()},
|
|
63
|
-
},
|
|
64
|
-
{...baseMessage, type: PayloadBundleType.PING, content: {hotKnock: false}},
|
|
65
|
-
];
|
|
66
|
-
messages.forEach(payloadBundle => {
|
|
67
|
-
it(`calls callbacks when sending '${payloadBundle.type}' message is starting and successful`, async () => {
|
|
68
|
-
const conversationService = account.service!.conversation;
|
|
69
|
-
const sentTime = new Date().toISOString();
|
|
70
|
-
spyOn<any>(conversationService, 'sendGenericMessage').and.returnValue(Promise.resolve({time: sentTime}));
|
|
71
|
-
const callbacks = {onStart: jasmine.createSpy(), onSuccess: jasmine.createSpy()};
|
|
72
|
-
const promise = conversationService.send({
|
|
73
|
-
callbacks,
|
|
74
|
-
payloadBundle,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
expect(callbacks.onStart).toHaveBeenCalled();
|
|
78
|
-
expect(callbacks.onSuccess).not.toHaveBeenCalled();
|
|
79
|
-
await promise;
|
|
80
|
-
expect(callbacks.onSuccess).toHaveBeenCalledWith(jasmine.any(Object), sentTime);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('targetted messages', () => {
|
|
85
|
-
const message: OtrMessage = {...baseMessage, type: PayloadBundleType.TEXT, content: {text: 'test'}};
|
|
86
|
-
it('fails if no userIds are given', done => {
|
|
87
|
-
const conversationService = account.service!.conversation;
|
|
88
|
-
conversationService
|
|
89
|
-
.send({
|
|
90
|
-
payloadBundle: message,
|
|
91
|
-
targetMode: MessageTargetMode.USERS,
|
|
92
|
-
})
|
|
93
|
-
.catch(error => {
|
|
94
|
-
expect(error.message).toContain('no userIds are given');
|
|
95
|
-
done();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
[{user1: ['client1'], user2: ['client11', 'client12']}, ['user1', 'user2']].forEach(recipients => {
|
|
100
|
-
it(`forwards the list of users to report (${JSON.stringify(recipients)})`, async () => {
|
|
101
|
-
const conversationService = account.service!.conversation;
|
|
102
|
-
spyOn<any>(conversationService, 'getRecipientsForConversation').and.returnValue(Promise.resolve({} as any));
|
|
103
|
-
spyOn(conversationService['messageService'], 'sendMessage').and.returnValue(Promise.resolve({} as any));
|
|
104
|
-
await conversationService.send({
|
|
105
|
-
payloadBundle: message,
|
|
106
|
-
targetMode: MessageTargetMode.USERS,
|
|
107
|
-
userIds: recipients,
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expect(conversationService['messageService'].sendMessage).toHaveBeenCalledWith(
|
|
111
|
-
jasmine.any(String),
|
|
112
|
-
jasmine.any(Object),
|
|
113
|
-
jasmine.any(Uint8Array),
|
|
114
|
-
jasmine.objectContaining({reportMissing: ['user1', 'user2']}),
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
[
|
|
120
|
-
{domain1: {user1: ['client1'], user2: ['client11', 'client12']}, domain2: {user3: ['client1']}},
|
|
121
|
-
[
|
|
122
|
-
{id: 'user1', domain: 'domain1'},
|
|
123
|
-
{id: 'user2', domain: 'domain1'},
|
|
124
|
-
{id: 'user3', domain: 'domain2'},
|
|
125
|
-
],
|
|
126
|
-
].forEach(recipients => {
|
|
127
|
-
it(`forwards the list of users to report for federated message (${JSON.stringify(recipients)})`, async () => {
|
|
128
|
-
const conversationService = account.service!.conversation;
|
|
129
|
-
spyOn<any>(conversationService, 'getQualifiedRecipientsForConversation').and.returnValue(
|
|
130
|
-
Promise.resolve({} as any),
|
|
131
|
-
);
|
|
132
|
-
spyOn(conversationService['messageService'], 'sendFederatedMessage').and.returnValue(
|
|
133
|
-
Promise.resolve({} as any),
|
|
134
|
-
);
|
|
135
|
-
await conversationService.send({
|
|
136
|
-
conversationDomain: 'domain1',
|
|
137
|
-
payloadBundle: message,
|
|
138
|
-
targetMode: MessageTargetMode.USERS,
|
|
139
|
-
userIds: recipients,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
expect(conversationService['messageService'].sendFederatedMessage).toHaveBeenCalledWith(
|
|
143
|
-
jasmine.any(String),
|
|
144
|
-
jasmine.any(Object),
|
|
145
|
-
jasmine.any(Uint8Array),
|
|
146
|
-
jasmine.objectContaining({
|
|
147
|
-
reportMissing: [
|
|
148
|
-
{id: 'user1', domain: 'domain1'},
|
|
149
|
-
{id: 'user2', domain: 'domain1'},
|
|
150
|
-
{id: 'user3', domain: 'domain2'},
|
|
151
|
-
],
|
|
152
|
-
}),
|
|
153
|
-
);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
[{user1: ['client1'], user2: ['client11', 'client12']}, ['user1', 'user2']].forEach(recipients => {
|
|
158
|
-
it(`ignores all missing user/client pair if targetMode is USER_CLIENTS`, async () => {
|
|
159
|
-
const conversationService = account.service!.conversation;
|
|
160
|
-
spyOn<any>(conversationService, 'getRecipientsForConversation').and.returnValue(Promise.resolve({} as any));
|
|
161
|
-
spyOn(conversationService['messageService'], 'sendMessage').and.returnValue(Promise.resolve({} as any));
|
|
162
|
-
await conversationService.send({
|
|
163
|
-
payloadBundle: message,
|
|
164
|
-
targetMode: MessageTargetMode.USERS_CLIENTS,
|
|
165
|
-
userIds: recipients,
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
expect(conversationService['messageService'].sendMessage).toHaveBeenCalledWith(
|
|
169
|
-
jasmine.any(String),
|
|
170
|
-
jasmine.any(Object),
|
|
171
|
-
jasmine.any(Uint8Array),
|
|
172
|
-
jasmine.objectContaining({reportMissing: false}),
|
|
173
|
-
);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
[
|
|
178
|
-
{domain1: {user1: ['client1'], user2: ['client11', 'client12']}, domain2: {user3: ['client1']}},
|
|
179
|
-
[
|
|
180
|
-
{id: 'user1', domain: 'domain1'},
|
|
181
|
-
{id: 'user2', domain: 'domain1'},
|
|
182
|
-
{id: 'user3', domain: 'domain2'},
|
|
183
|
-
],
|
|
184
|
-
].forEach(recipients => {
|
|
185
|
-
it(`ignores all missing user/client pair if targetMode is USER_CLIENTS on federated env`, async () => {
|
|
186
|
-
const conversationService = account.service!.conversation;
|
|
187
|
-
spyOn<any>(conversationService, 'getQualifiedRecipientsForConversation').and.returnValue(
|
|
188
|
-
Promise.resolve({} as any),
|
|
189
|
-
);
|
|
190
|
-
spyOn(conversationService['messageService'], 'sendFederatedMessage').and.returnValue(
|
|
191
|
-
Promise.resolve({} as any),
|
|
192
|
-
);
|
|
193
|
-
await conversationService.send({
|
|
194
|
-
conversationDomain: 'domain1',
|
|
195
|
-
payloadBundle: message,
|
|
196
|
-
targetMode: MessageTargetMode.USERS_CLIENTS,
|
|
197
|
-
userIds: recipients,
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
expect(conversationService['messageService'].sendFederatedMessage).toHaveBeenCalledWith(
|
|
201
|
-
jasmine.any(String),
|
|
202
|
-
jasmine.any(Object),
|
|
203
|
-
jasmine.any(Uint8Array),
|
|
204
|
-
jasmine.objectContaining({
|
|
205
|
-
reportMissing: false,
|
|
206
|
-
}),
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it(`cancels message sending if onStart returns false`, async () => {
|
|
213
|
-
const conversationService = account.service!.conversation;
|
|
214
|
-
spyOn<any>(conversationService, 'sendGenericMessage');
|
|
215
|
-
const message: OtrMessage = {...baseMessage, type: PayloadBundleType.TEXT, content: {text: 'test'}};
|
|
216
|
-
const callbacks = {onStart: () => Promise.resolve(false), onSuccess: jasmine.createSpy()};
|
|
217
|
-
const payloadBundle = await conversationService.send({
|
|
218
|
-
callbacks,
|
|
219
|
-
payloadBundle: message,
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
expect(callbacks.onSuccess).not.toHaveBeenCalled();
|
|
223
|
-
expect(conversationService['sendGenericMessage']).not.toHaveBeenCalled();
|
|
224
|
-
expect(payloadBundle.state).toBe(PayloadBundleState.CANCELLED);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it(`does not call onSuccess when message was canceled`, async () => {
|
|
228
|
-
const conversationService = account.service!.conversation;
|
|
229
|
-
spyOn<any>(conversationService, 'sendGenericMessage').and.returnValue(Promise.resolve({time: '', errored: true}));
|
|
230
|
-
const message: OtrMessage = {...baseMessage, type: PayloadBundleType.TEXT, content: {text: 'test'}};
|
|
231
|
-
const callbacks = {onSuccess: jasmine.createSpy()};
|
|
232
|
-
const payloadBundle = await conversationService.send({
|
|
233
|
-
callbacks,
|
|
234
|
-
payloadBundle: message,
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
expect(callbacks.onSuccess).not.toHaveBeenCalled();
|
|
238
|
-
expect(payloadBundle.state).toBe(PayloadBundleState.CANCELLED);
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
describe('"createText"', () => {
|
|
243
|
-
it('adds link previews correctly', async () => {
|
|
244
|
-
const url = 'http://example.com';
|
|
245
|
-
|
|
246
|
-
const permanentUrl = url;
|
|
247
|
-
const summary = 'Summary';
|
|
248
|
-
const text = url;
|
|
249
|
-
const title = 'Title';
|
|
250
|
-
const tweet = {
|
|
251
|
-
author: 'Author',
|
|
252
|
-
username: 'Username',
|
|
253
|
-
};
|
|
254
|
-
const urlOffset = 0;
|
|
255
|
-
|
|
256
|
-
const linkPreview = await account.service!.conversation.messageBuilder.createLinkPreview({
|
|
257
|
-
permanentUrl,
|
|
258
|
-
summary,
|
|
259
|
-
title,
|
|
260
|
-
tweet,
|
|
261
|
-
url,
|
|
262
|
-
urlOffset,
|
|
263
|
-
});
|
|
264
|
-
const textMessage = account
|
|
265
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
266
|
-
.withLinkPreviews([linkPreview])
|
|
267
|
-
.build();
|
|
268
|
-
|
|
269
|
-
expect(textMessage.content.text).toEqual(text);
|
|
270
|
-
expect(textMessage.content.linkPreviews).toEqual(jasmine.any(Array));
|
|
271
|
-
expect(textMessage.content.linkPreviews!.length).toBe(1);
|
|
272
|
-
|
|
273
|
-
expect(textMessage.content.linkPreviews![0]).toEqual(
|
|
274
|
-
jasmine.objectContaining({
|
|
275
|
-
permanentUrl,
|
|
276
|
-
summary,
|
|
277
|
-
title,
|
|
278
|
-
tweet,
|
|
279
|
-
url,
|
|
280
|
-
urlOffset,
|
|
281
|
-
}),
|
|
282
|
-
);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it('does not add link previews', () => {
|
|
286
|
-
const text = 'Hello, world!';
|
|
287
|
-
const textMessage = account.service!.conversation.messageBuilder.createText({conversationId: '', text}).build();
|
|
288
|
-
|
|
289
|
-
expect(textMessage.content.linkPreviews).toBeUndefined();
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it('uploads link previews', async () => {
|
|
293
|
-
spyOn(account.service!.asset, 'uploadImageAsset').and.returnValue(
|
|
294
|
-
Promise.resolve({
|
|
295
|
-
cipherText: Buffer.from([]),
|
|
296
|
-
key: '',
|
|
297
|
-
keyBytes: Buffer.from([]),
|
|
298
|
-
sha256: Buffer.from([]),
|
|
299
|
-
token: '',
|
|
300
|
-
}),
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
const url = 'http://example.com';
|
|
304
|
-
const image = {
|
|
305
|
-
data: Buffer.from([]),
|
|
306
|
-
height: 123,
|
|
307
|
-
type: 'image/jpeg',
|
|
308
|
-
width: 456,
|
|
309
|
-
};
|
|
310
|
-
const text = url;
|
|
311
|
-
const urlOffset = 0;
|
|
312
|
-
|
|
313
|
-
const linkPreview = await account.service!.conversation.messageBuilder.createLinkPreview({image, url, urlOffset});
|
|
314
|
-
const textMessage = account
|
|
315
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
316
|
-
.withLinkPreviews([linkPreview])
|
|
317
|
-
.build();
|
|
318
|
-
|
|
319
|
-
expect(account.service!.asset.uploadImageAsset).toHaveBeenCalledTimes(1);
|
|
320
|
-
|
|
321
|
-
expect(textMessage.content.linkPreviews).toEqual(jasmine.any(Array));
|
|
322
|
-
expect(textMessage.content.linkPreviews!.length).toBe(1);
|
|
323
|
-
|
|
324
|
-
expect(textMessage.content.linkPreviews![0]).toEqual(
|
|
325
|
-
jasmine.objectContaining({
|
|
326
|
-
url,
|
|
327
|
-
urlOffset,
|
|
328
|
-
}),
|
|
329
|
-
);
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
it('adds mentions correctly', () => {
|
|
333
|
-
const text = 'Hello @user!';
|
|
334
|
-
|
|
335
|
-
const mention: MentionContent = {
|
|
336
|
-
length: 5,
|
|
337
|
-
start: 6,
|
|
338
|
-
userId: PayloadHelper.getUUID(),
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
const textMessage = account
|
|
342
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
343
|
-
.withMentions([mention])
|
|
344
|
-
.build();
|
|
345
|
-
|
|
346
|
-
expect(textMessage.content.text).toEqual(text);
|
|
347
|
-
expect(textMessage.content.mentions).toEqual(jasmine.any(Array));
|
|
348
|
-
expect(textMessage.content.mentions!.length).toBe(1);
|
|
349
|
-
|
|
350
|
-
expect(textMessage.content.mentions![0]).toEqual(jasmine.objectContaining(mention));
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it('does not add mentions', () => {
|
|
354
|
-
const text = 'Hello, world!';
|
|
355
|
-
const textMessage = account.service!.conversation.messageBuilder.createText({conversationId: '', text}).build();
|
|
356
|
-
|
|
357
|
-
expect(textMessage.content.mentions).toBeUndefined();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it('adds a quote correctly', () => {
|
|
361
|
-
const quoteId = PayloadHelper.getUUID();
|
|
362
|
-
const text = 'I totally agree.';
|
|
363
|
-
|
|
364
|
-
const quote: QuoteContent = {
|
|
365
|
-
quotedMessageId: quoteId,
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
const replyMessage = account
|
|
369
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
370
|
-
.withQuote(quote)
|
|
371
|
-
.build();
|
|
372
|
-
|
|
373
|
-
expect(replyMessage.content.text).toEqual(text);
|
|
374
|
-
expect(replyMessage.content.quote).toEqual(jasmine.objectContaining({quotedMessageId: quoteId}));
|
|
375
|
-
expect(replyMessage.content.quote).toEqual(jasmine.objectContaining(quote));
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it('does not add a quote', () => {
|
|
379
|
-
const text = 'Hello, world!';
|
|
380
|
-
const textMessage = account.service!.conversation.messageBuilder.createText({conversationId: '', text}).build();
|
|
381
|
-
|
|
382
|
-
expect(textMessage.content.quote).toBeUndefined();
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it('adds a read confirmation request correctly', () => {
|
|
386
|
-
const text = 'Please read me';
|
|
387
|
-
|
|
388
|
-
const replyMessage = account
|
|
389
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
390
|
-
.withReadConfirmation(true)
|
|
391
|
-
.build();
|
|
392
|
-
|
|
393
|
-
expect(replyMessage.content.text).toEqual(text);
|
|
394
|
-
expect(replyMessage.content.expectsReadConfirmation).toEqual(true);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it('adds a legal hold status', () => {
|
|
398
|
-
const text = 'Please read me';
|
|
399
|
-
|
|
400
|
-
const firstMessage = account
|
|
401
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
402
|
-
.withLegalHoldStatus()
|
|
403
|
-
.build();
|
|
404
|
-
|
|
405
|
-
expect(firstMessage.content.legalHoldStatus).toEqual(LegalHoldStatus.UNKNOWN);
|
|
406
|
-
|
|
407
|
-
const replyMessage = account
|
|
408
|
-
.service!.conversation.messageBuilder.createText({conversationId: '', text})
|
|
409
|
-
.withLegalHoldStatus(LegalHoldStatus.ENABLED)
|
|
410
|
-
.build();
|
|
411
|
-
|
|
412
|
-
expect(replyMessage.content.text).toEqual(text);
|
|
413
|
-
expect(replyMessage.content.legalHoldStatus).toEqual(LegalHoldStatus.ENABLED);
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
});
|