add empty messages ts files
parent
15560a4cb5
commit
f4a24c5c98
@ -1,4 +1,3 @@
|
||||
import * as Outgoing from './outgoing';
|
||||
|
||||
// For Audric: Do you think we need to namespace?
|
||||
export { Outgoing };
|
||||
|
@ -0,0 +1,3 @@
|
||||
export interface Message {
|
||||
timestamp: number;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import { OutgoingContentMessage } from './OutgoingContentMessage';
|
||||
import { SignalService } from '../../../protobuf';
|
||||
|
||||
export class OutgoingDataMessage extends OutgoingContentMessage {
|
||||
public contentProto(): SignalService.Content {
|
||||
return new SignalService.Content({
|
||||
dataMessage: this.dataProto(),
|
||||
});
|
||||
}
|
||||
|
||||
protected dataProto(): SignalService.DataMessage {
|
||||
throw new Error('dataProto() needs to be implemented.');
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
export interface OutgoingMessage {
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
// Remove me once this is read
|
||||
// Note for Audric, we don't have a `plainText()` function here because i realised that we use Uint8Arrays when encrypting
|
||||
// It wouldn't make sense for this then to be `plainTextBuffer(): UInt8Array` as that's specific to OutgoingContentMessage.
|
||||
// Thus i've left it out and moved it to outgoing content message
|
@ -1,28 +1,23 @@
|
||||
import { OutgoingMessage } from './OutgoingMessage';
|
||||
import { SignalService } from '../../../protobuf';
|
||||
import { Message } from '../Message';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export class OutgoingContentMessage implements OutgoingMessage {
|
||||
public timestamp: number;
|
||||
public identifier: string;
|
||||
public ttl: number;
|
||||
export abstract class ContentMessage implements Message {
|
||||
public readonly timestamp: number;
|
||||
public readonly identifier: string;
|
||||
public readonly ttl: number;
|
||||
constructor(timestamp: number, identifier: string, ttl: number) {
|
||||
this.timestamp = timestamp;
|
||||
this.identifier = identifier;
|
||||
this.ttl = ttl;
|
||||
}
|
||||
|
||||
// To discuss:
|
||||
// should padding be the responsibility of the message or should it be the responsibility of the message sender to pad messages
|
||||
// If it is the responsibility of the sender then `contentProto()` needs to become `protected` and not `public`
|
||||
public plainTextBuffer(): Uint8Array {
|
||||
const encoded = SignalService.Content.encode(this.contentProto()).finish();
|
||||
|
||||
return this.processPlainTextBuffer(encoded);
|
||||
}
|
||||
|
||||
public contentProto(): SignalService.Content {
|
||||
throw new Error('contentProto() needs to be implemented.');
|
||||
}
|
||||
protected abstract contentProto(): SignalService.Content;
|
||||
|
||||
private processPlainTextBuffer(buffer: Uint8Array): Uint8Array {
|
||||
const paddedMessageLength = this.getPaddedMessageLength(
|
@ -0,0 +1,9 @@
|
||||
import { ContentMessage } from './ContentMessage';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export class DeviceLinkMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { SessionResetMessage } from './SessionResetMessage';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export class EndSessionMessage extends SessionResetMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import { ContentMessage } from './ContentMessage';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export class ReceiptMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
return new SignalService.Content({
|
||||
receiptMessage: this.receiptProto(),
|
||||
});
|
||||
}
|
||||
|
||||
protected receiptProto(): SignalService.ReceiptMessage {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { ContentMessage } from './ContentMessage';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export class SessionEstablishedMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { ContentMessage } from './ContentMessage';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export class SessionResetMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { ContentMessage } from './ContentMessage';
|
||||
import { SignalService } from '../../../../protobuf';
|
||||
|
||||
export abstract class TypingMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
return new SignalService.Content({
|
||||
typingMessage: this.typingProto(),
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract typingProto(): SignalService.TypingMessage;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { DataMessage } from './DataMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
|
||||
export class ClosedGroupMessage extends DataMessage {
|
||||
|
||||
protected dataProto(): SignalService.DataMessage {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { ContentMessage } from '../ContentMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
|
||||
export abstract class DataMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
return new SignalService.Content({
|
||||
dataMessage: this.dataProto(),
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract dataProto(): SignalService.DataMessage;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { DataMessage } from './DataMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
|
||||
export class DeviceUnlinkMessage extends DataMessage {
|
||||
|
||||
protected dataProto(): SignalService.DataMessage {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
import { DataMessage } from './DataMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
|
||||
export class GroupInvitationMessage extends DataMessage {
|
||||
|
||||
protected dataProto(): SignalService.DataMessage {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
import { DataMessage } from './DataMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
|
||||
// this message type is probably to sub divise again.
|
||||
// should handle quote, body, attachmentsPointer, ... @see DataMessage in compiled.d.ts
|
||||
export abstract class RegularMessage extends DataMessage {
|
||||
|
||||
protected dataProto(): SignalService.DataMessage {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { ContentMessage } from '../ContentMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
|
||||
export abstract class SyncMessage extends ContentMessage {
|
||||
|
||||
protected contentProto(): SignalService.Content {
|
||||
return new SignalService.Content({
|
||||
syncMessage: this.syncProto(),
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract syncProto(): SignalService.SyncMessage;
|
||||
}
|
@ -1,11 +1,40 @@
|
||||
import { OutgoingMessage } from './OutgoingMessage';
|
||||
import { OutgoingContentMessage } from './OutgoingContentMessage';
|
||||
import { OutgoingDataMessage } from './OutgoingDataMessage';
|
||||
import { Message } from './Message';
|
||||
import { ContentMessage } from './content/ContentMessage';
|
||||
import { DataMessage } from './content/data/DataMessage';
|
||||
import { OpenGroupMessage } from './OpenGroupMessage';
|
||||
import { SyncMessage } from './content/sync/SyncMessage';
|
||||
import { TypingMessage } from './content/TypingMessage';
|
||||
import { ReceiptMessage } from './content/ReceiptMessage';
|
||||
import { ClosedGroupMessage } from './content/data/ClosedGroupMessage';
|
||||
import { DeviceUnlinkMessage } from './content/data/DeviceUnlinkMessage';
|
||||
import { GroupInvitationMessage } from './content/data/GroupInvitationMessage';
|
||||
import { RegularMessage } from './content/data/RegularMessage';
|
||||
import { SessionResetMessage } from './content/SessionResetMessage';
|
||||
import { SessionEstablishedMessage } from './content/SessionEstablishedMessage';
|
||||
import { EndSessionMessage } from './content/EndSessionMessage';
|
||||
import { DeviceLinkMessage } from './content/DeviceLinkMessage';
|
||||
|
||||
export {
|
||||
OutgoingMessage,
|
||||
OutgoingContentMessage,
|
||||
OutgoingDataMessage,
|
||||
Message,
|
||||
OpenGroupMessage,
|
||||
|
||||
ContentMessage,
|
||||
|
||||
// children of ContentMessage
|
||||
DeviceLinkMessage,
|
||||
EndSessionMessage,
|
||||
ReceiptMessage,
|
||||
SessionEstablishedMessage,
|
||||
SessionResetMessage,
|
||||
SyncMessage,
|
||||
TypingMessage,
|
||||
|
||||
|
||||
DataMessage,
|
||||
|
||||
// children of DataMessage
|
||||
ClosedGroupMessage,
|
||||
DeviceUnlinkMessage,
|
||||
GroupInvitationMessage,
|
||||
RegularMessage
|
||||
};
|
||||
|
Loading…
Reference in New Issue