updateMediumGroup replaced with new pipeline
parent
a43abfd436
commit
39bad87a18
@ -0,0 +1,49 @@
|
||||
import { SignalService } from '../../../../../../protobuf';
|
||||
import {
|
||||
MediumGroupResponseKeysMessage,
|
||||
MediumGroupResponseKeysParams,
|
||||
} from './MediumGroupResponseKeysMessage';
|
||||
|
||||
interface MediumGroupCreateParams extends MediumGroupResponseKeysParams {
|
||||
groupSecretKey: Uint8Array;
|
||||
members: Array<Uint8Array>;
|
||||
admins: Array<string>;
|
||||
groupName: string;
|
||||
}
|
||||
|
||||
export abstract class MediumGroupCreateMessage extends MediumGroupResponseKeysMessage {
|
||||
public readonly groupSecretKey: Uint8Array;
|
||||
public readonly members: Array<Uint8Array>;
|
||||
public readonly admins: Array<string>;
|
||||
public readonly groupName: string;
|
||||
|
||||
constructor({
|
||||
timestamp,
|
||||
identifier,
|
||||
chainKey,
|
||||
keyIdx,
|
||||
groupId,
|
||||
groupSecretKey,
|
||||
members,
|
||||
admins,
|
||||
groupName,
|
||||
}: MediumGroupCreateParams) {
|
||||
super({ timestamp, identifier, groupId, chainKey, keyIdx });
|
||||
this.groupSecretKey = groupSecretKey;
|
||||
this.members = members;
|
||||
this.admins = admins;
|
||||
this.groupName = groupName;
|
||||
}
|
||||
|
||||
protected mediumGroupContext(): SignalService.MediumGroupUpdate {
|
||||
const mediumGroupContext = super.mediumGroupContext();
|
||||
|
||||
mediumGroupContext.type = SignalService.MediumGroupUpdate.Type.NEW_GROUP;
|
||||
mediumGroupContext.groupSecretKey = this.groupSecretKey;
|
||||
mediumGroupContext.members = this.members;
|
||||
mediumGroupContext.admins = this.admins;
|
||||
mediumGroupContext.groupName = this.groupName;
|
||||
|
||||
return mediumGroupContext;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
import { DataMessage } from '../DataMessage';
|
||||
import { SignalService } from '../../../../../../protobuf';
|
||||
import { MessageParams } from '../../../Message';
|
||||
import { PubKey } from '../../../../../types';
|
||||
import { StringUtils } from '../../../../../utils';
|
||||
|
||||
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 this.getDefaultTTL();
|
||||
}
|
||||
|
||||
protected mediumGroupContext(): SignalService.MediumGroupUpdate {
|
||||
return new SignalService.MediumGroupUpdate({ groupId: this.groupId.key });
|
||||
}
|
||||
|
||||
protected dataProto(): SignalService.DataMessage {
|
||||
const dataMessage = new SignalService.DataMessage();
|
||||
dataMessage.mediumGroupUpdate = this.mediumGroupContext();
|
||||
|
||||
return dataMessage;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { SignalService } from '../../../../../../protobuf';
|
||||
import { MediumGroupMessage } from '.';
|
||||
|
||||
export class MediumGroupRequestKeysMessage extends MediumGroupMessage {
|
||||
protected mediumGroupContext(): SignalService.MediumGroupUpdate {
|
||||
const mediumGroupContext = super.mediumGroupContext();
|
||||
|
||||
mediumGroupContext.type =
|
||||
SignalService.MediumGroupUpdate.Type.SENDER_KEY_REQUEST;
|
||||
|
||||
return mediumGroupContext;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
import { SignalService } from '../../../../../../protobuf';
|
||||
import { MediumGroupMessage, MediumGroupMessageParams } from '.';
|
||||
|
||||
export interface MediumGroupResponseKeysParams
|
||||
extends MediumGroupMessageParams {
|
||||
chainKey: string;
|
||||
keyIdx: number;
|
||||
}
|
||||
|
||||
export class MediumGroupResponseKeysMessage extends MediumGroupMessage {
|
||||
public readonly chainKey: string;
|
||||
public readonly keyIdx: number;
|
||||
|
||||
constructor({
|
||||
timestamp,
|
||||
identifier,
|
||||
groupId,
|
||||
chainKey,
|
||||
keyIdx,
|
||||
}: MediumGroupResponseKeysParams) {
|
||||
super({ timestamp, identifier, groupId });
|
||||
this.chainKey = chainKey;
|
||||
this.keyIdx = keyIdx;
|
||||
}
|
||||
|
||||
protected mediumGroupContext(): SignalService.MediumGroupUpdate {
|
||||
const mediumGroupContext = super.mediumGroupContext();
|
||||
|
||||
mediumGroupContext.type = SignalService.MediumGroupUpdate.Type.SENDER_KEY;
|
||||
mediumGroupContext.senderKey = new SignalService.SenderKey({
|
||||
chainKey: this.chainKey,
|
||||
keyIdx: this.keyIdx,
|
||||
});
|
||||
|
||||
return mediumGroupContext;
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
export * from './MediumGroupMessage';
|
||||
export * from './MediumGroupRequestKeysMessage';
|
||||
export * from './MediumGroupResponseKeysMessage';
|
||||
export * from './MediumGroupCreateMessage';
|
Loading…
Reference in New Issue