1
- import { ENV , MessageType } from '../constants' ;
1
+ import { ENV , MessageType , ALPHA_FEATURES } from '../constants' ;
2
2
import {
3
3
ChatSendOptionsType ,
4
4
GroupAccess ,
@@ -21,7 +21,6 @@ import {
21
21
ManageGroupOptions ,
22
22
RemoveFromGroupOptions ,
23
23
GetGroupParticipantsOptions ,
24
- FeatureTag ,
25
24
} from './pushAPITypes' ;
26
25
import * as PUSH_USER from '../user' ;
27
26
import * as PUSH_CHAT from '../chat' ;
@@ -36,16 +35,22 @@ import { updateGroupConfig } from '../chat/updateGroupConfig';
36
35
import { PushAPI } from './PushAPI' ;
37
36
export class Chat {
38
37
private userInstance : User ;
38
+ private groupScalabilityTag : 'ALPHA' | 'STABLE' ;
39
39
40
40
constructor (
41
41
private account : string ,
42
42
private env : ENV ,
43
- private featureTag : FeatureTag ,
43
+ private alpha : { feature : string [ ] } ,
44
44
private decryptedPgpPvtKey ?: string ,
45
45
private signer ?: SignerType ,
46
46
private progressHook ?: ( progress : ProgressHookType ) => void
47
47
) {
48
48
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' ;
49
54
}
50
55
51
56
async list (
@@ -165,7 +170,7 @@ export class Chat {
165
170
account : this . account ,
166
171
signer : this . signer ,
167
172
pgpPrivateKey : this . decryptedPgpPvtKey ,
168
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
173
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
169
174
} ) ;
170
175
}
171
176
@@ -299,8 +304,7 @@ export class Chat {
299
304
admins : options ?. admins ? options . admins : [ ] ,
300
305
} ;
301
306
const response = await PUSH_CHAT . createGroupV2 ( groupParams ) ;
302
-
303
- switch ( this . featureTag ) {
307
+ switch ( this . groupScalabilityTag ) {
304
308
case 'ALPHA' :
305
309
return response ;
306
310
case 'STABLE' :
@@ -340,7 +344,7 @@ export class Chat {
340
344
} ,
341
345
342
346
info : async ( chatId : string ) : Promise < GroupDTO | GroupInfoDTO > => {
343
- switch ( this . featureTag ) {
347
+ switch ( this . groupScalabilityTag ) {
344
348
case 'ALPHA' :
345
349
return await PUSH_CHAT . getGroupInfo ( {
346
350
chatId : chatId ,
@@ -396,7 +400,7 @@ export class Chat {
396
400
await updateGroupProfile ( updateGroupProfileOptions ) ;
397
401
const response = await updateGroupConfig ( updateGroupConfigOptions ) ;
398
402
399
- switch ( this . featureTag ) {
403
+ switch ( this . groupScalabilityTag ) {
400
404
case 'ALPHA' :
401
405
return response ;
402
406
case 'STABLE' :
@@ -440,7 +444,7 @@ export class Chat {
440
444
account : this . account ,
441
445
signer : this . signer ,
442
446
pgpPrivateKey : this . decryptedPgpPvtKey ,
443
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
447
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
444
448
} ) ;
445
449
} else {
446
450
response = await PUSH_CHAT . addMembers ( {
@@ -450,11 +454,11 @@ export class Chat {
450
454
account : this . account ,
451
455
signer : this . signer ,
452
456
pgpPrivateKey : this . decryptedPgpPvtKey ,
453
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
457
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
454
458
} ) ;
455
459
}
456
460
457
- switch ( this . featureTag ) {
461
+ switch ( this . groupScalabilityTag ) {
458
462
case 'ALPHA' :
459
463
return response ;
460
464
case 'STABLE' :
@@ -509,7 +513,7 @@ export class Chat {
509
513
account : this . account ,
510
514
signer : this . signer ,
511
515
pgpPrivateKey : this . decryptedPgpPvtKey ,
512
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
516
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
513
517
} ) ;
514
518
}
515
519
@@ -521,10 +525,10 @@ export class Chat {
521
525
account : this . account ,
522
526
signer : this . signer ,
523
527
pgpPrivateKey : this . decryptedPgpPvtKey ,
524
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
528
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
525
529
} ) ;
526
530
}
527
- switch ( this . featureTag ) {
531
+ switch ( this . groupScalabilityTag ) {
528
532
case 'ALPHA' :
529
533
return await PUSH_CHAT . getGroupInfo ( {
530
534
chatId : chatId ,
@@ -566,7 +570,7 @@ export class Chat {
566
570
account : this . account ,
567
571
signer : this . signer ,
568
572
pgpPrivateKey : this . decryptedPgpPvtKey ,
569
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
573
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
570
574
} ) ;
571
575
} ,
572
576
@@ -587,7 +591,7 @@ export class Chat {
587
591
account : this . account ,
588
592
signer : this . signer ,
589
593
pgpPrivateKey : this . decryptedPgpPvtKey ,
590
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
594
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
591
595
} ) ;
592
596
} else if ( ! status . isMember ) {
593
597
await PUSH_CHAT . addMembers ( {
@@ -597,10 +601,10 @@ export class Chat {
597
601
account : this . account ,
598
602
signer : this . signer ,
599
603
pgpPrivateKey : this . decryptedPgpPvtKey ,
600
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
604
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
601
605
} ) ;
602
606
}
603
- switch ( this . featureTag ) {
607
+ switch ( this . groupScalabilityTag ) {
604
608
case 'ALPHA' :
605
609
return await PUSH_CHAT . getGroupInfo ( {
606
610
chatId : target ,
@@ -635,7 +639,7 @@ export class Chat {
635
639
account : this . account ,
636
640
signer : this . signer ,
637
641
pgpPrivateKey : this . decryptedPgpPvtKey ,
638
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
642
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
639
643
} ) ;
640
644
} else {
641
645
response = await PUSH_CHAT . removeMembers ( {
@@ -645,11 +649,11 @@ export class Chat {
645
649
account : this . account ,
646
650
signer : this . signer ,
647
651
pgpPrivateKey : this . decryptedPgpPvtKey ,
648
- overrideSecretKeyGeneration : this . featureTag !== 'ALPHA' ,
652
+ overrideSecretKeyGeneration : this . groupScalabilityTag !== 'ALPHA' ,
649
653
} ) ;
650
654
}
651
655
652
- switch ( this . featureTag ) {
656
+ switch ( this . groupScalabilityTag ) {
653
657
case 'ALPHA' :
654
658
return response ;
655
659
case 'STABLE' :
0 commit comments