@wireapp/core 17.30.0 → 17.31.0
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 +11 -0
- package/package.json +2 -2
- package/src/main/cryptography/GenericMessageMapper.d.ts +0 -1
- package/src/main/cryptography/GenericMessageMapper.js +23 -158
- package/src/main/cryptography/GenericMessageMapper.js.map +1 -1
- package/src/main/cryptography/GenericMessageMapper.ts +29 -119
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [17.31.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@17.30.0...@wireapp/core@17.31.0) (2021-11-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **core:** Add more qualifiedIds when mapping messages ([#4184](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4184)) ([c81741b](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/c81741b6d0159fba14a32089b9f4ba520d6f6623))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [17.30.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@17.29.0...@wireapp/core@17.30.0) (2021-11-25)
|
|
7
18
|
|
|
8
19
|
|
package/package.json
CHANGED
|
@@ -69,6 +69,6 @@
|
|
|
69
69
|
"test:project": "yarn dist && yarn test",
|
|
70
70
|
"test:node": "nyc jasmine --config=jasmine.json"
|
|
71
71
|
},
|
|
72
|
-
"version": "17.
|
|
73
|
-
"gitHead": "
|
|
72
|
+
"version": "17.31.0",
|
|
73
|
+
"gitHead": "441dffe8ac9469096533d601c74b50006fb9c16f"
|
|
74
74
|
}
|
|
@@ -2,6 +2,5 @@ import type { ConversationOtrMessageAddEvent } from '@wireapp/api-client/src/eve
|
|
|
2
2
|
import { PayloadBundle, PayloadBundleSource } from '../conversation';
|
|
3
3
|
export declare class GenericMessageMapper {
|
|
4
4
|
private static readonly logger;
|
|
5
|
-
private static mapButtonActionMessage;
|
|
6
5
|
static mapGenericMessage(genericMessage: any, event: ConversationOtrMessageAddEvent, source: PayloadBundleSource): PayloadBundle;
|
|
7
6
|
}
|
|
@@ -25,24 +25,21 @@ exports.GenericMessageMapper = void 0;
|
|
|
25
25
|
const logdown_1 = __importDefault(require("logdown"));
|
|
26
26
|
const conversation_1 = require("../conversation");
|
|
27
27
|
class GenericMessageMapper {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
// TODO: Turn "any" into a specific type (or collection of types) and make the return type more specific based on the
|
|
29
|
+
// "genericMessage" input parameter.
|
|
30
|
+
static mapGenericMessage(genericMessage, event, source) {
|
|
31
|
+
const baseMessage = {
|
|
32
32
|
conversation: event.conversation,
|
|
33
|
-
|
|
33
|
+
qualifiedConversation: event.qualified_conversation,
|
|
34
|
+
qualifiedFrom: event.qualified_from,
|
|
34
35
|
fromClientId: event.data.sender,
|
|
35
|
-
|
|
36
|
-
messageTimer: 0,
|
|
37
|
-
source,
|
|
36
|
+
from: event.from,
|
|
38
37
|
state: conversation_1.PayloadBundleState.INCOMING,
|
|
39
38
|
timestamp: new Date(event.time).getTime(),
|
|
40
|
-
|
|
39
|
+
id: genericMessage.messageId,
|
|
40
|
+
messageTimer: 0,
|
|
41
|
+
source,
|
|
41
42
|
};
|
|
42
|
-
}
|
|
43
|
-
// TODO: Turn "any" into a specific type (or collection of types) and make the return type more specific based on the
|
|
44
|
-
// "genericMessage" input parameter.
|
|
45
|
-
static mapGenericMessage(genericMessage, event, source) {
|
|
46
43
|
switch (genericMessage.content) {
|
|
47
44
|
case conversation_1.GenericMessageType.TEXT: {
|
|
48
45
|
const { content: text, expectsReadConfirmation, legalHoldStatus, linkPreview: linkPreviews, mentions, quote, } = genericMessage[conversation_1.GenericMessageType.TEXT];
|
|
@@ -59,82 +56,27 @@ class GenericMessageMapper {
|
|
|
59
56
|
if (typeof legalHoldStatus !== 'undefined') {
|
|
60
57
|
content.legalHoldStatus = legalHoldStatus;
|
|
61
58
|
}
|
|
62
|
-
return {
|
|
63
|
-
content,
|
|
64
|
-
conversation: event.conversation,
|
|
65
|
-
from: event.from,
|
|
66
|
-
fromClientId: event.data.sender,
|
|
67
|
-
id: genericMessage.messageId,
|
|
68
|
-
messageTimer: 0,
|
|
69
|
-
source,
|
|
70
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
71
|
-
timestamp: new Date(event.time).getTime(),
|
|
72
|
-
type: conversation_1.PayloadBundleType.TEXT,
|
|
73
|
-
};
|
|
59
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.TEXT });
|
|
74
60
|
}
|
|
75
61
|
case conversation_1.GenericMessageType.BUTTON_ACTION: {
|
|
76
|
-
return
|
|
62
|
+
return Object.assign(Object.assign({}, baseMessage), { content: genericMessage.buttonAction, type: conversation_1.PayloadBundleType.BUTTON_ACTION });
|
|
77
63
|
}
|
|
78
64
|
case conversation_1.GenericMessageType.CALLING: {
|
|
79
|
-
return {
|
|
80
|
-
content: genericMessage.calling.content,
|
|
81
|
-
conversation: event.conversation,
|
|
82
|
-
from: event.from,
|
|
83
|
-
fromClientId: event.data.sender,
|
|
84
|
-
id: genericMessage.messageId,
|
|
85
|
-
messageTimer: 0,
|
|
86
|
-
source,
|
|
87
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
88
|
-
timestamp: new Date(event.time).getTime(),
|
|
89
|
-
type: conversation_1.PayloadBundleType.CALL,
|
|
90
|
-
};
|
|
65
|
+
return Object.assign(Object.assign({}, baseMessage), { content: genericMessage.calling.content, type: conversation_1.PayloadBundleType.CALL });
|
|
91
66
|
}
|
|
92
67
|
case conversation_1.GenericMessageType.CONFIRMATION: {
|
|
93
68
|
const { firstMessageId, moreMessageIds, type } = genericMessage[conversation_1.GenericMessageType.CONFIRMATION];
|
|
94
69
|
const content = { firstMessageId, moreMessageIds, type };
|
|
95
|
-
return {
|
|
96
|
-
content,
|
|
97
|
-
conversation: event.conversation,
|
|
98
|
-
from: event.from,
|
|
99
|
-
fromClientId: event.data.sender,
|
|
100
|
-
id: genericMessage.messageId,
|
|
101
|
-
messageTimer: 0,
|
|
102
|
-
source,
|
|
103
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
104
|
-
timestamp: new Date(event.time).getTime(),
|
|
105
|
-
type: conversation_1.PayloadBundleType.CONFIRMATION,
|
|
106
|
-
};
|
|
70
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.CONFIRMATION });
|
|
107
71
|
}
|
|
108
72
|
case conversation_1.GenericMessageType.CLEARED: {
|
|
109
73
|
const content = genericMessage[conversation_1.GenericMessageType.CLEARED];
|
|
110
|
-
return {
|
|
111
|
-
content,
|
|
112
|
-
conversation: event.conversation,
|
|
113
|
-
from: event.from,
|
|
114
|
-
fromClientId: event.data.sender,
|
|
115
|
-
id: genericMessage.messageId,
|
|
116
|
-
messageTimer: 0,
|
|
117
|
-
source,
|
|
118
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
119
|
-
timestamp: new Date(event.time).getTime(),
|
|
120
|
-
type: conversation_1.PayloadBundleType.CONVERSATION_CLEAR,
|
|
121
|
-
};
|
|
74
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.CONVERSATION_CLEAR });
|
|
122
75
|
}
|
|
123
76
|
case conversation_1.GenericMessageType.DELETED: {
|
|
124
77
|
const originalMessageId = genericMessage[conversation_1.GenericMessageType.DELETED].messageId;
|
|
125
78
|
const content = { messageId: originalMessageId };
|
|
126
|
-
return {
|
|
127
|
-
content,
|
|
128
|
-
conversation: event.conversation,
|
|
129
|
-
from: event.from,
|
|
130
|
-
fromClientId: event.data.sender,
|
|
131
|
-
id: genericMessage.messageId,
|
|
132
|
-
messageTimer: 0,
|
|
133
|
-
source,
|
|
134
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
135
|
-
timestamp: new Date(event.time).getTime(),
|
|
136
|
-
type: conversation_1.PayloadBundleType.MESSAGE_DELETE,
|
|
137
|
-
};
|
|
79
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.MESSAGE_DELETE });
|
|
138
80
|
}
|
|
139
81
|
case conversation_1.GenericMessageType.EDITED: {
|
|
140
82
|
const { expectsReadConfirmation, text: { content: editedText, legalHoldStatus, linkPreview: editedLinkPreviews, mentions: editedMentions, quote: editedQuote, }, replacingMessageId, } = genericMessage[conversation_1.GenericMessageType.EDITED];
|
|
@@ -153,18 +95,7 @@ class GenericMessageMapper {
|
|
|
153
95
|
if (editedQuote) {
|
|
154
96
|
content.quote = editedQuote;
|
|
155
97
|
}
|
|
156
|
-
return {
|
|
157
|
-
content,
|
|
158
|
-
conversation: event.conversation,
|
|
159
|
-
from: event.from,
|
|
160
|
-
fromClientId: event.data.sender,
|
|
161
|
-
id: genericMessage.messageId,
|
|
162
|
-
messageTimer: 0,
|
|
163
|
-
source,
|
|
164
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
165
|
-
timestamp: new Date(event.time).getTime(),
|
|
166
|
-
type: conversation_1.PayloadBundleType.MESSAGE_EDIT,
|
|
167
|
-
};
|
|
98
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.MESSAGE_EDIT });
|
|
168
99
|
}
|
|
169
100
|
case conversation_1.GenericMessageType.HIDDEN: {
|
|
170
101
|
const { conversationId, messageId } = genericMessage[conversation_1.GenericMessageType.HIDDEN];
|
|
@@ -172,34 +103,12 @@ class GenericMessageMapper {
|
|
|
172
103
|
conversationId,
|
|
173
104
|
messageId,
|
|
174
105
|
};
|
|
175
|
-
return {
|
|
176
|
-
content,
|
|
177
|
-
conversation: event.conversation,
|
|
178
|
-
from: event.from,
|
|
179
|
-
fromClientId: event.data.sender,
|
|
180
|
-
id: genericMessage.messageId,
|
|
181
|
-
messageTimer: 0,
|
|
182
|
-
source,
|
|
183
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
184
|
-
timestamp: new Date(event.time).getTime(),
|
|
185
|
-
type: conversation_1.PayloadBundleType.MESSAGE_HIDE,
|
|
186
|
-
};
|
|
106
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.MESSAGE_HIDE });
|
|
187
107
|
}
|
|
188
108
|
case conversation_1.GenericMessageType.KNOCK: {
|
|
189
109
|
const { expectsReadConfirmation, legalHoldStatus } = genericMessage[conversation_1.GenericMessageType.KNOCK];
|
|
190
110
|
const content = { expectsReadConfirmation, hotKnock: false, legalHoldStatus };
|
|
191
|
-
return {
|
|
192
|
-
content,
|
|
193
|
-
conversation: event.conversation,
|
|
194
|
-
from: event.from,
|
|
195
|
-
fromClientId: event.data.sender,
|
|
196
|
-
id: genericMessage.messageId,
|
|
197
|
-
messageTimer: 0,
|
|
198
|
-
source,
|
|
199
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
200
|
-
timestamp: new Date(event.time).getTime(),
|
|
201
|
-
type: conversation_1.PayloadBundleType.PING,
|
|
202
|
-
};
|
|
111
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.PING });
|
|
203
112
|
}
|
|
204
113
|
case conversation_1.GenericMessageType.LOCATION: {
|
|
205
114
|
const { expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom } = genericMessage[conversation_1.GenericMessageType.LOCATION];
|
|
@@ -211,18 +120,7 @@ class GenericMessageMapper {
|
|
|
211
120
|
name,
|
|
212
121
|
zoom,
|
|
213
122
|
};
|
|
214
|
-
return {
|
|
215
|
-
content,
|
|
216
|
-
conversation: event.conversation,
|
|
217
|
-
from: event.from,
|
|
218
|
-
fromClientId: event.data.sender,
|
|
219
|
-
id: genericMessage.messageId,
|
|
220
|
-
messageTimer: 0,
|
|
221
|
-
source,
|
|
222
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
223
|
-
timestamp: new Date(event.time).getTime(),
|
|
224
|
-
type: conversation_1.PayloadBundleType.LOCATION,
|
|
225
|
-
};
|
|
123
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.LOCATION });
|
|
226
124
|
}
|
|
227
125
|
case conversation_1.GenericMessageType.ASSET: {
|
|
228
126
|
const { expectsReadConfirmation, legalHoldStatus, notUploaded, original, preview, status, uploaded } = genericMessage[conversation_1.GenericMessageType.ASSET];
|
|
@@ -236,18 +134,7 @@ class GenericMessageMapper {
|
|
|
236
134
|
status,
|
|
237
135
|
uploaded,
|
|
238
136
|
};
|
|
239
|
-
return {
|
|
240
|
-
content,
|
|
241
|
-
conversation: event.conversation,
|
|
242
|
-
from: event.from,
|
|
243
|
-
fromClientId: event.data.sender,
|
|
244
|
-
id: genericMessage.messageId,
|
|
245
|
-
messageTimer: 0,
|
|
246
|
-
source,
|
|
247
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
248
|
-
timestamp: new Date(event.time).getTime(),
|
|
249
|
-
type: isImage ? conversation_1.PayloadBundleType.ASSET_IMAGE : conversation_1.PayloadBundleType.ASSET,
|
|
250
|
-
};
|
|
137
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: isImage ? conversation_1.PayloadBundleType.ASSET_IMAGE : conversation_1.PayloadBundleType.ASSET });
|
|
251
138
|
}
|
|
252
139
|
case conversation_1.GenericMessageType.REACTION: {
|
|
253
140
|
const { emoji, legalHoldStatus, messageId } = genericMessage[conversation_1.GenericMessageType.REACTION];
|
|
@@ -256,33 +143,11 @@ class GenericMessageMapper {
|
|
|
256
143
|
originalMessageId: messageId,
|
|
257
144
|
type: emoji,
|
|
258
145
|
};
|
|
259
|
-
return {
|
|
260
|
-
content,
|
|
261
|
-
conversation: event.conversation,
|
|
262
|
-
from: event.from,
|
|
263
|
-
fromClientId: event.data.sender,
|
|
264
|
-
id: genericMessage.messageId,
|
|
265
|
-
messageTimer: 0,
|
|
266
|
-
source,
|
|
267
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
268
|
-
timestamp: new Date(event.time).getTime(),
|
|
269
|
-
type: conversation_1.PayloadBundleType.REACTION,
|
|
270
|
-
};
|
|
146
|
+
return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.REACTION });
|
|
271
147
|
}
|
|
272
148
|
default: {
|
|
273
149
|
this.logger.warn(`Unhandled event type "${genericMessage.content}": ${JSON.stringify(genericMessage)}`);
|
|
274
|
-
return {
|
|
275
|
-
content: genericMessage.content,
|
|
276
|
-
conversation: event.conversation,
|
|
277
|
-
from: event.from,
|
|
278
|
-
fromClientId: event.data.sender,
|
|
279
|
-
id: genericMessage.messageId,
|
|
280
|
-
messageTimer: 0,
|
|
281
|
-
source,
|
|
282
|
-
state: conversation_1.PayloadBundleState.INCOMING,
|
|
283
|
-
timestamp: new Date(event.time).getTime(),
|
|
284
|
-
type: conversation_1.PayloadBundleType.UNKNOWN,
|
|
285
|
-
};
|
|
150
|
+
return Object.assign(Object.assign({}, baseMessage), { content: genericMessage.content, type: conversation_1.PayloadBundleType.UNKNOWN });
|
|
286
151
|
}
|
|
287
152
|
}
|
|
288
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericMessageMapper.js","sourceRoot":"","sources":["GenericMessageMapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;
|
|
1
|
+
{"version":3,"file":"GenericMessageMapper.js","sourceRoot":"","sources":["GenericMessageMapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;AAGH,sDAA8B;AAC9B,kDAMyB;AAczB,MAAa,oBAAoB;IAM/B,qHAAqH;IACrH,oCAAoC;IAC7B,MAAM,CAAC,iBAAiB,CAC7B,cAAmB,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AAC,QAAQ,CAAC,CAAC;gBAExF,MAAM,OAAO,GAAoB;oBAC/B,eAAe;oBACf,iBAAiB,EAAE,SAAS;oBAC5B,IAAI,EAAE,KAAK;iBACZ,CAAC;gBAEF,uCACK,WAAW,KACd,OAAO,EACP,IAAI,EAAE,gCAAiB,CAAC,QAAQ,IAChC;aACH;YACD,OAAO,CAAC,CAAC;gBACP,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,cAAc,CAAC,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBACxG,uCACK,WAAW,KACd,OAAO,EAAE,cAAc,CAAC,OAAO,EAC/B,IAAI,EAAE,gCAAiB,CAAC,OAAO,IAC/B;aACH;SACF;IACH,CAAC;;AAvOH,oDAwOC;AAvOyB,2BAAM,GAAG,IAAA,iBAAO,EAAC,iDAAiD,EAAE;IAC1F,MAAM,EAAE,OAAO;IACf,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC"}
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import type {ConversationOtrMessageAddEvent} from '@wireapp/api-client/src/event/';
|
|
21
|
-
import type {GenericMessage} from '@wireapp/protocol-messaging';
|
|
22
21
|
import logdown from 'logdown';
|
|
23
22
|
import {
|
|
24
23
|
GenericMessageType,
|
|
@@ -39,7 +38,6 @@ import type {
|
|
|
39
38
|
ReactionContent,
|
|
40
39
|
TextContent,
|
|
41
40
|
} from '../conversation/content';
|
|
42
|
-
import type {ButtonActionMessage} from '../conversation/message/OtrMessage';
|
|
43
41
|
|
|
44
42
|
export class GenericMessageMapper {
|
|
45
43
|
private static readonly logger = logdown('@wireapp/core/cryptography/GenericMessageMapper', {
|
|
@@ -47,26 +45,6 @@ export class GenericMessageMapper {
|
|
|
47
45
|
markdown: false,
|
|
48
46
|
});
|
|
49
47
|
|
|
50
|
-
private static mapButtonActionMessage(
|
|
51
|
-
genericMessage: GenericMessage,
|
|
52
|
-
event: ConversationOtrMessageAddEvent,
|
|
53
|
-
source: PayloadBundleSource,
|
|
54
|
-
): ButtonActionMessage {
|
|
55
|
-
const {buttonAction, messageId} = genericMessage;
|
|
56
|
-
return {
|
|
57
|
-
content: buttonAction!,
|
|
58
|
-
conversation: event.conversation,
|
|
59
|
-
from: event.from,
|
|
60
|
-
fromClientId: event.data.sender,
|
|
61
|
-
id: messageId,
|
|
62
|
-
messageTimer: 0,
|
|
63
|
-
source,
|
|
64
|
-
state: PayloadBundleState.INCOMING,
|
|
65
|
-
timestamp: new Date(event.time).getTime(),
|
|
66
|
-
type: PayloadBundleType.BUTTON_ACTION,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
48
|
// TODO: Turn "any" into a specific type (or collection of types) and make the return type more specific based on the
|
|
71
49
|
// "genericMessage" input parameter.
|
|
72
50
|
public static mapGenericMessage(
|
|
@@ -74,6 +52,18 @@ export class GenericMessageMapper {
|
|
|
74
52
|
event: ConversationOtrMessageAddEvent,
|
|
75
53
|
source: PayloadBundleSource,
|
|
76
54
|
): PayloadBundle {
|
|
55
|
+
const baseMessage: Omit<PayloadBundle, 'content' | 'type'> = {
|
|
56
|
+
conversation: event.conversation,
|
|
57
|
+
qualifiedConversation: event.qualified_conversation,
|
|
58
|
+
qualifiedFrom: event.qualified_from,
|
|
59
|
+
fromClientId: event.data.sender,
|
|
60
|
+
from: event.from,
|
|
61
|
+
state: PayloadBundleState.INCOMING,
|
|
62
|
+
timestamp: new Date(event.time).getTime(),
|
|
63
|
+
id: genericMessage.messageId,
|
|
64
|
+
messageTimer: 0,
|
|
65
|
+
source,
|
|
66
|
+
};
|
|
77
67
|
switch (genericMessage.content) {
|
|
78
68
|
case GenericMessageType.TEXT: {
|
|
79
69
|
const {
|
|
@@ -104,32 +94,22 @@ export class GenericMessageMapper {
|
|
|
104
94
|
}
|
|
105
95
|
|
|
106
96
|
return {
|
|
97
|
+
...baseMessage,
|
|
107
98
|
content,
|
|
108
|
-
conversation: event.conversation,
|
|
109
|
-
from: event.from,
|
|
110
|
-
fromClientId: event.data.sender,
|
|
111
|
-
id: genericMessage.messageId,
|
|
112
|
-
messageTimer: 0,
|
|
113
|
-
source,
|
|
114
|
-
state: PayloadBundleState.INCOMING,
|
|
115
|
-
timestamp: new Date(event.time).getTime(),
|
|
116
99
|
type: PayloadBundleType.TEXT,
|
|
117
100
|
};
|
|
118
101
|
}
|
|
119
102
|
case GenericMessageType.BUTTON_ACTION: {
|
|
120
|
-
return
|
|
103
|
+
return {
|
|
104
|
+
...baseMessage,
|
|
105
|
+
content: genericMessage.buttonAction!,
|
|
106
|
+
type: PayloadBundleType.BUTTON_ACTION,
|
|
107
|
+
};
|
|
121
108
|
}
|
|
122
109
|
case GenericMessageType.CALLING: {
|
|
123
110
|
return {
|
|
111
|
+
...baseMessage,
|
|
124
112
|
content: genericMessage.calling.content,
|
|
125
|
-
conversation: event.conversation,
|
|
126
|
-
from: event.from,
|
|
127
|
-
fromClientId: event.data.sender,
|
|
128
|
-
id: genericMessage.messageId,
|
|
129
|
-
messageTimer: 0,
|
|
130
|
-
source,
|
|
131
|
-
state: PayloadBundleState.INCOMING,
|
|
132
|
-
timestamp: new Date(event.time).getTime(),
|
|
133
113
|
type: PayloadBundleType.CALL,
|
|
134
114
|
};
|
|
135
115
|
}
|
|
@@ -139,15 +119,8 @@ export class GenericMessageMapper {
|
|
|
139
119
|
const content: ConfirmationContent = {firstMessageId, moreMessageIds, type};
|
|
140
120
|
|
|
141
121
|
return {
|
|
122
|
+
...baseMessage,
|
|
142
123
|
content,
|
|
143
|
-
conversation: event.conversation,
|
|
144
|
-
from: event.from,
|
|
145
|
-
fromClientId: event.data.sender,
|
|
146
|
-
id: genericMessage.messageId,
|
|
147
|
-
messageTimer: 0,
|
|
148
|
-
source,
|
|
149
|
-
state: PayloadBundleState.INCOMING,
|
|
150
|
-
timestamp: new Date(event.time).getTime(),
|
|
151
124
|
type: PayloadBundleType.CONFIRMATION,
|
|
152
125
|
};
|
|
153
126
|
}
|
|
@@ -155,15 +128,8 @@ export class GenericMessageMapper {
|
|
|
155
128
|
const content: ClearedContent = genericMessage[GenericMessageType.CLEARED];
|
|
156
129
|
|
|
157
130
|
return {
|
|
131
|
+
...baseMessage,
|
|
158
132
|
content,
|
|
159
|
-
conversation: event.conversation,
|
|
160
|
-
from: event.from,
|
|
161
|
-
fromClientId: event.data.sender,
|
|
162
|
-
id: genericMessage.messageId,
|
|
163
|
-
messageTimer: 0,
|
|
164
|
-
source,
|
|
165
|
-
state: PayloadBundleState.INCOMING,
|
|
166
|
-
timestamp: new Date(event.time).getTime(),
|
|
167
133
|
type: PayloadBundleType.CONVERSATION_CLEAR,
|
|
168
134
|
};
|
|
169
135
|
}
|
|
@@ -173,15 +139,8 @@ export class GenericMessageMapper {
|
|
|
173
139
|
const content: DeletedContent = {messageId: originalMessageId};
|
|
174
140
|
|
|
175
141
|
return {
|
|
142
|
+
...baseMessage,
|
|
176
143
|
content,
|
|
177
|
-
conversation: event.conversation,
|
|
178
|
-
from: event.from,
|
|
179
|
-
fromClientId: event.data.sender,
|
|
180
|
-
id: genericMessage.messageId,
|
|
181
|
-
messageTimer: 0,
|
|
182
|
-
source,
|
|
183
|
-
state: PayloadBundleState.INCOMING,
|
|
184
|
-
timestamp: new Date(event.time).getTime(),
|
|
185
144
|
type: PayloadBundleType.MESSAGE_DELETE,
|
|
186
145
|
};
|
|
187
146
|
}
|
|
@@ -218,15 +177,8 @@ export class GenericMessageMapper {
|
|
|
218
177
|
}
|
|
219
178
|
|
|
220
179
|
return {
|
|
180
|
+
...baseMessage,
|
|
221
181
|
content,
|
|
222
|
-
conversation: event.conversation,
|
|
223
|
-
from: event.from,
|
|
224
|
-
fromClientId: event.data.sender,
|
|
225
|
-
id: genericMessage.messageId,
|
|
226
|
-
messageTimer: 0,
|
|
227
|
-
source,
|
|
228
|
-
state: PayloadBundleState.INCOMING,
|
|
229
|
-
timestamp: new Date(event.time).getTime(),
|
|
230
182
|
type: PayloadBundleType.MESSAGE_EDIT,
|
|
231
183
|
};
|
|
232
184
|
}
|
|
@@ -239,15 +191,8 @@ export class GenericMessageMapper {
|
|
|
239
191
|
};
|
|
240
192
|
|
|
241
193
|
return {
|
|
194
|
+
...baseMessage,
|
|
242
195
|
content,
|
|
243
|
-
conversation: event.conversation,
|
|
244
|
-
from: event.from,
|
|
245
|
-
fromClientId: event.data.sender,
|
|
246
|
-
id: genericMessage.messageId,
|
|
247
|
-
messageTimer: 0,
|
|
248
|
-
source,
|
|
249
|
-
state: PayloadBundleState.INCOMING,
|
|
250
|
-
timestamp: new Date(event.time).getTime(),
|
|
251
196
|
type: PayloadBundleType.MESSAGE_HIDE,
|
|
252
197
|
};
|
|
253
198
|
}
|
|
@@ -256,15 +201,8 @@ export class GenericMessageMapper {
|
|
|
256
201
|
const content: KnockContent = {expectsReadConfirmation, hotKnock: false, legalHoldStatus};
|
|
257
202
|
|
|
258
203
|
return {
|
|
204
|
+
...baseMessage,
|
|
259
205
|
content,
|
|
260
|
-
conversation: event.conversation,
|
|
261
|
-
from: event.from,
|
|
262
|
-
fromClientId: event.data.sender,
|
|
263
|
-
id: genericMessage.messageId,
|
|
264
|
-
messageTimer: 0,
|
|
265
|
-
source,
|
|
266
|
-
state: PayloadBundleState.INCOMING,
|
|
267
|
-
timestamp: new Date(event.time).getTime(),
|
|
268
206
|
type: PayloadBundleType.PING,
|
|
269
207
|
};
|
|
270
208
|
}
|
|
@@ -282,15 +220,8 @@ export class GenericMessageMapper {
|
|
|
282
220
|
};
|
|
283
221
|
|
|
284
222
|
return {
|
|
223
|
+
...baseMessage,
|
|
285
224
|
content,
|
|
286
|
-
conversation: event.conversation,
|
|
287
|
-
from: event.from,
|
|
288
|
-
fromClientId: event.data.sender,
|
|
289
|
-
id: genericMessage.messageId,
|
|
290
|
-
messageTimer: 0,
|
|
291
|
-
source,
|
|
292
|
-
state: PayloadBundleState.INCOMING,
|
|
293
|
-
timestamp: new Date(event.time).getTime(),
|
|
294
225
|
type: PayloadBundleType.LOCATION,
|
|
295
226
|
};
|
|
296
227
|
}
|
|
@@ -310,15 +241,8 @@ export class GenericMessageMapper {
|
|
|
310
241
|
};
|
|
311
242
|
|
|
312
243
|
return {
|
|
244
|
+
...baseMessage,
|
|
313
245
|
content,
|
|
314
|
-
conversation: event.conversation,
|
|
315
|
-
from: event.from,
|
|
316
|
-
fromClientId: event.data.sender,
|
|
317
|
-
id: genericMessage.messageId,
|
|
318
|
-
messageTimer: 0,
|
|
319
|
-
source,
|
|
320
|
-
state: PayloadBundleState.INCOMING,
|
|
321
|
-
timestamp: new Date(event.time).getTime(),
|
|
322
246
|
type: isImage ? PayloadBundleType.ASSET_IMAGE : PayloadBundleType.ASSET,
|
|
323
247
|
};
|
|
324
248
|
}
|
|
@@ -332,30 +256,16 @@ export class GenericMessageMapper {
|
|
|
332
256
|
};
|
|
333
257
|
|
|
334
258
|
return {
|
|
259
|
+
...baseMessage,
|
|
335
260
|
content,
|
|
336
|
-
conversation: event.conversation,
|
|
337
|
-
from: event.from,
|
|
338
|
-
fromClientId: event.data.sender,
|
|
339
|
-
id: genericMessage.messageId,
|
|
340
|
-
messageTimer: 0,
|
|
341
|
-
source,
|
|
342
|
-
state: PayloadBundleState.INCOMING,
|
|
343
|
-
timestamp: new Date(event.time).getTime(),
|
|
344
261
|
type: PayloadBundleType.REACTION,
|
|
345
262
|
};
|
|
346
263
|
}
|
|
347
264
|
default: {
|
|
348
265
|
this.logger.warn(`Unhandled event type "${genericMessage.content}": ${JSON.stringify(genericMessage)}`);
|
|
349
266
|
return {
|
|
267
|
+
...baseMessage,
|
|
350
268
|
content: genericMessage.content,
|
|
351
|
-
conversation: event.conversation,
|
|
352
|
-
from: event.from,
|
|
353
|
-
fromClientId: event.data.sender,
|
|
354
|
-
id: genericMessage.messageId,
|
|
355
|
-
messageTimer: 0,
|
|
356
|
-
source,
|
|
357
|
-
state: PayloadBundleState.INCOMING,
|
|
358
|
-
timestamp: new Date(event.time).getTime(),
|
|
359
269
|
type: PayloadBundleType.UNKNOWN,
|
|
360
270
|
};
|
|
361
271
|
}
|