1- import { ENV , MessageType } from '../constants' ;
1+ import { ENV , MessageType , ALPHA_FEATURES } from '../constants' ;
22import {
33 ChatSendOptionsType ,
44 GroupAccess ,
@@ -21,7 +21,6 @@ import {
2121 ManageGroupOptions ,
2222 RemoveFromGroupOptions ,
2323 GetGroupParticipantsOptions ,
24- FeatureTag ,
2524} from './pushAPITypes' ;
2625import * as PUSH_USER from '../user' ;
2726import * as PUSH_CHAT from '../chat' ;
@@ -36,16 +35,22 @@ import { updateGroupConfig } from '../chat/updateGroupConfig';
3635import { PushAPI } from './PushAPI' ;
3736export class Chat {
3837 private userInstance : User ;
38+ private groupScalabilityTag : 'ALPHA' | 'STABLE' ;
3939
4040 constructor (
4141 private account : string ,
4242 private env : ENV ,
43- private featureTag : FeatureTag ,
43+ private alpha : { feature : string [ ] } ,
4444 private decryptedPgpPvtKey ?: string ,
4545 private signer ?: SignerType ,
4646 private progressHook ?: ( progress : ProgressHookType ) => void
4747 ) {
4848 this . userInstance = new User ( this . account , this . env ) ;
49+ this . groupScalabilityTag = this . alpha . feature . includes (
50+ ALPHA_FEATURES . GROUP_SCALABILITY
51+ )
52+ ? 'ALPHA'
53+ : 'STABLE' ;
4954 }
5055
5156 async list (
@@ -165,7 +170,7 @@ export class Chat {
165170 account : this . account ,
166171 signer : this . signer ,
167172 pgpPrivateKey : this . decryptedPgpPvtKey ,
168- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
173+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
169174 } ) ;
170175 }
171176
@@ -299,8 +304,7 @@ export class Chat {
299304 admins : options ?. admins ? options . admins : [ ] ,
300305 } ;
301306 const response = await PUSH_CHAT . createGroupV2 ( groupParams ) ;
302-
303- switch ( this . featureTag ) {
307+ switch ( this . groupScalabilityTag ) {
304308 case 'ALPHA' :
305309 return response ;
306310 case 'STABLE' :
@@ -340,7 +344,7 @@ export class Chat {
340344 } ,
341345
342346 info : async ( chatId : string ) : Promise < GroupDTO | GroupInfoDTO > => {
343- switch ( this . featureTag ) {
347+ switch ( this . groupScalabilityTag ) {
344348 case 'ALPHA' :
345349 return await PUSH_CHAT . getGroupInfo ( {
346350 chatId : chatId ,
@@ -396,7 +400,7 @@ export class Chat {
396400 await updateGroupProfile ( updateGroupProfileOptions ) ;
397401 const response = await updateGroupConfig ( updateGroupConfigOptions ) ;
398402
399- switch ( this . featureTag ) {
403+ switch ( this . groupScalabilityTag ) {
400404 case 'ALPHA' :
401405 return response ;
402406 case 'STABLE' :
@@ -440,7 +444,7 @@ export class Chat {
440444 account : this . account ,
441445 signer : this . signer ,
442446 pgpPrivateKey : this . decryptedPgpPvtKey ,
443- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
447+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
444448 } ) ;
445449 } else {
446450 response = await PUSH_CHAT . addMembers ( {
@@ -450,11 +454,11 @@ export class Chat {
450454 account : this . account ,
451455 signer : this . signer ,
452456 pgpPrivateKey : this . decryptedPgpPvtKey ,
453- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
457+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
454458 } ) ;
455459 }
456460
457- switch ( this . featureTag ) {
461+ switch ( this . groupScalabilityTag ) {
458462 case 'ALPHA' :
459463 return response ;
460464 case 'STABLE' :
@@ -509,7 +513,7 @@ export class Chat {
509513 account : this . account ,
510514 signer : this . signer ,
511515 pgpPrivateKey : this . decryptedPgpPvtKey ,
512- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
516+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
513517 } ) ;
514518 }
515519
@@ -521,10 +525,10 @@ export class Chat {
521525 account : this . account ,
522526 signer : this . signer ,
523527 pgpPrivateKey : this . decryptedPgpPvtKey ,
524- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
528+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
525529 } ) ;
526530 }
527- switch ( this . featureTag ) {
531+ switch ( this . groupScalabilityTag ) {
528532 case 'ALPHA' :
529533 return await PUSH_CHAT . getGroupInfo ( {
530534 chatId : chatId ,
@@ -566,7 +570,7 @@ export class Chat {
566570 account : this . account ,
567571 signer : this . signer ,
568572 pgpPrivateKey : this . decryptedPgpPvtKey ,
569- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
573+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
570574 } ) ;
571575 } ,
572576
@@ -587,7 +591,7 @@ export class Chat {
587591 account : this . account ,
588592 signer : this . signer ,
589593 pgpPrivateKey : this . decryptedPgpPvtKey ,
590- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
594+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
591595 } ) ;
592596 } else if ( ! status . isMember ) {
593597 await PUSH_CHAT . addMembers ( {
@@ -597,10 +601,10 @@ export class Chat {
597601 account : this . account ,
598602 signer : this . signer ,
599603 pgpPrivateKey : this . decryptedPgpPvtKey ,
600- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
604+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
601605 } ) ;
602606 }
603- switch ( this . featureTag ) {
607+ switch ( this . groupScalabilityTag ) {
604608 case 'ALPHA' :
605609 return await PUSH_CHAT . getGroupInfo ( {
606610 chatId : target ,
@@ -635,7 +639,7 @@ export class Chat {
635639 account : this . account ,
636640 signer : this . signer ,
637641 pgpPrivateKey : this . decryptedPgpPvtKey ,
638- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
642+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
639643 } ) ;
640644 } else {
641645 response = await PUSH_CHAT . removeMembers ( {
@@ -645,11 +649,11 @@ export class Chat {
645649 account : this . account ,
646650 signer : this . signer ,
647651 pgpPrivateKey : this . decryptedPgpPvtKey ,
648- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
652+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
649653 } ) ;
650654 }
651655
652- switch ( this . featureTag ) {
656+ switch ( this . groupScalabilityTag ) {
653657 case 'ALPHA' :
654658 return response ;
655659 case 'STABLE' :
0 commit comments