|
|
@ -1,21 +1,23 @@
|
|
|
|
import { DataMessage } from '../DataMessage';
|
|
|
|
import { DataMessage } from '../DataMessage';
|
|
|
|
import { SignalService } from '../../../../../../protobuf';
|
|
|
|
import { SignalService } from '../../../../../../protobuf';
|
|
|
|
import { MessageParams } from '../../../Message';
|
|
|
|
import { MessageParams } from '../../../Message';
|
|
|
|
|
|
|
|
import { PubKey } from '../../../../../types';
|
|
|
|
import { StringUtils } from '../../../../../utils';
|
|
|
|
import { StringUtils } from '../../../../../utils';
|
|
|
|
|
|
|
|
|
|
|
|
export interface ClosedGroupMessageParams extends MessageParams {
|
|
|
|
export interface ClosedGroupMessageParams extends MessageParams {
|
|
|
|
groupId: string;
|
|
|
|
groupId: string | PubKey;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export abstract class ClosedGroupMessage extends DataMessage {
|
|
|
|
export abstract class ClosedGroupMessage extends DataMessage {
|
|
|
|
public readonly groupId: string;
|
|
|
|
public readonly groupId: PubKey;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(params: ClosedGroupMessageParams) {
|
|
|
|
constructor(params: ClosedGroupMessageParams) {
|
|
|
|
super({
|
|
|
|
super({
|
|
|
|
timestamp: params.timestamp,
|
|
|
|
timestamp: params.timestamp,
|
|
|
|
identifier: params.identifier,
|
|
|
|
identifier: params.identifier,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.groupId = params.groupId;
|
|
|
|
const { groupId } = params;
|
|
|
|
|
|
|
|
this.groupId = typeof groupId === 'string' ? new PubKey(groupId) : groupId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ttl(): number {
|
|
|
|
public ttl(): number {
|
|
|
@ -25,7 +27,7 @@ export abstract class ClosedGroupMessage extends DataMessage {
|
|
|
|
protected abstract groupContextType(): SignalService.GroupContext.Type;
|
|
|
|
protected abstract groupContextType(): SignalService.GroupContext.Type;
|
|
|
|
|
|
|
|
|
|
|
|
protected groupContext(): SignalService.GroupContext {
|
|
|
|
protected groupContext(): SignalService.GroupContext {
|
|
|
|
const id = new Uint8Array(StringUtils.encode(this.groupId, 'utf8'));
|
|
|
|
const id = new Uint8Array(StringUtils.encode(this.groupId.key, 'utf8'));
|
|
|
|
const type = this.groupContextType();
|
|
|
|
const type = this.groupContextType();
|
|
|
|
|
|
|
|
|
|
|
|
return new SignalService.GroupContext({ id, type });
|
|
|
|
return new SignalService.GroupContext({ id, type });
|
|
|
|