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.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
|
5 years ago
|
import { DataMessage } from '../DataMessage';
|
||
|
|
import { MessageParams } from '../../../Message';
|
||
|
|
import { PubKey } from '../../../../../types';
|
||
|
5 years ago
|
import { Constants } from '../../../../..';
|
||
|
5 years ago
|
import { SignalService } from '../../../../../../protobuf';
|
||
|
5 years ago
|
|
||
|
5 years ago
|
export interface ClosedGroupV2MessageParams extends MessageParams {
|
||
|
5 years ago
|
groupId: string | PubKey;
|
||
|
5 years ago
|
expireTimer: number;
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
export abstract class ClosedGroupV2Message extends DataMessage {
|
||
|
5 years ago
|
public readonly groupId: PubKey;
|
||
|
5 years ago
|
public readonly expireTimer: number;
|
||
|
5 years ago
|
|
||
|
5 years ago
|
constructor(params: ClosedGroupV2MessageParams) {
|
||
|
5 years ago
|
super({
|
||
|
|
timestamp: params.timestamp,
|
||
|
|
identifier: params.identifier,
|
||
|
|
});
|
||
|
5 years ago
|
|
||
|
5 years ago
|
this.groupId = PubKey.cast(params.groupId);
|
||
|
5 years ago
|
this.expireTimer = params.expireTimer;
|
||
|
|
if (!this.groupId || this.groupId.key.length === 0) {
|
||
|
|
throw new Error('groupId must be set');
|
||
|
|
}
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
|
public ttl(): number {
|
||
|
5 years ago
|
return Constants.TTL_DEFAULT.REGULAR_MESSAGE;
|
||
|
5 years ago
|
}
|
||
|
|
|
||
|
5 years ago
|
public dataProto(): SignalService.DataMessage {
|
||
|
5 years ago
|
const dataMessage = new SignalService.DataMessage();
|
||
|
|
|
||
|
5 years ago
|
dataMessage.closedGroupUpdateV2 = new SignalService.ClosedGroupUpdateV2();
|
||
|
|
dataMessage.expireTimer = this.expireTimer;
|
||
|
5 years ago
|
|
||
|
5 years ago
|
return dataMessage;
|
||
|
5 years ago
|
}
|
||
|
5 years ago
|
}
|