diff --git a/ts/session/messages/outgoing/Message.ts b/ts/session/messages/outgoing/Message.ts index 1fdd1f12a..1322f8618 100644 --- a/ts/session/messages/outgoing/Message.ts +++ b/ts/session/messages/outgoing/Message.ts @@ -1,9 +1,14 @@ +export interface MessageParams { + timestamp: number; + identifier: string; +} + export abstract class Message { public readonly timestamp: number; public identifier: string; - constructor({ timestamp, identifier }: { timestamp: number; identifier: string }) { + constructor({ timestamp, identifier }: MessageParams) { if (identifier.length === 0) { throw new Error('Cannot set empty identifier'); } diff --git a/ts/session/messages/outgoing/OpenGroupMessage.ts b/ts/session/messages/outgoing/OpenGroupMessage.ts index 34914d95b..d92252239 100644 --- a/ts/session/messages/outgoing/OpenGroupMessage.ts +++ b/ts/session/messages/outgoing/OpenGroupMessage.ts @@ -1,10 +1,8 @@ -import { Message } from './Message'; +import { Message, MessageParams } from './Message'; import { AttachmentType } from '../../../types/Attachment'; import { QuotedAttachmentType } from '../../../components/conversation/Quote'; -interface OpenGroupMessageParams { - timestamp: number; - identifier: string; +interface OpenGroupMessageParams extends MessageParams { server: string; attachments: [AttachmentType]; body?: string; diff --git a/ts/session/messages/outgoing/content/SessionResetMessage.ts b/ts/session/messages/outgoing/content/SessionResetMessage.ts index 77ccf0060..b7d21221f 100644 --- a/ts/session/messages/outgoing/content/SessionResetMessage.ts +++ b/ts/session/messages/outgoing/content/SessionResetMessage.ts @@ -1,5 +1,6 @@ import { ContentMessage } from './ContentMessage'; import { SignalService } from '../../../../protobuf'; +import { MessageParams } from '../Message'; export interface PreKeyBundleType { @@ -13,9 +14,7 @@ export interface PreKeyBundleType { } -interface SessionResetParams { - timestamp: number; - identifier: string; +interface SessionResetParams extends MessageParams { preKeyBundle: PreKeyBundleType; } diff --git a/ts/session/messages/outgoing/content/TypingMessage.ts b/ts/session/messages/outgoing/content/TypingMessage.ts index d21b0a6c2..5a220eb61 100644 --- a/ts/session/messages/outgoing/content/TypingMessage.ts +++ b/ts/session/messages/outgoing/content/TypingMessage.ts @@ -1,10 +1,9 @@ import { ContentMessage } from './ContentMessage'; import { SignalService } from '../../../../protobuf'; import { TextEncoder } from 'util'; +import { MessageParams } from '../Message'; -interface TypingMessageParams { - timestamp: number; - identifier: string; +interface TypingMessageParams extends MessageParams { isTyping: boolean; typingTimestamp: number | null; groupId: string | null; diff --git a/ts/session/messages/outgoing/content/data/GroupInvitationMessage.ts b/ts/session/messages/outgoing/content/data/GroupInvitationMessage.ts index b22325fb6..69c019230 100644 --- a/ts/session/messages/outgoing/content/data/GroupInvitationMessage.ts +++ b/ts/session/messages/outgoing/content/data/GroupInvitationMessage.ts @@ -1,9 +1,8 @@ import { DataMessage } from './DataMessage'; import { SignalService } from '../../../../../protobuf'; +import { MessageParams } from '../../Message'; -interface GroupInvitationMessageParams { - timestamp: number; - identifier: string; +interface GroupInvitationMessageParams extends MessageParams { serverAddress: string; channelId: number; serverName: string; diff --git a/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts b/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts index ce585e28c..e1acaef73 100644 --- a/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts +++ b/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts @@ -1,17 +1,9 @@ import { SignalService } from '../../../../../protobuf'; -import { DeviceLinkRequestMessage } from './DeviceLinkRequestMessage'; +import { DeviceLinkMessageParams, DeviceLinkRequestMessage } from './DeviceLinkRequestMessage'; import { LokiProfile } from '../../../../../types/Message'; -interface DeviceLinkGrantMessageParams { - timestamp: number; - identifier: string; - - // pairing authorisation - primaryDevicePubKey: string; - secondaryDevicePubKey: string; - requestSignature: Uint8Array; +interface DeviceLinkGrantMessageParams extends DeviceLinkMessageParams { grantSignature: Uint8Array; - lokiProfile: LokiProfile; } diff --git a/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts b/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts index 58df123f0..56b95e514 100644 --- a/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts +++ b/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts @@ -1,9 +1,7 @@ import { ContentMessage } from '../ContentMessage'; import { SignalService } from '../../../../../protobuf'; -interface DeviceLinkMessageParams { - timestamp: number; - identifier: string; - +import { MessageParams } from '../../Message'; +export interface DeviceLinkMessageParams extends MessageParams{ primaryDevicePubKey: string; secondaryDevicePubKey: string; requestSignature: Uint8Array; diff --git a/ts/session/messages/outgoing/content/receipt/ReceiptMessage.ts b/ts/session/messages/outgoing/content/receipt/ReceiptMessage.ts index 53fe7e16e..9e00042e9 100644 --- a/ts/session/messages/outgoing/content/receipt/ReceiptMessage.ts +++ b/ts/session/messages/outgoing/content/receipt/ReceiptMessage.ts @@ -1,11 +1,15 @@ import { ContentMessage } from '../ContentMessage'; import { SignalService } from '../../../../../protobuf'; +import { MessageParams } from '../../Message'; +interface ReceiptMessageParams extends MessageParams { + timestamps: Array; +} export abstract class ReceiptMessage extends ContentMessage { private readonly timestamps: Array; constructor({ timestamp, identifier, timestamps }: - { timestamp: number; identifier: string; timestamps: Array }) { + ReceiptMessageParams) { super({timestamp, identifier}); this.timestamps = timestamps; }