You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { DataMessage } from '../DataMessage';
|
|
import { SignalService } from '../../../../../../protobuf';
|
|
import { MessageParams } from '../../../Message';
|
|
import { PubKey } from '../../../../../types';
|
|
import { StringUtils } from '../../../../../utils';
|
|
import { Constants } from '../../../../..';
|
|
|
|
export interface RatchetKey {
|
|
chainKey: Uint8Array;
|
|
keyIdx: number;
|
|
pubKey: Uint8Array;
|
|
}
|
|
|
|
export interface MediumGroupMessageParams extends MessageParams {
|
|
groupId: string | PubKey;
|
|
}
|
|
|
|
export abstract class MediumGroupMessage extends DataMessage {
|
|
public readonly groupId: PubKey;
|
|
|
|
constructor(params: MediumGroupMessageParams) {
|
|
super({
|
|
timestamp: params.timestamp,
|
|
identifier: params.identifier,
|
|
});
|
|
this.groupId = PubKey.cast(params.groupId);
|
|
}
|
|
|
|
public ttl(): number {
|
|
return Constants.TTL_DEFAULT.REGULAR_MESSAGE;
|
|
}
|
|
|
|
public dataProto(): SignalService.DataMessage {
|
|
const dataMessage = new SignalService.DataMessage();
|
|
dataMessage.mediumGroupUpdate = this.mediumGroupContext();
|
|
|
|
return dataMessage;
|
|
}
|
|
|
|
protected mediumGroupContext(): SignalService.MediumGroupUpdate {
|
|
const groupPublicKey = new Uint8Array(
|
|
StringUtils.encode(this.groupId.key, 'hex')
|
|
);
|
|
return new SignalService.MediumGroupUpdate({ groupPublicKey });
|
|
}
|
|
}
|