add verifierSyncMesage and syncReadMessages
parent
e38ea17e21
commit
d114b6c130
@ -0,0 +1,30 @@
|
||||
import { SyncMessage } from './SyncMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
import { MessageParams } from '../../Message';
|
||||
|
||||
interface SyncReadMessageParams extends MessageParams {
|
||||
readMessages: any;
|
||||
}
|
||||
|
||||
export abstract class SyncReadMessage extends SyncMessage {
|
||||
public readonly readMessages: any;
|
||||
|
||||
|
||||
constructor(params: SyncReadMessageParams) {
|
||||
super({ timestamp: params.timestamp, identifier: params.identifier });
|
||||
this.readMessages = params.readMessages;
|
||||
}
|
||||
|
||||
protected syncProto(): SignalService.SyncMessage {
|
||||
const syncMessage = super.syncProto();
|
||||
syncMessage.read = [];
|
||||
for (const read of this.readMessages) {
|
||||
const readMessage = new SignalService.SyncMessage.Read();
|
||||
read.timestamp = readMessage.timestamp;
|
||||
read.sender = readMessage.sender;
|
||||
syncMessage.read.push(readMessage);
|
||||
}
|
||||
|
||||
return syncMessage;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
import { SyncMessage } from './SyncMessage';
|
||||
import { SignalService } from '../../../../../protobuf';
|
||||
import { MessageParams } from '../../Message';
|
||||
import { PubKey } from '../../../../types';
|
||||
|
||||
interface VerifiedSyncMessageParams extends MessageParams {
|
||||
padding: Buffer;
|
||||
identityKey: Uint8Array;
|
||||
destination: PubKey;
|
||||
state: SignalService.Verified.State;
|
||||
}
|
||||
|
||||
export abstract class VerifiedSyncMessage extends SyncMessage {
|
||||
public readonly state: SignalService.Verified.State;
|
||||
public readonly destination: PubKey;
|
||||
public readonly identityKey: Uint8Array;
|
||||
public readonly padding: Buffer;
|
||||
|
||||
constructor(params: VerifiedSyncMessageParams) {
|
||||
super({ timestamp: params.timestamp, identifier: params.identifier });
|
||||
this.state = params.state;
|
||||
this.destination = params.destination;
|
||||
this.identityKey = params.identityKey;
|
||||
this.padding = params.padding;
|
||||
}
|
||||
|
||||
protected syncProto(): SignalService.SyncMessage {
|
||||
const syncMessage = super.syncProto();
|
||||
syncMessage.verified = new SignalService.Verified();
|
||||
syncMessage.verified.state = this.state;
|
||||
syncMessage.verified.destination = this.destination.key;
|
||||
syncMessage.verified.identityKey = this.identityKey;
|
||||
syncMessage.verified.nullMessage = this.padding;
|
||||
|
||||
return syncMessage;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue