From 2d4e9455c2d11fa8a4dc3bfcab357a09a02de2de Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 14 Jul 2020 13:31:51 +1000 Subject: [PATCH] asd --- ts/receiver/receiver.ts | 1 + ts/session/types/ClosedGroup.ts | 140 -------------------------------- 2 files changed, 1 insertion(+), 140 deletions(-) delete mode 100644 ts/session/types/ClosedGroup.ts diff --git a/ts/receiver/receiver.ts b/ts/receiver/receiver.ts index 9cea77c21..911b78516 100644 --- a/ts/receiver/receiver.ts +++ b/ts/receiver/receiver.ts @@ -14,6 +14,7 @@ import { onError } from './errors'; import { handleContentMessage, innerHandleContentMessage, + isBlocked, onDeliveryReceipt, } from './contentMessage'; import _ from 'lodash'; diff --git a/ts/session/types/ClosedGroup.ts b/ts/session/types/ClosedGroup.ts deleted file mode 100644 index 711cca5af..000000000 --- a/ts/session/types/ClosedGroup.ts +++ /dev/null @@ -1,140 +0,0 @@ - - -// This is the (Closed | Medium) Group equivalent to the SessionGroup type. - -import { PubKey } from '.'; -import { UserUtil } from '../../util'; -import { MultiDeviceProtocol } from '../protocols'; - -enum ClosedGroupType { - SMALL, - MEDIUM, -} - -interface ClosedGroupParams { - id: PubKey; - type: ClosedGroupType; - admins: Array; - members: Array; -} - -class ClosedGroup { - public readonly id: PubKey; - public readonly type: ClosedGroupType; - public admins: Array; - public members: Array; - - constructor(params: ClosedGroupParams) { - this.id = params.id; - this.type = params.type; - this.admins = params.admins; - this.members = params.members; - } - - public static async create(name: string, type: ClosedGroupType, members: Array, onSuccess: any): Promise { - const { ConversationController, StringView, libsignal } = window; - - // Manage small group size - // TODO - Eventually we want to default to MediumGroups and abandon regular groups - // once medium groups have been thoroughly tested - if ( - type === ClosedGroupType.SMALL && - members.length === 0 || - members.length >= window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT - ) { - console.warn(`ClosedGroup create: Cannot create a small group with more than ${window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT} members`); - } - - const user = await UserUtil.getCurrentDevicePubKey(); - if (!user) { - return; - } - - const primaryDevice = await MultiDeviceProtocol.getPrimaryDevice(user); - const allMembers = [primaryDevice, ...members]; - - // Create Group Identity - const identityKeys = await libsignal.KeyHelper.generateIdentityKeyPair(); - - const keypair = await libsignal.KeyHelper.generateIdentityKeyPair(); - const id = StringView.arrayBufferToHex(keypair.pubKey); - - // Medium groups - const senderKey = (type === ClosedGroupType.MEDIUM) - ? await window.SenderKeyAPI.createSenderKeyForGroup(id, primaryDevice) - : undefined; - - const secretKey = (type === ClosedGroupType.MEDIUM) - ? identityKeys.privKey - : undefined; - - const groupSecretKeyHex = StringView.arrayBufferToHex( - identityKeys.privKey - ); - - const ev = { - groupDetails: { - id, - name, - members: allMembers, - recipients: allMembers, - active: true, - expireTimer: 0, - avatar: '', - secretKey, - senderKey, - is_medium_group: type === ClosedGroupType.MEDIUM, - }, - confirm: () => null, - }; - - await window.NewReceiver.onGroupReceived(ev); - } - - public static get(id: PubKey): ClosedGroup | undefined { - // Gets a closed group from its group id - return; - } - - public update(): Promise> { - // - } - - public updateMembers(): Promise> { - // Abstraction on update - - // Update the conversation and this object - } - - public async removeMembers(): Promise> { - // Abstraction on updateMembers - } - - public async addMembers(): Promise> { - // Abstraction on updateMembers - } - - public async setName(): Promise { - // Set or update the name of the group - } - - public leave() { - // Leave group - } - - - // static from(groupId) { - // // Returns a new instance from a groupId if it's valid - // const groupIdAsPubKey = groupId instanceof _1.PubKey - // ? groupId - // : _1.PubKey.from(groupId); - // openGroupParams = { - // groupId: - // }; - // return new SessionGroup(openGroupParams); - // } - - -} - -