session-desktop/ts/types/Message.ts

57 lines
1.2 KiB
TypeScript
Raw Normal View History

2018-04-10 01:26:48 +02:00
import { Attachment } from './Attachment';
import { IndexableBoolean, IndexablePresence } from './IndexedDB';
2018-04-10 01:26:48 +02:00
export type Message = UserMessage;
export type UserMessage = IncomingMessage;
2018-04-10 01:26:48 +02:00
2018-04-13 22:25:52 +02:00
export type IncomingMessage = Readonly<
{
type: 'incoming';
// Required
attachments: Array<Attachment>;
id: string;
received_at: number;
2018-04-10 01:26:48 +02:00
2018-04-13 22:25:52 +02:00
// Optional
body?: string;
decrypted_at?: number;
errors?: Array<any>;
expireTimer?: number;
2018-04-13 22:25:52 +02:00
flags?: number;
source?: string;
sourceDevice?: number;
} & SharedMessageProperties &
MessageSchemaVersion5 &
2018-04-13 22:25:52 +02:00
ExpirationTimerUpdate
>;
2018-04-12 00:36:11 +02:00
type SharedMessageProperties = Readonly<{
conversationId: string;
sent_at: number;
2018-04-10 01:26:48 +02:00
timestamp: number;
2018-04-12 00:36:11 +02:00
}>;
2018-04-14 04:09:56 +02:00
type ExpirationTimerUpdate = Partial<
Readonly<{
expirationTimerUpdate: Readonly<{
expireTimer: number;
fromSync: boolean;
2021-01-27 23:46:15 +01:00
source: string;
2018-04-14 04:09:56 +02:00
}>;
}>
>;
2018-04-10 01:26:48 +02:00
type MessageSchemaVersion5 = Partial<
2018-04-14 04:09:56 +02:00
Readonly<{
hasAttachments: IndexableBoolean;
hasVisualMediaAttachments: IndexablePresence;
hasFileAttachments: IndexablePresence;
2018-04-14 04:09:56 +02:00
}>
>;
export type LokiProfile = {
displayName: string;
avatarPointer?: string;
2021-01-29 01:29:24 +01:00
profileKey: Uint8Array | null;
};