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.
		
		
		
		
		
			
		
			
				
	
	
		
			62 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
| import { SignalService } from '../../../../../../protobuf';
 | |
| import {
 | |
|   MediumGroupMessage,
 | |
|   MediumGroupMessageParams,
 | |
| } from './MediumGroupMessage';
 | |
| import { RatchetState } from '../../../../../medium_group/senderKeys';
 | |
| 
 | |
| interface MediumGroupCreateParams extends MediumGroupMessageParams {
 | |
|   groupSecretKey: Uint8Array;
 | |
|   members: Array<Uint8Array>;
 | |
|   admins: Array<Uint8Array>;
 | |
|   groupName: string;
 | |
|   senderKeys: Array<RatchetState>;
 | |
| }
 | |
| 
 | |
| export class MediumGroupCreateMessage extends MediumGroupMessage {
 | |
|   public readonly groupSecretKey: Uint8Array;
 | |
|   public readonly members: Array<Uint8Array>;
 | |
|   public readonly admins: Array<Uint8Array>;
 | |
|   public readonly groupName: string;
 | |
|   public readonly senderKeys: Array<RatchetState>;
 | |
| 
 | |
|   constructor({
 | |
|     timestamp,
 | |
|     identifier,
 | |
|     groupId,
 | |
|     groupSecretKey,
 | |
|     members,
 | |
|     admins,
 | |
|     groupName,
 | |
|     senderKeys,
 | |
|   }: MediumGroupCreateParams) {
 | |
|     super({ timestamp, identifier, groupId });
 | |
|     this.groupSecretKey = groupSecretKey;
 | |
|     this.members = members;
 | |
|     this.admins = admins;
 | |
|     this.groupName = groupName;
 | |
|     this.senderKeys = senderKeys;
 | |
|   }
 | |
| 
 | |
|   protected mediumGroupContext(): SignalService.MediumGroupUpdate {
 | |
|     const mediumGroupContext = super.mediumGroupContext();
 | |
| 
 | |
|     const senderKeys = this.senderKeys.map(sk => {
 | |
|       return {
 | |
|         chainKey: sk.chainKey,
 | |
|         keyIndex: sk.keyIdx,
 | |
|         publicKey: sk.pubKey,
 | |
|       };
 | |
|     });
 | |
| 
 | |
|     mediumGroupContext.type = SignalService.MediumGroupUpdate.Type.NEW;
 | |
|     mediumGroupContext.groupPrivateKey = this.groupSecretKey;
 | |
|     mediumGroupContext.members = this.members;
 | |
|     mediumGroupContext.admins = this.admins;
 | |
|     mediumGroupContext.name = this.groupName;
 | |
|     mediumGroupContext.senderKeys = senderKeys;
 | |
| 
 | |
|     return mediumGroupContext;
 | |
|   }
 | |
| }
 |