2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-07-09 19:36:10 +00:00
|
|
|
import type {
|
2021-04-05 22:18:19 +00:00
|
|
|
ConversationAttributesType,
|
|
|
|
MessageAttributesType,
|
2021-12-08 19:52:46 +00:00
|
|
|
SenderKeyInfoType,
|
2020-09-24 21:53:21 +00:00
|
|
|
} from '../model-types.d';
|
2021-07-09 19:36:10 +00:00
|
|
|
import type { StoredJob } from '../jobs/types';
|
|
|
|
import type { ReactionType } from '../types/Reactions';
|
|
|
|
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StorageAccessType } from '../types/Storage.d';
|
2021-07-09 19:36:10 +00:00
|
|
|
import type { AttachmentType } from '../types/Attachment';
|
2023-04-10 16:31:45 +00:00
|
|
|
import type { BytesToStrings } from '../types/Util';
|
2021-09-10 02:38:11 +00:00
|
|
|
import type { QualifiedAddressStringType } from '../types/QualifiedAddress';
|
2023-08-10 16:43:33 +00:00
|
|
|
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
|
|
|
import type { AciString, ServiceIdString } from '../types/ServiceId';
|
2021-11-02 23:01:13 +00:00
|
|
|
import type { BadgeType } from '../badges/types';
|
2021-08-30 21:39:57 +00:00
|
|
|
import type { RemoveAllConfiguration } from '../types/RemoveAllConfiguration';
|
2021-09-16 21:54:06 +00:00
|
|
|
import type { LoggerType } from '../types/Logging';
|
2022-04-29 23:42:47 +00:00
|
|
|
import type { ReadStatus } from '../messages/MessageReadStatus';
|
2023-04-10 16:31:45 +00:00
|
|
|
import type { RawBodyRange } from '../types/BodyRange';
|
2023-03-20 22:23:53 +00:00
|
|
|
import type { GetMessagesBetweenOptions } from './Server';
|
|
|
|
import type { MessageTimestamps } from '../state/ducks/conversations';
|
2023-08-09 00:53:06 +00:00
|
|
|
import type {
|
|
|
|
CallHistoryDetails,
|
|
|
|
CallHistoryFilter,
|
|
|
|
CallHistoryGroup,
|
|
|
|
CallHistoryPagination,
|
|
|
|
} from '../types/CallDisposition';
|
2021-06-17 17:15:10 +00:00
|
|
|
|
2023-03-04 03:03:15 +00:00
|
|
|
export type AdjacentMessagesByConversationOptionsType = Readonly<{
|
|
|
|
conversationId: string;
|
|
|
|
messageId?: string;
|
|
|
|
includeStoryReplies: boolean;
|
|
|
|
limit?: number;
|
|
|
|
receivedAt?: number;
|
|
|
|
sentAt?: number;
|
|
|
|
storyId: string | undefined;
|
|
|
|
requireVisualMediaAttachments?: boolean;
|
|
|
|
}>;
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
export type GetNearbyMessageFromDeletedSetOptionsType = Readonly<{
|
|
|
|
conversationId: string;
|
|
|
|
lastSelectedMessage: MessageTimestamps;
|
|
|
|
deletedMessageIds: ReadonlyArray<string>;
|
|
|
|
storyId: string | undefined;
|
|
|
|
includeStoryReplies: boolean;
|
|
|
|
}>;
|
|
|
|
|
2021-06-17 17:15:10 +00:00
|
|
|
export type AttachmentDownloadJobTypeType =
|
|
|
|
| 'long-message'
|
|
|
|
| 'attachment'
|
|
|
|
| 'preview'
|
|
|
|
| 'contact'
|
|
|
|
| 'quote'
|
|
|
|
| 'sticker';
|
2020-09-24 21:53:21 +00:00
|
|
|
|
2021-04-05 22:18:19 +00:00
|
|
|
export type AttachmentDownloadJobType = {
|
2021-06-17 17:15:10 +00:00
|
|
|
attachment: AttachmentType;
|
|
|
|
attempts: number;
|
2021-04-05 22:18:19 +00:00
|
|
|
id: string;
|
2021-06-17 17:15:10 +00:00
|
|
|
index: number;
|
|
|
|
messageId: string;
|
2021-04-05 22:18:19 +00:00
|
|
|
pending: number;
|
2021-06-17 17:15:10 +00:00
|
|
|
timestamp: number;
|
|
|
|
type: AttachmentDownloadJobTypeType;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
|
|
|
export type MessageMetricsType = {
|
|
|
|
id: string;
|
|
|
|
received_at: number;
|
|
|
|
sent_at: number;
|
|
|
|
};
|
|
|
|
export type ConversationMetricsType = {
|
|
|
|
oldest?: MessageMetricsType;
|
|
|
|
newest?: MessageMetricsType;
|
2022-04-22 18:35:14 +00:00
|
|
|
oldestUnseen?: MessageMetricsType;
|
|
|
|
totalUnseen: number;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
|
|
|
export type ConversationType = ConversationAttributesType;
|
|
|
|
export type EmojiType = {
|
|
|
|
shortName: string;
|
|
|
|
lastUsage: number;
|
|
|
|
};
|
2021-09-10 02:38:11 +00:00
|
|
|
|
2021-04-05 22:18:19 +00:00
|
|
|
export type IdentityKeyType = {
|
|
|
|
firstUse: boolean;
|
2023-08-10 16:43:33 +00:00
|
|
|
id: ServiceIdString | `conversation:${string}`;
|
2021-04-05 22:18:19 +00:00
|
|
|
nonblockingApproval: boolean;
|
2021-09-24 00:49:05 +00:00
|
|
|
publicKey: Uint8Array;
|
2021-04-05 22:18:19 +00:00
|
|
|
timestamp: number;
|
|
|
|
verified: number;
|
|
|
|
};
|
2022-07-28 16:35:29 +00:00
|
|
|
export type StoredIdentityKeyType = {
|
|
|
|
firstUse: boolean;
|
2023-08-10 16:43:33 +00:00
|
|
|
id: ServiceIdString | `conversation:${string}`;
|
2022-07-28 16:35:29 +00:00
|
|
|
nonblockingApproval: boolean;
|
|
|
|
publicKey: string;
|
|
|
|
timestamp: number;
|
|
|
|
verified: number;
|
|
|
|
};
|
2021-09-10 02:38:11 +00:00
|
|
|
export type IdentityKeyIdType = IdentityKeyType['id'];
|
|
|
|
|
2021-06-15 00:09:37 +00:00
|
|
|
export type ItemKeyType = keyof StorageAccessType;
|
|
|
|
export type AllItemsType = Partial<StorageAccessType>;
|
2022-07-28 16:35:29 +00:00
|
|
|
export type StoredAllItemsType = Partial<BytesToStrings<StorageAccessType>>;
|
2021-06-15 00:09:37 +00:00
|
|
|
export type ItemType<K extends ItemKeyType> = {
|
|
|
|
id: K;
|
|
|
|
value: StorageAccessType[K];
|
|
|
|
};
|
2022-07-28 16:35:29 +00:00
|
|
|
export type StoredItemType<K extends ItemKeyType> = {
|
|
|
|
id: K;
|
|
|
|
value: BytesToStrings<StorageAccessType[K]>;
|
|
|
|
};
|
2021-04-05 22:18:19 +00:00
|
|
|
export type MessageType = MessageAttributesType;
|
2021-07-12 23:51:45 +00:00
|
|
|
export type MessageTypeUnhydrated = {
|
|
|
|
json: string;
|
|
|
|
};
|
2023-07-14 16:53:20 +00:00
|
|
|
|
2023-08-10 16:43:33 +00:00
|
|
|
export type PreKeyIdType = `${ServiceIdString}:${number}`;
|
2023-07-14 16:53:20 +00:00
|
|
|
export type KyberPreKeyType = {
|
|
|
|
id: PreKeyIdType;
|
|
|
|
|
|
|
|
createdAt: number;
|
|
|
|
data: Uint8Array;
|
|
|
|
isConfirmed: boolean;
|
|
|
|
isLastResort: boolean;
|
|
|
|
keyId: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourUuid: ServiceIdString;
|
2023-07-14 16:53:20 +00:00
|
|
|
};
|
|
|
|
export type StoredKyberPreKeyType = KyberPreKeyType & {
|
|
|
|
data: string;
|
|
|
|
};
|
2021-04-05 22:18:19 +00:00
|
|
|
export type PreKeyType = {
|
2023-07-14 16:53:20 +00:00
|
|
|
id: PreKeyIdType;
|
|
|
|
|
|
|
|
createdAt: number;
|
2021-09-10 02:38:11 +00:00
|
|
|
keyId: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourUuid: ServiceIdString;
|
2021-09-24 00:49:05 +00:00
|
|
|
privateKey: Uint8Array;
|
|
|
|
publicKey: Uint8Array;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
2023-07-14 16:53:20 +00:00
|
|
|
|
|
|
|
export type StoredPreKeyType = PreKeyType & {
|
2022-07-28 16:35:29 +00:00
|
|
|
privateKey: string;
|
|
|
|
publicKey: string;
|
|
|
|
};
|
2021-12-10 22:51:54 +00:00
|
|
|
export type ServerSearchResultMessageType = {
|
2021-07-12 23:51:45 +00:00
|
|
|
json: string;
|
2023-06-26 18:25:48 +00:00
|
|
|
|
|
|
|
// If the FTS matches text in message.body, snippet will be populated
|
|
|
|
ftsSnippet: string | null;
|
|
|
|
|
|
|
|
// Otherwise, a matching mention will be returned
|
|
|
|
mentionUuid: string | null;
|
|
|
|
mentionStart: number | null;
|
|
|
|
mentionLength: number | null;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
|
|
|
export type ClientSearchResultMessageType = MessageType & {
|
|
|
|
json: string;
|
2023-04-10 16:31:45 +00:00
|
|
|
bodyRanges: ReadonlyArray<RawBodyRange>;
|
2021-04-05 22:18:19 +00:00
|
|
|
snippet: string;
|
|
|
|
};
|
2021-07-15 23:48:09 +00:00
|
|
|
|
|
|
|
export type SentProtoType = {
|
|
|
|
contentHint: number;
|
2021-09-24 00:49:05 +00:00
|
|
|
proto: Uint8Array;
|
2021-07-15 23:48:09 +00:00
|
|
|
timestamp: number;
|
2022-07-01 16:55:13 +00:00
|
|
|
urgent: boolean;
|
2022-08-15 21:53:33 +00:00
|
|
|
hasPniSignatureMessage: boolean;
|
2021-07-15 23:48:09 +00:00
|
|
|
};
|
|
|
|
export type SentProtoWithMessageIdsType = SentProtoType & {
|
|
|
|
messageIds: Array<string>;
|
|
|
|
};
|
2023-08-10 16:43:33 +00:00
|
|
|
export type SentRecipientsType = Record<ServiceIdString, Array<number>>;
|
2021-07-15 23:48:09 +00:00
|
|
|
export type SentMessagesType = Array<string>;
|
|
|
|
|
|
|
|
// These two are for test only
|
|
|
|
export type SentRecipientsDBType = {
|
|
|
|
payloadId: number;
|
|
|
|
recipientUuid: string;
|
|
|
|
deviceId: number;
|
|
|
|
};
|
|
|
|
export type SentMessageDBType = {
|
|
|
|
payloadId: number;
|
|
|
|
messageId: string;
|
|
|
|
};
|
|
|
|
|
2021-05-14 01:18:43 +00:00
|
|
|
export type SenderKeyType = {
|
|
|
|
// Primary key
|
2021-09-10 02:38:11 +00:00
|
|
|
id: `${QualifiedAddressStringType}--${string}`;
|
2021-05-14 01:18:43 +00:00
|
|
|
// These two are combined into one string to give us the final id
|
|
|
|
senderId: string;
|
|
|
|
distributionId: string;
|
|
|
|
// Raw data to serialize/deserialize into signal-client SenderKeyRecord
|
2021-09-24 00:49:05 +00:00
|
|
|
data: Uint8Array;
|
2021-05-14 01:18:43 +00:00
|
|
|
lastUpdatedDate: number;
|
|
|
|
};
|
2021-09-10 02:38:11 +00:00
|
|
|
export type SenderKeyIdType = SenderKeyType['id'];
|
2021-04-05 22:18:19 +00:00
|
|
|
export type SessionType = {
|
2021-09-10 02:38:11 +00:00
|
|
|
id: QualifiedAddressStringType;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourUuid: ServiceIdString;
|
|
|
|
uuid: ServiceIdString;
|
2021-04-05 22:18:19 +00:00
|
|
|
conversationId: string;
|
|
|
|
deviceId: number;
|
|
|
|
record: string;
|
2021-04-16 23:13:13 +00:00
|
|
|
version?: number;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
2021-09-10 02:38:11 +00:00
|
|
|
export type SessionIdType = SessionType['id'];
|
2021-04-05 22:18:19 +00:00
|
|
|
export type SignedPreKeyType = {
|
|
|
|
confirmed: boolean;
|
|
|
|
created_at: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourUuid: ServiceIdString;
|
|
|
|
id: `${ServiceIdString}:${number}`;
|
2021-09-10 02:38:11 +00:00
|
|
|
keyId: number;
|
2021-09-24 00:49:05 +00:00
|
|
|
privateKey: Uint8Array;
|
|
|
|
publicKey: Uint8Array;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
2022-07-28 16:35:29 +00:00
|
|
|
export type StoredSignedPreKeyType = {
|
|
|
|
confirmed: boolean;
|
|
|
|
created_at: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourUuid: ServiceIdString;
|
|
|
|
id: `${ServiceIdString}:${number}`;
|
2022-07-28 16:35:29 +00:00
|
|
|
keyId: number;
|
|
|
|
privateKey: string;
|
|
|
|
publicKey: string;
|
|
|
|
};
|
2021-09-10 02:38:11 +00:00
|
|
|
export type SignedPreKeyIdType = SignedPreKeyType['id'];
|
2021-04-05 22:18:19 +00:00
|
|
|
|
2021-07-09 19:36:10 +00:00
|
|
|
export type StickerType = Readonly<{
|
2021-04-05 22:18:19 +00:00
|
|
|
id: number;
|
|
|
|
packId: string;
|
|
|
|
|
2021-07-09 19:36:10 +00:00
|
|
|
emoji?: string;
|
2021-04-07 20:00:22 +00:00
|
|
|
isCoverOnly: boolean;
|
|
|
|
lastUsed?: number;
|
2021-04-05 22:18:19 +00:00
|
|
|
path: string;
|
2021-07-09 19:36:10 +00:00
|
|
|
|
2021-04-05 22:18:19 +00:00
|
|
|
width: number;
|
|
|
|
height: number;
|
2021-07-09 19:36:10 +00:00
|
|
|
}>;
|
|
|
|
|
|
|
|
export const StickerPackStatuses = [
|
|
|
|
'known',
|
|
|
|
'ephemeral',
|
|
|
|
'downloaded',
|
|
|
|
'installed',
|
|
|
|
'pending',
|
|
|
|
'error',
|
|
|
|
] as const;
|
|
|
|
|
|
|
|
export type StickerPackStatusType = typeof StickerPackStatuses[number];
|
|
|
|
|
2022-08-03 17:10:49 +00:00
|
|
|
export type StorageServiceFieldsType = Readonly<{
|
|
|
|
storageID?: string;
|
|
|
|
storageVersion?: number;
|
|
|
|
storageUnknownFields?: Uint8Array | null;
|
|
|
|
storageNeedsSync: boolean;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type InstalledStickerPackType = Readonly<{
|
2021-04-05 22:18:19 +00:00
|
|
|
id: string;
|
|
|
|
key: string;
|
|
|
|
|
2022-08-03 17:10:49 +00:00
|
|
|
uninstalledAt?: undefined;
|
|
|
|
position?: number | null;
|
|
|
|
}> &
|
|
|
|
StorageServiceFieldsType;
|
|
|
|
|
|
|
|
export type UninstalledStickerPackType = Readonly<{
|
|
|
|
id: string;
|
|
|
|
key?: undefined;
|
|
|
|
|
|
|
|
uninstalledAt: number;
|
|
|
|
position?: undefined;
|
|
|
|
}> &
|
|
|
|
StorageServiceFieldsType;
|
|
|
|
|
|
|
|
export type StickerPackInfoType =
|
|
|
|
| InstalledStickerPackType
|
|
|
|
| UninstalledStickerPackType;
|
|
|
|
|
|
|
|
export type StickerPackType = InstalledStickerPackType &
|
|
|
|
Readonly<{
|
|
|
|
attemptedStatus?: 'downloaded' | 'installed' | 'ephemeral';
|
|
|
|
author: string;
|
|
|
|
coverStickerId: number;
|
|
|
|
createdAt: number;
|
|
|
|
downloadAttempts: number;
|
|
|
|
installedAt?: number;
|
|
|
|
lastUsed?: number;
|
|
|
|
status: StickerPackStatusType;
|
|
|
|
stickerCount: number;
|
|
|
|
stickers: Record<string, StickerType>;
|
|
|
|
title: string;
|
|
|
|
}>;
|
2021-07-09 19:36:10 +00:00
|
|
|
|
2021-04-05 22:18:19 +00:00
|
|
|
export type UnprocessedType = {
|
|
|
|
id: string;
|
|
|
|
timestamp: number;
|
2022-03-24 21:28:56 +00:00
|
|
|
receivedAtCounter: number | null;
|
2021-04-05 22:18:19 +00:00
|
|
|
version: number;
|
|
|
|
attempts: number;
|
2021-05-17 18:03:42 +00:00
|
|
|
envelope?: string;
|
2021-04-05 22:18:19 +00:00
|
|
|
|
2022-06-13 21:39:35 +00:00
|
|
|
messageAgeSec?: number;
|
2021-04-05 22:18:19 +00:00
|
|
|
source?: string;
|
2023-08-10 16:43:33 +00:00
|
|
|
sourceUuid?: ServiceIdString;
|
2021-05-17 18:03:42 +00:00
|
|
|
sourceDevice?: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
destinationUuid?: ServiceIdString;
|
|
|
|
updatedPni?: ServiceIdString;
|
2021-05-27 20:17:05 +00:00
|
|
|
serverGuid?: string;
|
2021-04-05 22:18:19 +00:00
|
|
|
serverTimestamp?: number;
|
|
|
|
decrypted?: string;
|
2022-07-05 22:20:30 +00:00
|
|
|
urgent?: boolean;
|
2022-10-07 17:02:08 +00:00
|
|
|
story?: boolean;
|
2023-02-08 00:55:12 +00:00
|
|
|
reportingToken?: string;
|
2021-04-05 22:18:19 +00:00
|
|
|
};
|
2020-04-01 18:59:11 +00:00
|
|
|
|
2021-04-16 23:13:13 +00:00
|
|
|
export type UnprocessedUpdateType = {
|
|
|
|
source?: string;
|
2023-08-10 16:43:33 +00:00
|
|
|
sourceUuid?: ServiceIdString;
|
2021-08-02 21:55:31 +00:00
|
|
|
sourceDevice?: number;
|
2021-05-27 20:17:05 +00:00
|
|
|
serverGuid?: string;
|
2021-04-16 23:13:13 +00:00
|
|
|
serverTimestamp?: number;
|
|
|
|
decrypted?: string;
|
|
|
|
};
|
|
|
|
|
2022-03-16 00:11:28 +00:00
|
|
|
export type ConversationMessageStatsType = {
|
2021-08-16 16:56:27 +00:00
|
|
|
activity?: MessageType;
|
|
|
|
preview?: MessageType;
|
|
|
|
hasUserInitiatedMessages: boolean;
|
|
|
|
};
|
|
|
|
|
2021-08-31 21:35:01 +00:00
|
|
|
export type DeleteSentProtoRecipientOptionsType = Readonly<{
|
|
|
|
timestamp: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
recipientServiceId: ServiceIdString;
|
2021-08-31 21:35:01 +00:00
|
|
|
deviceId: number;
|
|
|
|
}>;
|
|
|
|
|
2022-08-15 21:53:33 +00:00
|
|
|
export type DeleteSentProtoRecipientResultType = Readonly<{
|
|
|
|
successfulPhoneNumberShares: ReadonlyArray<string>;
|
|
|
|
}>;
|
|
|
|
|
2021-12-08 19:52:46 +00:00
|
|
|
export type StoryDistributionType = Readonly<{
|
2023-08-10 16:43:33 +00:00
|
|
|
id: StoryDistributionIdString;
|
2021-12-08 19:52:46 +00:00
|
|
|
name: string;
|
2022-07-01 00:52:03 +00:00
|
|
|
deletedAtTimestamp?: number;
|
|
|
|
allowsReplies: boolean;
|
|
|
|
isBlockList: boolean;
|
2021-12-08 19:52:46 +00:00
|
|
|
senderKeyInfo: SenderKeyInfoType | undefined;
|
2022-08-03 17:10:49 +00:00
|
|
|
}> &
|
|
|
|
StorageServiceFieldsType;
|
2021-12-08 19:52:46 +00:00
|
|
|
export type StoryDistributionMemberType = Readonly<{
|
2023-08-10 16:43:33 +00:00
|
|
|
listId: StoryDistributionIdString;
|
|
|
|
uuid: ServiceIdString;
|
2021-12-08 19:52:46 +00:00
|
|
|
}>;
|
|
|
|
export type StoryDistributionWithMembersType = Readonly<
|
|
|
|
{
|
2023-08-10 16:43:33 +00:00
|
|
|
members: Array<ServiceIdString>;
|
2021-12-08 19:52:46 +00:00
|
|
|
} & StoryDistributionType
|
|
|
|
>;
|
|
|
|
|
|
|
|
export type StoryReadType = Readonly<{
|
2023-08-10 16:43:33 +00:00
|
|
|
authorId: ServiceIdString;
|
2022-07-08 20:46:25 +00:00
|
|
|
conversationId: string;
|
|
|
|
storyId: string;
|
2021-12-08 19:52:46 +00:00
|
|
|
storyReadDate: number;
|
|
|
|
}>;
|
|
|
|
|
2022-07-28 16:35:29 +00:00
|
|
|
export type ReactionResultType = Pick<
|
|
|
|
ReactionType,
|
|
|
|
'targetAuthorUuid' | 'targetTimestamp' | 'messageId'
|
|
|
|
> & { rowid: number };
|
|
|
|
|
|
|
|
export type GetUnreadByConversationAndMarkReadResultType = Array<
|
|
|
|
{ originalReadStatus: ReadStatus | undefined } & Pick<
|
|
|
|
MessageType,
|
|
|
|
| 'id'
|
|
|
|
| 'source'
|
|
|
|
| 'sourceUuid'
|
|
|
|
| 'sent_at'
|
|
|
|
| 'type'
|
|
|
|
| 'readStatus'
|
|
|
|
| 'seenStatus'
|
|
|
|
>
|
|
|
|
>;
|
|
|
|
|
|
|
|
export type GetConversationRangeCenteredOnMessageResultType<Message> =
|
|
|
|
Readonly<{
|
|
|
|
older: Array<Message>;
|
|
|
|
newer: Array<Message>;
|
|
|
|
metrics: ConversationMetricsType;
|
|
|
|
}>;
|
|
|
|
|
2022-11-17 00:29:15 +00:00
|
|
|
export type MessageAttachmentsCursorType = Readonly<{
|
|
|
|
done: boolean;
|
|
|
|
runId: string;
|
|
|
|
count: number;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type GetKnownMessageAttachmentsResultType = Readonly<{
|
|
|
|
cursor: MessageAttachmentsCursorType;
|
|
|
|
attachments: ReadonlyArray<string>;
|
|
|
|
}>;
|
|
|
|
|
2022-11-28 17:19:48 +00:00
|
|
|
export type GetAllStoriesResultType = ReadonlyArray<
|
|
|
|
MessageType & {
|
|
|
|
hasReplies: boolean;
|
|
|
|
hasRepliesFromSelf: boolean;
|
|
|
|
}
|
|
|
|
>;
|
|
|
|
|
2023-02-09 21:13:08 +00:00
|
|
|
export type FTSOptimizationStateType = Readonly<{
|
|
|
|
steps: number;
|
|
|
|
done?: boolean;
|
|
|
|
}>;
|
|
|
|
|
2023-03-27 23:48:57 +00:00
|
|
|
export type EditedMessageType = Readonly<{
|
2023-05-16 17:37:12 +00:00
|
|
|
conversationId: string;
|
2023-03-27 23:48:57 +00:00
|
|
|
messageId: string;
|
|
|
|
sentAt: number;
|
|
|
|
readStatus: MessageType['readStatus'];
|
|
|
|
}>;
|
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
export type DataInterface = {
|
2020-04-01 18:59:11 +00:00
|
|
|
close: () => Promise<void>;
|
|
|
|
removeDB: () => Promise<void>;
|
|
|
|
removeIndexedDBFiles: () => Promise<void>;
|
|
|
|
|
2021-09-10 02:38:11 +00:00
|
|
|
removeIdentityKeyById: (id: IdentityKeyIdType) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
removeAllIdentityKeys: () => Promise<void>;
|
|
|
|
|
2023-07-14 16:53:20 +00:00
|
|
|
removeKyberPreKeyById: (
|
|
|
|
id: PreKeyIdType | Array<PreKeyIdType>
|
|
|
|
) => Promise<void>;
|
2023-08-10 16:43:33 +00:00
|
|
|
removeKyberPreKeysByServiceId: (serviceId: ServiceIdString) => Promise<void>;
|
2023-07-14 16:53:20 +00:00
|
|
|
removeAllKyberPreKeys: () => Promise<void>;
|
|
|
|
|
|
|
|
removePreKeyById: (id: PreKeyIdType | Array<PreKeyIdType>) => Promise<void>;
|
2023-08-10 16:43:33 +00:00
|
|
|
removePreKeysByServiceId: (serviceId: ServiceIdString) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
removeAllPreKeys: () => Promise<void>;
|
|
|
|
|
2023-07-14 16:53:20 +00:00
|
|
|
removeSignedPreKeyById: (
|
|
|
|
id: SignedPreKeyIdType | Array<SignedPreKeyIdType>
|
|
|
|
) => Promise<void>;
|
2023-08-10 16:43:33 +00:00
|
|
|
removeSignedPreKeysByServiceId: (serviceId: ServiceIdString) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
removeAllSignedPreKeys: () => Promise<void>;
|
|
|
|
|
|
|
|
removeAllItems: () => Promise<void>;
|
2023-07-14 16:53:20 +00:00
|
|
|
removeItemById: (id: ItemKeyType | Array<ItemKeyType>) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
2021-05-14 01:18:43 +00:00
|
|
|
createOrUpdateSenderKey: (key: SenderKeyType) => Promise<void>;
|
2021-09-10 02:38:11 +00:00
|
|
|
getSenderKeyById: (id: SenderKeyIdType) => Promise<SenderKeyType | undefined>;
|
2021-05-14 01:18:43 +00:00
|
|
|
removeAllSenderKeys: () => Promise<void>;
|
|
|
|
getAllSenderKeys: () => Promise<Array<SenderKeyType>>;
|
2021-09-10 02:38:11 +00:00
|
|
|
removeSenderKeyById: (id: SenderKeyIdType) => Promise<void>;
|
2021-05-14 01:18:43 +00:00
|
|
|
|
2021-07-15 23:48:09 +00:00
|
|
|
insertSentProto: (
|
|
|
|
proto: SentProtoType,
|
|
|
|
options: {
|
|
|
|
recipients: SentRecipientsType;
|
|
|
|
messageIds: SentMessagesType;
|
|
|
|
}
|
|
|
|
) => Promise<number>;
|
|
|
|
deleteSentProtosOlderThan: (timestamp: number) => Promise<void>;
|
|
|
|
deleteSentProtoByMessageId: (messageId: string) => Promise<void>;
|
|
|
|
insertProtoRecipients: (options: {
|
|
|
|
id: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
recipientServiceId: ServiceIdString;
|
2021-07-15 23:48:09 +00:00
|
|
|
deviceIds: Array<number>;
|
|
|
|
}) => Promise<void>;
|
2021-08-31 21:35:01 +00:00
|
|
|
deleteSentProtoRecipient: (
|
|
|
|
options:
|
|
|
|
| DeleteSentProtoRecipientOptionsType
|
|
|
|
| ReadonlyArray<DeleteSentProtoRecipientOptionsType>
|
2022-08-15 21:53:33 +00:00
|
|
|
) => Promise<DeleteSentProtoRecipientResultType>;
|
2021-07-15 23:48:09 +00:00
|
|
|
getSentProtoByRecipient: (options: {
|
|
|
|
now: number;
|
2023-08-10 16:43:33 +00:00
|
|
|
recipientServiceId: ServiceIdString;
|
2021-07-15 23:48:09 +00:00
|
|
|
timestamp: number;
|
|
|
|
}) => Promise<SentProtoWithMessageIdsType | undefined>;
|
|
|
|
removeAllSentProtos: () => Promise<void>;
|
|
|
|
getAllSentProtos: () => Promise<Array<SentProtoType>>;
|
|
|
|
// Test-only
|
|
|
|
_getAllSentProtoRecipients: () => Promise<Array<SentRecipientsDBType>>;
|
|
|
|
_getAllSentProtoMessageIds: () => Promise<Array<SentMessageDBType>>;
|
|
|
|
|
2020-04-01 18:59:11 +00:00
|
|
|
createOrUpdateSession: (data: SessionType) => Promise<void>;
|
|
|
|
createOrUpdateSessions: (array: Array<SessionType>) => Promise<void>;
|
2022-01-08 02:12:13 +00:00
|
|
|
commitDecryptResult(options: {
|
|
|
|
senderKeys: Array<SenderKeyType>;
|
2021-05-17 18:03:42 +00:00
|
|
|
sessions: Array<SessionType>;
|
|
|
|
unprocessed: Array<UnprocessedType>;
|
|
|
|
}): Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
bulkAddSessions: (array: Array<SessionType>) => Promise<void>;
|
2021-09-10 02:38:11 +00:00
|
|
|
removeSessionById: (id: SessionIdType) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
removeSessionsByConversation: (conversationId: string) => Promise<void>;
|
2023-08-10 16:43:33 +00:00
|
|
|
removeSessionsByServiceId: (serviceId: ServiceIdString) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
removeAllSessions: () => Promise<void>;
|
|
|
|
getAllSessions: () => Promise<Array<SessionType>>;
|
|
|
|
|
2020-09-09 00:56:23 +00:00
|
|
|
eraseStorageServiceStateFromConversations: () => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getConversationCount: () => Promise<number>;
|
|
|
|
saveConversation: (data: ConversationType) => Promise<void>;
|
|
|
|
saveConversations: (array: Array<ConversationType>) => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
getConversationById: (id: string) => Promise<ConversationType | undefined>;
|
|
|
|
// updateConversation is a normal data method on Server, a sync batch-add on Client
|
2020-04-01 18:59:11 +00:00
|
|
|
updateConversations: (array: Array<ConversationType>) => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
// removeConversation handles either one id or an array on Server, and one id on Client
|
2022-08-09 21:39:00 +00:00
|
|
|
_removeAllConversations: () => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
updateAllConversationColors: (
|
|
|
|
conversationColor?: ConversationColorType,
|
|
|
|
customColorData?: {
|
|
|
|
id: string;
|
|
|
|
value: CustomColorType;
|
|
|
|
}
|
|
|
|
) => Promise<void>;
|
2022-07-08 20:46:25 +00:00
|
|
|
removeAllProfileKeyCredentials: () => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
|
|
|
|
getAllConversations: () => Promise<Array<ConversationType>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getAllConversationIds: () => Promise<Array<string>>;
|
2023-08-10 16:43:33 +00:00
|
|
|
getAllGroupsInvolvingServiceId: (
|
|
|
|
serviceId: ServiceIdString
|
2021-12-10 22:51:54 +00:00
|
|
|
) => Promise<Array<ConversationType>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
2021-12-10 22:51:54 +00:00
|
|
|
getMessageCount: (conversationId?: string) => Promise<number>;
|
2022-03-29 01:10:08 +00:00
|
|
|
getStoryCount: (conversationId: string) => Promise<number>;
|
2021-07-19 20:45:18 +00:00
|
|
|
saveMessage: (
|
|
|
|
data: MessageType,
|
2021-12-20 21:04:02 +00:00
|
|
|
options: {
|
2021-08-31 20:58:39 +00:00
|
|
|
jobToInsert?: StoredJob;
|
|
|
|
forceSave?: boolean;
|
2023-08-10 16:43:33 +00:00
|
|
|
ourAci: AciString;
|
2021-08-31 20:58:39 +00:00
|
|
|
}
|
2021-07-19 20:45:18 +00:00
|
|
|
) => Promise<string>;
|
|
|
|
saveMessages: (
|
2022-03-16 00:11:28 +00:00
|
|
|
arrayOfMessages: ReadonlyArray<MessageType>,
|
2023-08-10 16:43:33 +00:00
|
|
|
options: { forceSave?: boolean; ourAci: AciString }
|
2021-07-19 20:45:18 +00:00
|
|
|
) => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
removeMessage: (id: string) => Promise<void>;
|
2022-12-22 00:07:02 +00:00
|
|
|
removeMessages: (ids: ReadonlyArray<string>) => Promise<void>;
|
2021-12-08 19:52:46 +00:00
|
|
|
getTotalUnreadForConversation: (
|
2021-07-15 23:48:09 +00:00
|
|
|
conversationId: string,
|
2022-04-27 17:41:24 +00:00
|
|
|
options: {
|
2023-03-04 03:03:15 +00:00
|
|
|
storyId: string | undefined;
|
2022-09-30 00:57:11 +00:00
|
|
|
includeStoryReplies: boolean;
|
2022-04-27 17:41:24 +00:00
|
|
|
}
|
2021-12-08 19:52:46 +00:00
|
|
|
) => Promise<number>;
|
2023-05-23 21:59:07 +00:00
|
|
|
getTotalUnreadMentionsOfMeForConversation: (
|
|
|
|
conversationId: string,
|
|
|
|
options: {
|
|
|
|
storyId?: string;
|
|
|
|
includeStoryReplies: boolean;
|
|
|
|
}
|
|
|
|
) => Promise<number>;
|
|
|
|
getOldestUnreadMentionOfMeForConversation(
|
|
|
|
conversationId: string,
|
|
|
|
options: {
|
|
|
|
storyId?: string;
|
|
|
|
includeStoryReplies: boolean;
|
|
|
|
}
|
|
|
|
): Promise<MessageMetricsType | undefined>;
|
2021-12-08 19:52:46 +00:00
|
|
|
getUnreadByConversationAndMarkRead: (options: {
|
|
|
|
conversationId: string;
|
2022-09-30 00:57:11 +00:00
|
|
|
includeStoryReplies: boolean;
|
2021-12-08 19:52:46 +00:00
|
|
|
newestUnreadAt: number;
|
2022-09-22 23:49:06 +00:00
|
|
|
now?: number;
|
2021-12-08 19:52:46 +00:00
|
|
|
readAt?: number;
|
2023-03-04 03:03:15 +00:00
|
|
|
storyId?: string;
|
2022-07-28 16:35:29 +00:00
|
|
|
}) => Promise<GetUnreadByConversationAndMarkReadResultType>;
|
2023-03-27 23:48:57 +00:00
|
|
|
getUnreadEditedMessagesAndMarkRead: (options: {
|
2023-05-16 17:37:12 +00:00
|
|
|
conversationId: string;
|
2023-03-27 23:48:57 +00:00
|
|
|
newestUnreadAt: number;
|
|
|
|
}) => Promise<GetUnreadByConversationAndMarkReadResultType>;
|
2021-12-08 19:52:46 +00:00
|
|
|
getUnreadReactionsAndMarkRead: (options: {
|
|
|
|
conversationId: string;
|
|
|
|
newestUnreadAt: number;
|
2023-03-04 03:03:15 +00:00
|
|
|
storyId?: string;
|
2022-07-28 16:35:29 +00:00
|
|
|
}) => Promise<Array<ReactionResultType>>;
|
2021-07-15 23:48:09 +00:00
|
|
|
markReactionAsRead: (
|
2023-08-10 16:43:33 +00:00
|
|
|
targetAuthorServiceId: ServiceIdString,
|
2021-07-15 23:48:09 +00:00
|
|
|
targetTimestamp: number
|
|
|
|
) => Promise<ReactionType | undefined>;
|
|
|
|
removeReactionFromConversation: (reaction: {
|
|
|
|
emoji: string;
|
|
|
|
fromId: string;
|
2023-08-10 16:43:33 +00:00
|
|
|
targetAuthorServiceId: ServiceIdString;
|
2021-07-15 23:48:09 +00:00
|
|
|
targetTimestamp: number;
|
|
|
|
}) => Promise<void>;
|
|
|
|
addReaction: (reactionObj: ReactionType) => Promise<void>;
|
2021-10-15 22:54:31 +00:00
|
|
|
_getAllReactions: () => Promise<Array<ReactionType>>;
|
2021-12-08 19:52:46 +00:00
|
|
|
_removeAllReactions: () => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
getMessageBySender: (options: {
|
2023-01-05 21:58:13 +00:00
|
|
|
source?: string;
|
2023-08-10 16:43:33 +00:00
|
|
|
sourceUuid?: ServiceIdString;
|
2023-01-05 21:58:13 +00:00
|
|
|
sourceDevice?: number;
|
2021-12-10 22:51:54 +00:00
|
|
|
sent_at: number;
|
|
|
|
}) => Promise<MessageType | undefined>;
|
|
|
|
getMessageById: (id: string) => Promise<MessageType | undefined>;
|
2023-03-20 22:23:53 +00:00
|
|
|
getMessagesById: (
|
|
|
|
messageIds: ReadonlyArray<string>
|
|
|
|
) => Promise<Array<MessageType>>;
|
2021-12-10 22:51:54 +00:00
|
|
|
_getAllMessages: () => Promise<Array<MessageType>>;
|
2023-03-27 23:48:57 +00:00
|
|
|
_getAllEditedMessages: () => Promise<
|
|
|
|
Array<{ messageId: string; sentAt: number }>
|
|
|
|
>;
|
2021-12-10 22:51:54 +00:00
|
|
|
_removeAllMessages: () => Promise<void>;
|
|
|
|
getAllMessageIds: () => Promise<Array<string>>;
|
|
|
|
getMessagesBySentAt: (sentAt: number) => Promise<Array<MessageType>>;
|
|
|
|
getExpiredMessages: () => Promise<Array<MessageType>>;
|
|
|
|
getMessagesUnexpectedlyMissingExpirationStartTimestamp: () => Promise<
|
|
|
|
Array<MessageType>
|
|
|
|
>;
|
|
|
|
getSoonestMessageExpiry: () => Promise<undefined | number>;
|
|
|
|
getNextTapToViewMessageTimestampToAgeOut: () => Promise<undefined | number>;
|
|
|
|
getTapToViewMessagesNeedingErase: () => Promise<Array<MessageType>>;
|
|
|
|
// getOlderMessagesByConversation is JSON on server, full message on Client
|
2022-10-22 06:26:16 +00:00
|
|
|
getAllStories: (options: {
|
2021-12-10 22:51:54 +00:00
|
|
|
conversationId?: string;
|
2023-08-10 16:43:33 +00:00
|
|
|
sourceUuid?: ServiceIdString;
|
2022-11-28 17:19:48 +00:00
|
|
|
}) => Promise<GetAllStoriesResultType>;
|
2021-12-10 22:51:54 +00:00
|
|
|
// getNewerMessagesByConversation is JSON on server, full message on Client
|
2023-03-04 03:03:15 +00:00
|
|
|
getMessageMetricsForConversation: (options: {
|
|
|
|
conversationId: string;
|
|
|
|
storyId?: string;
|
|
|
|
includeStoryReplies: boolean;
|
|
|
|
}) => Promise<ConversationMetricsType>;
|
2021-12-20 21:05:13 +00:00
|
|
|
// getConversationRangeCenteredOnMessage is JSON on server, full message on client
|
2022-03-16 00:11:28 +00:00
|
|
|
getConversationMessageStats: (options: {
|
2021-12-10 22:51:54 +00:00
|
|
|
conversationId: string;
|
2022-09-30 00:57:11 +00:00
|
|
|
includeStoryReplies: boolean;
|
2022-03-16 00:11:28 +00:00
|
|
|
}) => Promise<ConversationMessageStatsType>;
|
|
|
|
getLastConversationMessage(options: {
|
|
|
|
conversationId: string;
|
|
|
|
}): Promise<MessageType | undefined>;
|
2023-08-09 00:53:06 +00:00
|
|
|
getAllCallHistory: () => Promise<ReadonlyArray<CallHistoryDetails>>;
|
|
|
|
clearCallHistory: (beforeTimestamp: number) => Promise<Array<string>>;
|
|
|
|
getCallHistoryMessageByCallId(options: {
|
|
|
|
conversationId: string;
|
|
|
|
callId: string;
|
|
|
|
}): Promise<MessageType | undefined>;
|
|
|
|
getCallHistory(
|
|
|
|
callId: string,
|
2023-08-10 16:43:33 +00:00
|
|
|
peerId: ServiceIdString | string
|
2023-08-09 00:53:06 +00:00
|
|
|
): Promise<CallHistoryDetails | undefined>;
|
|
|
|
getCallHistoryGroupsCount(filter: CallHistoryFilter): Promise<number>;
|
|
|
|
getCallHistoryGroups(
|
|
|
|
filter: CallHistoryFilter,
|
|
|
|
pagination: CallHistoryPagination
|
|
|
|
): Promise<Array<CallHistoryGroup>>;
|
|
|
|
saveCallHistory(callHistory: CallHistoryDetails): Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
hasGroupCallHistoryMessage: (
|
|
|
|
conversationId: string,
|
|
|
|
eraId: string
|
|
|
|
) => Promise<boolean>;
|
|
|
|
migrateConversationMessages: (
|
|
|
|
obsoleteId: string,
|
|
|
|
currentId: string
|
|
|
|
) => Promise<void>;
|
2023-03-20 22:23:53 +00:00
|
|
|
getMessagesBetween: (
|
|
|
|
conversationId: string,
|
|
|
|
options: GetMessagesBetweenOptions
|
|
|
|
) => Promise<Array<string>>;
|
|
|
|
getNearbyMessageFromDeletedSet: (
|
|
|
|
options: GetNearbyMessageFromDeletedSetOptionsType
|
|
|
|
) => Promise<string | null>;
|
2023-03-27 23:48:57 +00:00
|
|
|
saveEditedMessage: (
|
|
|
|
mainMessage: MessageType,
|
2023-08-10 16:43:33 +00:00
|
|
|
ourAci: AciString,
|
2023-03-27 23:48:57 +00:00
|
|
|
opts: EditedMessageType
|
|
|
|
) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getUnprocessedCount: () => Promise<number>;
|
2023-02-02 19:39:07 +00:00
|
|
|
getUnprocessedByIdsAndIncrementAttempts: (
|
|
|
|
ids: ReadonlyArray<string>
|
|
|
|
) => Promise<Array<UnprocessedType>>;
|
|
|
|
getAllUnprocessedIds: () => Promise<Array<string>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
updateUnprocessedWithData: (
|
|
|
|
id: string,
|
2021-04-16 23:13:13 +00:00
|
|
|
data: UnprocessedUpdateType
|
2020-04-01 18:59:11 +00:00
|
|
|
) => Promise<void>;
|
2021-04-05 22:18:19 +00:00
|
|
|
updateUnprocessedsWithData: (
|
2021-04-16 23:13:13 +00:00
|
|
|
array: Array<{ id: string; data: UnprocessedUpdateType }>
|
2021-04-05 22:18:19 +00:00
|
|
|
) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getUnprocessedById: (id: string) => Promise<UnprocessedType | undefined>;
|
2021-02-26 23:42:45 +00:00
|
|
|
removeUnprocessed: (id: string | Array<string>) => Promise<void>;
|
2023-02-02 19:39:07 +00:00
|
|
|
|
|
|
|
/** only for testing */
|
2020-04-01 18:59:11 +00:00
|
|
|
removeAllUnprocessed: () => Promise<void>;
|
|
|
|
|
2022-05-23 23:07:41 +00:00
|
|
|
getAttachmentDownloadJobById: (
|
|
|
|
id: string
|
|
|
|
) => Promise<AttachmentDownloadJobType | undefined>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getNextAttachmentDownloadJobs: (
|
|
|
|
limit?: number,
|
|
|
|
options?: { timestamp?: number }
|
|
|
|
) => Promise<Array<AttachmentDownloadJobType>>;
|
|
|
|
saveAttachmentDownloadJob: (job: AttachmentDownloadJobType) => Promise<void>;
|
2021-12-10 22:51:54 +00:00
|
|
|
resetAttachmentDownloadPending: () => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
setAttachmentDownloadJobPending: (
|
|
|
|
id: string,
|
|
|
|
pending: boolean
|
|
|
|
) => Promise<void>;
|
|
|
|
removeAttachmentDownloadJob: (id: string) => Promise<void>;
|
|
|
|
removeAllAttachmentDownloadJobs: () => Promise<void>;
|
|
|
|
|
|
|
|
createOrUpdateStickerPack: (pack: StickerPackType) => Promise<void>;
|
|
|
|
updateStickerPackStatus: (
|
|
|
|
id: string,
|
|
|
|
status: StickerPackStatusType,
|
|
|
|
options?: { timestamp: number }
|
|
|
|
) => Promise<void>;
|
2022-08-03 17:10:49 +00:00
|
|
|
updateStickerPackInfo: (info: StickerPackInfoType) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
createOrUpdateSticker: (sticker: StickerType) => Promise<void>;
|
|
|
|
updateStickerLastUsed: (
|
|
|
|
packId: string,
|
|
|
|
stickerId: number,
|
|
|
|
lastUsed: number
|
|
|
|
) => Promise<void>;
|
|
|
|
addStickerPackReference: (messageId: string, packId: string) => Promise<void>;
|
|
|
|
deleteStickerPackReference: (
|
|
|
|
messageId: string,
|
|
|
|
packId: string
|
2021-07-29 18:59:26 +00:00
|
|
|
) => Promise<ReadonlyArray<string> | undefined>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getStickerCount: () => Promise<number>;
|
|
|
|
deleteStickerPack: (packId: string) => Promise<Array<string>>;
|
|
|
|
getAllStickerPacks: () => Promise<Array<StickerPackType>>;
|
2022-08-03 17:10:49 +00:00
|
|
|
addUninstalledStickerPack: (
|
|
|
|
pack: UninstalledStickerPackType
|
|
|
|
) => Promise<void>;
|
|
|
|
removeUninstalledStickerPack: (packId: string) => Promise<void>;
|
|
|
|
getInstalledStickerPacks: () => Promise<Array<StickerPackType>>;
|
|
|
|
getUninstalledStickerPacks: () => Promise<Array<UninstalledStickerPackType>>;
|
|
|
|
installStickerPack: (packId: string, timestamp: number) => Promise<void>;
|
|
|
|
uninstallStickerPack: (packId: string, timestamp: number) => Promise<void>;
|
|
|
|
getStickerPackInfo: (
|
|
|
|
packId: string
|
|
|
|
) => Promise<StickerPackInfoType | undefined>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getAllStickers: () => Promise<Array<StickerType>>;
|
|
|
|
getRecentStickers: (options?: {
|
|
|
|
limit?: number;
|
|
|
|
}) => Promise<Array<StickerType>>;
|
2021-01-27 22:39:45 +00:00
|
|
|
clearAllErrorStickerPackAttempts: () => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
|
|
|
updateEmojiUsage: (shortName: string, timeUsed?: number) => Promise<void>;
|
|
|
|
getRecentEmojis: (limit?: number) => Promise<Array<EmojiType>>;
|
|
|
|
|
2021-11-02 23:01:13 +00:00
|
|
|
getAllBadges(): Promise<Array<BadgeType>>;
|
|
|
|
updateOrCreateBadges(badges: ReadonlyArray<BadgeType>): Promise<void>;
|
|
|
|
badgeImageFileDownloaded(url: string, localPath: string): Promise<void>;
|
|
|
|
|
2021-12-08 19:52:46 +00:00
|
|
|
_getAllStoryDistributions(): Promise<Array<StoryDistributionType>>;
|
|
|
|
_getAllStoryDistributionMembers(): Promise<
|
|
|
|
Array<StoryDistributionMemberType>
|
|
|
|
>;
|
|
|
|
_deleteAllStoryDistributions(): Promise<void>;
|
|
|
|
createNewStoryDistribution(
|
2021-12-10 02:15:59 +00:00
|
|
|
distribution: StoryDistributionWithMembersType
|
2021-12-08 19:52:46 +00:00
|
|
|
): Promise<void>;
|
|
|
|
getAllStoryDistributionsWithMembers(): Promise<
|
|
|
|
Array<StoryDistributionWithMembersType>
|
|
|
|
>;
|
2022-03-04 21:14:52 +00:00
|
|
|
getStoryDistributionWithMembers(
|
|
|
|
id: string
|
|
|
|
): Promise<StoryDistributionWithMembersType | undefined>;
|
2021-12-10 02:15:59 +00:00
|
|
|
modifyStoryDistribution(distribution: StoryDistributionType): Promise<void>;
|
2021-12-08 19:52:46 +00:00
|
|
|
modifyStoryDistributionMembers(
|
2022-07-01 00:52:03 +00:00
|
|
|
listId: string,
|
|
|
|
options: {
|
2023-08-10 16:43:33 +00:00
|
|
|
toAdd: Array<ServiceIdString>;
|
|
|
|
toRemove: Array<ServiceIdString>;
|
2022-07-01 00:52:03 +00:00
|
|
|
}
|
|
|
|
): Promise<void>;
|
|
|
|
modifyStoryDistributionWithMembers(
|
|
|
|
distribution: StoryDistributionType,
|
2021-12-08 19:52:46 +00:00
|
|
|
options: {
|
2023-08-10 16:43:33 +00:00
|
|
|
toAdd: Array<ServiceIdString>;
|
|
|
|
toRemove: Array<ServiceIdString>;
|
2021-12-08 19:52:46 +00:00
|
|
|
}
|
|
|
|
): Promise<void>;
|
2023-08-10 16:43:33 +00:00
|
|
|
deleteStoryDistribution(id: StoryDistributionIdString): Promise<void>;
|
2021-12-08 19:52:46 +00:00
|
|
|
|
|
|
|
_getAllStoryReads(): Promise<Array<StoryReadType>>;
|
|
|
|
_deleteAllStoryReads(): Promise<void>;
|
|
|
|
addNewStoryRead(read: StoryReadType): Promise<void>;
|
|
|
|
getLastStoryReadsForAuthor(options: {
|
2023-08-10 16:43:33 +00:00
|
|
|
authorId: ServiceIdString;
|
|
|
|
conversationId?: string;
|
2021-12-08 19:52:46 +00:00
|
|
|
limit?: number;
|
|
|
|
}): Promise<Array<StoryReadType>>;
|
2022-03-29 01:10:08 +00:00
|
|
|
countStoryReadsByConversation(conversationId: string): Promise<number>;
|
2021-12-08 19:52:46 +00:00
|
|
|
|
2020-04-01 18:59:11 +00:00
|
|
|
removeAll: () => Promise<void>;
|
2021-08-30 21:39:57 +00:00
|
|
|
removeAllConfiguration: (type?: RemoveAllConfiguration) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
|
|
|
getMessagesNeedingUpgrade: (
|
|
|
|
limit: number,
|
|
|
|
options: { maxVersion: number }
|
|
|
|
) => Promise<Array<MessageType>>;
|
|
|
|
getMessagesWithVisualMediaAttachments: (
|
|
|
|
conversationId: string,
|
|
|
|
options: { limit: number }
|
|
|
|
) => Promise<Array<MessageType>>;
|
|
|
|
getMessagesWithFileAttachments: (
|
|
|
|
conversationId: string,
|
|
|
|
options: { limit: number }
|
|
|
|
) => Promise<Array<MessageType>>;
|
2021-05-27 20:17:05 +00:00
|
|
|
getMessageServerGuidsForSpam: (
|
|
|
|
conversationId: string
|
|
|
|
) => Promise<Array<string>>;
|
2021-04-29 23:02:27 +00:00
|
|
|
|
|
|
|
getJobsInQueue(queueType: string): Promise<Array<StoredJob>>;
|
|
|
|
insertJob(job: Readonly<StoredJob>): Promise<void>;
|
|
|
|
deleteJob(id: string): Promise<void>;
|
2021-05-28 16:15:17 +00:00
|
|
|
|
2022-11-17 02:52:04 +00:00
|
|
|
wasGroupCallRingPreviouslyCanceled(ringId: bigint): Promise<boolean>;
|
|
|
|
processGroupCallRingCancellation(ringId: bigint): Promise<void>;
|
|
|
|
cleanExpiredGroupCallRingCancellations(): Promise<void>;
|
2021-08-20 16:06:15 +00:00
|
|
|
|
2021-09-15 18:45:22 +00:00
|
|
|
getMaxMessageCounter(): Promise<number | undefined>;
|
2021-12-10 22:51:54 +00:00
|
|
|
|
2021-07-30 16:43:16 +00:00
|
|
|
getStatisticsForLogging(): Promise<Record<string, string>>;
|
2023-02-09 21:13:08 +00:00
|
|
|
|
|
|
|
optimizeFTS: (
|
|
|
|
state?: FTSOptimizationStateType
|
|
|
|
) => Promise<FTSOptimizationStateType | undefined>;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2020-04-01 18:59:11 +00:00
|
|
|
|
2021-12-10 22:51:54 +00:00
|
|
|
export type ServerInterface = DataInterface & {
|
|
|
|
// Differing signature on client/server
|
2020-04-01 18:59:11 +00:00
|
|
|
|
2021-12-10 22:51:54 +00:00
|
|
|
updateConversation: (data: ConversationType) => Promise<void>;
|
|
|
|
removeConversation: (id: Array<string> | string) => Promise<void>;
|
|
|
|
|
2023-06-26 18:25:48 +00:00
|
|
|
searchMessages: ({
|
|
|
|
query,
|
|
|
|
conversationId,
|
|
|
|
options,
|
|
|
|
contactUuidsMatchingQuery,
|
|
|
|
}: {
|
|
|
|
query: string;
|
|
|
|
conversationId?: string;
|
|
|
|
options?: { limit?: number };
|
|
|
|
contactUuidsMatchingQuery?: Array<string>;
|
|
|
|
}) => Promise<Array<ServerSearchResultMessageType>>;
|
2023-07-21 22:10:32 +00:00
|
|
|
|
|
|
|
getRecentStoryReplies(
|
|
|
|
storyId: string,
|
|
|
|
options?: GetRecentStoryRepliesOptionsType
|
|
|
|
): Promise<Array<MessageTypeUnhydrated>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getOlderMessagesByConversation: (
|
2023-03-04 03:03:15 +00:00
|
|
|
options: AdjacentMessagesByConversationOptionsType
|
2021-07-12 23:51:45 +00:00
|
|
|
) => Promise<Array<MessageTypeUnhydrated>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getNewerMessagesByConversation: (
|
2023-03-04 03:03:15 +00:00
|
|
|
options: AdjacentMessagesByConversationOptionsType
|
2021-07-12 23:51:45 +00:00
|
|
|
) => Promise<Array<MessageTypeUnhydrated>>;
|
2023-03-04 03:03:15 +00:00
|
|
|
getConversationRangeCenteredOnMessage: (
|
|
|
|
options: AdjacentMessagesByConversationOptionsType
|
|
|
|
) => Promise<
|
2022-07-28 16:35:29 +00:00
|
|
|
GetConversationRangeCenteredOnMessageResultType<MessageTypeUnhydrated>
|
|
|
|
>;
|
|
|
|
|
|
|
|
createOrUpdateIdentityKey: (data: StoredIdentityKeyType) => Promise<void>;
|
|
|
|
getIdentityKeyById: (
|
|
|
|
id: IdentityKeyIdType
|
|
|
|
) => Promise<StoredIdentityKeyType | undefined>;
|
|
|
|
bulkAddIdentityKeys: (array: Array<StoredIdentityKeyType>) => Promise<void>;
|
|
|
|
getAllIdentityKeys: () => Promise<Array<StoredIdentityKeyType>>;
|
|
|
|
|
2023-07-14 16:53:20 +00:00
|
|
|
createOrUpdateKyberPreKey: (data: StoredKyberPreKeyType) => Promise<void>;
|
|
|
|
getKyberPreKeyById: (
|
|
|
|
id: PreKeyIdType
|
|
|
|
) => Promise<StoredKyberPreKeyType | undefined>;
|
|
|
|
bulkAddKyberPreKeys: (array: Array<StoredKyberPreKeyType>) => Promise<void>;
|
|
|
|
getAllKyberPreKeys: () => Promise<Array<StoredKyberPreKeyType>>;
|
|
|
|
|
2022-07-28 16:35:29 +00:00
|
|
|
createOrUpdatePreKey: (data: StoredPreKeyType) => Promise<void>;
|
|
|
|
getPreKeyById: (id: PreKeyIdType) => Promise<StoredPreKeyType | undefined>;
|
|
|
|
bulkAddPreKeys: (array: Array<StoredPreKeyType>) => Promise<void>;
|
|
|
|
getAllPreKeys: () => Promise<Array<StoredPreKeyType>>;
|
|
|
|
|
|
|
|
createOrUpdateSignedPreKey: (data: StoredSignedPreKeyType) => Promise<void>;
|
|
|
|
getSignedPreKeyById: (
|
|
|
|
id: SignedPreKeyIdType
|
|
|
|
) => Promise<StoredSignedPreKeyType | undefined>;
|
|
|
|
bulkAddSignedPreKeys: (array: Array<StoredSignedPreKeyType>) => Promise<void>;
|
|
|
|
getAllSignedPreKeys: () => Promise<Array<StoredSignedPreKeyType>>;
|
|
|
|
|
|
|
|
createOrUpdateItem<K extends ItemKeyType>(
|
|
|
|
data: StoredItemType<K>
|
|
|
|
): Promise<void>;
|
|
|
|
getItemById<K extends ItemKeyType>(
|
|
|
|
id: K
|
|
|
|
): Promise<StoredItemType<K> | undefined>;
|
|
|
|
getAllItems: () => Promise<StoredAllItemsType>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
|
|
|
// Server-only
|
|
|
|
|
2021-09-16 21:54:06 +00:00
|
|
|
initialize: (options: {
|
|
|
|
configDir: string;
|
|
|
|
key: string;
|
|
|
|
logger: LoggerType;
|
|
|
|
}) => Promise<void>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
2022-11-17 00:29:15 +00:00
|
|
|
getKnownMessageAttachments: (
|
|
|
|
cursor?: MessageAttachmentsCursorType
|
|
|
|
) => Promise<GetKnownMessageAttachmentsResultType>;
|
|
|
|
finishGetKnownMessageAttachments: (
|
|
|
|
cursor: MessageAttachmentsCursorType
|
|
|
|
) => Promise<void>;
|
|
|
|
getKnownConversationAttachments: () => Promise<Array<string>>;
|
|
|
|
removeKnownStickers: (
|
|
|
|
allStickers: ReadonlyArray<string>
|
2020-04-01 18:59:11 +00:00
|
|
|
) => Promise<Array<string>>;
|
|
|
|
removeKnownDraftAttachments: (
|
2022-11-17 00:29:15 +00:00
|
|
|
allStickers: ReadonlyArray<string>
|
2020-04-01 18:59:11 +00:00
|
|
|
) => Promise<Array<string>>;
|
2021-11-02 23:01:13 +00:00
|
|
|
getAllBadgeImageFileLocalPaths: () => Promise<Set<string>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
};
|
|
|
|
|
2023-07-21 22:10:32 +00:00
|
|
|
export type GetRecentStoryRepliesOptionsType = {
|
|
|
|
limit?: number;
|
|
|
|
messageId?: string;
|
|
|
|
receivedAt?: number;
|
|
|
|
sentAt?: number;
|
|
|
|
};
|
|
|
|
|
2022-11-17 00:29:15 +00:00
|
|
|
// Differing signature on client/server
|
|
|
|
export type ClientExclusiveInterface = {
|
2021-12-10 22:51:54 +00:00
|
|
|
// Differing signature on client/server
|
|
|
|
|
|
|
|
updateConversation: (data: ConversationType) => void;
|
|
|
|
removeConversation: (id: string) => Promise<void>;
|
|
|
|
|
2023-06-26 18:25:48 +00:00
|
|
|
searchMessages: ({
|
|
|
|
query,
|
|
|
|
conversationId,
|
|
|
|
options,
|
|
|
|
contactUuidsMatchingQuery,
|
|
|
|
}: {
|
|
|
|
query: string;
|
|
|
|
conversationId?: string;
|
|
|
|
options?: { limit?: number };
|
|
|
|
contactUuidsMatchingQuery?: Array<string>;
|
|
|
|
}) => Promise<Array<ClientSearchResultMessageType>>;
|
2023-07-21 22:10:32 +00:00
|
|
|
|
|
|
|
getRecentStoryReplies(
|
|
|
|
storyId: string,
|
|
|
|
options?: GetRecentStoryRepliesOptionsType
|
|
|
|
): Promise<Array<MessageAttributesType>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getOlderMessagesByConversation: (
|
2023-03-04 03:03:15 +00:00
|
|
|
options: AdjacentMessagesByConversationOptionsType
|
2021-12-10 22:51:54 +00:00
|
|
|
) => Promise<Array<MessageAttributesType>>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getNewerMessagesByConversation: (
|
2023-03-04 03:03:15 +00:00
|
|
|
options: AdjacentMessagesByConversationOptionsType
|
2021-12-10 22:51:54 +00:00
|
|
|
) => Promise<Array<MessageAttributesType>>;
|
2023-03-04 03:03:15 +00:00
|
|
|
getConversationRangeCenteredOnMessage: (
|
|
|
|
options: AdjacentMessagesByConversationOptionsType
|
|
|
|
) => Promise<GetConversationRangeCenteredOnMessageResultType<MessageType>>;
|
2022-07-28 16:35:29 +00:00
|
|
|
|
|
|
|
createOrUpdateIdentityKey: (data: IdentityKeyType) => Promise<void>;
|
|
|
|
getIdentityKeyById: (
|
|
|
|
id: IdentityKeyIdType
|
|
|
|
) => Promise<IdentityKeyType | undefined>;
|
|
|
|
bulkAddIdentityKeys: (array: Array<IdentityKeyType>) => Promise<void>;
|
|
|
|
getAllIdentityKeys: () => Promise<Array<IdentityKeyType>>;
|
|
|
|
|
2023-07-14 16:53:20 +00:00
|
|
|
createOrUpdateKyberPreKey: (data: KyberPreKeyType) => Promise<void>;
|
|
|
|
getKyberPreKeyById: (
|
|
|
|
id: PreKeyIdType
|
|
|
|
) => Promise<KyberPreKeyType | undefined>;
|
|
|
|
bulkAddKyberPreKeys: (array: Array<KyberPreKeyType>) => Promise<void>;
|
|
|
|
getAllKyberPreKeys: () => Promise<Array<KyberPreKeyType>>;
|
|
|
|
|
2022-07-28 16:35:29 +00:00
|
|
|
createOrUpdatePreKey: (data: PreKeyType) => Promise<void>;
|
|
|
|
getPreKeyById: (id: PreKeyIdType) => Promise<PreKeyType | undefined>;
|
|
|
|
bulkAddPreKeys: (array: Array<PreKeyType>) => Promise<void>;
|
|
|
|
getAllPreKeys: () => Promise<Array<PreKeyType>>;
|
|
|
|
|
|
|
|
createOrUpdateSignedPreKey: (data: SignedPreKeyType) => Promise<void>;
|
|
|
|
getSignedPreKeyById: (
|
|
|
|
id: SignedPreKeyIdType
|
|
|
|
) => Promise<SignedPreKeyType | undefined>;
|
|
|
|
bulkAddSignedPreKeys: (array: Array<SignedPreKeyType>) => Promise<void>;
|
|
|
|
getAllSignedPreKeys: () => Promise<Array<SignedPreKeyType>>;
|
|
|
|
|
|
|
|
createOrUpdateItem<K extends ItemKeyType>(data: ItemType<K>): Promise<void>;
|
|
|
|
getItemById<K extends ItemKeyType>(id: K): Promise<ItemType<K> | undefined>;
|
|
|
|
getAllItems: () => Promise<AllItemsType>;
|
2020-04-01 18:59:11 +00:00
|
|
|
|
|
|
|
// Client-side only
|
|
|
|
|
|
|
|
shutdown: () => Promise<void>;
|
|
|
|
removeAllMessagesInConversation: (
|
|
|
|
conversationId: string,
|
2021-01-13 00:42:15 +00:00
|
|
|
options: {
|
|
|
|
logId: string;
|
|
|
|
}
|
2020-04-01 18:59:11 +00:00
|
|
|
) => Promise<void>;
|
|
|
|
removeOtherData: () => Promise<void>;
|
|
|
|
cleanupOrphanedAttachments: () => Promise<void>;
|
|
|
|
ensureFilePermissions: () => Promise<void>;
|
|
|
|
};
|
|
|
|
|
2022-11-17 00:29:15 +00:00
|
|
|
export type ClientInterface = DataInterface & ClientExclusiveInterface;
|