From 1659354f5124ab7bfc73d3f456107b176c7538f0 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Wed, 11 Apr 2018 18:36:11 -0400 Subject: [PATCH] Expand `Message` type definitions --- ts/types/Message.ts | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/ts/types/Message.ts b/ts/types/Message.ts index d41f59f1b6fb..f539ed1a8d81 100644 --- a/ts/types/Message.ts +++ b/ts/types/Message.ts @@ -1,29 +1,28 @@ import { Attachment } from './Attachment'; -export type Message = IncomingMessage | OutgoingMessage; +export type Message + = IncomingMessage + | OutgoingMessage + | VerifiedChangeMessage; -export type IncomingMessage = { +export type IncomingMessage = Readonly<{ type: 'incoming'; attachments: Array; body?: string; - conversationId: string; decrypted_at?: number; errors?: Array; flags?: number; id: string; received_at: number; - sent_at: number; source?: string; sourceDevice?: number; - timestamp: number; -} & Message4 +} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>; -export type OutgoingMessage = { +export type OutgoingMessage = Readonly<{ type: 'outgoing'; attachments: Array; body?: string; - conversationId: string; delivered: number; delivered_to: Array; destination: string; // PhoneNumber @@ -34,14 +33,30 @@ export type OutgoingMessage = { received_at: number; recipients?: Array; // Array sent: boolean; - sent_at: number; sent_to: Array; // Array synced: boolean; - timestamp: number; -} & Message4 +} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>; -interface Message4 { +export type VerifiedChangeMessage = Readonly<{ + type: 'verified-change'; +} & SharedMessageProperties & Message4 & ExpirationTimerUpdate>; + +type SharedMessageProperties = Readonly<{ + conversationId: string; + sent_at: number; + timestamp: number; +}>; + +type ExpirationTimerUpdate = Readonly<{ + expirationTimerUpdate?: Readonly<{ + expireTimer: number; + fromSync: boolean; + source: string; // PhoneNumber + }>, +}>; + +type Message4 = Readonly<{ numAttachments?: number; numVisualMediaAttachments?: number; numFileAttachments?: number; -} +}>;