session-desktop/ts/types/Message.ts

57 lines
1.2 KiB
TypeScript

import { Attachment } from './Attachment';
import { IndexableBoolean, IndexablePresence } from './IndexedDB';
export type Message = UserMessage;
export type UserMessage = IncomingMessage;
export type IncomingMessage = Readonly<
{
type: 'incoming';
// Required
attachments: Array<Attachment>;
id: string;
received_at: number;
// Optional
body?: string;
decrypted_at?: number;
errors?: Array<any>;
expireTimer?: number;
flags?: number;
source?: string;
sourceDevice?: number;
} & SharedMessageProperties &
MessageSchemaVersion5 &
ExpirationTimerUpdate
>;
type SharedMessageProperties = Readonly<{
conversationId: string;
sent_at: number;
timestamp: number;
}>;
type ExpirationTimerUpdate = Partial<
Readonly<{
expirationTimerUpdate: Readonly<{
expireTimer: number;
fromSync: boolean;
source: string;
}>;
}>
>;
type MessageSchemaVersion5 = Partial<
Readonly<{
hasAttachments: IndexableBoolean;
hasVisualMediaAttachments: IndexablePresence;
hasFileAttachments: IndexablePresence;
}>
>;
export type LokiProfile = {
displayName: string;
avatarPointer?: string;
profileKey: Uint8Array | null;
};