session-desktop/ts/types/Message.ts

70 lines
1.6 KiB
TypeScript
Raw Normal View History

2018-04-10 01:26:48 +02:00
import { Attachment } from './Attachment';
2018-04-12 00:36:11 +02:00
export type Message
= IncomingMessage
| OutgoingMessage
| VerifiedChangeMessage;
2018-04-10 01:26:48 +02:00
2018-04-12 00:36:11 +02:00
export type IncomingMessage = Readonly<{
2018-04-10 01:26:48 +02:00
type: 'incoming';
// Required
2018-04-10 01:26:48 +02:00
attachments: Array<Attachment>;
id: string;
received_at: number;
// Optional
2018-04-10 01:26:48 +02:00
body?: string;
decrypted_at?: number;
errors?: Array<any>;
flags?: number;
source?: string;
sourceDevice?: number;
2018-04-12 00:36:11 +02:00
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
2018-04-10 01:26:48 +02:00
2018-04-12 00:36:11 +02:00
export type OutgoingMessage = Readonly<{
2018-04-10 01:26:48 +02:00
type: 'outgoing';
// Required
2018-04-10 01:26:48 +02:00
attachments: Array<Attachment>;
delivered: number;
delivered_to: Array<string>;
destination: string; // PhoneNumber
expirationStartTimestamp: number;
id: string;
received_at: number;
sent: boolean;
sent_to: Array<string>; // Array<PhoneNumber>
// Optional
body?: string;
expires_at?: number;
expireTimer?: number;
recipients?: Array<string>; // Array<PhoneNumber>
2018-04-10 01:26:48 +02:00
synced: boolean;
2018-04-12 00:36:11 +02:00
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
export type VerifiedChangeMessage = Readonly<{
type: 'verified-change';
} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>;
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
}>;
type ExpirationTimerUpdate = Readonly<{
expirationTimerUpdate?: Readonly<{
expireTimer: number;
fromSync: boolean;
source: string; // PhoneNumber
}>,
}>;
2018-04-10 01:26:48 +02:00
2018-04-12 00:36:11 +02:00
type Message4 = Readonly<{
2018-04-10 01:26:48 +02:00
numAttachments?: number;
numVisualMediaAttachments?: number;
numFileAttachments?: number;
2018-04-12 00:36:11 +02:00
}>;