@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
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2020 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 {Runtime} from '@wireapp/commons';
|
|
22
|
-
import {CallConfigData} from '@wireapp/api-client/src/account/CallConfigData';
|
|
23
|
-
|
|
24
|
-
export class AccountService {
|
|
25
|
-
constructor(private readonly apiClient: APIClient) {}
|
|
26
|
-
|
|
27
|
-
getCallConfig(): Promise<CallConfigData> {
|
|
28
|
-
const iceCandidateLimit = Runtime.isFirefox() ? 3 : undefined;
|
|
29
|
-
return this.apiClient.api.account.getCallConfig(iceCandidateLimit);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;AAEH,mDAAiC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Wire
|
|
3
|
-
* Copyright (C) 2020 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
|
-
export * from './AccountService';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { OtrMessage } from '../message/OtrMessage';
|
|
2
|
-
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
3
|
-
import { MessageTimer } from '../MessageTimer';
|
|
4
|
-
interface GeneratedMessage<T extends OtrMessage> {
|
|
5
|
-
genericMessage: GenericMessage;
|
|
6
|
-
content: T['content'];
|
|
7
|
-
}
|
|
8
|
-
export declare function generateGenericMessage<T extends OtrMessage>(payload: T, messageTimer: MessageTimer): GeneratedMessage<T>;
|
|
9
|
-
export {};
|
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Wire
|
|
4
|
-
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
-
*
|
|
6
|
-
* This program is free software: you can redistribute it and/or modify
|
|
7
|
-
* it under the terms of the GNU General Public License as published by
|
|
8
|
-
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
-
* (at your option) any later version.
|
|
10
|
-
*
|
|
11
|
-
* This program is distributed in the hope that it will be useful,
|
|
12
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
-
* GNU General Public License for more details.
|
|
15
|
-
*
|
|
16
|
-
* You should have received a copy of the GNU General Public License
|
|
17
|
-
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.generateGenericMessage = void 0;
|
|
22
|
-
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
23
|
-
const PayloadBundle_1 = require("../message/PayloadBundle");
|
|
24
|
-
const MessageToProtoMapper_1 = require("../message/MessageToProtoMapper");
|
|
25
|
-
const GenericMessageType_1 = require("../GenericMessageType");
|
|
26
|
-
const AssetTransferState_1 = require("../AssetTransferState");
|
|
27
|
-
function generateGenericMessage(payload, messageTimer) {
|
|
28
|
-
const content = payload.content;
|
|
29
|
-
switch (payload.type) {
|
|
30
|
-
case PayloadBundle_1.PayloadBundleType.ASSET:
|
|
31
|
-
return { genericMessage: generateFileDataGenericMessage(payload, messageTimer), content };
|
|
32
|
-
case PayloadBundle_1.PayloadBundleType.ASSET_ABORT:
|
|
33
|
-
return { genericMessage: generateFileAbortGenericMessage(payload, messageTimer), content };
|
|
34
|
-
case PayloadBundle_1.PayloadBundleType.ASSET_META:
|
|
35
|
-
return { genericMessage: generateFileMetaDataGenericMessage(payload, messageTimer), content };
|
|
36
|
-
case PayloadBundle_1.PayloadBundleType.ASSET_IMAGE:
|
|
37
|
-
return generateImageGenericMessage(payload, messageTimer);
|
|
38
|
-
case PayloadBundle_1.PayloadBundleType.BUTTON_ACTION:
|
|
39
|
-
return { genericMessage: generateButtonActionGenericMessage(payload), content };
|
|
40
|
-
case PayloadBundle_1.PayloadBundleType.BUTTON_ACTION_CONFIRMATION:
|
|
41
|
-
return { genericMessage: generateButtonActionConfirmationGenericMessage(payload), content };
|
|
42
|
-
case PayloadBundle_1.PayloadBundleType.CALL:
|
|
43
|
-
return { genericMessage: generateCallGenericMessage(payload), content };
|
|
44
|
-
case PayloadBundle_1.PayloadBundleType.CLIENT_ACTION:
|
|
45
|
-
return { genericMessage: generateSessionResetGenericMessage(payload), content };
|
|
46
|
-
case PayloadBundle_1.PayloadBundleType.COMPOSITE:
|
|
47
|
-
return { genericMessage: generateCompositeGenericMessage(payload), content };
|
|
48
|
-
case PayloadBundle_1.PayloadBundleType.CONFIRMATION:
|
|
49
|
-
return { genericMessage: generateConfirmationGenericMessage(payload), content };
|
|
50
|
-
case PayloadBundle_1.PayloadBundleType.LOCATION:
|
|
51
|
-
return { genericMessage: generateLocationGenericMessage(payload, messageTimer), content };
|
|
52
|
-
case PayloadBundle_1.PayloadBundleType.MESSAGE_EDIT:
|
|
53
|
-
return { genericMessage: generateEditedTextGenericMessage(payload), content };
|
|
54
|
-
case PayloadBundle_1.PayloadBundleType.PING:
|
|
55
|
-
return { genericMessage: generatePingGenericMessage(payload, messageTimer), content };
|
|
56
|
-
case PayloadBundle_1.PayloadBundleType.REACTION:
|
|
57
|
-
return { genericMessage: generateReactionGenericMessage(payload), content };
|
|
58
|
-
case PayloadBundle_1.PayloadBundleType.TEXT:
|
|
59
|
-
return { genericMessage: generateTextGenericMessage(payload, messageTimer), content };
|
|
60
|
-
case PayloadBundle_1.PayloadBundleType.MESSAGE_DELETE:
|
|
61
|
-
return { genericMessage: generateDeleteMessage(payload), content };
|
|
62
|
-
case PayloadBundle_1.PayloadBundleType.MESSAGE_HIDE:
|
|
63
|
-
return { genericMessage: generateHideMessage(payload), content };
|
|
64
|
-
/**
|
|
65
|
-
* ToDo: Create Generic implementation for everything else
|
|
66
|
-
*/
|
|
67
|
-
default:
|
|
68
|
-
throw new Error(`No send method implemented for "${payload['type']}".`);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
exports.generateGenericMessage = generateGenericMessage;
|
|
72
|
-
function generateButtonActionGenericMessage(payloadBundle) {
|
|
73
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
74
|
-
[GenericMessageType_1.GenericMessageType.BUTTON_ACTION]: protocol_messaging_1.ButtonAction.create(payloadBundle.content),
|
|
75
|
-
messageId: payloadBundle.id,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
function generateButtonActionConfirmationGenericMessage(payloadBundle) {
|
|
79
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
80
|
-
[GenericMessageType_1.GenericMessageType.BUTTON_ACTION_CONFIRMATION]: protocol_messaging_1.ButtonActionConfirmation.create(payloadBundle.content),
|
|
81
|
-
messageId: payloadBundle.id,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
function generateCompositeGenericMessage(payloadBundle) {
|
|
85
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
86
|
-
[GenericMessageType_1.GenericMessageType.COMPOSITE]: protocol_messaging_1.Composite.create(payloadBundle.content),
|
|
87
|
-
messageId: payloadBundle.id,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function generateConfirmationGenericMessage(payloadBundle) {
|
|
91
|
-
const content = protocol_messaging_1.Confirmation.create(payloadBundle.content);
|
|
92
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
93
|
-
[GenericMessageType_1.GenericMessageType.CONFIRMATION]: content,
|
|
94
|
-
messageId: payloadBundle.id,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
function generateEditedTextGenericMessage(payloadBundle) {
|
|
98
|
-
const editedMessage = protocol_messaging_1.MessageEdit.create({
|
|
99
|
-
replacingMessageId: payloadBundle.content.originalMessageId,
|
|
100
|
-
text: MessageToProtoMapper_1.MessageToProtoMapper.mapText(payloadBundle),
|
|
101
|
-
});
|
|
102
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
103
|
-
[GenericMessageType_1.GenericMessageType.EDITED]: editedMessage,
|
|
104
|
-
messageId: payloadBundle.id,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
function generateFileDataGenericMessage(payloadBundle, messageTimer) {
|
|
108
|
-
if (!payloadBundle.content) {
|
|
109
|
-
throw new Error('No content for sendFileData provided.');
|
|
110
|
-
}
|
|
111
|
-
const { asset, expectsReadConfirmation, legalHoldStatus } = payloadBundle.content;
|
|
112
|
-
const remoteData = protocol_messaging_1.Asset.RemoteData.create({
|
|
113
|
-
assetId: asset.key,
|
|
114
|
-
assetToken: asset.token,
|
|
115
|
-
otrKey: asset.keyBytes,
|
|
116
|
-
sha256: asset.sha256,
|
|
117
|
-
assetDomain: asset.domain,
|
|
118
|
-
});
|
|
119
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
120
|
-
expectsReadConfirmation,
|
|
121
|
-
legalHoldStatus,
|
|
122
|
-
uploaded: remoteData,
|
|
123
|
-
});
|
|
124
|
-
assetMessage.status = AssetTransferState_1.AssetTransferState.UPLOADED;
|
|
125
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
126
|
-
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
127
|
-
messageId: payloadBundle.id,
|
|
128
|
-
});
|
|
129
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
130
|
-
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
131
|
-
}
|
|
132
|
-
function generateFileMetaDataGenericMessage(payloadBundle, messageTimer) {
|
|
133
|
-
if (!payloadBundle.content) {
|
|
134
|
-
throw new Error('No content for sendFileMetaData provided.');
|
|
135
|
-
}
|
|
136
|
-
const { expectsReadConfirmation, legalHoldStatus, metaData } = payloadBundle.content;
|
|
137
|
-
const original = protocol_messaging_1.Asset.Original.create({
|
|
138
|
-
audio: metaData.audio,
|
|
139
|
-
mimeType: metaData.type,
|
|
140
|
-
name: metaData.name,
|
|
141
|
-
size: metaData.length,
|
|
142
|
-
video: metaData.video,
|
|
143
|
-
image: metaData.image,
|
|
144
|
-
});
|
|
145
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
146
|
-
expectsReadConfirmation,
|
|
147
|
-
legalHoldStatus,
|
|
148
|
-
original,
|
|
149
|
-
});
|
|
150
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
151
|
-
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
152
|
-
messageId: payloadBundle.id,
|
|
153
|
-
});
|
|
154
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
155
|
-
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
156
|
-
}
|
|
157
|
-
function generateFileAbortGenericMessage(payloadBundle, messageTimer) {
|
|
158
|
-
if (!payloadBundle.content) {
|
|
159
|
-
throw new Error('No content for sendFileAbort provided.');
|
|
160
|
-
}
|
|
161
|
-
const { expectsReadConfirmation, legalHoldStatus, reason } = payloadBundle.content;
|
|
162
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
163
|
-
expectsReadConfirmation,
|
|
164
|
-
legalHoldStatus,
|
|
165
|
-
notUploaded: reason,
|
|
166
|
-
});
|
|
167
|
-
assetMessage.status = AssetTransferState_1.AssetTransferState.NOT_UPLOADED;
|
|
168
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
169
|
-
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
170
|
-
messageId: payloadBundle.id,
|
|
171
|
-
});
|
|
172
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
173
|
-
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
174
|
-
}
|
|
175
|
-
function generateImageGenericMessage(payloadBundle, messageTimer) {
|
|
176
|
-
const imageAsset = generateAsset(payloadBundle);
|
|
177
|
-
let genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
178
|
-
[GenericMessageType_1.GenericMessageType.ASSET]: imageAsset,
|
|
179
|
-
messageId: payloadBundle.id,
|
|
180
|
-
});
|
|
181
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
182
|
-
if (expireAfterMillis) {
|
|
183
|
-
genericMessage = createEphemeral(genericMessage, expireAfterMillis);
|
|
184
|
-
}
|
|
185
|
-
return { genericMessage, content: imageAsset };
|
|
186
|
-
}
|
|
187
|
-
function generateLocationGenericMessage(payloadBundle, messageTimer) {
|
|
188
|
-
const { expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom } = payloadBundle.content;
|
|
189
|
-
const locationMessage = protocol_messaging_1.Location.create({
|
|
190
|
-
expectsReadConfirmation,
|
|
191
|
-
latitude,
|
|
192
|
-
legalHoldStatus,
|
|
193
|
-
longitude,
|
|
194
|
-
name,
|
|
195
|
-
zoom,
|
|
196
|
-
});
|
|
197
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
198
|
-
[GenericMessageType_1.GenericMessageType.LOCATION]: locationMessage,
|
|
199
|
-
messageId: payloadBundle.id,
|
|
200
|
-
});
|
|
201
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
202
|
-
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
203
|
-
}
|
|
204
|
-
function generatePingGenericMessage(payloadBundle, messageTimer) {
|
|
205
|
-
const content = protocol_messaging_1.Knock.create(payloadBundle.content);
|
|
206
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
207
|
-
[GenericMessageType_1.GenericMessageType.KNOCK]: content,
|
|
208
|
-
messageId: payloadBundle.id,
|
|
209
|
-
});
|
|
210
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
211
|
-
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
212
|
-
}
|
|
213
|
-
function generateReactionGenericMessage(payloadBundle) {
|
|
214
|
-
const { legalHoldStatus, originalMessageId, type } = payloadBundle.content;
|
|
215
|
-
const reaction = protocol_messaging_1.Reaction.create({
|
|
216
|
-
emoji: type,
|
|
217
|
-
legalHoldStatus,
|
|
218
|
-
messageId: originalMessageId,
|
|
219
|
-
});
|
|
220
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
221
|
-
[GenericMessageType_1.GenericMessageType.REACTION]: reaction,
|
|
222
|
-
messageId: payloadBundle.id,
|
|
223
|
-
});
|
|
224
|
-
return genericMessage;
|
|
225
|
-
}
|
|
226
|
-
function generateSessionResetGenericMessage(payload) {
|
|
227
|
-
if (payload.content.clientAction !== protocol_messaging_1.ClientAction.RESET_SESSION) {
|
|
228
|
-
throw new Error(`No send method implemented for "${payload.type}" and ClientAction "${payload.content}".`);
|
|
229
|
-
}
|
|
230
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
231
|
-
[GenericMessageType_1.GenericMessageType.CLIENT_ACTION]: protocol_messaging_1.ClientAction.RESET_SESSION,
|
|
232
|
-
messageId: payload.id,
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
function generateCallGenericMessage(payloadBundle) {
|
|
236
|
-
const callMessage = protocol_messaging_1.Calling.create({
|
|
237
|
-
content: payloadBundle.content,
|
|
238
|
-
});
|
|
239
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
240
|
-
[GenericMessageType_1.GenericMessageType.CALLING]: callMessage,
|
|
241
|
-
messageId: payloadBundle.id,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
function generateDeleteMessage(payload) {
|
|
245
|
-
const content = protocol_messaging_1.MessageDelete.create({
|
|
246
|
-
messageId: payload.content.messageId,
|
|
247
|
-
});
|
|
248
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
249
|
-
[GenericMessageType_1.GenericMessageType.DELETED]: content,
|
|
250
|
-
messageId: payload.id,
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
function generateHideMessage(payload) {
|
|
254
|
-
const content = protocol_messaging_1.MessageHide.create({
|
|
255
|
-
messageId: payload.content.messageId,
|
|
256
|
-
conversationId: payload.content.conversationId,
|
|
257
|
-
});
|
|
258
|
-
return protocol_messaging_1.GenericMessage.create({
|
|
259
|
-
[GenericMessageType_1.GenericMessageType.HIDDEN]: content,
|
|
260
|
-
messageId: payload.id,
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function generateTextGenericMessage(payloadBundle, messageTimer) {
|
|
264
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
265
|
-
messageId: payloadBundle.id,
|
|
266
|
-
[GenericMessageType_1.GenericMessageType.TEXT]: MessageToProtoMapper_1.MessageToProtoMapper.mapText(payloadBundle),
|
|
267
|
-
});
|
|
268
|
-
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
269
|
-
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
270
|
-
}
|
|
271
|
-
function generateAsset(payloadBundle) {
|
|
272
|
-
if (!payloadBundle.content) {
|
|
273
|
-
throw new Error('No content for sendImage provided.');
|
|
274
|
-
}
|
|
275
|
-
const { asset, expectsReadConfirmation, image, legalHoldStatus } = payloadBundle.content;
|
|
276
|
-
const imageMetadata = protocol_messaging_1.Asset.ImageMetaData.create({
|
|
277
|
-
height: image.height,
|
|
278
|
-
width: image.width,
|
|
279
|
-
});
|
|
280
|
-
const original = protocol_messaging_1.Asset.Original.create({
|
|
281
|
-
[GenericMessageType_1.GenericMessageType.IMAGE]: imageMetadata,
|
|
282
|
-
mimeType: image.type,
|
|
283
|
-
name: null,
|
|
284
|
-
size: image.data.length,
|
|
285
|
-
});
|
|
286
|
-
const remoteData = protocol_messaging_1.Asset.RemoteData.create({
|
|
287
|
-
assetId: asset.key,
|
|
288
|
-
assetToken: asset.token,
|
|
289
|
-
assetDomain: asset.domain,
|
|
290
|
-
otrKey: asset.keyBytes,
|
|
291
|
-
sha256: asset.sha256,
|
|
292
|
-
});
|
|
293
|
-
const assetMessage = protocol_messaging_1.Asset.create({
|
|
294
|
-
expectsReadConfirmation,
|
|
295
|
-
legalHoldStatus,
|
|
296
|
-
original,
|
|
297
|
-
uploaded: remoteData,
|
|
298
|
-
});
|
|
299
|
-
assetMessage.status = AssetTransferState_1.AssetTransferState.UPLOADED;
|
|
300
|
-
return assetMessage;
|
|
301
|
-
}
|
|
302
|
-
function createEphemeral(originalGenericMessage, expireAfterMillis) {
|
|
303
|
-
const ephemeralMessage = protocol_messaging_1.Ephemeral.create({
|
|
304
|
-
expireAfterMillis,
|
|
305
|
-
[originalGenericMessage.content]: originalGenericMessage[originalGenericMessage.content],
|
|
306
|
-
});
|
|
307
|
-
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
308
|
-
[GenericMessageType_1.GenericMessageType.EPHEMERAL]: ephemeralMessage,
|
|
309
|
-
messageId: originalGenericMessage.messageId,
|
|
310
|
-
});
|
|
311
|
-
return genericMessage;
|
|
312
|
-
}
|
|
313
|
-
//# sourceMappingURL=messageGenerator.js.map
|