2021-01-04 19:46:24 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-07-27 18:15:32 +00:00
|
|
|
import * as Backbone from 'backbone';
|
2020-07-10 18:28:49 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
import { GroupV2ChangeType } from './groups';
|
2020-11-03 01:19:52 +00:00
|
|
|
import { LocalizerType, BodyRangeType, BodyRangesType } from './types/Util';
|
2020-12-07 20:43:19 +00:00
|
|
|
import { CallHistoryDetailsFromDiskType } from './types/Calling';
|
2020-08-13 20:53:45 +00:00
|
|
|
import { ColorType } from './types/Colors';
|
2020-09-24 20:57:54 +00:00
|
|
|
import {
|
|
|
|
ConversationType,
|
|
|
|
MessageType,
|
|
|
|
LastMessageStatus,
|
|
|
|
} from './state/ducks/conversations';
|
2020-07-10 18:28:49 +00:00
|
|
|
import { SendOptionsType } from './textsecure/SendMessage';
|
2020-12-01 23:45:39 +00:00
|
|
|
import {
|
|
|
|
AccessRequiredEnum,
|
|
|
|
MemberRoleEnum,
|
|
|
|
SyncMessageClass,
|
|
|
|
} from './textsecure.d';
|
2020-09-24 20:57:54 +00:00
|
|
|
import { UserMessage } from './types/Message';
|
|
|
|
import { MessageModel } from './models/messages';
|
|
|
|
import { ConversationModel } from './models/conversations';
|
|
|
|
import { ProfileNameChangeType } from './util/getStringForProfileChange';
|
2020-11-20 17:30:45 +00:00
|
|
|
import { CapabilitiesType } from './textsecure/WebAPI';
|
2020-07-27 18:15:32 +00:00
|
|
|
|
2020-09-24 20:57:54 +00:00
|
|
|
export type WhatIsThis = any;
|
|
|
|
|
2020-07-27 18:15:32 +00:00
|
|
|
type DeletesAttributesType = {
|
|
|
|
fromId: string;
|
|
|
|
serverTimestamp: number;
|
|
|
|
targetSentTimestamp: number;
|
|
|
|
};
|
|
|
|
|
2020-09-14 21:56:35 +00:00
|
|
|
export declare class DeletesModelType extends Backbone.Model<
|
|
|
|
DeletesAttributesType
|
|
|
|
> {
|
2020-09-24 20:57:54 +00:00
|
|
|
forMessage(message: MessageModel): Array<DeletesModelType>;
|
2020-07-27 18:15:32 +00:00
|
|
|
onDelete(doe: DeletesAttributesType): Promise<void>;
|
|
|
|
}
|
|
|
|
|
|
|
|
type TaskResultType = any;
|
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
export type CustomError = Error & {
|
2020-09-24 20:57:54 +00:00
|
|
|
identifier?: string;
|
|
|
|
number?: string;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2020-09-24 20:57:54 +00:00
|
|
|
|
2020-12-01 23:45:39 +00:00
|
|
|
export type GroupMigrationType = {
|
|
|
|
areWeInvited: boolean;
|
|
|
|
droppedMemberIds: Array<string>;
|
|
|
|
invitedMembers: Array<GroupV2PendingMemberType>;
|
|
|
|
};
|
|
|
|
|
2020-09-11 19:37:01 +00:00
|
|
|
export type MessageAttributesType = {
|
2020-09-24 20:57:54 +00:00
|
|
|
bodyPending: boolean;
|
|
|
|
bodyRanges: BodyRangesType;
|
2020-12-07 20:43:19 +00:00
|
|
|
callHistoryDetails: CallHistoryDetailsFromDiskType;
|
2020-09-24 20:57:54 +00:00
|
|
|
changedId: string;
|
|
|
|
dataMessage: ArrayBuffer | null;
|
|
|
|
decrypted_at: number;
|
|
|
|
deletedForEveryone: boolean;
|
2020-09-29 22:55:56 +00:00
|
|
|
deletedForEveryoneTimestamp?: number;
|
2020-09-24 20:57:54 +00:00
|
|
|
delivered: number;
|
|
|
|
delivered_to: Array<string | null>;
|
|
|
|
errors: Array<CustomError> | null;
|
|
|
|
expirationStartTimestamp: number | null;
|
|
|
|
expireTimer: number;
|
|
|
|
expires_at: number;
|
2020-12-01 23:45:39 +00:00
|
|
|
groupMigration?: GroupMigrationType;
|
2020-09-24 20:57:54 +00:00
|
|
|
group_update: {
|
|
|
|
avatarUpdated: boolean;
|
|
|
|
joined: Array<string>;
|
|
|
|
left: string | 'You';
|
|
|
|
name: string;
|
|
|
|
};
|
|
|
|
hasAttachments: boolean;
|
|
|
|
hasFileAttachments: boolean;
|
|
|
|
hasVisualMediaAttachments: boolean;
|
|
|
|
isErased: boolean;
|
|
|
|
isTapToViewInvalid: boolean;
|
|
|
|
isViewOnce: boolean;
|
|
|
|
key_changed: string;
|
|
|
|
local: boolean;
|
|
|
|
logger: unknown;
|
|
|
|
message: unknown;
|
|
|
|
messageTimer: unknown;
|
|
|
|
profileChange: ProfileNameChangeType;
|
|
|
|
quote: {
|
|
|
|
attachments: Array<typeof window.WhatIsThis>;
|
|
|
|
author: string;
|
|
|
|
authorUuid: string;
|
|
|
|
bodyRanges: BodyRangesType;
|
|
|
|
id: string;
|
|
|
|
referencedMessageNotFound: boolean;
|
|
|
|
text: string;
|
|
|
|
} | null;
|
2020-10-16 18:31:57 +00:00
|
|
|
reactions: Array<{ fromId: string; emoji: string; timestamp: number }>;
|
2020-09-24 20:57:54 +00:00
|
|
|
read_by: Array<string | null>;
|
|
|
|
requiredProtocolVersion: number;
|
|
|
|
sent: boolean;
|
|
|
|
sourceDevice: string | number;
|
|
|
|
snippet: unknown;
|
|
|
|
supportedVersionAtReceive: unknown;
|
|
|
|
synced: boolean;
|
|
|
|
unidentifiedDeliveryReceived: boolean;
|
|
|
|
verified: boolean;
|
|
|
|
verifiedChanged: string;
|
|
|
|
|
2020-07-27 18:15:32 +00:00
|
|
|
id: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
type?: string;
|
2020-09-24 20:57:54 +00:00
|
|
|
body: string;
|
|
|
|
attachments: Array<WhatIsThis>;
|
|
|
|
preview: Array<WhatIsThis>;
|
|
|
|
sticker: WhatIsThis;
|
|
|
|
sent_at: WhatIsThis;
|
|
|
|
sent_to: Array<string>;
|
|
|
|
unidentifiedDeliveries: Array<string>;
|
|
|
|
contact: Array<WhatIsThis>;
|
|
|
|
conversationId: string;
|
|
|
|
recipients: Array<WhatIsThis>;
|
|
|
|
reaction: WhatIsThis;
|
|
|
|
destination?: WhatIsThis;
|
|
|
|
destinationUuid?: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
expirationTimerUpdate?: {
|
|
|
|
expireTimer: number;
|
2020-09-24 20:57:54 +00:00
|
|
|
fromSync?: unknown;
|
2020-09-09 02:25:05 +00:00
|
|
|
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;
|
|
|
|
// 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;
|
|
|
|
serverTimestamp?: number;
|
2020-09-24 20:57:54 +00:00
|
|
|
source?: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
sourceUuid?: string;
|
2020-07-27 18:15:32 +00:00
|
|
|
|
2020-09-24 20:57:54 +00:00
|
|
|
unread: number;
|
|
|
|
timestamp: number;
|
2020-12-01 23:45:39 +00:00
|
|
|
|
|
|
|
// Backwards-compatibility with prerelease data schema
|
|
|
|
invitedGV2Members?: Array<GroupV2PendingMemberType>;
|
|
|
|
droppedGV2MemberIds?: Array<string>;
|
2020-09-24 20:57:54 +00:00
|
|
|
};
|
2020-07-27 18:15:32 +00:00
|
|
|
|
2020-09-24 20:57:54 +00:00
|
|
|
export type ConversationAttributesTypeType = 'private' | 'group';
|
2020-07-27 18:15:32 +00:00
|
|
|
|
2020-09-11 19:37:01 +00:00
|
|
|
export type ConversationAttributesType = {
|
2020-09-24 20:57:54 +00:00
|
|
|
accessKey: string | null;
|
2020-10-06 17:06:34 +00:00
|
|
|
addedBy?: string;
|
2020-11-20 17:30:45 +00:00
|
|
|
capabilities?: CapabilitiesType;
|
2020-10-16 18:31:57 +00:00
|
|
|
color?: string;
|
2020-09-24 20:57:54 +00:00
|
|
|
discoveredUnregisteredAt: number;
|
|
|
|
draftAttachments: Array<unknown>;
|
2020-11-03 01:19:52 +00:00
|
|
|
draftBodyRanges: Array<BodyRangeType>;
|
2020-09-24 20:57:54 +00:00
|
|
|
draftTimestamp: number | null;
|
|
|
|
inbox_position: number;
|
2020-09-29 22:07:03 +00:00
|
|
|
isPinned: boolean;
|
2020-10-28 21:54:33 +00:00
|
|
|
lastMessageDeletedForEveryone: boolean;
|
2020-09-24 20:57:54 +00:00
|
|
|
lastMessageStatus: LastMessageStatus | null;
|
2020-10-28 22:54:32 +00:00
|
|
|
markedUnread: boolean;
|
2020-09-24 20:57:54 +00:00
|
|
|
messageCount: number;
|
|
|
|
messageCountBeforeMessageRequests: number;
|
|
|
|
messageRequestResponseType: number;
|
|
|
|
muteExpiresAt: number;
|
|
|
|
profileAvatar: WhatIsThis;
|
2020-10-06 17:06:34 +00:00
|
|
|
profileKeyCredential: string | null;
|
|
|
|
profileKeyVersion: string | null;
|
2020-09-24 20:57:54 +00:00
|
|
|
quotedMessageId: string;
|
|
|
|
sealedSender: unknown;
|
|
|
|
sentMessageCount: number;
|
|
|
|
sharedGroupNames: Array<string>;
|
|
|
|
|
2020-07-27 18:15:32 +00:00
|
|
|
id: string;
|
2020-09-24 20:57:54 +00:00
|
|
|
type: ConversationAttributesTypeType;
|
|
|
|
timestamp: number | null;
|
2020-07-27 18:15:32 +00:00
|
|
|
|
2020-09-09 02:25:05 +00:00
|
|
|
// Shared fields
|
2020-07-27 18:15:32 +00:00
|
|
|
active_at?: number | null;
|
2020-09-24 20:57:54 +00:00
|
|
|
draft?: string | null;
|
2020-07-27 18:15:32 +00:00
|
|
|
isArchived?: boolean;
|
2020-09-24 20:57:54 +00:00
|
|
|
lastMessage?: string | null;
|
2020-09-09 02:25:05 +00:00
|
|
|
name?: string;
|
2020-09-09 00:56:23 +00:00
|
|
|
needsStorageServiceSync?: boolean;
|
2020-07-27 18:15:32 +00:00
|
|
|
needsVerification?: boolean;
|
|
|
|
profileSharing: boolean;
|
|
|
|
storageID?: string;
|
2020-09-09 00:56:23 +00:00
|
|
|
storageUnknownFields: string;
|
2020-07-27 18:15:32 +00:00
|
|
|
unreadCount?: number;
|
|
|
|
version: number;
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
// Private core info
|
|
|
|
uuid?: string;
|
|
|
|
e164?: string;
|
|
|
|
|
|
|
|
// Private other fields
|
2021-01-26 01:01:19 +00:00
|
|
|
about?: string;
|
|
|
|
aboutEmoji?: string;
|
2020-09-24 20:57:54 +00:00
|
|
|
profileFamilyName?: string;
|
|
|
|
profileKey?: string;
|
|
|
|
profileName?: string;
|
2020-09-29 23:29:11 +00:00
|
|
|
storageProfileKey?: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
verified?: number;
|
|
|
|
|
|
|
|
// Group-only
|
|
|
|
groupId?: string;
|
|
|
|
left: boolean;
|
|
|
|
groupVersion?: number;
|
|
|
|
|
|
|
|
// GroupV1 only
|
|
|
|
members?: Array<string>;
|
2020-11-20 17:30:45 +00:00
|
|
|
derivedGroupV2Id?: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
|
|
|
|
// GroupV2 core info
|
|
|
|
masterKey?: string;
|
|
|
|
secretParams?: string;
|
|
|
|
publicParams?: string;
|
|
|
|
revision?: number;
|
|
|
|
|
|
|
|
// GroupV2 other fields
|
|
|
|
accessControl?: {
|
2020-12-01 23:45:39 +00:00
|
|
|
attributes: AccessRequiredEnum;
|
|
|
|
members: AccessRequiredEnum;
|
2020-12-18 19:27:43 +00:00
|
|
|
addFromInviteLink: AccessRequiredEnum;
|
2020-09-09 02:25:05 +00:00
|
|
|
};
|
|
|
|
avatar?: {
|
|
|
|
url: string;
|
|
|
|
path: string;
|
|
|
|
hash: string;
|
2020-09-24 20:57:54 +00:00
|
|
|
} | null;
|
2020-09-09 02:25:05 +00:00
|
|
|
expireTimer?: number;
|
|
|
|
membersV2?: Array<GroupV2MemberType>;
|
|
|
|
pendingMembersV2?: Array<GroupV2PendingMemberType>;
|
2020-12-18 19:27:43 +00:00
|
|
|
pendingAdminApprovalV2?: Array<GroupV2PendingAdminApprovalType>;
|
|
|
|
groupInviteLinkPassword?: string;
|
2020-11-20 17:30:45 +00:00
|
|
|
previousGroupV1Id?: string;
|
|
|
|
previousGroupV1Members?: Array<string>;
|
2020-09-09 02:25:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export type GroupV2MemberType = {
|
|
|
|
conversationId: string;
|
2020-12-01 23:45:39 +00:00
|
|
|
role: MemberRoleEnum;
|
2020-09-09 02:25:05 +00:00
|
|
|
joinedAtVersion: number;
|
2020-12-18 19:27:43 +00:00
|
|
|
|
|
|
|
// 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;
|
2020-09-09 02:25:05 +00:00
|
|
|
};
|
|
|
|
export type GroupV2PendingMemberType = {
|
2020-11-20 17:30:45 +00:00
|
|
|
addedByUserId?: string;
|
2020-09-09 02:25:05 +00:00
|
|
|
conversationId: string;
|
|
|
|
timestamp: number;
|
2020-12-01 23:45:39 +00:00
|
|
|
role: MemberRoleEnum;
|
2020-07-27 18:15:32 +00:00
|
|
|
};
|
2020-12-18 19:27:43 +00:00
|
|
|
export type GroupV2PendingAdminApprovalType = {
|
|
|
|
conversationId: string;
|
|
|
|
timestamp: number;
|
|
|
|
};
|
2020-07-27 18:15:32 +00:00
|
|
|
|
2020-09-24 20:57:54 +00:00
|
|
|
export type VerificationOptions = {
|
2020-09-09 00:56:23 +00:00
|
|
|
key?: null | ArrayBuffer;
|
|
|
|
viaContactSync?: boolean;
|
|
|
|
viaStorageServiceSync?: boolean;
|
|
|
|
viaSyncMessage?: boolean;
|
|
|
|
};
|
|
|
|
|
2020-09-11 19:37:01 +00:00
|
|
|
export declare class ConversationModelCollectionType extends Backbone.Collection<
|
2020-09-24 20:57:54 +00:00
|
|
|
ConversationModel
|
2020-07-27 18:15:32 +00:00
|
|
|
> {
|
|
|
|
resetLookups(): void;
|
|
|
|
}
|
|
|
|
|
2020-09-24 20:57:54 +00:00
|
|
|
export declare class MessageModelCollectionType extends Backbone.Collection<
|
|
|
|
MessageModel
|
2020-07-27 18:15:32 +00:00
|
|
|
> {}
|