/
model-types.d.ts
462 lines (413 loc) · 13.2 KB
/
model-types.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
// Copyright 2020-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable max-classes-per-file */
import * as Backbone from 'backbone';
import type { GroupV2ChangeType } from './groups';
import type { BodyRangeType, BodyRangesType } from './types/Util';
import type { CallHistoryDetailsFromDiskType } from './types/Calling';
import type { CustomColorType, ConversationColorType } from './types/Colors';
import type { DeviceType } from './textsecure/Types.d';
import type { SendMessageChallengeData } from './textsecure/Errors';
import type { MessageModel } from './models/messages';
import type { ConversationModel } from './models/conversations';
import type { ProfileNameChangeType } from './util/getStringForProfileChange';
import type { CapabilitiesType } from './textsecure/WebAPI';
import type { ReadStatus } from './messages/MessageReadStatus';
import type { SendStateByConversationId } from './messages/MessageSendState';
import type { GroupNameCollisionsWithIdsByTitle } from './util/groupMemberNameCollisions';
import type { AttachmentDraftType, AttachmentType } from './types/Attachment';
import type { EmbeddedContactType } from './types/EmbeddedContact';
import { SignalService as Proto } from './protobuf';
import type { AvatarDataType } from './types/Avatar';
import type { UUIDStringType } from './types/UUID';
import type { ReactionSource } from './reactions/ReactionSource';
import type { SeenStatus } from './MessageSeenStatus';
import type { GiftBadgeStates } from './components/conversation/Message';
import type { LinkPreviewType } from './types/message/LinkPreviews';
import type { StickerType } from './types/Stickers';
import type { StorySendMode } from './types/Stories';
import type { MIMEType } from './types/MIME';
import AccessRequiredEnum = Proto.AccessControl.AccessRequired;
import MemberRoleEnum = Proto.Member.Role;
export type LastMessageStatus =
| 'paused'
| 'error'
| 'partial-sent'
| 'sending'
| 'sent'
| 'delivered'
| 'read'
| 'viewed';
export type SenderKeyInfoType = {
createdAtDate: number;
distributionId: string;
memberDevices: Array<DeviceType>;
};
export type CustomError = Error & {
identifier?: string;
number?: string;
data?: object;
retryAfter?: number;
};
export type GroupMigrationType = {
areWeInvited: boolean;
droppedMemberIds: Array<string>;
invitedMembers: Array<GroupV2PendingMemberType>;
};
export type QuotedAttachment = {
contentType: MIMEType;
fileName?: string;
thumbnail?: AttachmentType;
};
export type QuotedMessageType = {
// TODO DESKTOP-3826
// eslint-disable-next-line @typescript-eslint/no-explicit-any
attachments: Array<any>;
// `author` is an old attribute that holds the author's E164. We shouldn't use it for
// new messages, but old messages might have this attribute.
author?: string;
authorUuid?: string;
bodyRanges?: BodyRangesType;
id: number;
isGiftBadge?: boolean;
isViewOnce: boolean;
messageId: string;
referencedMessageNotFound: boolean;
text?: string;
};
type StoryReplyContextType = {
attachment?: AttachmentType;
authorUuid?: string;
messageId: string;
};
export type RetryOptions = Readonly<{
type: 'session-reset';
uuid: string;
e164: string;
now: number;
}>;
export type GroupV1Update = {
avatarUpdated?: boolean;
joined?: Array<string>;
left?: string | 'You';
name?: string;
};
export type MessageReactionType = {
emoji: undefined | string;
fromId: string;
targetAuthorUuid: string;
targetTimestamp: number;
timestamp: number;
isSentByConversationId?: Record<string, boolean>;
};
/* eslint-disable camelcase */
export type MessageAttributesType = {
bodyAttachment?: AttachmentType;
bodyRanges?: BodyRangesType;
callHistoryDetails?: CallHistoryDetailsFromDiskType;
canReplyToStory?: boolean;
changedId?: string;
dataMessage?: Uint8Array | null;
decrypted_at?: number;
deletedForEveryone?: boolean;
deletedForEveryoneTimestamp?: number;
errors?: Array<CustomError>;
expirationStartTimestamp?: number | null;
expireTimer?: number;
groupMigration?: GroupMigrationType;
group_update?: GroupV1Update;
hasAttachments?: boolean | 0 | 1;
hasFileAttachments?: boolean | 0 | 1;
hasVisualMediaAttachments?: boolean | 0 | 1;
isErased?: boolean;
isTapToViewInvalid?: boolean;
isViewOnce?: boolean;
key_changed?: string;
local?: boolean;
logger?: unknown;
message?: unknown;
messageTimer?: unknown;
profileChange?: ProfileNameChangeType;
quote?: QuotedMessageType;
reactions?: ReadonlyArray<MessageReactionType>;
requiredProtocolVersion?: number;
retryOptions?: RetryOptions;
sourceDevice?: number;
storyDistributionListId?: string;
storyId?: string;
storyReplyContext?: StoryReplyContextType;
supportedVersionAtReceive?: unknown;
synced?: boolean;
unidentifiedDeliveryReceived?: boolean;
verified?: boolean;
verifiedChanged?: string;
id: string;
type:
| 'call-history'
| 'chat-session-refreshed'
| 'delivery-issue'
| 'group'
| 'group-v1-migration'
| 'group-v2-change'
| 'incoming'
| 'keychange'
| 'outgoing'
| 'profile-change'
| 'story'
| 'timer-notification'
| 'universal-timer-notification'
| 'change-number-notification'
| 'verified-change';
body?: string;
attachments?: Array<AttachmentType>;
preview?: Array<LinkPreviewType>;
sticker?: StickerType;
sent_at: number;
unidentifiedDeliveries?: Array<string>;
contact?: Array<EmbeddedContactType>;
conversationId: string;
storyReaction?: {
emoji: string;
targetAuthorUuid: string;
targetTimestamp: number;
};
giftBadge?: {
expiration: number;
level: number;
id: string | undefined;
receiptCredentialPresentation: string;
state: GiftBadgeStates;
};
expirationTimerUpdate?: {
expireTimer: number;
fromSync?: unknown;
source?: string;
sourceUuid?: string;
};
// Legacy fields for timer update notification only
flags?: number;
groupV2Change?: GroupV2ChangeType;
// Required. Used to sort messages in the database for the conversation timeline.
received_at: number;
received_at_ms?: number;
// More of a legacy feature, needed as we were updating the schema of messages in the
// background, when we were still in IndexedDB, before attachments had gone to disk
// We set this so that the idle message upgrade process doesn't pick this message up
schemaVersion?: number;
// migrateMessageData will increment this field on every failure and give up
// when the value is too high.
schemaMigrationAttempts?: number;
// This should always be set for new messages, but older messages may not have them. We
// may not have these for outbound messages, either, as we have not needed them.
serverGuid?: string;
serverTimestamp?: number;
source?: string;
sourceUuid?: UUIDStringType;
timestamp: number;
// Backwards-compatibility with prerelease data schema
invitedGV2Members?: Array<GroupV2PendingMemberType>;
droppedGV2MemberIds?: Array<string>;
sendHQImages?: boolean;
// Should only be present for incoming messages and errors
readAt?: number;
readStatus?: ReadStatus;
// Used for all kinds of notifications, as well as incoming messages
seenStatus?: SeenStatus;
// Should only be present for outgoing messages
sendStateByConversationId?: SendStateByConversationId;
// Should only be present for messages deleted for everyone
deletedForEveryoneSendStatus?: Record<string, boolean>;
deletedForEveryoneFailed?: boolean;
};
/* eslint-enable camelcase */
export type ConversationAttributesTypeType = 'private' | 'group';
export type ConversationLastProfileType = Readonly<{
profileKey: string;
profileKeyVersion: string;
}>;
export type ValidateConversationType = Pick<
ConversationAttributesType,
'e164' | 'uuid' | 'type' | 'groupId'
>;
/* eslint-disable camelcase */
export type ConversationAttributesType = {
accessKey?: string | null;
addedBy?: string;
badges?: Array<
| { id: string }
| {
id: string;
expiresAt: number;
isVisible: boolean;
}
>;
capabilities?: CapabilitiesType;
color?: string;
conversationColor?: ConversationColorType;
customColor?: CustomColorType;
customColorId?: string;
discoveredUnregisteredAt?: number;
firstUnregisteredAt?: number;
draftChanged?: boolean;
draftAttachments?: Array<AttachmentDraftType>;
draftBodyRanges?: Array<BodyRangeType>;
draftTimestamp?: number | null;
hideStory?: boolean;
inbox_position?: number;
isPinned?: boolean;
lastMessageDeletedForEveryone?: boolean;
lastMessageStatus?: LastMessageStatus | null;
lastMessageAuthor?: string | null;
markedUnread?: boolean;
messageCount?: number;
messageCountBeforeMessageRequests?: number | null;
messageRequestResponseType?: number;
muteExpiresAt?: number;
dontNotifyForMentionsIfMuted?: boolean;
profileAvatar?: null | {
hash: string;
path: string;
};
profileKeyCredential?: string | null;
profileKeyCredentialExpiration?: number | null;
// TODO: DESKTOP-4223
pniCredential?: void;
lastProfile?: ConversationLastProfileType;
quotedMessageId?: string | null;
sealedSender?: unknown;
sentMessageCount?: number;
sharedGroupNames?: Array<string>;
voiceNotePlaybackRate?: number;
id: string;
type: ConversationAttributesTypeType;
timestamp?: number | null;
// Shared fields
active_at?: number | null;
draft?: string | null;
hasPostedStory?: boolean;
isArchived?: boolean;
lastMessage?: string | null;
name?: string;
systemGivenName?: string;
systemFamilyName?: string;
needsStorageServiceSync?: boolean;
needsVerification?: boolean;
profileSharing?: boolean;
storageID?: string;
storageVersion?: number;
storageUnknownFields?: string;
unreadCount?: number;
version: number;
// Private core info
uuid?: UUIDStringType;
pni?: UUIDStringType;
e164?: string;
// Private other fields
about?: string;
aboutEmoji?: string;
profileFamilyName?: string;
profileKey?: string;
profileName?: string;
verified?: number;
profileLastFetchedAt?: number;
pendingUniversalTimer?: string;
username?: string;
shareMyPhoneNumber?: boolean;
// Group-only
groupId?: string;
// A shorthand, representing whether the user is part of the group. Not strictly for
// when the user manually left the group. But historically, that was the only way
// to leave a group.
left?: boolean;
groupVersion?: number;
storySendMode?: StorySendMode;
// GroupV1 only
members?: Array<string>;
derivedGroupV2Id?: string;
// GroupV2 core info
masterKey?: string;
secretParams?: string;
publicParams?: string;
revision?: number;
senderKeyInfo?: SenderKeyInfoType;
// GroupV2 other fields
accessControl?: {
attributes: AccessRequiredEnum;
members: AccessRequiredEnum;
addFromInviteLink: AccessRequiredEnum;
};
announcementsOnly?: boolean;
avatar?: {
url: string;
path: string;
hash?: string;
} | null;
avatars?: Array<AvatarDataType>;
description?: string;
expireTimer?: number;
membersV2?: Array<GroupV2MemberType>;
pendingMembersV2?: Array<GroupV2PendingMemberType>;
pendingAdminApprovalV2?: Array<GroupV2PendingAdminApprovalType>;
bannedMembersV2?: Array<GroupV2BannedMemberType>;
groupInviteLinkPassword?: string;
previousGroupV1Id?: string;
previousGroupV1Members?: Array<string>;
acknowledgedGroupNameCollisions?: GroupNameCollisionsWithIdsByTitle;
// Used only when user is waiting for approval to join via link
isTemporary?: boolean;
temporaryMemberCount?: number;
// Avatars are blurred for some unapproved conversations, but users can manually unblur
// them. If the avatar was unblurred and then changed, we don't update this value so
// the new avatar gets blurred.
//
// This value is useless once the message request has been approved. We don't clean it
// up but could. We don't persist it but could (though we'd probably want to clean it
// up in that case).
unblurredAvatarPath?: string;
};
/* eslint-enable camelcase */
export type GroupV2MemberType = {
uuid: UUIDStringType;
role: MemberRoleEnum;
joinedAtVersion: number;
// Note that these are temporary flags, generated by applyGroupChange, but eliminated
// by applyGroupState. They are used to make our diff-generation more intelligent but
// not after that.
joinedFromLink?: boolean;
approvedByAdmin?: boolean;
};
export type GroupV2PendingMemberType = {
addedByUserId?: UUIDStringType;
uuid: UUIDStringType;
timestamp: number;
role: MemberRoleEnum;
};
export type GroupV2BannedMemberType = {
uuid: UUIDStringType;
timestamp: number;
};
export type GroupV2PendingAdminApprovalType = {
uuid: UUIDStringType;
timestamp: number;
};
export type VerificationOptions = {
key?: null | Uint8Array;
viaStorageServiceSync?: boolean;
};
export type ShallowChallengeError = CustomError & {
readonly retryAfter: number;
readonly data: SendMessageChallengeData;
};
export declare class ConversationModelCollectionType extends Backbone.Collection<ConversationModel> {
resetLookups(): void;
}
export declare class MessageModelCollectionType extends Backbone.Collection<MessageModel> {}
export type ReactionAttributesType = {
emoji: string;
remove?: boolean;
targetAuthorUuid: string;
targetTimestamp: number;
fromId: string;
timestamp: number;
source: ReactionSource;
};