mezon-js 2.8.67 → 2.8.69
Sign up to get free protection for your applications and to get access to all the features.
- package/api.gen.ts +245 -54
- package/client.ts +2317 -1160
- package/dist/api.gen.d.ts +29 -32
- package/dist/client.d.ts +6 -1
- package/dist/mezon-js.cjs.js +364 -38
- package/dist/mezon-js.esm.mjs +364 -38
- package/package.json +1 -1
package/client.ts
CHANGED
@@ -96,6 +96,10 @@ import {
|
|
96
96
|
ApiAppList,
|
97
97
|
ApiApp,
|
98
98
|
MezonUpdateAppBody,
|
99
|
+
ApiSystemMessagesList,
|
100
|
+
ApiSystemMessage,
|
101
|
+
ApiSystemMessageRequest,
|
102
|
+
MezonUpdateSystemMessageBody,
|
99
103
|
} from "./api.gen";
|
100
104
|
|
101
105
|
import { Session } from "./session";
|
@@ -117,13 +121,13 @@ export enum ChannelType {
|
|
117
121
|
CHANNEL_TYPE_ANNOUNCEMENT = 6,
|
118
122
|
CHANNEL_TYPE_THREAD = 7,
|
119
123
|
}
|
120
|
-
export enum ChannelStreamMode {
|
124
|
+
export enum ChannelStreamMode {
|
121
125
|
STREAM_MODE_CHANNEL = 2,
|
122
126
|
STREAM_MODE_GROUP = 3,
|
123
127
|
STREAM_MODE_DM = 4,
|
124
128
|
}
|
125
129
|
|
126
|
-
export enum NotificationType {
|
130
|
+
export enum NotificationType {
|
127
131
|
ALL_MESSAGE = 1,
|
128
132
|
MENTION_MESSAGE = 2,
|
129
133
|
NOTHING_MESSAGE = 3,
|
@@ -444,9 +448,7 @@ export interface ApiUpdateRoleRequest {
|
|
444
448
|
role_icon: string | undefined;
|
445
449
|
description: string | undefined;
|
446
450
|
display_online: number | undefined;
|
447
|
-
allow_mention:
|
448
|
-
| number
|
449
|
-
| undefined;
|
451
|
+
allow_mention: number | undefined;
|
450
452
|
/** The users to add. */
|
451
453
|
add_user_ids: string[];
|
452
454
|
/** The permissions to add. */
|
@@ -456,12 +458,11 @@ export interface ApiUpdateRoleRequest {
|
|
456
458
|
/** The permissions to remove. */
|
457
459
|
remove_permission_ids: string[];
|
458
460
|
//
|
459
|
-
clan_id: string
|
461
|
+
clan_id: string;
|
460
462
|
}
|
461
463
|
|
462
464
|
/** A client for Mezon server. */
|
463
465
|
export class Client {
|
464
|
-
|
465
466
|
/** The expired timespan used to check session lifetime. */
|
466
467
|
public expiredTimespanMs = DEFAULT_EXPIRED_TIMESPAN_MS;
|
467
468
|
|
@@ -469,116 +470,224 @@ export class Client {
|
|
469
470
|
private readonly apiClient: MezonApi;
|
470
471
|
|
471
472
|
constructor(
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
473
|
+
readonly serverkey = DEFAULT_SERVER_KEY,
|
474
|
+
readonly host = DEFAULT_HOST,
|
475
|
+
readonly port = DEFAULT_PORT,
|
476
|
+
readonly useSSL = false,
|
477
|
+
readonly timeout = DEFAULT_TIMEOUT_MS,
|
478
|
+
readonly autoRefreshSession = true
|
479
|
+
) {
|
480
|
+
const scheme = useSSL ? "https://" : "http://";
|
479
481
|
const basePath = `${scheme}${host}:${port}`;
|
480
482
|
|
481
483
|
this.apiClient = new MezonApi(serverkey, basePath, timeout);
|
482
484
|
}
|
483
485
|
|
484
486
|
/** Add users to a channel, or accept their join requests. */
|
485
|
-
async addChannelUsers(
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
487
|
+
async addChannelUsers(
|
488
|
+
session: Session,
|
489
|
+
channelId: string,
|
490
|
+
ids?: Array<string>
|
491
|
+
): Promise<boolean> {
|
492
|
+
if (
|
493
|
+
this.autoRefreshSession &&
|
494
|
+
session.refresh_token &&
|
495
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
496
|
+
) {
|
497
|
+
await this.sessionRefresh(session);
|
490
498
|
}
|
491
499
|
|
492
|
-
return this.apiClient
|
493
|
-
|
494
|
-
|
500
|
+
return this.apiClient
|
501
|
+
.addChannelUsers(session.token, channelId, ids)
|
502
|
+
.then((response: any) => {
|
503
|
+
return response !== undefined;
|
504
|
+
});
|
495
505
|
}
|
496
506
|
|
497
507
|
/** Add friends by ID or username to a user's account. */
|
498
|
-
async addFriends(
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
508
|
+
async addFriends(
|
509
|
+
session: Session,
|
510
|
+
ids?: Array<string>,
|
511
|
+
usernames?: Array<string>
|
512
|
+
): Promise<boolean> {
|
513
|
+
if (
|
514
|
+
this.autoRefreshSession &&
|
515
|
+
session.refresh_token &&
|
516
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
517
|
+
) {
|
518
|
+
await this.sessionRefresh(session);
|
503
519
|
}
|
504
520
|
|
505
|
-
return this.apiClient
|
506
|
-
|
507
|
-
|
521
|
+
return this.apiClient
|
522
|
+
.addFriends(session.token, ids, usernames)
|
523
|
+
.then((response: any) => {
|
524
|
+
return response !== undefined;
|
525
|
+
});
|
508
526
|
}
|
509
527
|
|
510
528
|
/** Authenticate a user with an Apple ID against the server. */
|
511
|
-
async authenticateApple(
|
512
|
-
|
529
|
+
async authenticateApple(
|
530
|
+
token: string,
|
531
|
+
create?: boolean,
|
532
|
+
username?: string,
|
533
|
+
vars: Record<string, string> = {},
|
534
|
+
options: any = {}
|
535
|
+
) {
|
513
536
|
const request = {
|
514
|
-
|
515
|
-
|
537
|
+
token: token,
|
538
|
+
vars: vars,
|
516
539
|
};
|
517
540
|
|
518
|
-
return this.apiClient
|
519
|
-
|
520
|
-
|
541
|
+
return this.apiClient
|
542
|
+
.authenticateApple(this.serverkey, "", request, create, username, options)
|
543
|
+
.then((apiSession: ApiSession) => {
|
544
|
+
return new Session(
|
545
|
+
apiSession.token || "",
|
546
|
+
apiSession.refresh_token || "",
|
547
|
+
apiSession.created || false
|
548
|
+
);
|
549
|
+
});
|
521
550
|
}
|
522
551
|
|
523
552
|
/** Authenticate a user with a custom id against the server. */
|
524
|
-
authenticateCustom(
|
553
|
+
authenticateCustom(
|
554
|
+
id: string,
|
555
|
+
create?: boolean,
|
556
|
+
username?: string,
|
557
|
+
vars: Record<string, string> = {},
|
558
|
+
options: any = {}
|
559
|
+
): Promise<Session> {
|
525
560
|
const request = {
|
526
|
-
|
527
|
-
|
561
|
+
id: id,
|
562
|
+
vars: vars,
|
528
563
|
};
|
529
|
-
return this.apiClient
|
530
|
-
|
531
|
-
|
564
|
+
return this.apiClient
|
565
|
+
.authenticateCustom(
|
566
|
+
this.serverkey,
|
567
|
+
"",
|
568
|
+
request,
|
569
|
+
create,
|
570
|
+
username,
|
571
|
+
options
|
572
|
+
)
|
573
|
+
.then((apiSession: ApiSession) => {
|
574
|
+
return new Session(
|
575
|
+
apiSession.token || "",
|
576
|
+
apiSession.refresh_token || "",
|
577
|
+
apiSession.created || false
|
578
|
+
);
|
579
|
+
});
|
532
580
|
}
|
533
581
|
|
534
582
|
/** Authenticate a user with a device id against the server. */
|
535
|
-
authenticateDevice(
|
583
|
+
authenticateDevice(
|
584
|
+
id: string,
|
585
|
+
create?: boolean,
|
586
|
+
username?: string,
|
587
|
+
vars?: Record<string, string>
|
588
|
+
): Promise<Session> {
|
536
589
|
const request = {
|
537
|
-
|
538
|
-
|
590
|
+
id: id,
|
591
|
+
vars: vars,
|
539
592
|
};
|
540
593
|
|
541
|
-
return this.apiClient
|
542
|
-
|
543
|
-
|
594
|
+
return this.apiClient
|
595
|
+
.authenticateDevice(this.serverkey, "", request, create, username)
|
596
|
+
.then((apiSession: ApiSession) => {
|
597
|
+
return new Session(
|
598
|
+
apiSession.token || "",
|
599
|
+
apiSession.refresh_token || "",
|
600
|
+
apiSession.created || false
|
601
|
+
);
|
602
|
+
});
|
544
603
|
}
|
545
604
|
|
546
605
|
/** Authenticate a user with an email+password against the server. */
|
547
|
-
authenticateEmail(
|
606
|
+
authenticateEmail(
|
607
|
+
email: string,
|
608
|
+
password: string,
|
609
|
+
username?: string,
|
610
|
+
vars?: Record<string, string>
|
611
|
+
): Promise<Session> {
|
548
612
|
const request = {
|
549
|
-
|
550
|
-
|
551
|
-
|
613
|
+
email: email,
|
614
|
+
password: password,
|
615
|
+
vars: vars,
|
552
616
|
};
|
553
617
|
|
554
|
-
return this.apiClient
|
555
|
-
|
556
|
-
|
618
|
+
return this.apiClient
|
619
|
+
.authenticateEmail(this.serverkey, "", request, username)
|
620
|
+
.then((apiSession: ApiSession) => {
|
621
|
+
return new Session(
|
622
|
+
apiSession.token || "",
|
623
|
+
apiSession.refresh_token || "",
|
624
|
+
apiSession.created || false
|
625
|
+
);
|
626
|
+
});
|
557
627
|
}
|
558
628
|
|
559
629
|
/** Authenticate a user with a Facebook Instant Game token against the server. */
|
560
|
-
authenticateFacebookInstantGame(
|
630
|
+
authenticateFacebookInstantGame(
|
631
|
+
signedPlayerInfo: string,
|
632
|
+
create?: boolean,
|
633
|
+
username?: string,
|
634
|
+
vars?: Record<string, string>,
|
635
|
+
options: any = {}
|
636
|
+
): Promise<Session> {
|
561
637
|
const request = {
|
562
|
-
|
563
|
-
|
638
|
+
signed_player_info: signedPlayerInfo,
|
639
|
+
vars: vars,
|
564
640
|
};
|
565
641
|
|
566
|
-
return this.apiClient
|
567
|
-
|
568
|
-
|
642
|
+
return this.apiClient
|
643
|
+
.authenticateFacebookInstantGame(
|
644
|
+
this.serverkey,
|
645
|
+
"",
|
646
|
+
{ signed_player_info: request.signed_player_info, vars: request.vars },
|
647
|
+
create,
|
648
|
+
username,
|
649
|
+
options
|
650
|
+
)
|
651
|
+
.then((apiSession: ApiSession) => {
|
652
|
+
return new Session(
|
653
|
+
apiSession.token || "",
|
654
|
+
apiSession.refresh_token || "",
|
655
|
+
apiSession.created || false
|
656
|
+
);
|
569
657
|
});
|
570
658
|
}
|
571
659
|
|
572
660
|
/** Authenticate a user with a Facebook OAuth token against the server. */
|
573
|
-
authenticateFacebook(
|
661
|
+
authenticateFacebook(
|
662
|
+
token: string,
|
663
|
+
create?: boolean,
|
664
|
+
username?: string,
|
665
|
+
sync?: boolean,
|
666
|
+
vars?: Record<string, string>,
|
667
|
+
options: any = {}
|
668
|
+
): Promise<Session> {
|
574
669
|
const request = {
|
575
|
-
|
576
|
-
|
670
|
+
token: token,
|
671
|
+
vars: vars,
|
577
672
|
};
|
578
673
|
|
579
|
-
return this.apiClient
|
580
|
-
|
581
|
-
|
674
|
+
return this.apiClient
|
675
|
+
.authenticateFacebook(
|
676
|
+
this.serverkey,
|
677
|
+
"",
|
678
|
+
request,
|
679
|
+
create,
|
680
|
+
username,
|
681
|
+
sync,
|
682
|
+
options
|
683
|
+
)
|
684
|
+
.then((apiSession: ApiSession) => {
|
685
|
+
return new Session(
|
686
|
+
apiSession.token || "",
|
687
|
+
apiSession.refresh_token || "",
|
688
|
+
apiSession.created || false
|
689
|
+
);
|
690
|
+
});
|
582
691
|
}
|
583
692
|
|
584
693
|
/** Authenticate a user with Google against the server. */
|
@@ -621,7 +730,7 @@ export class Client {
|
|
621
730
|
username?: string,
|
622
731
|
create?: boolean,
|
623
732
|
vars?: Record<string, string>,
|
624
|
-
options: any = {}
|
733
|
+
options: any = {}
|
625
734
|
): Promise<Session> {
|
626
735
|
const request: ApiAccountGameCenter = {
|
627
736
|
bundle_id: bundleId,
|
@@ -650,1626 +759,2674 @@ export class Client {
|
|
650
759
|
}
|
651
760
|
|
652
761
|
/** Authenticate a user with Steam against the server. */
|
653
|
-
async authenticateSteam(
|
762
|
+
async authenticateSteam(
|
763
|
+
token: string,
|
764
|
+
create?: boolean,
|
765
|
+
username?: string,
|
766
|
+
sync?: boolean,
|
767
|
+
vars?: Record<string, string>
|
768
|
+
): Promise<Session> {
|
654
769
|
const request = {
|
655
|
-
|
656
|
-
|
657
|
-
|
770
|
+
token: token,
|
771
|
+
vars: vars,
|
772
|
+
sync: sync,
|
658
773
|
};
|
659
774
|
|
660
|
-
return this.apiClient
|
661
|
-
|
662
|
-
|
775
|
+
return this.apiClient
|
776
|
+
.authenticateSteam(this.serverkey, "", request, create, username)
|
777
|
+
.then((apiSession: ApiSession) => {
|
778
|
+
return new Session(
|
779
|
+
apiSession.token || "",
|
780
|
+
apiSession.refresh_token || "",
|
781
|
+
apiSession.created || false
|
782
|
+
);
|
783
|
+
});
|
663
784
|
}
|
664
785
|
|
665
786
|
/** Block one or more users by ID or username. */
|
666
|
-
async blockFriends(
|
667
|
-
|
668
|
-
|
669
|
-
|
787
|
+
async blockFriends(
|
788
|
+
session: Session,
|
789
|
+
ids?: Array<string>,
|
790
|
+
usernames?: Array<string>
|
791
|
+
): Promise<boolean> {
|
792
|
+
if (
|
793
|
+
this.autoRefreshSession &&
|
794
|
+
session.refresh_token &&
|
795
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
796
|
+
) {
|
797
|
+
await this.sessionRefresh(session);
|
670
798
|
}
|
671
799
|
|
672
|
-
return this.apiClient
|
673
|
-
|
674
|
-
|
800
|
+
return this.apiClient
|
801
|
+
.blockFriends(session.token, ids, usernames)
|
802
|
+
.then((response: any) => {
|
803
|
+
return Promise.resolve(response != undefined);
|
804
|
+
});
|
675
805
|
}
|
676
806
|
|
677
807
|
/** Create a new group with the current user as the creator and superadmin. */
|
678
|
-
async uploadAttachmentFile(
|
679
|
-
|
680
|
-
|
681
|
-
|
808
|
+
async uploadAttachmentFile(
|
809
|
+
session: Session,
|
810
|
+
request: ApiUploadAttachmentRequest
|
811
|
+
): Promise<ApiUploadAttachment> {
|
812
|
+
if (
|
813
|
+
this.autoRefreshSession &&
|
814
|
+
session.refresh_token &&
|
815
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
816
|
+
) {
|
817
|
+
await this.sessionRefresh(session);
|
682
818
|
}
|
683
819
|
|
684
820
|
return this.apiClient.uploadAttachmentFile(session.token, request);
|
685
821
|
}
|
686
822
|
|
687
823
|
/** Create a channel within clan */
|
688
|
-
async createChannelDesc(
|
689
|
-
|
690
|
-
|
691
|
-
|
824
|
+
async createChannelDesc(
|
825
|
+
session: Session,
|
826
|
+
request: ApiCreateChannelDescRequest
|
827
|
+
): Promise<ApiChannelDescription> {
|
828
|
+
if (
|
829
|
+
this.autoRefreshSession &&
|
830
|
+
session.refresh_token &&
|
831
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
832
|
+
) {
|
833
|
+
await this.sessionRefresh(session);
|
692
834
|
}
|
693
835
|
|
694
|
-
return this.apiClient
|
695
|
-
|
696
|
-
|
836
|
+
return this.apiClient
|
837
|
+
.createChannelDesc(session.token, request)
|
838
|
+
.then((response: ApiChannelDescription) => {
|
839
|
+
return Promise.resolve(response);
|
840
|
+
});
|
697
841
|
}
|
698
842
|
|
699
843
|
/** Create a clan */
|
700
|
-
async createClanDesc(
|
701
|
-
|
702
|
-
|
703
|
-
|
844
|
+
async createClanDesc(
|
845
|
+
session: Session,
|
846
|
+
request: ApiCreateClanDescRequest
|
847
|
+
): Promise<ApiClanDesc> {
|
848
|
+
if (
|
849
|
+
this.autoRefreshSession &&
|
850
|
+
session.refresh_token &&
|
851
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
852
|
+
) {
|
853
|
+
await this.sessionRefresh(session);
|
704
854
|
}
|
705
855
|
|
706
|
-
return this.apiClient
|
707
|
-
|
708
|
-
|
856
|
+
return this.apiClient
|
857
|
+
.createClanDesc(session.token, request)
|
858
|
+
.then((response: ApiClanDesc) => {
|
859
|
+
return Promise.resolve(response);
|
860
|
+
});
|
709
861
|
}
|
710
862
|
|
711
863
|
/** */
|
712
|
-
async createCategoryDesc(
|
713
|
-
|
714
|
-
|
715
|
-
|
864
|
+
async createCategoryDesc(
|
865
|
+
session: Session,
|
866
|
+
request: ApiCreateCategoryDescRequest
|
867
|
+
): Promise<ApiCategoryDesc> {
|
868
|
+
if (
|
869
|
+
this.autoRefreshSession &&
|
870
|
+
session.refresh_token &&
|
871
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
872
|
+
) {
|
873
|
+
await this.sessionRefresh(session);
|
716
874
|
}
|
717
875
|
|
718
|
-
return this.apiClient
|
719
|
-
|
720
|
-
|
876
|
+
return this.apiClient
|
877
|
+
.createCategoryDesc(session.token, request)
|
878
|
+
.then((response: ApiCategoryDesc) => {
|
879
|
+
return Promise.resolve(response);
|
880
|
+
});
|
721
881
|
}
|
722
882
|
|
723
883
|
/** Create a new role for clan. */
|
724
|
-
async createRole(
|
725
|
-
|
726
|
-
|
727
|
-
|
884
|
+
async createRole(
|
885
|
+
session: Session,
|
886
|
+
request: ApiCreateRoleRequest
|
887
|
+
): Promise<ApiRole> {
|
888
|
+
if (
|
889
|
+
this.autoRefreshSession &&
|
890
|
+
session.refresh_token &&
|
891
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
892
|
+
) {
|
893
|
+
await this.sessionRefresh(session);
|
728
894
|
}
|
729
895
|
|
730
|
-
return this.apiClient
|
731
|
-
|
732
|
-
|
896
|
+
return this.apiClient
|
897
|
+
.createRole(session.token, request)
|
898
|
+
.then((response: ApiRole) => {
|
899
|
+
return Promise.resolve(response);
|
900
|
+
});
|
733
901
|
}
|
734
902
|
|
735
903
|
/** Create a new event for clan. */
|
736
|
-
async createEvent(
|
737
|
-
|
738
|
-
|
739
|
-
|
904
|
+
async createEvent(
|
905
|
+
session: Session,
|
906
|
+
request: ApiCreateEventRequest
|
907
|
+
): Promise<ApiEventManagement> {
|
908
|
+
if (
|
909
|
+
this.autoRefreshSession &&
|
910
|
+
session.refresh_token &&
|
911
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
912
|
+
) {
|
913
|
+
await this.sessionRefresh(session);
|
740
914
|
}
|
741
915
|
|
742
|
-
return this.apiClient
|
743
|
-
|
744
|
-
|
916
|
+
return this.apiClient
|
917
|
+
.createEvent(session.token, request)
|
918
|
+
.then((response: ApiEventManagement) => {
|
919
|
+
return Promise.resolve(response);
|
920
|
+
});
|
745
921
|
}
|
746
922
|
|
747
|
-
|
748
923
|
/** add role for channel. */
|
749
|
-
async addRolesChannelDesc(
|
750
|
-
|
751
|
-
|
752
|
-
|
924
|
+
async addRolesChannelDesc(
|
925
|
+
session: Session,
|
926
|
+
request: ApiAddRoleChannelDescRequest
|
927
|
+
): Promise<boolean> {
|
928
|
+
if (
|
929
|
+
this.autoRefreshSession &&
|
930
|
+
session.refresh_token &&
|
931
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
932
|
+
) {
|
933
|
+
await this.sessionRefresh(session);
|
753
934
|
}
|
754
935
|
|
755
|
-
return this.apiClient
|
756
|
-
|
757
|
-
|
936
|
+
return this.apiClient
|
937
|
+
.addRolesChannelDesc(session.token, request)
|
938
|
+
.then((response: ApiRole) => {
|
939
|
+
return response !== undefined;
|
940
|
+
});
|
758
941
|
}
|
759
942
|
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
943
|
+
/** Update action role when delete role */
|
944
|
+
async deleteRoleChannelDesc(
|
945
|
+
session: Session,
|
946
|
+
request: ApiDeleteRoleRequest
|
947
|
+
): Promise<boolean> {
|
948
|
+
if (
|
949
|
+
this.autoRefreshSession &&
|
950
|
+
session.refresh_token &&
|
951
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
952
|
+
) {
|
953
|
+
await this.sessionRefresh(session);
|
765
954
|
}
|
766
955
|
|
767
|
-
return this.apiClient
|
768
|
-
|
769
|
-
|
956
|
+
return this.apiClient
|
957
|
+
.deleteRoleChannelDesc(session.token, request)
|
958
|
+
.then((response: any) => {
|
959
|
+
return response !== undefined;
|
960
|
+
});
|
770
961
|
}
|
771
962
|
|
772
963
|
async deleteApp(session: Session, appId: string): Promise<boolean> {
|
773
|
-
if (
|
774
|
-
|
775
|
-
|
964
|
+
if (
|
965
|
+
this.autoRefreshSession &&
|
966
|
+
session.refresh_token &&
|
967
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
968
|
+
) {
|
969
|
+
await this.sessionRefresh(session);
|
776
970
|
}
|
777
971
|
|
778
|
-
return this.apiClient
|
779
|
-
|
780
|
-
|
972
|
+
return this.apiClient
|
973
|
+
.deleteApp(session.token, appId)
|
974
|
+
.then((response: any) => {
|
975
|
+
return response !== undefined;
|
976
|
+
});
|
781
977
|
}
|
782
978
|
|
783
979
|
/** A socket created with the client's configuration. */
|
784
|
-
createSocket(
|
785
|
-
|
980
|
+
createSocket(
|
981
|
+
useSSL = false,
|
982
|
+
verbose: boolean = false,
|
983
|
+
adapter: WebSocketAdapter = new WebSocketAdapterText(),
|
984
|
+
sendTimeoutMs: number = DefaultSocket.DefaultSendTimeoutMs
|
985
|
+
): Socket {
|
986
|
+
return new DefaultSocket(
|
987
|
+
this.host,
|
988
|
+
this.port,
|
989
|
+
useSSL,
|
990
|
+
verbose,
|
991
|
+
adapter,
|
992
|
+
sendTimeoutMs
|
993
|
+
);
|
786
994
|
}
|
787
995
|
|
788
996
|
/** Delete one or more users by ID or username. */
|
789
|
-
async deleteFriends(
|
790
|
-
|
791
|
-
|
792
|
-
|
997
|
+
async deleteFriends(
|
998
|
+
session: Session,
|
999
|
+
ids?: Array<string>,
|
1000
|
+
usernames?: Array<string>
|
1001
|
+
): Promise<boolean> {
|
1002
|
+
if (
|
1003
|
+
this.autoRefreshSession &&
|
1004
|
+
session.refresh_token &&
|
1005
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1006
|
+
) {
|
1007
|
+
await this.sessionRefresh(session);
|
793
1008
|
}
|
794
1009
|
|
795
|
-
return this.apiClient
|
796
|
-
|
797
|
-
|
1010
|
+
return this.apiClient
|
1011
|
+
.deleteFriends(session.token, ids, usernames)
|
1012
|
+
.then((response: any) => {
|
1013
|
+
return response !== undefined;
|
1014
|
+
});
|
798
1015
|
}
|
799
1016
|
|
800
1017
|
/** Delete a channel by ID. */
|
801
|
-
async deleteChannelDesc(
|
802
|
-
|
803
|
-
|
804
|
-
|
1018
|
+
async deleteChannelDesc(
|
1019
|
+
session: Session,
|
1020
|
+
channelId: string
|
1021
|
+
): Promise<boolean> {
|
1022
|
+
if (
|
1023
|
+
this.autoRefreshSession &&
|
1024
|
+
session.refresh_token &&
|
1025
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1026
|
+
) {
|
1027
|
+
await this.sessionRefresh(session);
|
805
1028
|
}
|
806
1029
|
|
807
|
-
return this.apiClient
|
808
|
-
|
809
|
-
|
1030
|
+
return this.apiClient
|
1031
|
+
.deleteChannelDesc(session.token, channelId)
|
1032
|
+
.then((response: any) => {
|
1033
|
+
return response !== undefined;
|
1034
|
+
});
|
810
1035
|
}
|
811
1036
|
|
812
1037
|
/** Delete a clan desc by ID. */
|
813
1038
|
async deleteClanDesc(session: Session, clanDescId: string): Promise<boolean> {
|
814
|
-
if (
|
815
|
-
|
816
|
-
|
1039
|
+
if (
|
1040
|
+
this.autoRefreshSession &&
|
1041
|
+
session.refresh_token &&
|
1042
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1043
|
+
) {
|
1044
|
+
await this.sessionRefresh(session);
|
817
1045
|
}
|
818
1046
|
|
819
|
-
return this.apiClient
|
820
|
-
|
821
|
-
|
1047
|
+
return this.apiClient
|
1048
|
+
.deleteClanDesc(session.token, clanDescId)
|
1049
|
+
.then((response: any) => {
|
1050
|
+
return response !== undefined;
|
1051
|
+
});
|
822
1052
|
}
|
823
1053
|
|
824
1054
|
/** Delete a category by ID. */
|
825
|
-
async deleteCategoryDesc(
|
826
|
-
|
827
|
-
|
828
|
-
|
1055
|
+
async deleteCategoryDesc(
|
1056
|
+
session: Session,
|
1057
|
+
creatorId: string
|
1058
|
+
): Promise<boolean> {
|
1059
|
+
if (
|
1060
|
+
this.autoRefreshSession &&
|
1061
|
+
session.refresh_token &&
|
1062
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1063
|
+
) {
|
1064
|
+
await this.sessionRefresh(session);
|
829
1065
|
}
|
830
1066
|
|
831
|
-
return this.apiClient
|
832
|
-
|
833
|
-
|
1067
|
+
return this.apiClient
|
1068
|
+
.deleteCategoryDesc(session.token, creatorId)
|
1069
|
+
.then((response: any) => {
|
1070
|
+
return response !== undefined;
|
1071
|
+
});
|
834
1072
|
}
|
835
1073
|
|
836
1074
|
/** Delete one or more notifications */
|
837
|
-
async deleteNotifications(
|
838
|
-
|
839
|
-
|
840
|
-
|
1075
|
+
async deleteNotifications(
|
1076
|
+
session: Session,
|
1077
|
+
ids?: Array<string>
|
1078
|
+
): Promise<boolean> {
|
1079
|
+
if (
|
1080
|
+
this.autoRefreshSession &&
|
1081
|
+
session.refresh_token &&
|
1082
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1083
|
+
) {
|
1084
|
+
await this.sessionRefresh(session);
|
841
1085
|
}
|
842
1086
|
|
843
|
-
return this.apiClient
|
844
|
-
|
845
|
-
|
1087
|
+
return this.apiClient
|
1088
|
+
.deleteNotifications(session.token, ids)
|
1089
|
+
.then((response: any) => {
|
1090
|
+
return Promise.resolve(response != undefined);
|
1091
|
+
});
|
846
1092
|
}
|
847
1093
|
|
848
1094
|
/** Delete a role by ID. */
|
849
|
-
async deleteRole(
|
850
|
-
|
851
|
-
|
852
|
-
|
1095
|
+
async deleteRole(
|
1096
|
+
session: Session,
|
1097
|
+
roleId: string,
|
1098
|
+
clanId: string
|
1099
|
+
): Promise<boolean> {
|
1100
|
+
if (
|
1101
|
+
this.autoRefreshSession &&
|
1102
|
+
session.refresh_token &&
|
1103
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1104
|
+
) {
|
1105
|
+
await this.sessionRefresh(session);
|
853
1106
|
}
|
854
1107
|
|
855
|
-
return this.apiClient
|
856
|
-
|
857
|
-
|
1108
|
+
return this.apiClient
|
1109
|
+
.deleteRole(session.token, roleId, "", clanId)
|
1110
|
+
.then((response: any) => {
|
1111
|
+
return response !== undefined;
|
1112
|
+
});
|
858
1113
|
}
|
859
1114
|
|
860
1115
|
/** Delete a event by ID. */
|
861
|
-
async deleteEvent(
|
862
|
-
|
863
|
-
|
864
|
-
|
1116
|
+
async deleteEvent(
|
1117
|
+
session: Session,
|
1118
|
+
eventId: string,
|
1119
|
+
clanId: string
|
1120
|
+
): Promise<boolean> {
|
1121
|
+
if (
|
1122
|
+
this.autoRefreshSession &&
|
1123
|
+
session.refresh_token &&
|
1124
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1125
|
+
) {
|
1126
|
+
await this.sessionRefresh(session);
|
865
1127
|
}
|
866
1128
|
|
867
|
-
return this.apiClient
|
868
|
-
|
869
|
-
|
1129
|
+
return this.apiClient
|
1130
|
+
.deleteEvent(session.token, eventId, clanId)
|
1131
|
+
.then((response: any) => {
|
1132
|
+
return response !== undefined;
|
1133
|
+
});
|
870
1134
|
}
|
871
1135
|
|
872
1136
|
/** update user a event by ID. */
|
873
|
-
async updateEventUser(
|
874
|
-
|
875
|
-
|
876
|
-
|
1137
|
+
async updateEventUser(
|
1138
|
+
session: Session,
|
1139
|
+
request: ApiDeleteEventRequest
|
1140
|
+
): Promise<boolean> {
|
1141
|
+
if (
|
1142
|
+
this.autoRefreshSession &&
|
1143
|
+
session.refresh_token &&
|
1144
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1145
|
+
) {
|
1146
|
+
await this.sessionRefresh(session);
|
877
1147
|
}
|
878
1148
|
|
879
|
-
return this.apiClient
|
880
|
-
|
881
|
-
|
1149
|
+
return this.apiClient
|
1150
|
+
.updateEventUser(session.token, request)
|
1151
|
+
.then((response: any) => {
|
1152
|
+
return response !== undefined;
|
1153
|
+
});
|
882
1154
|
}
|
883
1155
|
|
884
1156
|
/** Submit an event for processing in the server's registered runtime custom events handler. */
|
885
1157
|
async emitEvent(session: Session, request: ApiEvent): Promise<boolean> {
|
886
|
-
if (
|
887
|
-
|
888
|
-
|
1158
|
+
if (
|
1159
|
+
this.autoRefreshSession &&
|
1160
|
+
session.refresh_token &&
|
1161
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1162
|
+
) {
|
1163
|
+
await this.sessionRefresh(session);
|
889
1164
|
}
|
890
1165
|
|
891
|
-
return this.apiClient
|
892
|
-
|
893
|
-
|
1166
|
+
return this.apiClient
|
1167
|
+
.event(session.token, request)
|
1168
|
+
.then((response: any) => {
|
1169
|
+
return Promise.resolve(response != undefined);
|
1170
|
+
});
|
894
1171
|
}
|
895
1172
|
|
896
1173
|
/** Fetch the current user's account. */
|
897
1174
|
async getAccount(session: Session): Promise<ApiAccount> {
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
1175
|
+
if (
|
1176
|
+
this.autoRefreshSession &&
|
1177
|
+
session.refresh_token &&
|
1178
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1179
|
+
) {
|
1180
|
+
await this.sessionRefresh(session);
|
902
1181
|
}
|
903
1182
|
|
904
1183
|
return this.apiClient.getAccount(session.token);
|
905
1184
|
}
|
906
1185
|
|
907
1186
|
/** Import Facebook friends and add them to a user's account. */
|
908
|
-
async importFacebookFriends(
|
909
|
-
|
910
|
-
|
911
|
-
|
1187
|
+
async importFacebookFriends(
|
1188
|
+
session: Session,
|
1189
|
+
request: ApiAccountFacebook
|
1190
|
+
): Promise<boolean> {
|
1191
|
+
if (
|
1192
|
+
this.autoRefreshSession &&
|
1193
|
+
session.refresh_token &&
|
1194
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1195
|
+
) {
|
1196
|
+
await this.sessionRefresh(session);
|
912
1197
|
}
|
913
1198
|
|
914
|
-
return this.apiClient
|
915
|
-
|
916
|
-
|
1199
|
+
return this.apiClient
|
1200
|
+
.importFacebookFriends(session.token, request)
|
1201
|
+
.then((response: any) => {
|
1202
|
+
return response !== undefined;
|
1203
|
+
});
|
917
1204
|
}
|
918
1205
|
|
919
|
-
|
920
|
-
async importSteamFriends(
|
921
|
-
|
922
|
-
|
923
|
-
|
1206
|
+
/** Import Steam friends and add them to a user's account. */
|
1207
|
+
async importSteamFriends(
|
1208
|
+
session: Session,
|
1209
|
+
request: ApiAccountSteam,
|
1210
|
+
reset: boolean
|
1211
|
+
): Promise<boolean> {
|
1212
|
+
if (
|
1213
|
+
this.autoRefreshSession &&
|
1214
|
+
session.refresh_token &&
|
1215
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1216
|
+
) {
|
1217
|
+
await this.sessionRefresh(session);
|
924
1218
|
}
|
925
1219
|
|
926
|
-
return this.apiClient
|
1220
|
+
return this.apiClient
|
1221
|
+
.importSteamFriends(session.token, request, reset)
|
1222
|
+
.then((response: any) => {
|
927
1223
|
return response !== undefined;
|
928
|
-
|
1224
|
+
});
|
929
1225
|
}
|
930
1226
|
|
931
1227
|
/** Fetch zero or more users by ID and/or username. */
|
932
|
-
async getUsers(
|
933
|
-
|
934
|
-
|
935
|
-
|
1228
|
+
async getUsers(
|
1229
|
+
session: Session,
|
1230
|
+
ids?: Array<string>,
|
1231
|
+
usernames?: Array<string>,
|
1232
|
+
facebookIds?: Array<string>
|
1233
|
+
): Promise<Users> {
|
1234
|
+
if (
|
1235
|
+
this.autoRefreshSession &&
|
1236
|
+
session.refresh_token &&
|
1237
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1238
|
+
) {
|
1239
|
+
await this.sessionRefresh(session);
|
936
1240
|
}
|
937
1241
|
|
938
|
-
return this.apiClient
|
939
|
-
|
940
|
-
|
941
|
-
|
1242
|
+
return this.apiClient
|
1243
|
+
.getUsers(session.token, ids, usernames, facebookIds)
|
1244
|
+
.then((response: ApiUsers) => {
|
1245
|
+
var result: Users = {
|
1246
|
+
users: [],
|
1247
|
+
};
|
1248
|
+
|
1249
|
+
if (response.users == null) {
|
1250
|
+
return Promise.resolve(result);
|
1251
|
+
}
|
942
1252
|
|
943
|
-
|
1253
|
+
response.users!.forEach((u) => {
|
1254
|
+
result.users!.push({
|
1255
|
+
avatar_url: u.avatar_url,
|
1256
|
+
create_time: u.create_time,
|
1257
|
+
display_name: u.display_name,
|
1258
|
+
edge_count: u.edge_count ? Number(u.edge_count) : 0,
|
1259
|
+
facebook_id: u.facebook_id,
|
1260
|
+
gamecenter_id: u.gamecenter_id,
|
1261
|
+
google_id: u.google_id,
|
1262
|
+
id: u.id,
|
1263
|
+
lang_tag: u.lang_tag,
|
1264
|
+
location: u.location,
|
1265
|
+
online: u.online,
|
1266
|
+
steam_id: u.steam_id,
|
1267
|
+
timezone: u.timezone,
|
1268
|
+
update_time: u.update_time,
|
1269
|
+
username: u.username,
|
1270
|
+
metadata: u.metadata ? JSON.parse(u.metadata) : undefined,
|
1271
|
+
});
|
1272
|
+
});
|
944
1273
|
return Promise.resolve(result);
|
945
|
-
}
|
946
|
-
|
947
|
-
response.users!.forEach(u => {
|
948
|
-
result.users!.push({
|
949
|
-
avatar_url: u.avatar_url,
|
950
|
-
create_time: u.create_time,
|
951
|
-
display_name: u.display_name,
|
952
|
-
edge_count: u.edge_count ? Number(u.edge_count) : 0,
|
953
|
-
facebook_id: u.facebook_id,
|
954
|
-
gamecenter_id: u.gamecenter_id,
|
955
|
-
google_id: u.google_id,
|
956
|
-
id: u.id,
|
957
|
-
lang_tag: u.lang_tag,
|
958
|
-
location: u.location,
|
959
|
-
online: u.online,
|
960
|
-
steam_id: u.steam_id,
|
961
|
-
timezone: u.timezone,
|
962
|
-
update_time: u.update_time,
|
963
|
-
username: u.username,
|
964
|
-
metadata: u.metadata ? JSON.parse(u.metadata) : undefined
|
965
|
-
})
|
966
|
-
});
|
967
|
-
return Promise.resolve(result);
|
968
|
-
});
|
1274
|
+
});
|
969
1275
|
}
|
970
1276
|
|
971
1277
|
/** Kick a set of users from a clan. */
|
972
|
-
async removeClanUsers(
|
973
|
-
|
974
|
-
|
975
|
-
|
1278
|
+
async removeClanUsers(
|
1279
|
+
session: Session,
|
1280
|
+
clanId: string,
|
1281
|
+
ids?: Array<string>
|
1282
|
+
): Promise<boolean> {
|
1283
|
+
if (
|
1284
|
+
this.autoRefreshSession &&
|
1285
|
+
session.refresh_token &&
|
1286
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1287
|
+
) {
|
1288
|
+
await this.sessionRefresh(session);
|
976
1289
|
}
|
977
1290
|
|
978
|
-
return this.apiClient
|
979
|
-
|
980
|
-
|
1291
|
+
return this.apiClient
|
1292
|
+
.removeClanUsers(session.token, clanId, ids)
|
1293
|
+
.then((response: any) => {
|
1294
|
+
return Promise.resolve(response != undefined);
|
1295
|
+
});
|
981
1296
|
}
|
982
1297
|
|
983
1298
|
/** Kick users from a channel, or decline their join requests. */
|
984
|
-
async removeChannelUsers(
|
985
|
-
|
986
|
-
|
987
|
-
|
1299
|
+
async removeChannelUsers(
|
1300
|
+
session: Session,
|
1301
|
+
channelId: string,
|
1302
|
+
ids?: Array<string>
|
1303
|
+
): Promise<boolean> {
|
1304
|
+
if (
|
1305
|
+
this.autoRefreshSession &&
|
1306
|
+
session.refresh_token &&
|
1307
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1308
|
+
) {
|
1309
|
+
await this.sessionRefresh(session);
|
988
1310
|
}
|
989
1311
|
|
990
|
-
return this.apiClient
|
991
|
-
|
992
|
-
|
1312
|
+
return this.apiClient
|
1313
|
+
.removeChannelUsers(session.token, channelId, ids)
|
1314
|
+
.then((response: any) => {
|
1315
|
+
return Promise.resolve(response != undefined);
|
1316
|
+
});
|
993
1317
|
}
|
994
1318
|
|
995
1319
|
/** List a channel's message history. */
|
996
|
-
async listChannelMessages(
|
997
|
-
|
998
|
-
|
999
|
-
|
1320
|
+
async listChannelMessages(
|
1321
|
+
session: Session,
|
1322
|
+
channelId: string,
|
1323
|
+
messageId?: string,
|
1324
|
+
direction?: number,
|
1325
|
+
limit?: number
|
1326
|
+
): Promise<ChannelMessageList> {
|
1327
|
+
if (
|
1328
|
+
this.autoRefreshSession &&
|
1329
|
+
session.refresh_token &&
|
1330
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1331
|
+
) {
|
1332
|
+
await this.sessionRefresh(session);
|
1000
1333
|
}
|
1001
1334
|
|
1002
|
-
return this.apiClient
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
try {
|
1020
|
-
reactions = JSON.parse(m.reactions || '[]');
|
1021
|
-
} catch(e) {
|
1022
|
-
//console.log("error parse reactions", e);
|
1023
|
-
}
|
1024
|
-
try {
|
1025
|
-
mentions = JSON.parse(m.mentions || '[]');
|
1026
|
-
} catch(e) {
|
1027
|
-
//console.log("error parse mentions", e);
|
1028
|
-
}
|
1029
|
-
try {
|
1030
|
-
attachments = JSON.parse(m.attachments || '[]');
|
1031
|
-
} catch(e) {
|
1032
|
-
//console.log("error parse attachments", e);
|
1335
|
+
return this.apiClient
|
1336
|
+
.listChannelMessages(
|
1337
|
+
session.token,
|
1338
|
+
channelId,
|
1339
|
+
messageId,
|
1340
|
+
direction,
|
1341
|
+
limit
|
1342
|
+
)
|
1343
|
+
.then((response: ApiChannelMessageList) => {
|
1344
|
+
var result: ChannelMessageList = {
|
1345
|
+
messages: [],
|
1346
|
+
last_seen_message: response.last_seen_message,
|
1347
|
+
last_sent_message: response.last_sent_message,
|
1348
|
+
};
|
1349
|
+
|
1350
|
+
if (response.messages == null) {
|
1351
|
+
return Promise.resolve(result);
|
1033
1352
|
}
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1353
|
+
response.messages!.forEach((m) => {
|
1354
|
+
var content, reactions, mentions, attachments, references;
|
1355
|
+
try {
|
1356
|
+
content = JSON.parse(m.content);
|
1357
|
+
} catch (e) {
|
1358
|
+
//console.log("error parse content", e);
|
1359
|
+
}
|
1360
|
+
try {
|
1361
|
+
reactions = JSON.parse(m.reactions || "[]");
|
1362
|
+
} catch (e) {
|
1363
|
+
//console.log("error parse reactions", e);
|
1364
|
+
}
|
1365
|
+
try {
|
1366
|
+
mentions = JSON.parse(m.mentions || "[]");
|
1367
|
+
} catch (e) {
|
1368
|
+
//console.log("error parse mentions", e);
|
1369
|
+
}
|
1370
|
+
try {
|
1371
|
+
attachments = JSON.parse(m.attachments || "[]");
|
1372
|
+
} catch (e) {
|
1373
|
+
//console.log("error parse attachments", e);
|
1374
|
+
}
|
1375
|
+
try {
|
1376
|
+
references = JSON.parse(m.references || "[]");
|
1377
|
+
} catch (e) {
|
1378
|
+
//console.log("error parse references", e);
|
1379
|
+
}
|
1380
|
+
result.messages!.push({
|
1381
|
+
channel_id: m.channel_id,
|
1382
|
+
code: m.code ? Number(m.code) : 0,
|
1383
|
+
create_time: m.create_time || "",
|
1384
|
+
id: m.message_id,
|
1385
|
+
sender_id: m.sender_id,
|
1386
|
+
update_time: m.update_time,
|
1387
|
+
username: m.username,
|
1388
|
+
display_name: m.display_name,
|
1389
|
+
avatar: m.avatar,
|
1390
|
+
content: content,
|
1391
|
+
channel_label: m.channel_label,
|
1392
|
+
clan_logo: m.clan_logo,
|
1393
|
+
category_name: m.category_name,
|
1394
|
+
clan_nick: m.clan_nick,
|
1395
|
+
clan_avatar: m.clan_avatar,
|
1396
|
+
attachments: attachments,
|
1397
|
+
mentions: mentions,
|
1398
|
+
reactions: reactions,
|
1399
|
+
references: references,
|
1400
|
+
clan_id: m.clan_id,
|
1401
|
+
create_time_seconds: m.create_time_seconds,
|
1402
|
+
update_time_seconds: m.update_time_seconds,
|
1403
|
+
});
|
1404
|
+
});
|
1405
|
+
return Promise.resolve(result);
|
1406
|
+
});
|
1066
1407
|
}
|
1067
1408
|
|
1068
1409
|
/** List a channel's users. */
|
1069
|
-
async listChannelVoiceUsers(
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1410
|
+
async listChannelVoiceUsers(
|
1411
|
+
session: Session,
|
1412
|
+
clanId: string,
|
1413
|
+
channelId: string,
|
1414
|
+
channelType: number,
|
1415
|
+
state?: number,
|
1416
|
+
limit?: number,
|
1417
|
+
cursor?: string
|
1418
|
+
): Promise<ApiVoiceChannelUserList> {
|
1419
|
+
if (
|
1420
|
+
this.autoRefreshSession &&
|
1421
|
+
session.refresh_token &&
|
1422
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1423
|
+
) {
|
1424
|
+
await this.sessionRefresh(session);
|
1073
1425
|
}
|
1074
1426
|
|
1075
|
-
return this.apiClient
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1427
|
+
return this.apiClient
|
1428
|
+
.listChannelVoiceUsers(
|
1429
|
+
session.token,
|
1430
|
+
clanId,
|
1431
|
+
channelId,
|
1432
|
+
channelType,
|
1433
|
+
limit,
|
1434
|
+
state,
|
1435
|
+
cursor
|
1436
|
+
)
|
1437
|
+
.then((response: ApiVoiceChannelUserList) => {
|
1438
|
+
var result: ApiVoiceChannelUserList = {
|
1439
|
+
voice_channel_users: [],
|
1440
|
+
};
|
1441
|
+
|
1442
|
+
if (response.voice_channel_users == null) {
|
1443
|
+
return Promise.resolve(result);
|
1444
|
+
}
|
1079
1445
|
|
1080
|
-
|
1446
|
+
response.voice_channel_users!.forEach((gu) => {
|
1447
|
+
result.voice_channel_users!.push({
|
1448
|
+
id: gu.id,
|
1449
|
+
channel_id: gu.channel_id,
|
1450
|
+
user_id: gu.user_id,
|
1451
|
+
participant: gu.participant,
|
1452
|
+
});
|
1453
|
+
});
|
1081
1454
|
return Promise.resolve(result);
|
1082
|
-
}
|
1083
|
-
|
1084
|
-
response.voice_channel_users!.forEach(gu => {
|
1085
|
-
result.voice_channel_users!.push({
|
1086
|
-
id: gu.id,
|
1087
|
-
channel_id: gu.channel_id,
|
1088
|
-
user_id: gu.user_id,
|
1089
|
-
participant: gu.participant
|
1090
|
-
})
|
1091
1455
|
});
|
1092
|
-
return Promise.resolve(result);
|
1093
|
-
});
|
1094
1456
|
}
|
1095
1457
|
|
1096
1458
|
/** List a channel's users. */
|
1097
|
-
async listChannelUsers(
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1459
|
+
async listChannelUsers(
|
1460
|
+
session: Session,
|
1461
|
+
clanId: string,
|
1462
|
+
channelId: string,
|
1463
|
+
channelType: number,
|
1464
|
+
state?: number,
|
1465
|
+
limit?: number,
|
1466
|
+
cursor?: string
|
1467
|
+
): Promise<ApiChannelUserList> {
|
1468
|
+
if (
|
1469
|
+
this.autoRefreshSession &&
|
1470
|
+
session.refresh_token &&
|
1471
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1472
|
+
) {
|
1473
|
+
await this.sessionRefresh(session);
|
1101
1474
|
}
|
1102
1475
|
|
1103
|
-
return this.apiClient
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1476
|
+
return this.apiClient
|
1477
|
+
.listChannelUsers(
|
1478
|
+
session.token,
|
1479
|
+
clanId,
|
1480
|
+
channelId,
|
1481
|
+
channelType,
|
1482
|
+
limit,
|
1483
|
+
state,
|
1484
|
+
cursor
|
1485
|
+
)
|
1486
|
+
.then((response: ApiChannelUserList) => {
|
1487
|
+
var result: ApiChannelUserList = {
|
1488
|
+
channel_users: [],
|
1489
|
+
cursor: response.cursor,
|
1490
|
+
channel_id: response.channel_id,
|
1491
|
+
};
|
1492
|
+
|
1493
|
+
if (response.channel_users == null) {
|
1494
|
+
return Promise.resolve(result);
|
1495
|
+
}
|
1109
1496
|
|
1110
|
-
|
1497
|
+
response.channel_users!.forEach((gu) => {
|
1498
|
+
result.channel_users!.push({
|
1499
|
+
user: {
|
1500
|
+
avatar_url: gu.user!.avatar_url,
|
1501
|
+
create_time: gu.user!.create_time,
|
1502
|
+
display_name: gu.user!.display_name,
|
1503
|
+
edge_count: gu.user!.edge_count ? Number(gu.user!.edge_count) : 0,
|
1504
|
+
facebook_id: gu.user!.facebook_id,
|
1505
|
+
gamecenter_id: gu.user!.gamecenter_id,
|
1506
|
+
google_id: gu.user!.google_id,
|
1507
|
+
id: gu.user!.id,
|
1508
|
+
lang_tag: gu.user!.lang_tag,
|
1509
|
+
location: gu.user!.location,
|
1510
|
+
online: gu.user!.online,
|
1511
|
+
steam_id: gu.user!.steam_id,
|
1512
|
+
timezone: gu.user!.timezone,
|
1513
|
+
update_time: gu.user!.update_time,
|
1514
|
+
username: gu.user!.username,
|
1515
|
+
about_me: gu.user?.about_me,
|
1516
|
+
metadata: gu.user!.metadata
|
1517
|
+
? JSON.parse(gu.user!.metadata!)
|
1518
|
+
: undefined,
|
1519
|
+
},
|
1520
|
+
role_id: gu!.role_id,
|
1521
|
+
thread_id: gu.thread_id,
|
1522
|
+
clan_avatar: gu.clan_avatar,
|
1523
|
+
clan_nick: gu.clan_nick,
|
1524
|
+
id: gu.id,
|
1525
|
+
clan_id: gu.clan_id,
|
1526
|
+
});
|
1527
|
+
});
|
1111
1528
|
return Promise.resolve(result);
|
1112
|
-
}
|
1113
|
-
|
1114
|
-
response.channel_users!.forEach(gu => {
|
1115
|
-
result.channel_users!.push({
|
1116
|
-
user: {
|
1117
|
-
avatar_url: gu.user!.avatar_url,
|
1118
|
-
create_time: gu.user!.create_time,
|
1119
|
-
display_name: gu.user!.display_name,
|
1120
|
-
edge_count: gu.user!.edge_count ? Number(gu.user!.edge_count): 0,
|
1121
|
-
facebook_id: gu.user!.facebook_id,
|
1122
|
-
gamecenter_id: gu.user!.gamecenter_id,
|
1123
|
-
google_id: gu.user!.google_id,
|
1124
|
-
id: gu.user!.id,
|
1125
|
-
lang_tag: gu.user!.lang_tag,
|
1126
|
-
location: gu.user!.location,
|
1127
|
-
online: gu.user!.online,
|
1128
|
-
steam_id: gu.user!.steam_id,
|
1129
|
-
timezone: gu.user!.timezone,
|
1130
|
-
update_time: gu.user!.update_time,
|
1131
|
-
username: gu.user!.username,
|
1132
|
-
about_me: gu.user?.about_me,
|
1133
|
-
metadata: gu.user!.metadata ? JSON.parse(gu.user!.metadata!) : undefined
|
1134
|
-
},
|
1135
|
-
role_id: gu!.role_id,
|
1136
|
-
thread_id: gu.thread_id,
|
1137
|
-
clan_avatar: gu.clan_avatar,
|
1138
|
-
clan_nick: gu.clan_nick,
|
1139
|
-
id: gu.id,
|
1140
|
-
clan_id: gu.clan_id
|
1141
|
-
})
|
1142
|
-
});
|
1143
|
-
return Promise.resolve(result);
|
1144
|
-
});
|
1529
|
+
});
|
1145
1530
|
}
|
1146
1531
|
|
1147
1532
|
/** List a channel's attachment. */
|
1148
|
-
async listChannelAttachments(
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1533
|
+
async listChannelAttachments(
|
1534
|
+
session: Session,
|
1535
|
+
clanId: string,
|
1536
|
+
channelId: string,
|
1537
|
+
fileType: string,
|
1538
|
+
state?: number,
|
1539
|
+
limit?: number,
|
1540
|
+
cursor?: string
|
1541
|
+
): Promise<ApiChannelAttachmentList> {
|
1542
|
+
if (
|
1543
|
+
this.autoRefreshSession &&
|
1544
|
+
session.refresh_token &&
|
1545
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1546
|
+
) {
|
1547
|
+
await this.sessionRefresh(session);
|
1152
1548
|
}
|
1153
1549
|
|
1154
|
-
return this.apiClient
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1550
|
+
return this.apiClient
|
1551
|
+
.listChannelAttachment(
|
1552
|
+
session.token,
|
1553
|
+
clanId,
|
1554
|
+
channelId,
|
1555
|
+
fileType,
|
1556
|
+
limit,
|
1557
|
+
state,
|
1558
|
+
cursor
|
1559
|
+
)
|
1560
|
+
.then((response: ApiChannelAttachmentList) => {
|
1561
|
+
var result: ApiChannelAttachmentList = {
|
1562
|
+
attachments: [],
|
1563
|
+
};
|
1564
|
+
|
1565
|
+
if (response.attachments == null) {
|
1566
|
+
return Promise.resolve(result);
|
1567
|
+
}
|
1158
1568
|
|
1159
|
-
|
1569
|
+
response.attachments!.forEach((at) => {
|
1570
|
+
result.attachments!.push({
|
1571
|
+
filename: at.filename,
|
1572
|
+
filesize: at.filesize,
|
1573
|
+
filetype: at.filetype,
|
1574
|
+
id: at.id,
|
1575
|
+
uploader: at.uploader,
|
1576
|
+
url: at.url,
|
1577
|
+
create_time: at.create_time,
|
1578
|
+
});
|
1579
|
+
});
|
1160
1580
|
return Promise.resolve(result);
|
1161
|
-
}
|
1162
|
-
|
1163
|
-
response.attachments!.forEach(at => {
|
1164
|
-
result.attachments!.push({
|
1165
|
-
filename: at.filename,
|
1166
|
-
filesize: at.filesize,
|
1167
|
-
filetype: at.filetype,
|
1168
|
-
id: at.id,
|
1169
|
-
uploader: at.uploader,
|
1170
|
-
url: at.url,
|
1171
|
-
create_time: at.create_time
|
1172
|
-
})
|
1173
|
-
});
|
1174
|
-
return Promise.resolve(result);
|
1175
|
-
});
|
1581
|
+
});
|
1176
1582
|
}
|
1177
1583
|
|
1178
1584
|
/** List a channel's users. */
|
1179
|
-
async listClanUsers(
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1585
|
+
async listClanUsers(
|
1586
|
+
session: Session,
|
1587
|
+
clanId: string
|
1588
|
+
): Promise<ApiClanUserList> {
|
1589
|
+
if (
|
1590
|
+
this.autoRefreshSession &&
|
1591
|
+
session.refresh_token &&
|
1592
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1593
|
+
) {
|
1594
|
+
await this.sessionRefresh(session);
|
1183
1595
|
}
|
1184
1596
|
|
1185
|
-
return this.apiClient
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1597
|
+
return this.apiClient
|
1598
|
+
.listClanUsers(session.token, clanId)
|
1599
|
+
.then((response: ApiClanUserList) => {
|
1600
|
+
var result: ApiClanUserList = {
|
1601
|
+
clan_users: [],
|
1602
|
+
cursor: response.cursor,
|
1603
|
+
clan_id: response.clan_id,
|
1604
|
+
};
|
1605
|
+
|
1606
|
+
if (response.clan_users == null) {
|
1607
|
+
return Promise.resolve(result);
|
1608
|
+
}
|
1191
1609
|
|
1192
|
-
|
1610
|
+
response.clan_users!.forEach((gu) => {
|
1611
|
+
result.clan_users!.push({
|
1612
|
+
user: {
|
1613
|
+
avatar_url: gu.user!.avatar_url,
|
1614
|
+
create_time: gu.user!.create_time,
|
1615
|
+
display_name: gu.user!.display_name,
|
1616
|
+
edge_count: gu.user!.edge_count ? Number(gu.user!.edge_count) : 0,
|
1617
|
+
facebook_id: gu.user!.facebook_id,
|
1618
|
+
gamecenter_id: gu.user!.gamecenter_id,
|
1619
|
+
google_id: gu.user!.google_id,
|
1620
|
+
id: gu.user!.id,
|
1621
|
+
lang_tag: gu.user!.lang_tag,
|
1622
|
+
location: gu.user!.location,
|
1623
|
+
online: gu.user!.online,
|
1624
|
+
steam_id: gu.user!.steam_id,
|
1625
|
+
timezone: gu.user!.timezone,
|
1626
|
+
update_time: gu.user!.update_time,
|
1627
|
+
username: gu.user!.username,
|
1628
|
+
metadata: gu.user!.metadata
|
1629
|
+
? JSON.parse(gu.user!.metadata!)
|
1630
|
+
: undefined,
|
1631
|
+
},
|
1632
|
+
role_id: gu!.role_id,
|
1633
|
+
clan_nick: gu!.clan_nick,
|
1634
|
+
clan_avatar: gu!.clan_avatar,
|
1635
|
+
});
|
1636
|
+
});
|
1193
1637
|
return Promise.resolve(result);
|
1194
|
-
}
|
1195
|
-
|
1196
|
-
response.clan_users!.forEach(gu => {
|
1197
|
-
result.clan_users!.push({
|
1198
|
-
user: {
|
1199
|
-
avatar_url: gu.user!.avatar_url,
|
1200
|
-
create_time: gu.user!.create_time,
|
1201
|
-
display_name: gu.user!.display_name,
|
1202
|
-
edge_count: gu.user!.edge_count ? Number(gu.user!.edge_count): 0,
|
1203
|
-
facebook_id: gu.user!.facebook_id,
|
1204
|
-
gamecenter_id: gu.user!.gamecenter_id,
|
1205
|
-
google_id: gu.user!.google_id,
|
1206
|
-
id: gu.user!.id,
|
1207
|
-
lang_tag: gu.user!.lang_tag,
|
1208
|
-
location: gu.user!.location,
|
1209
|
-
online: gu.user!.online,
|
1210
|
-
steam_id: gu.user!.steam_id,
|
1211
|
-
timezone: gu.user!.timezone,
|
1212
|
-
update_time: gu.user!.update_time,
|
1213
|
-
username: gu.user!.username,
|
1214
|
-
metadata: gu.user!.metadata ? JSON.parse(gu.user!.metadata!) : undefined
|
1215
|
-
},
|
1216
|
-
role_id: gu!.role_id,
|
1217
|
-
clan_nick: gu!.clan_nick,
|
1218
|
-
clan_avatar: gu!.clan_avatar
|
1219
|
-
})
|
1220
|
-
});
|
1221
|
-
return Promise.resolve(result);
|
1222
|
-
});
|
1638
|
+
});
|
1223
1639
|
}
|
1224
1640
|
|
1225
1641
|
/** List channels. */
|
1226
|
-
async listChannelDescs(
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1642
|
+
async listChannelDescs(
|
1643
|
+
session: Session,
|
1644
|
+
limit?: number,
|
1645
|
+
state?: number,
|
1646
|
+
cursor?: string,
|
1647
|
+
clanId?: string,
|
1648
|
+
channelType?: number
|
1649
|
+
): Promise<ApiChannelDescList> {
|
1650
|
+
if (
|
1651
|
+
this.autoRefreshSession &&
|
1652
|
+
session.refresh_token &&
|
1653
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1654
|
+
) {
|
1655
|
+
await this.sessionRefresh(session);
|
1230
1656
|
}
|
1231
1657
|
|
1232
|
-
return this.apiClient
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1658
|
+
return this.apiClient
|
1659
|
+
.listChannelDescs(
|
1660
|
+
session.token,
|
1661
|
+
limit,
|
1662
|
+
state,
|
1663
|
+
cursor,
|
1664
|
+
clanId,
|
1665
|
+
channelType
|
1666
|
+
)
|
1667
|
+
.then((response: ApiChannelDescList) => {
|
1668
|
+
var result: ApiChannelDescList = {
|
1669
|
+
channeldesc: [],
|
1670
|
+
next_cursor: response.next_cursor,
|
1671
|
+
prev_cursor: response.prev_cursor,
|
1672
|
+
cacheable_cursor: response.cacheable_cursor,
|
1673
|
+
};
|
1674
|
+
|
1675
|
+
if (response.channeldesc == null) {
|
1676
|
+
return Promise.resolve(result);
|
1677
|
+
}
|
1239
1678
|
|
1240
|
-
|
1679
|
+
result.channeldesc = response.channeldesc;
|
1241
1680
|
return Promise.resolve(result);
|
1242
|
-
}
|
1243
|
-
|
1244
|
-
result.channeldesc = response.channeldesc;
|
1245
|
-
return Promise.resolve(result);
|
1246
|
-
});
|
1681
|
+
});
|
1247
1682
|
}
|
1248
1683
|
|
1249
1684
|
/** List clans */
|
1250
|
-
async listClanDescs(
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1685
|
+
async listClanDescs(
|
1686
|
+
session: Session,
|
1687
|
+
limit?: number,
|
1688
|
+
state?: number,
|
1689
|
+
cursor?: string
|
1690
|
+
): Promise<ApiClanDescList> {
|
1691
|
+
if (
|
1692
|
+
this.autoRefreshSession &&
|
1693
|
+
session.refresh_token &&
|
1694
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1695
|
+
) {
|
1696
|
+
await this.sessionRefresh(session);
|
1254
1697
|
}
|
1255
1698
|
|
1256
|
-
return this.apiClient
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1699
|
+
return this.apiClient
|
1700
|
+
.listClanDescs(session.token, limit, state, cursor)
|
1701
|
+
.then((response: ApiClanDescList) => {
|
1702
|
+
var result: ApiClanDescList = {
|
1703
|
+
clandesc: [],
|
1704
|
+
};
|
1705
|
+
|
1706
|
+
if (response.clandesc == null) {
|
1707
|
+
return Promise.resolve(result);
|
1708
|
+
}
|
1260
1709
|
|
1261
|
-
|
1710
|
+
result.clandesc = response.clandesc;
|
1262
1711
|
return Promise.resolve(result);
|
1263
|
-
}
|
1264
|
-
|
1265
|
-
result.clandesc = response.clandesc;
|
1266
|
-
return Promise.resolve(result);
|
1267
|
-
});
|
1712
|
+
});
|
1268
1713
|
}
|
1269
1714
|
|
1270
1715
|
/** List categories. */
|
1271
|
-
async listCategoryDescs(
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1716
|
+
async listCategoryDescs(
|
1717
|
+
session: Session,
|
1718
|
+
clanId: string,
|
1719
|
+
creatorId?: string,
|
1720
|
+
categoryName?: string
|
1721
|
+
): Promise<ApiCategoryDescList> {
|
1722
|
+
if (
|
1723
|
+
this.autoRefreshSession &&
|
1724
|
+
session.refresh_token &&
|
1725
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1726
|
+
) {
|
1727
|
+
await this.sessionRefresh(session);
|
1275
1728
|
}
|
1276
1729
|
|
1277
|
-
return this.apiClient
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1730
|
+
return this.apiClient
|
1731
|
+
.listCategoryDescs(session.token, clanId, creatorId, categoryName)
|
1732
|
+
.then((response: ApiCategoryDescList) => {
|
1733
|
+
var result: ApiCategoryDescList = {
|
1734
|
+
categorydesc: [],
|
1735
|
+
};
|
1281
1736
|
|
1282
|
-
|
1737
|
+
if (response.categorydesc == null) {
|
1738
|
+
return Promise.resolve(result);
|
1739
|
+
}
|
1740
|
+
|
1741
|
+
result.categorydesc = response.categorydesc;
|
1283
1742
|
return Promise.resolve(result);
|
1284
|
-
}
|
1285
|
-
|
1286
|
-
result.categorydesc = response.categorydesc;
|
1287
|
-
return Promise.resolve(result);
|
1288
|
-
});
|
1743
|
+
});
|
1289
1744
|
}
|
1290
1745
|
|
1291
|
-
|
1292
|
-
|
1293
|
-
if (
|
1294
|
-
|
1295
|
-
|
1746
|
+
/** List event */
|
1747
|
+
async listEvents(session: Session, clanId?: string): Promise<ApiEventList> {
|
1748
|
+
if (
|
1749
|
+
this.autoRefreshSession &&
|
1750
|
+
session.refresh_token &&
|
1751
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1752
|
+
) {
|
1753
|
+
await this.sessionRefresh(session);
|
1296
1754
|
}
|
1297
1755
|
|
1298
|
-
return this.apiClient
|
1299
|
-
|
1300
|
-
|
1756
|
+
return this.apiClient
|
1757
|
+
.listEvents(session.token, clanId)
|
1758
|
+
.then((response: ApiEventList) => {
|
1759
|
+
return Promise.resolve(response);
|
1760
|
+
});
|
1301
1761
|
}
|
1302
1762
|
|
1303
1763
|
/** List permission */
|
1304
1764
|
async getListPermission(session: Session): Promise<ApiPermissionList> {
|
1305
|
-
if (
|
1306
|
-
|
1307
|
-
|
1765
|
+
if (
|
1766
|
+
this.autoRefreshSession &&
|
1767
|
+
session.refresh_token &&
|
1768
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1769
|
+
) {
|
1770
|
+
await this.sessionRefresh(session);
|
1308
1771
|
}
|
1309
1772
|
|
1310
|
-
return this.apiClient
|
1311
|
-
|
1312
|
-
|
1773
|
+
return this.apiClient
|
1774
|
+
.getListPermission(session.token)
|
1775
|
+
.then((response: ApiPermissionList) => {
|
1776
|
+
return Promise.resolve(response);
|
1777
|
+
});
|
1313
1778
|
}
|
1314
1779
|
|
1315
1780
|
/** List user roles */
|
1316
|
-
async listRolePermissions(
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1781
|
+
async listRolePermissions(
|
1782
|
+
session: Session,
|
1783
|
+
roleId: string
|
1784
|
+
): Promise<ApiPermissionList> {
|
1785
|
+
if (
|
1786
|
+
this.autoRefreshSession &&
|
1787
|
+
session.refresh_token &&
|
1788
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1789
|
+
) {
|
1790
|
+
await this.sessionRefresh(session);
|
1320
1791
|
}
|
1321
1792
|
|
1322
|
-
return this.apiClient
|
1323
|
-
|
1324
|
-
|
1793
|
+
return this.apiClient
|
1794
|
+
.listRolePermissions(session.token, roleId)
|
1795
|
+
.then((response: ApiPermissionList) => {
|
1796
|
+
return Promise.resolve(response);
|
1797
|
+
});
|
1325
1798
|
}
|
1326
1799
|
|
1327
1800
|
/** List user roles */
|
1328
|
-
async listRoleUsers(
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1801
|
+
async listRoleUsers(
|
1802
|
+
session: Session,
|
1803
|
+
roleId: string,
|
1804
|
+
limit?: number,
|
1805
|
+
cursor?: string
|
1806
|
+
): Promise<ApiRoleUserList> {
|
1807
|
+
if (
|
1808
|
+
this.autoRefreshSession &&
|
1809
|
+
session.refresh_token &&
|
1810
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1811
|
+
) {
|
1812
|
+
await this.sessionRefresh(session);
|
1332
1813
|
}
|
1333
1814
|
|
1334
|
-
return this.apiClient
|
1335
|
-
|
1336
|
-
|
1815
|
+
return this.apiClient
|
1816
|
+
.listRoleUsers(session.token, roleId, limit, cursor)
|
1817
|
+
.then((response: ApiRoleUserList) => {
|
1818
|
+
return Promise.resolve(response);
|
1819
|
+
});
|
1337
1820
|
}
|
1338
1821
|
|
1339
|
-
async registFCMDeviceToken(
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1822
|
+
async registFCMDeviceToken(
|
1823
|
+
session: Session,
|
1824
|
+
tokenId: string,
|
1825
|
+
deviceId: string,
|
1826
|
+
platform: string
|
1827
|
+
): Promise<boolean> {
|
1828
|
+
if (
|
1829
|
+
this.autoRefreshSession &&
|
1830
|
+
session.refresh_token &&
|
1831
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1832
|
+
) {
|
1833
|
+
await this.sessionRefresh(session);
|
1343
1834
|
}
|
1344
1835
|
|
1345
|
-
return this.apiClient
|
1346
|
-
|
1347
|
-
|
1836
|
+
return this.apiClient
|
1837
|
+
.registFCMDeviceToken(session.token, tokenId, deviceId, platform)
|
1838
|
+
.then((response: any) => {
|
1839
|
+
return response !== undefined;
|
1840
|
+
});
|
1348
1841
|
}
|
1349
1842
|
|
1350
1843
|
/** Get a clan desc profile */
|
1351
|
-
async getClanDescProfile(
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1844
|
+
async getClanDescProfile(
|
1845
|
+
session: Session,
|
1846
|
+
clanId: string
|
1847
|
+
): Promise<ApiClanDescProfile> {
|
1848
|
+
if (
|
1849
|
+
this.autoRefreshSession &&
|
1850
|
+
session.refresh_token &&
|
1851
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1852
|
+
) {
|
1853
|
+
await this.sessionRefresh(session);
|
1355
1854
|
}
|
1356
1855
|
|
1357
|
-
return this.apiClient
|
1358
|
-
|
1359
|
-
|
1856
|
+
return this.apiClient
|
1857
|
+
.getClanDescProfile(session.token, clanId)
|
1858
|
+
.then((response: ApiClanDescProfile) => {
|
1859
|
+
return Promise.resolve(response);
|
1860
|
+
});
|
1360
1861
|
}
|
1361
1862
|
|
1362
|
-
async getUserProfileOnClan(
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1863
|
+
async getUserProfileOnClan(
|
1864
|
+
session: Session,
|
1865
|
+
clanId: string
|
1866
|
+
): Promise<ApiClanProfile> {
|
1867
|
+
if (
|
1868
|
+
this.autoRefreshSession &&
|
1869
|
+
session.refresh_token &&
|
1870
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1871
|
+
) {
|
1872
|
+
await this.sessionRefresh(session);
|
1366
1873
|
}
|
1367
1874
|
|
1368
|
-
return this.apiClient
|
1369
|
-
|
1370
|
-
|
1875
|
+
return this.apiClient
|
1876
|
+
.getUserProfileOnClan(session.token, clanId)
|
1877
|
+
.then((response: ApiClanProfile) => {
|
1878
|
+
return Promise.resolve(response);
|
1879
|
+
});
|
1371
1880
|
}
|
1372
1881
|
|
1373
1882
|
/** Add an Apple ID to the social profiles on the current user's account. */
|
1374
|
-
async linkApple(
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1883
|
+
async linkApple(
|
1884
|
+
session: Session,
|
1885
|
+
request: ApiAccountApple
|
1886
|
+
): Promise<boolean> {
|
1887
|
+
if (
|
1888
|
+
this.autoRefreshSession &&
|
1889
|
+
session.refresh_token &&
|
1890
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1891
|
+
) {
|
1892
|
+
await this.sessionRefresh(session);
|
1378
1893
|
}
|
1379
1894
|
|
1380
|
-
return this.apiClient
|
1381
|
-
|
1382
|
-
|
1895
|
+
return this.apiClient
|
1896
|
+
.linkApple(session.token, request)
|
1897
|
+
.then((response: any) => {
|
1898
|
+
return response !== undefined;
|
1899
|
+
});
|
1383
1900
|
}
|
1384
1901
|
|
1385
1902
|
//
|
1386
|
-
async closeDirectMess(
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1903
|
+
async closeDirectMess(
|
1904
|
+
session: Session,
|
1905
|
+
request: ApiDeleteChannelDescRequest
|
1906
|
+
): Promise<boolean> {
|
1907
|
+
if (
|
1908
|
+
this.autoRefreshSession &&
|
1909
|
+
session.refresh_token &&
|
1910
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1911
|
+
) {
|
1912
|
+
await this.sessionRefresh(session);
|
1390
1913
|
}
|
1391
1914
|
|
1392
|
-
return this.apiClient
|
1393
|
-
|
1394
|
-
|
1915
|
+
return this.apiClient
|
1916
|
+
.closeDirectMess(session.token, request)
|
1917
|
+
.then((response: any) => {
|
1918
|
+
return response !== undefined;
|
1919
|
+
});
|
1395
1920
|
}
|
1396
1921
|
//
|
1397
|
-
async openDirectMess(
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1922
|
+
async openDirectMess(
|
1923
|
+
session: Session,
|
1924
|
+
request: ApiDeleteChannelDescRequest
|
1925
|
+
): Promise<boolean> {
|
1926
|
+
if (
|
1927
|
+
this.autoRefreshSession &&
|
1928
|
+
session.refresh_token &&
|
1929
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1930
|
+
) {
|
1931
|
+
await this.sessionRefresh(session);
|
1401
1932
|
}
|
1402
1933
|
|
1403
|
-
return this.apiClient
|
1404
|
-
|
1405
|
-
|
1934
|
+
return this.apiClient
|
1935
|
+
.openDirectMess(session.token, request)
|
1936
|
+
.then((response: any) => {
|
1937
|
+
return response !== undefined;
|
1938
|
+
});
|
1406
1939
|
}
|
1407
1940
|
|
1408
1941
|
/** Add a custom ID to the social profiles on the current user's account. */
|
1409
|
-
async linkCustom(
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1942
|
+
async linkCustom(
|
1943
|
+
session: Session,
|
1944
|
+
request: ApiAccountCustom
|
1945
|
+
): Promise<boolean> {
|
1946
|
+
if (
|
1947
|
+
this.autoRefreshSession &&
|
1948
|
+
session.refresh_token &&
|
1949
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1950
|
+
) {
|
1951
|
+
await this.sessionRefresh(session);
|
1413
1952
|
}
|
1414
1953
|
|
1415
|
-
return this.apiClient
|
1416
|
-
|
1417
|
-
|
1954
|
+
return this.apiClient
|
1955
|
+
.linkCustom(session.token, request)
|
1956
|
+
.then((response: any) => {
|
1957
|
+
return response !== undefined;
|
1958
|
+
});
|
1418
1959
|
}
|
1419
1960
|
|
1420
1961
|
/** Add a device ID to the social profiles on the current user's account. */
|
1421
|
-
async linkDevice(
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1962
|
+
async linkDevice(
|
1963
|
+
session: Session,
|
1964
|
+
request: ApiAccountDevice
|
1965
|
+
): Promise<boolean> {
|
1966
|
+
if (
|
1967
|
+
this.autoRefreshSession &&
|
1968
|
+
session.refresh_token &&
|
1969
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1970
|
+
) {
|
1971
|
+
await this.sessionRefresh(session);
|
1425
1972
|
}
|
1426
1973
|
|
1427
|
-
return this.apiClient
|
1428
|
-
|
1429
|
-
|
1974
|
+
return this.apiClient
|
1975
|
+
.linkDevice(session.token, request)
|
1976
|
+
.then((response: any) => {
|
1977
|
+
return response !== undefined;
|
1978
|
+
});
|
1430
1979
|
}
|
1431
1980
|
|
1432
1981
|
/** Add an email+password to the social profiles on the current user's account. */
|
1433
|
-
async linkEmail(
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1982
|
+
async linkEmail(
|
1983
|
+
session: Session,
|
1984
|
+
request: ApiAccountEmail
|
1985
|
+
): Promise<boolean> {
|
1986
|
+
if (
|
1987
|
+
this.autoRefreshSession &&
|
1988
|
+
session.refresh_token &&
|
1989
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
1990
|
+
) {
|
1991
|
+
await this.sessionRefresh(session);
|
1437
1992
|
}
|
1438
1993
|
|
1439
|
-
return this.apiClient
|
1440
|
-
|
1441
|
-
|
1994
|
+
return this.apiClient
|
1995
|
+
.linkEmail(session.token, request)
|
1996
|
+
.then((response: any) => {
|
1997
|
+
return response !== undefined;
|
1998
|
+
});
|
1442
1999
|
}
|
1443
2000
|
|
1444
2001
|
/** Add Facebook to the social profiles on the current user's account. */
|
1445
|
-
async linkFacebook(
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
2002
|
+
async linkFacebook(
|
2003
|
+
session: Session,
|
2004
|
+
request: ApiAccountFacebook
|
2005
|
+
): Promise<boolean> {
|
2006
|
+
if (
|
2007
|
+
this.autoRefreshSession &&
|
2008
|
+
session.refresh_token &&
|
2009
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2010
|
+
) {
|
2011
|
+
await this.sessionRefresh(session);
|
1449
2012
|
}
|
1450
2013
|
|
1451
|
-
return this.apiClient
|
1452
|
-
|
1453
|
-
|
2014
|
+
return this.apiClient
|
2015
|
+
.linkFacebook(session.token, request)
|
2016
|
+
.then((response: any) => {
|
2017
|
+
return response !== undefined;
|
2018
|
+
});
|
1454
2019
|
}
|
1455
2020
|
|
1456
2021
|
/** Add Facebook Instant to the social profiles on the current user's account. */
|
1457
|
-
async linkFacebookInstantGame(
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
2022
|
+
async linkFacebookInstantGame(
|
2023
|
+
session: Session,
|
2024
|
+
request: ApiAccountFacebookInstantGame
|
2025
|
+
): Promise<boolean> {
|
2026
|
+
if (
|
2027
|
+
this.autoRefreshSession &&
|
2028
|
+
session.refresh_token &&
|
2029
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2030
|
+
) {
|
2031
|
+
await this.sessionRefresh(session);
|
1461
2032
|
}
|
1462
2033
|
|
1463
|
-
return this.apiClient
|
1464
|
-
|
1465
|
-
|
2034
|
+
return this.apiClient
|
2035
|
+
.linkFacebookInstantGame(session.token, request)
|
2036
|
+
.then((response: any) => {
|
2037
|
+
return response !== undefined;
|
2038
|
+
});
|
1466
2039
|
}
|
1467
2040
|
|
1468
2041
|
/** Add Google to the social profiles on the current user's account. */
|
1469
|
-
async linkGoogle(
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
2042
|
+
async linkGoogle(
|
2043
|
+
session: Session,
|
2044
|
+
request: ApiAccountGoogle
|
2045
|
+
): Promise<boolean> {
|
2046
|
+
if (
|
2047
|
+
this.autoRefreshSession &&
|
2048
|
+
session.refresh_token &&
|
2049
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2050
|
+
) {
|
2051
|
+
await this.sessionRefresh(session);
|
1473
2052
|
}
|
1474
2053
|
|
1475
|
-
return this.apiClient
|
1476
|
-
|
1477
|
-
|
2054
|
+
return this.apiClient
|
2055
|
+
.linkGoogle(session.token, request)
|
2056
|
+
.then((response: any) => {
|
2057
|
+
return response !== undefined;
|
2058
|
+
});
|
1478
2059
|
}
|
1479
2060
|
|
1480
2061
|
/** Add GameCenter to the social profiles on the current user's account. */
|
1481
|
-
async linkGameCenter(
|
1482
|
-
|
1483
|
-
|
1484
|
-
|
2062
|
+
async linkGameCenter(
|
2063
|
+
session: Session,
|
2064
|
+
request: ApiAccountGameCenter
|
2065
|
+
): Promise<boolean> {
|
2066
|
+
if (
|
2067
|
+
this.autoRefreshSession &&
|
2068
|
+
session.refresh_token &&
|
2069
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2070
|
+
) {
|
2071
|
+
await this.sessionRefresh(session);
|
1485
2072
|
}
|
1486
2073
|
|
1487
|
-
return this.apiClient
|
1488
|
-
|
1489
|
-
|
2074
|
+
return this.apiClient
|
2075
|
+
.linkGameCenter(session.token, request)
|
2076
|
+
.then((response: any) => {
|
2077
|
+
return response !== undefined;
|
2078
|
+
});
|
1490
2079
|
}
|
1491
2080
|
|
1492
2081
|
/** Add Steam to the social profiles on the current user's account. */
|
1493
|
-
async linkSteam(
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
2082
|
+
async linkSteam(
|
2083
|
+
session: Session,
|
2084
|
+
request: ApiLinkSteamRequest
|
2085
|
+
): Promise<boolean> {
|
2086
|
+
if (
|
2087
|
+
this.autoRefreshSession &&
|
2088
|
+
session.refresh_token &&
|
2089
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2090
|
+
) {
|
2091
|
+
await this.sessionRefresh(session);
|
1497
2092
|
}
|
1498
2093
|
|
1499
|
-
return this.apiClient
|
1500
|
-
|
1501
|
-
|
2094
|
+
return this.apiClient
|
2095
|
+
.linkSteam(session.token, request)
|
2096
|
+
.then((response: any) => {
|
2097
|
+
return response !== undefined;
|
2098
|
+
});
|
1502
2099
|
}
|
1503
2100
|
|
1504
2101
|
/** List all friends for the current user. */
|
1505
|
-
async listFriends(
|
1506
|
-
|
1507
|
-
|
1508
|
-
|
2102
|
+
async listFriends(
|
2103
|
+
session: Session,
|
2104
|
+
state?: number,
|
2105
|
+
limit?: number,
|
2106
|
+
cursor?: string
|
2107
|
+
): Promise<Friends> {
|
2108
|
+
if (
|
2109
|
+
this.autoRefreshSession &&
|
2110
|
+
session.refresh_token &&
|
2111
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2112
|
+
) {
|
2113
|
+
await this.sessionRefresh(session);
|
1509
2114
|
}
|
1510
2115
|
|
1511
|
-
return this.apiClient
|
2116
|
+
return this.apiClient
|
2117
|
+
.listFriends(session.token, limit, state, cursor)
|
2118
|
+
.then((response: ApiFriendList) => {
|
2119
|
+
var result: Friends = {
|
2120
|
+
friends: [],
|
2121
|
+
cursor: response.cursor,
|
2122
|
+
};
|
1512
2123
|
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
};
|
2124
|
+
if (response.friends == null) {
|
2125
|
+
return Promise.resolve(result);
|
2126
|
+
}
|
1517
2127
|
|
1518
|
-
|
2128
|
+
response.friends!.forEach((f) => {
|
2129
|
+
result.friends!.push({
|
2130
|
+
user: {
|
2131
|
+
avatar_url: f.user!.avatar_url,
|
2132
|
+
create_time: f.user!.create_time,
|
2133
|
+
display_name: f.user!.display_name,
|
2134
|
+
edge_count: f.user!.edge_count ? Number(f.user!.edge_count) : 0,
|
2135
|
+
facebook_id: f.user!.facebook_id,
|
2136
|
+
gamecenter_id: f.user!.gamecenter_id,
|
2137
|
+
google_id: f.user!.google_id,
|
2138
|
+
id: f.user!.id,
|
2139
|
+
lang_tag: f.user!.lang_tag,
|
2140
|
+
location: f.user!.location,
|
2141
|
+
online: f.user!.online,
|
2142
|
+
steam_id: f.user!.steam_id,
|
2143
|
+
timezone: f.user!.timezone,
|
2144
|
+
update_time: f.user!.update_time,
|
2145
|
+
username: f.user!.username,
|
2146
|
+
metadata: f.user!.metadata
|
2147
|
+
? JSON.parse(f.user!.metadata!)
|
2148
|
+
: undefined,
|
2149
|
+
},
|
2150
|
+
state: f.state,
|
2151
|
+
});
|
2152
|
+
});
|
1519
2153
|
return Promise.resolve(result);
|
1520
|
-
}
|
1521
|
-
|
1522
|
-
response.friends!.forEach(f => {
|
1523
|
-
result.friends!.push({
|
1524
|
-
user: {
|
1525
|
-
avatar_url: f.user!.avatar_url,
|
1526
|
-
create_time: f.user!.create_time,
|
1527
|
-
display_name: f.user!.display_name,
|
1528
|
-
edge_count: f.user!.edge_count ? Number(f.user!.edge_count) : 0,
|
1529
|
-
facebook_id: f.user!.facebook_id,
|
1530
|
-
gamecenter_id: f.user!.gamecenter_id,
|
1531
|
-
google_id: f.user!.google_id,
|
1532
|
-
id: f.user!.id,
|
1533
|
-
lang_tag: f.user!.lang_tag,
|
1534
|
-
location: f.user!.location,
|
1535
|
-
online: f.user!.online,
|
1536
|
-
steam_id: f.user!.steam_id,
|
1537
|
-
timezone: f.user!.timezone,
|
1538
|
-
update_time: f.user!.update_time,
|
1539
|
-
username: f.user!.username,
|
1540
|
-
metadata: f.user!.metadata ? JSON.parse(f.user!.metadata!) : undefined,
|
1541
|
-
},
|
1542
|
-
state: f.state
|
1543
|
-
})
|
1544
|
-
});
|
1545
|
-
return Promise.resolve(result);
|
1546
|
-
});
|
2154
|
+
});
|
1547
2155
|
}
|
1548
2156
|
|
1549
2157
|
/** Fetch list of notifications. */
|
1550
|
-
async listNotifications(
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
2158
|
+
async listNotifications(
|
2159
|
+
session: Session,
|
2160
|
+
clanId: string,
|
2161
|
+
limit?: number,
|
2162
|
+
cacheableCursor?: string
|
2163
|
+
): Promise<NotificationList> {
|
2164
|
+
if (
|
2165
|
+
this.autoRefreshSession &&
|
2166
|
+
session.refresh_token &&
|
2167
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2168
|
+
) {
|
2169
|
+
await this.sessionRefresh(session);
|
1554
2170
|
}
|
1555
2171
|
|
1556
|
-
return this.apiClient
|
1557
|
-
|
1558
|
-
|
1559
|
-
|
1560
|
-
|
2172
|
+
return this.apiClient
|
2173
|
+
.listNotifications(session.token, clanId, limit, cacheableCursor)
|
2174
|
+
.then((response: ApiNotificationList) => {
|
2175
|
+
var result: NotificationList = {
|
2176
|
+
cacheable_cursor: response.cacheable_cursor,
|
2177
|
+
notifications: [],
|
2178
|
+
};
|
2179
|
+
|
2180
|
+
if (response.notifications == null) {
|
2181
|
+
return Promise.resolve(result);
|
2182
|
+
}
|
1561
2183
|
|
1562
|
-
|
2184
|
+
response.notifications!.forEach((n) => {
|
2185
|
+
result.notifications!.push({
|
2186
|
+
code: n.code ? Number(n.code) : 0,
|
2187
|
+
create_time: n.create_time,
|
2188
|
+
id: n.id,
|
2189
|
+
persistent: n.persistent,
|
2190
|
+
sender_id: n.sender_id,
|
2191
|
+
subject: n.subject,
|
2192
|
+
content: n.content ? JSON.parse(n.content) : undefined,
|
2193
|
+
});
|
2194
|
+
});
|
1563
2195
|
return Promise.resolve(result);
|
1564
|
-
}
|
1565
|
-
|
1566
|
-
response.notifications!.forEach(n => {
|
1567
|
-
result.notifications!.push({
|
1568
|
-
code: n.code ? Number(n.code) : 0,
|
1569
|
-
create_time: n.create_time,
|
1570
|
-
id: n.id,
|
1571
|
-
persistent: n.persistent,
|
1572
|
-
sender_id: n.sender_id,
|
1573
|
-
subject: n.subject,
|
1574
|
-
content: n.content ? JSON.parse(n.content) : undefined
|
1575
|
-
})
|
1576
|
-
});
|
1577
|
-
return Promise.resolve(result);
|
1578
|
-
});
|
2196
|
+
});
|
1579
2197
|
}
|
1580
2198
|
|
1581
2199
|
/** Execute an RPC function on the server. */
|
1582
|
-
async rpc(
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
2200
|
+
async rpc(
|
2201
|
+
session: Session,
|
2202
|
+
basicAuthUsername: string,
|
2203
|
+
basicAuthPassword: string,
|
2204
|
+
id: string,
|
2205
|
+
input: object
|
2206
|
+
): Promise<RpcResponse> {
|
2207
|
+
if (
|
2208
|
+
this.autoRefreshSession &&
|
2209
|
+
session.refresh_token &&
|
2210
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2211
|
+
) {
|
2212
|
+
await this.sessionRefresh(session);
|
1587
2213
|
}
|
1588
2214
|
|
1589
|
-
return this.apiClient
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
2215
|
+
return this.apiClient
|
2216
|
+
.rpcFunc(
|
2217
|
+
session.token,
|
2218
|
+
basicAuthUsername,
|
2219
|
+
basicAuthPassword,
|
2220
|
+
id,
|
2221
|
+
JSON.stringify(input)
|
2222
|
+
)
|
2223
|
+
.then((response: ApiRpc) => {
|
2224
|
+
return Promise.resolve({
|
2225
|
+
id: response.id,
|
2226
|
+
payload: !response.payload ? undefined : JSON.parse(response.payload),
|
2227
|
+
});
|
1593
2228
|
});
|
1594
|
-
});
|
1595
2229
|
}
|
1596
2230
|
|
1597
2231
|
/** Execute an RPC function on the server. */
|
1598
|
-
async rpcHttpKey(
|
1599
|
-
|
2232
|
+
async rpcHttpKey(
|
2233
|
+
httpKey: string,
|
2234
|
+
id: string,
|
2235
|
+
input?: object
|
2236
|
+
): Promise<RpcResponse> {
|
2237
|
+
return this.apiClient
|
2238
|
+
.rpcFunc2("", id, (input && JSON.stringify(input)) || "", httpKey)
|
1600
2239
|
.then((response: ApiRpc) => {
|
1601
2240
|
return Promise.resolve({
|
1602
2241
|
id: response.id,
|
1603
|
-
payload:
|
2242
|
+
payload: !response.payload ? undefined : JSON.parse(response.payload),
|
1604
2243
|
});
|
1605
|
-
})
|
2244
|
+
})
|
2245
|
+
.catch((err: any) => {
|
1606
2246
|
throw err;
|
1607
2247
|
});
|
1608
2248
|
}
|
1609
2249
|
|
1610
2250
|
/** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
|
1611
|
-
async sessionLogout(
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
2251
|
+
async sessionLogout(
|
2252
|
+
session: Session,
|
2253
|
+
token: string,
|
2254
|
+
refreshToken: string
|
2255
|
+
): Promise<boolean> {
|
2256
|
+
if (
|
2257
|
+
this.autoRefreshSession &&
|
2258
|
+
session.refresh_token &&
|
2259
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2260
|
+
) {
|
2261
|
+
await this.sessionRefresh(session);
|
1615
2262
|
}
|
1616
2263
|
|
1617
|
-
return this.apiClient
|
2264
|
+
return this.apiClient
|
2265
|
+
.sessionLogout(session.token, {
|
2266
|
+
refresh_token: refreshToken,
|
2267
|
+
token: token,
|
2268
|
+
})
|
2269
|
+
.then((response: any) => {
|
1618
2270
|
return response !== undefined;
|
1619
|
-
|
2271
|
+
});
|
1620
2272
|
}
|
1621
2273
|
|
1622
2274
|
/** Refresh a user's session using a refresh token retrieved from a previous authentication request. */
|
1623
|
-
async sessionRefresh(
|
1624
|
-
|
2275
|
+
async sessionRefresh(
|
2276
|
+
session: Session,
|
2277
|
+
vars: Record<string, string> = {}
|
2278
|
+
): Promise<Session> {
|
1625
2279
|
if (!session) {
|
1626
|
-
|
1627
|
-
|
2280
|
+
console.error("Cannot refresh a null session.");
|
2281
|
+
return session;
|
1628
2282
|
}
|
1629
2283
|
|
1630
2284
|
if (session.created && session.expires_at! - session.created_at < 70) {
|
1631
|
-
|
2285
|
+
console.warn(
|
2286
|
+
"Session lifetime too short, please set '--session.token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"
|
2287
|
+
);
|
1632
2288
|
}
|
1633
2289
|
|
1634
|
-
if (
|
1635
|
-
|
2290
|
+
if (
|
2291
|
+
session.created &&
|
2292
|
+
session.refresh_expires_at! - session.created_at < 3700
|
2293
|
+
) {
|
2294
|
+
console.warn(
|
2295
|
+
"Session refresh lifetime too short, please set '--session.refresh_token_expiry_sec' option. See the documentation for more info: https://mezon.vn/docs/mezon/getting-started/configuration/#session"
|
2296
|
+
);
|
1636
2297
|
}
|
1637
2298
|
|
1638
|
-
const apiSession = await this.apiClient.sessionRefresh(this.serverkey, "", {
|
2299
|
+
const apiSession = await this.apiClient.sessionRefresh(this.serverkey, "", {
|
2300
|
+
token: session.refresh_token,
|
2301
|
+
vars: vars,
|
2302
|
+
});
|
1639
2303
|
session.update(apiSession.token!, apiSession.refresh_token!);
|
1640
2304
|
return session;
|
1641
2305
|
}
|
1642
2306
|
|
1643
2307
|
/** Remove the Apple ID from the social profiles on the current user's account. */
|
1644
|
-
async unlinkApple(
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
2308
|
+
async unlinkApple(
|
2309
|
+
session: Session,
|
2310
|
+
request: ApiAccountApple
|
2311
|
+
): Promise<boolean> {
|
2312
|
+
if (
|
2313
|
+
this.autoRefreshSession &&
|
2314
|
+
session.refresh_token &&
|
2315
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2316
|
+
) {
|
2317
|
+
await this.sessionRefresh(session);
|
1648
2318
|
}
|
1649
2319
|
|
1650
|
-
return this.apiClient
|
1651
|
-
|
1652
|
-
|
2320
|
+
return this.apiClient
|
2321
|
+
.unlinkApple(session.token, request)
|
2322
|
+
.then((response: any) => {
|
2323
|
+
return response !== undefined;
|
2324
|
+
});
|
1653
2325
|
}
|
1654
2326
|
|
1655
|
-
|
1656
2327
|
/** Remove custom ID from the social profiles on the current user's account. */
|
1657
|
-
async unlinkCustom(
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
2328
|
+
async unlinkCustom(
|
2329
|
+
session: Session,
|
2330
|
+
request: ApiAccountCustom
|
2331
|
+
): Promise<boolean> {
|
2332
|
+
if (
|
2333
|
+
this.autoRefreshSession &&
|
2334
|
+
session.refresh_token &&
|
2335
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2336
|
+
) {
|
2337
|
+
await this.sessionRefresh(session);
|
1661
2338
|
}
|
1662
2339
|
|
1663
|
-
return this.apiClient
|
1664
|
-
|
1665
|
-
|
2340
|
+
return this.apiClient
|
2341
|
+
.unlinkCustom(session.token, request)
|
2342
|
+
.then((response: any) => {
|
2343
|
+
return response !== undefined;
|
2344
|
+
});
|
1666
2345
|
}
|
1667
2346
|
|
1668
2347
|
/** Remove a device ID from the social profiles on the current user's account. */
|
1669
|
-
async unlinkDevice(
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
2348
|
+
async unlinkDevice(
|
2349
|
+
session: Session,
|
2350
|
+
request: ApiAccountDevice
|
2351
|
+
): Promise<boolean> {
|
2352
|
+
if (
|
2353
|
+
this.autoRefreshSession &&
|
2354
|
+
session.refresh_token &&
|
2355
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2356
|
+
) {
|
2357
|
+
await this.sessionRefresh(session);
|
1673
2358
|
}
|
1674
2359
|
|
1675
|
-
return this.apiClient
|
1676
|
-
|
1677
|
-
|
2360
|
+
return this.apiClient
|
2361
|
+
.unlinkDevice(session.token, request)
|
2362
|
+
.then((response: any) => {
|
2363
|
+
return response !== undefined;
|
2364
|
+
});
|
1678
2365
|
}
|
1679
2366
|
|
1680
2367
|
/** Remove an email+password from the social profiles on the current user's account. */
|
1681
|
-
async unlinkEmail(
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
2368
|
+
async unlinkEmail(
|
2369
|
+
session: Session,
|
2370
|
+
request: ApiAccountEmail
|
2371
|
+
): Promise<boolean> {
|
2372
|
+
if (
|
2373
|
+
this.autoRefreshSession &&
|
2374
|
+
session.refresh_token &&
|
2375
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2376
|
+
) {
|
2377
|
+
await this.sessionRefresh(session);
|
1685
2378
|
}
|
1686
2379
|
|
1687
|
-
return this.apiClient
|
1688
|
-
|
1689
|
-
|
2380
|
+
return this.apiClient
|
2381
|
+
.unlinkEmail(session.token, request)
|
2382
|
+
.then((response: any) => {
|
2383
|
+
return response !== undefined;
|
2384
|
+
});
|
1690
2385
|
}
|
1691
2386
|
|
1692
2387
|
/** Remove Facebook from the social profiles on the current user's account. */
|
1693
|
-
async unlinkFacebook(
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
2388
|
+
async unlinkFacebook(
|
2389
|
+
session: Session,
|
2390
|
+
request: ApiAccountFacebook
|
2391
|
+
): Promise<boolean> {
|
2392
|
+
if (
|
2393
|
+
this.autoRefreshSession &&
|
2394
|
+
session.refresh_token &&
|
2395
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2396
|
+
) {
|
2397
|
+
await this.sessionRefresh(session);
|
1697
2398
|
}
|
1698
2399
|
|
1699
|
-
return this.apiClient
|
1700
|
-
|
1701
|
-
|
2400
|
+
return this.apiClient
|
2401
|
+
.unlinkFacebook(session.token, request)
|
2402
|
+
.then((response: any) => {
|
2403
|
+
return response !== undefined;
|
2404
|
+
});
|
1702
2405
|
}
|
1703
2406
|
|
1704
2407
|
/** Remove Facebook Instant social profiles from the current user's account. */
|
1705
|
-
async unlinkFacebookInstantGame(
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
2408
|
+
async unlinkFacebookInstantGame(
|
2409
|
+
session: Session,
|
2410
|
+
request: ApiAccountFacebookInstantGame
|
2411
|
+
): Promise<boolean> {
|
2412
|
+
if (
|
2413
|
+
this.autoRefreshSession &&
|
2414
|
+
session.refresh_token &&
|
2415
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2416
|
+
) {
|
2417
|
+
await this.sessionRefresh(session);
|
1709
2418
|
}
|
1710
2419
|
|
1711
|
-
return this.apiClient
|
1712
|
-
|
1713
|
-
|
2420
|
+
return this.apiClient
|
2421
|
+
.unlinkFacebookInstantGame(session.token, request)
|
2422
|
+
.then((response: any) => {
|
2423
|
+
return response !== undefined;
|
2424
|
+
});
|
1714
2425
|
}
|
1715
2426
|
|
1716
2427
|
/** Remove Google from the social profiles on the current user's account. */
|
1717
|
-
async unlinkGoogle(
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
2428
|
+
async unlinkGoogle(
|
2429
|
+
session: Session,
|
2430
|
+
request: ApiAccountGoogle
|
2431
|
+
): Promise<boolean> {
|
2432
|
+
if (
|
2433
|
+
this.autoRefreshSession &&
|
2434
|
+
session.refresh_token &&
|
2435
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2436
|
+
) {
|
2437
|
+
await this.sessionRefresh(session);
|
1721
2438
|
}
|
1722
2439
|
|
1723
|
-
return this.apiClient
|
1724
|
-
|
1725
|
-
|
2440
|
+
return this.apiClient
|
2441
|
+
.unlinkGoogle(session.token, request)
|
2442
|
+
.then((response: any) => {
|
2443
|
+
return response !== undefined;
|
2444
|
+
});
|
1726
2445
|
}
|
1727
2446
|
|
1728
2447
|
/** Remove GameCenter from the social profiles on the current user's account. */
|
1729
|
-
async unlinkGameCenter(
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
2448
|
+
async unlinkGameCenter(
|
2449
|
+
session: Session,
|
2450
|
+
request: ApiAccountGameCenter
|
2451
|
+
): Promise<boolean> {
|
2452
|
+
if (
|
2453
|
+
this.autoRefreshSession &&
|
2454
|
+
session.refresh_token &&
|
2455
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2456
|
+
) {
|
2457
|
+
await this.sessionRefresh(session);
|
1733
2458
|
}
|
1734
2459
|
|
1735
|
-
return this.apiClient
|
1736
|
-
|
1737
|
-
|
2460
|
+
return this.apiClient
|
2461
|
+
.unlinkGameCenter(session.token, request)
|
2462
|
+
.then((response: any) => {
|
2463
|
+
return response !== undefined;
|
2464
|
+
});
|
1738
2465
|
}
|
1739
2466
|
|
1740
2467
|
/** Remove Steam from the social profiles on the current user's account. */
|
1741
|
-
async unlinkSteam(
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
2468
|
+
async unlinkSteam(
|
2469
|
+
session: Session,
|
2470
|
+
request: ApiAccountSteam
|
2471
|
+
): Promise<boolean> {
|
2472
|
+
if (
|
2473
|
+
this.autoRefreshSession &&
|
2474
|
+
session.refresh_token &&
|
2475
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2476
|
+
) {
|
2477
|
+
await this.sessionRefresh(session);
|
1745
2478
|
}
|
1746
|
-
return this.apiClient
|
1747
|
-
|
1748
|
-
|
2479
|
+
return this.apiClient
|
2480
|
+
.unlinkSteam(session.token, request)
|
2481
|
+
.then((response: any) => {
|
2482
|
+
return response !== undefined;
|
2483
|
+
});
|
1749
2484
|
}
|
1750
2485
|
|
1751
2486
|
/** Update fields in the current user's account. */
|
1752
|
-
async updateAccount(
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
2487
|
+
async updateAccount(
|
2488
|
+
session: Session,
|
2489
|
+
request: ApiUpdateAccountRequest
|
2490
|
+
): Promise<boolean> {
|
2491
|
+
if (
|
2492
|
+
this.autoRefreshSession &&
|
2493
|
+
session.refresh_token &&
|
2494
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2495
|
+
) {
|
2496
|
+
await this.sessionRefresh(session);
|
1756
2497
|
}
|
1757
2498
|
|
1758
|
-
return this.apiClient
|
1759
|
-
|
1760
|
-
|
2499
|
+
return this.apiClient
|
2500
|
+
.updateAccount(session.token, request)
|
2501
|
+
.then((response: any) => {
|
2502
|
+
return response !== undefined;
|
2503
|
+
});
|
1761
2504
|
}
|
1762
2505
|
|
1763
2506
|
/** Update fields in a given channel */
|
1764
|
-
async updateChannelDesc(
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
2507
|
+
async updateChannelDesc(
|
2508
|
+
session: Session,
|
2509
|
+
channelId: string,
|
2510
|
+
request: ApiUpdateChannelDescRequest
|
2511
|
+
): Promise<boolean> {
|
2512
|
+
if (
|
2513
|
+
this.autoRefreshSession &&
|
2514
|
+
session.refresh_token &&
|
2515
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2516
|
+
) {
|
2517
|
+
await this.sessionRefresh(session);
|
1768
2518
|
}
|
1769
2519
|
|
1770
|
-
return this.apiClient
|
1771
|
-
|
1772
|
-
|
2520
|
+
return this.apiClient
|
2521
|
+
.updateChannelDesc(session.token, channelId, request)
|
2522
|
+
.then((response: any) => {
|
2523
|
+
return response !== undefined;
|
2524
|
+
});
|
1773
2525
|
}
|
1774
2526
|
|
1775
2527
|
/** Update fields in a given clan. */
|
1776
|
-
async updateClanDesc(
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
2528
|
+
async updateClanDesc(
|
2529
|
+
session: Session,
|
2530
|
+
clanId: string,
|
2531
|
+
request: ApiUpdateClanDescRequest
|
2532
|
+
): Promise<boolean> {
|
2533
|
+
if (
|
2534
|
+
this.autoRefreshSession &&
|
2535
|
+
session.refresh_token &&
|
2536
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2537
|
+
) {
|
2538
|
+
await this.sessionRefresh(session);
|
1780
2539
|
}
|
1781
2540
|
|
1782
|
-
return this.apiClient
|
1783
|
-
|
1784
|
-
|
2541
|
+
return this.apiClient
|
2542
|
+
.updateClanDesc(session.token, clanId, request)
|
2543
|
+
.then((response: any) => {
|
2544
|
+
return response !== undefined;
|
2545
|
+
});
|
1785
2546
|
}
|
1786
2547
|
|
1787
2548
|
/** Update fields in a given category. */
|
1788
|
-
async updateCategory(
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
2549
|
+
async updateCategory(
|
2550
|
+
session: Session,
|
2551
|
+
request: ApiUpdateCategoryDescRequest
|
2552
|
+
): Promise<boolean> {
|
2553
|
+
if (
|
2554
|
+
this.autoRefreshSession &&
|
2555
|
+
session.refresh_token &&
|
2556
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2557
|
+
) {
|
2558
|
+
await this.sessionRefresh(session);
|
1792
2559
|
}
|
1793
2560
|
|
1794
|
-
return this.apiClient
|
1795
|
-
|
1796
|
-
|
2561
|
+
return this.apiClient
|
2562
|
+
.updateCategory(session.token, request)
|
2563
|
+
.then((response: any) => {
|
2564
|
+
return response !== undefined;
|
2565
|
+
});
|
1797
2566
|
}
|
1798
2567
|
|
1799
2568
|
/** Update fields in a given clan profile. */
|
1800
|
-
async updateClanDescProfile(
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
2569
|
+
async updateClanDescProfile(
|
2570
|
+
session: Session,
|
2571
|
+
clanId: string,
|
2572
|
+
request: ApiUpdateClanDescProfileRequest
|
2573
|
+
): Promise<boolean> {
|
2574
|
+
if (
|
2575
|
+
this.autoRefreshSession &&
|
2576
|
+
session.refresh_token &&
|
2577
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2578
|
+
) {
|
2579
|
+
await this.sessionRefresh(session);
|
1804
2580
|
}
|
1805
2581
|
|
1806
|
-
return this.apiClient
|
1807
|
-
|
1808
|
-
|
2582
|
+
return this.apiClient
|
2583
|
+
.updateClanDescProfile(session.token, clanId, request)
|
2584
|
+
.then((response: any) => {
|
2585
|
+
return response !== undefined;
|
2586
|
+
});
|
1809
2587
|
}
|
1810
2588
|
|
1811
|
-
async updateUserProfileByClan(
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
2589
|
+
async updateUserProfileByClan(
|
2590
|
+
session: Session,
|
2591
|
+
clanId: string,
|
2592
|
+
request: ApiUpdateClanProfileRequest
|
2593
|
+
): Promise<boolean> {
|
2594
|
+
if (
|
2595
|
+
this.autoRefreshSession &&
|
2596
|
+
session.refresh_token &&
|
2597
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2598
|
+
) {
|
2599
|
+
await this.sessionRefresh(session);
|
1815
2600
|
}
|
1816
2601
|
|
1817
|
-
return this.apiClient
|
1818
|
-
|
1819
|
-
|
2602
|
+
return this.apiClient
|
2603
|
+
.updateUserProfileByClan(session.token, clanId, request)
|
2604
|
+
.then((response: any) => {
|
2605
|
+
return response !== undefined;
|
2606
|
+
});
|
1820
2607
|
}
|
1821
2608
|
|
1822
2609
|
/** Update fields in a given role. */
|
1823
|
-
async updateRole(
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
2610
|
+
async updateRole(
|
2611
|
+
session: Session,
|
2612
|
+
roleId: string,
|
2613
|
+
request: ApiUpdateRoleRequest
|
2614
|
+
): Promise<boolean> {
|
2615
|
+
if (
|
2616
|
+
this.autoRefreshSession &&
|
2617
|
+
session.refresh_token &&
|
2618
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2619
|
+
) {
|
2620
|
+
await this.sessionRefresh(session);
|
1827
2621
|
}
|
1828
2622
|
|
1829
|
-
return this.apiClient
|
1830
|
-
|
1831
|
-
|
2623
|
+
return this.apiClient
|
2624
|
+
.updateRole(session.token, roleId, request)
|
2625
|
+
.then((response: any) => {
|
2626
|
+
return response !== undefined;
|
2627
|
+
});
|
1832
2628
|
}
|
1833
2629
|
|
1834
2630
|
/** Update fields in a given event. */
|
1835
|
-
async updateEvent(
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
2631
|
+
async updateEvent(
|
2632
|
+
session: Session,
|
2633
|
+
roleId: string,
|
2634
|
+
request: ApiUpdateEventRequest
|
2635
|
+
): Promise<boolean> {
|
2636
|
+
if (
|
2637
|
+
this.autoRefreshSession &&
|
2638
|
+
session.refresh_token &&
|
2639
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2640
|
+
) {
|
2641
|
+
await this.sessionRefresh(session);
|
1839
2642
|
}
|
1840
2643
|
|
1841
|
-
return this.apiClient
|
1842
|
-
|
1843
|
-
|
2644
|
+
return this.apiClient
|
2645
|
+
.updateEvent(session.token, roleId, request)
|
2646
|
+
.then((response: any) => {
|
2647
|
+
return response !== undefined;
|
2648
|
+
});
|
1844
2649
|
}
|
1845
2650
|
|
1846
2651
|
/** Update fields in a given event. */
|
1847
|
-
async updateApp(
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
2652
|
+
async updateApp(
|
2653
|
+
session: Session,
|
2654
|
+
roleId: string,
|
2655
|
+
request: MezonUpdateAppBody
|
2656
|
+
): Promise<boolean> {
|
2657
|
+
if (
|
2658
|
+
this.autoRefreshSession &&
|
2659
|
+
session.refresh_token &&
|
2660
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2661
|
+
) {
|
2662
|
+
await this.sessionRefresh(session);
|
1851
2663
|
}
|
1852
2664
|
|
1853
|
-
return this.apiClient
|
1854
|
-
|
1855
|
-
|
2665
|
+
return this.apiClient
|
2666
|
+
.updateApp(session.token, roleId, request)
|
2667
|
+
.then((response: any) => {
|
2668
|
+
return response !== undefined;
|
2669
|
+
});
|
1856
2670
|
}
|
1857
2671
|
|
1858
2672
|
/** Update fields in a given clan profile. */
|
1859
|
-
async createLinkInviteUser(
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
2673
|
+
async createLinkInviteUser(
|
2674
|
+
session: Session,
|
2675
|
+
request: ApiLinkInviteUserRequest
|
2676
|
+
): Promise<ApiLinkInviteUser> {
|
2677
|
+
if (
|
2678
|
+
this.autoRefreshSession &&
|
2679
|
+
session.refresh_token &&
|
2680
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2681
|
+
) {
|
2682
|
+
await this.sessionRefresh(session);
|
1863
2683
|
}
|
1864
2684
|
|
1865
|
-
return this.apiClient
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
2685
|
+
return this.apiClient
|
2686
|
+
.createLinkInviteUser(session.token, request)
|
2687
|
+
.then((response: ApiLinkInviteUser) => {
|
2688
|
+
return Promise.resolve(response);
|
2689
|
+
});
|
1869
2690
|
}
|
1870
2691
|
|
1871
2692
|
/** Get link invite user */
|
1872
|
-
async getLinkInvite(
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
2693
|
+
async getLinkInvite(
|
2694
|
+
session: Session,
|
2695
|
+
inviteId: string
|
2696
|
+
): Promise<ApiInviteUserRes> {
|
2697
|
+
if (
|
2698
|
+
this.autoRefreshSession &&
|
2699
|
+
session.refresh_token &&
|
2700
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2701
|
+
) {
|
2702
|
+
await this.sessionRefresh(session);
|
1876
2703
|
}
|
1877
|
-
|
1878
|
-
return this.apiClient
|
1879
|
-
|
1880
|
-
|
1881
|
-
|
2704
|
+
|
2705
|
+
return this.apiClient
|
2706
|
+
.getLinkInvite(session.token, inviteId)
|
2707
|
+
.then((response: ApiInviteUserRes) => {
|
2708
|
+
return Promise.resolve(response);
|
2709
|
+
});
|
1882
2710
|
}
|
1883
|
-
|
2711
|
+
|
1884
2712
|
/** Get permission of user in the clan */
|
1885
|
-
async getPermissionOfUserInTheClan(
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
2713
|
+
async getPermissionOfUserInTheClan(
|
2714
|
+
session: Session,
|
2715
|
+
clanId: string
|
2716
|
+
): Promise<ApiPermissionList> {
|
2717
|
+
if (
|
2718
|
+
this.autoRefreshSession &&
|
2719
|
+
session.refresh_token &&
|
2720
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2721
|
+
) {
|
2722
|
+
await this.sessionRefresh(session);
|
1889
2723
|
}
|
1890
|
-
|
1891
|
-
return this.apiClient
|
1892
|
-
|
1893
|
-
|
1894
|
-
|
2724
|
+
|
2725
|
+
return this.apiClient
|
2726
|
+
.getPermissionOfUserInTheClan(session.token, clanId)
|
2727
|
+
.then((response: ApiPermissionList) => {
|
2728
|
+
return Promise.resolve(response);
|
2729
|
+
});
|
1895
2730
|
}
|
1896
2731
|
|
1897
2732
|
/** invite user */
|
1898
|
-
async inviteUser(
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
2733
|
+
async inviteUser(
|
2734
|
+
session: Session,
|
2735
|
+
inviteId: string
|
2736
|
+
): Promise<ApiInviteUserRes> {
|
2737
|
+
if (
|
2738
|
+
this.autoRefreshSession &&
|
2739
|
+
session.refresh_token &&
|
2740
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2741
|
+
) {
|
2742
|
+
await this.sessionRefresh(session);
|
1902
2743
|
}
|
1903
|
-
|
1904
|
-
return this.apiClient
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
2744
|
+
|
2745
|
+
return this.apiClient
|
2746
|
+
.inviteUser(session.token, inviteId)
|
2747
|
+
.then((response: ApiInviteUserRes) => {
|
2748
|
+
return Promise.resolve(response);
|
2749
|
+
});
|
1908
2750
|
}
|
1909
2751
|
|
1910
2752
|
/** Set default notification clan*/
|
1911
|
-
async setNotificationClan(
|
1912
|
-
|
1913
|
-
|
2753
|
+
async setNotificationClan(
|
2754
|
+
session: Session,
|
2755
|
+
request: ApiSetDefaultNotificationRequest
|
2756
|
+
): Promise<boolean> {
|
2757
|
+
if (
|
2758
|
+
this.autoRefreshSession &&
|
2759
|
+
session.refresh_token &&
|
2760
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2761
|
+
) {
|
1914
2762
|
await this.sessionRefresh(session);
|
1915
|
-
|
2763
|
+
}
|
1916
2764
|
|
1917
|
-
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
2765
|
+
return this.apiClient
|
2766
|
+
.setNotificationClanSetting(session.token, request)
|
2767
|
+
.then((response: any) => {
|
2768
|
+
return response !== undefined;
|
2769
|
+
});
|
2770
|
+
}
|
1921
2771
|
|
1922
|
-
|
1923
|
-
async setNotificationChannel(
|
1924
|
-
|
1925
|
-
|
2772
|
+
/** Set notification channel*/
|
2773
|
+
async setNotificationChannel(
|
2774
|
+
session: Session,
|
2775
|
+
request: ApiSetNotificationRequest
|
2776
|
+
): Promise<boolean> {
|
2777
|
+
if (
|
2778
|
+
this.autoRefreshSession &&
|
2779
|
+
session.refresh_token &&
|
2780
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2781
|
+
) {
|
1926
2782
|
await this.sessionRefresh(session);
|
1927
|
-
|
2783
|
+
}
|
1928
2784
|
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
2785
|
+
return this.apiClient
|
2786
|
+
.setNotificationChannelSetting(session.token, request)
|
2787
|
+
.then((response: any) => {
|
2788
|
+
return response !== undefined;
|
2789
|
+
});
|
2790
|
+
}
|
1933
2791
|
|
1934
|
-
/** Set notification category*/
|
1935
|
-
async setMuteNotificationCategory(
|
1936
|
-
|
1937
|
-
|
2792
|
+
/** Set notification category*/
|
2793
|
+
async setMuteNotificationCategory(
|
2794
|
+
session: Session,
|
2795
|
+
request: ApiSetMuteNotificationRequest
|
2796
|
+
): Promise<boolean> {
|
2797
|
+
if (
|
2798
|
+
this.autoRefreshSession &&
|
2799
|
+
session.refresh_token &&
|
2800
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2801
|
+
) {
|
1938
2802
|
await this.sessionRefresh(session);
|
1939
|
-
|
2803
|
+
}
|
1940
2804
|
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
|
2805
|
+
return this.apiClient
|
2806
|
+
.setMuteNotificationCategory(session.token, request)
|
2807
|
+
.then((response: any) => {
|
2808
|
+
return response !== undefined;
|
2809
|
+
});
|
2810
|
+
}
|
1945
2811
|
|
1946
|
-
/** Set notification channel*/
|
1947
|
-
async setMuteNotificationChannel(
|
1948
|
-
|
1949
|
-
|
2812
|
+
/** Set notification channel*/
|
2813
|
+
async setMuteNotificationChannel(
|
2814
|
+
session: Session,
|
2815
|
+
request: ApiSetMuteNotificationRequest
|
2816
|
+
): Promise<boolean> {
|
2817
|
+
if (
|
2818
|
+
this.autoRefreshSession &&
|
2819
|
+
session.refresh_token &&
|
2820
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2821
|
+
) {
|
1950
2822
|
await this.sessionRefresh(session);
|
1951
|
-
|
2823
|
+
}
|
1952
2824
|
|
1953
|
-
|
1954
|
-
|
1955
|
-
|
1956
|
-
|
2825
|
+
return this.apiClient
|
2826
|
+
.setMuteNotificationChannel(session.token, request)
|
2827
|
+
.then((response: any) => {
|
2828
|
+
return response !== undefined;
|
2829
|
+
});
|
2830
|
+
}
|
1957
2831
|
|
1958
|
-
/** update channel private*/
|
1959
|
-
async updateChannelPrivate(
|
1960
|
-
|
1961
|
-
|
2832
|
+
/** update channel private*/
|
2833
|
+
async updateChannelPrivate(
|
2834
|
+
session: Session,
|
2835
|
+
request: ApiChangeChannelPrivateRequest
|
2836
|
+
): Promise<boolean> {
|
2837
|
+
if (
|
2838
|
+
this.autoRefreshSession &&
|
2839
|
+
session.refresh_token &&
|
2840
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2841
|
+
) {
|
1962
2842
|
await this.sessionRefresh(session);
|
1963
|
-
|
2843
|
+
}
|
1964
2844
|
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1968
|
-
|
2845
|
+
return this.apiClient
|
2846
|
+
.updateChannelPrivate(session.token, request)
|
2847
|
+
.then((response: any) => {
|
2848
|
+
return response !== undefined;
|
2849
|
+
});
|
2850
|
+
}
|
1969
2851
|
|
1970
|
-
|
1971
|
-
|
1972
|
-
|
1973
|
-
|
2852
|
+
/** Set default notification category*/
|
2853
|
+
async setNotificationCategory(
|
2854
|
+
session: Session,
|
2855
|
+
request: ApiSetDefaultNotificationRequest
|
2856
|
+
): Promise<boolean> {
|
2857
|
+
if (
|
2858
|
+
this.autoRefreshSession &&
|
2859
|
+
session.refresh_token &&
|
2860
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2861
|
+
) {
|
1974
2862
|
await this.sessionRefresh(session);
|
1975
|
-
|
2863
|
+
}
|
1976
2864
|
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
2865
|
+
return this.apiClient
|
2866
|
+
.setNotificationCategorySetting(session.token, request)
|
2867
|
+
.then((response: any) => {
|
2868
|
+
return response !== undefined;
|
2869
|
+
});
|
2870
|
+
}
|
1981
2871
|
|
1982
|
-
async deleteNotificationCategory(
|
1983
|
-
|
1984
|
-
|
2872
|
+
async deleteNotificationCategory(
|
2873
|
+
session: Session,
|
2874
|
+
category_id: string
|
2875
|
+
): Promise<boolean> {
|
2876
|
+
if (
|
2877
|
+
this.autoRefreshSession &&
|
2878
|
+
session.refresh_token &&
|
2879
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2880
|
+
) {
|
1985
2881
|
await this.sessionRefresh(session);
|
1986
|
-
|
2882
|
+
}
|
1987
2883
|
|
1988
|
-
|
1989
|
-
|
1990
|
-
|
1991
|
-
|
2884
|
+
return this.apiClient
|
2885
|
+
.deleteNotificationCategorySetting(session.token, category_id)
|
2886
|
+
.then((response: any) => {
|
2887
|
+
return response !== undefined;
|
2888
|
+
});
|
2889
|
+
}
|
1992
2890
|
|
1993
|
-
async deleteNotificationChannel(
|
1994
|
-
|
1995
|
-
|
2891
|
+
async deleteNotificationChannel(
|
2892
|
+
session: Session,
|
2893
|
+
channel_id: string
|
2894
|
+
): Promise<boolean> {
|
2895
|
+
if (
|
2896
|
+
this.autoRefreshSession &&
|
2897
|
+
session.refresh_token &&
|
2898
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2899
|
+
) {
|
1996
2900
|
await this.sessionRefresh(session);
|
1997
|
-
|
2901
|
+
}
|
1998
2902
|
|
1999
|
-
|
2000
|
-
|
2001
|
-
|
2002
|
-
|
2903
|
+
return this.apiClient
|
2904
|
+
.deleteNotificationChannel(session.token, channel_id)
|
2905
|
+
.then((response: any) => {
|
2906
|
+
return response !== undefined;
|
2907
|
+
});
|
2908
|
+
}
|
2003
2909
|
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
2910
|
+
/** */
|
2911
|
+
async setNotificationReactMessage(
|
2912
|
+
session: Session,
|
2913
|
+
channel_id: string
|
2914
|
+
): Promise<boolean> {
|
2915
|
+
if (
|
2916
|
+
this.autoRefreshSession &&
|
2917
|
+
session.refresh_token &&
|
2918
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2919
|
+
) {
|
2008
2920
|
await this.sessionRefresh(session);
|
2921
|
+
}
|
2922
|
+
|
2923
|
+
return this.apiClient
|
2924
|
+
.setNotificationReactMessage(session.token, { channel_id })
|
2925
|
+
.then((response: any) => {
|
2926
|
+
return response !== undefined;
|
2927
|
+
});
|
2009
2928
|
}
|
2010
2929
|
|
2011
|
-
|
2012
|
-
|
2013
|
-
|
2014
|
-
|
2930
|
+
//** */
|
2931
|
+
async deleteNotiReactMessage(
|
2932
|
+
session: Session,
|
2933
|
+
channel_id: string
|
2934
|
+
): Promise<boolean> {
|
2935
|
+
if (
|
2936
|
+
this.autoRefreshSession &&
|
2937
|
+
session.refresh_token &&
|
2938
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2939
|
+
) {
|
2940
|
+
await this.sessionRefresh(session);
|
2941
|
+
}
|
2942
|
+
|
2943
|
+
return this.apiClient
|
2944
|
+
.deleteNotiReactMessage(session.token, channel_id)
|
2945
|
+
.then((response: any) => {
|
2946
|
+
return response !== undefined;
|
2947
|
+
});
|
2948
|
+
}
|
2015
2949
|
|
2016
|
-
|
2017
|
-
async
|
2018
|
-
|
2019
|
-
|
2950
|
+
/** query message in elasticsearch */
|
2951
|
+
async searchMessage(
|
2952
|
+
session: Session,
|
2953
|
+
request: ApiSearchMessageRequest
|
2954
|
+
): Promise<ApiSearchMessageResponse> {
|
2955
|
+
if (
|
2956
|
+
this.autoRefreshSession &&
|
2957
|
+
session.refresh_token &&
|
2958
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2959
|
+
) {
|
2020
2960
|
await this.sessionRefresh(session);
|
2961
|
+
}
|
2962
|
+
|
2963
|
+
return this.apiClient
|
2964
|
+
.searchMessage(session.token, request)
|
2965
|
+
.then((response: ApiSearchMessageResponse) => {
|
2966
|
+
return Promise.resolve(response);
|
2967
|
+
});
|
2021
2968
|
}
|
2022
2969
|
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2970
|
+
/** */
|
2971
|
+
async createPinMessage(
|
2972
|
+
session: Session,
|
2973
|
+
request: ApiPinMessageRequest
|
2974
|
+
): Promise<boolean> {
|
2975
|
+
if (
|
2976
|
+
this.autoRefreshSession &&
|
2977
|
+
session.refresh_token &&
|
2978
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2979
|
+
) {
|
2980
|
+
await this.sessionRefresh(session);
|
2981
|
+
}
|
2027
2982
|
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2983
|
+
return this.apiClient
|
2984
|
+
.createPinMessage(session.token, request)
|
2985
|
+
.then((response: any) => {
|
2986
|
+
return response !== undefined;
|
2987
|
+
});
|
2988
|
+
}
|
2989
|
+
|
2990
|
+
async pinMessagesList(
|
2991
|
+
session: Session,
|
2992
|
+
channelId: string
|
2993
|
+
): Promise<ApiPinMessagesList> {
|
2994
|
+
if (
|
2995
|
+
this.autoRefreshSession &&
|
2996
|
+
session.refresh_token &&
|
2997
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
2998
|
+
) {
|
2032
2999
|
await this.sessionRefresh(session);
|
3000
|
+
}
|
3001
|
+
|
3002
|
+
return this.apiClient
|
3003
|
+
.getPinMessagesList(session.token, channelId)
|
3004
|
+
.then((response: ApiPinMessagesList) => {
|
3005
|
+
return Promise.resolve(response);
|
3006
|
+
});
|
2033
3007
|
}
|
2034
3008
|
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
3009
|
+
//** */
|
3010
|
+
async deletePinMessage(
|
3011
|
+
session: Session,
|
3012
|
+
message_id: string
|
3013
|
+
): Promise<boolean> {
|
3014
|
+
if (
|
3015
|
+
this.autoRefreshSession &&
|
3016
|
+
session.refresh_token &&
|
3017
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3018
|
+
) {
|
3019
|
+
await this.sessionRefresh(session);
|
3020
|
+
}
|
2039
3021
|
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
3022
|
+
return this.apiClient
|
3023
|
+
.deletePinMessage(session.token, message_id)
|
3024
|
+
.then((response: any) => {
|
3025
|
+
return response !== undefined;
|
3026
|
+
});
|
3027
|
+
}
|
2046
3028
|
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
3029
|
+
/** create clan emoji */
|
3030
|
+
async createClanEmoji(session: Session, request: ApiClanEmojiCreateRequest) {
|
3031
|
+
if (
|
3032
|
+
this.autoRefreshSession &&
|
3033
|
+
session.refresh_token &&
|
3034
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3035
|
+
) {
|
3036
|
+
await this.sessionRefresh(session);
|
3037
|
+
}
|
2051
3038
|
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
3039
|
+
return this.apiClient
|
3040
|
+
.createClanEmoji(session.token, request)
|
3041
|
+
.then((response: any) => {
|
3042
|
+
return response !== undefined;
|
3043
|
+
});
|
3044
|
+
}
|
3045
|
+
|
3046
|
+
//**update clan emoji by id */
|
3047
|
+
async updateClanEmojiById(
|
3048
|
+
session: Session,
|
3049
|
+
id: string,
|
3050
|
+
request: MezonUpdateClanEmojiByIdBody
|
3051
|
+
) {
|
3052
|
+
if (
|
3053
|
+
this.autoRefreshSession &&
|
3054
|
+
session.refresh_token &&
|
3055
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3056
|
+
) {
|
2055
3057
|
await this.sessionRefresh(session);
|
3058
|
+
}
|
3059
|
+
|
3060
|
+
return this.apiClient
|
3061
|
+
.updateClanEmojiById(session.token, id, request)
|
3062
|
+
.then((response: any) => {
|
3063
|
+
return response !== undefined;
|
3064
|
+
});
|
2056
3065
|
}
|
2057
3066
|
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
3067
|
+
//**delete clan emoji by id */
|
3068
|
+
async deleteByIdClanEmoji(session: Session, id: string, clan_id: string) {
|
3069
|
+
if (
|
3070
|
+
this.autoRefreshSession &&
|
3071
|
+
session.refresh_token &&
|
3072
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3073
|
+
) {
|
3074
|
+
await this.sessionRefresh(session);
|
3075
|
+
}
|
2062
3076
|
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
3077
|
+
return this.apiClient
|
3078
|
+
.deleteClanEmojiById(session.token, id, clan_id)
|
3079
|
+
.then((response: any) => {
|
3080
|
+
return response !== undefined;
|
3081
|
+
});
|
3082
|
+
}
|
3083
|
+
|
3084
|
+
//**create webhook for chaneel */
|
3085
|
+
async generateWebhookLink(
|
3086
|
+
session: Session,
|
3087
|
+
request: ApiWebhookCreateRequest
|
3088
|
+
): Promise<ApiWebhookGenerateResponse> {
|
3089
|
+
if (
|
3090
|
+
this.autoRefreshSession &&
|
3091
|
+
session.refresh_token &&
|
3092
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3093
|
+
) {
|
2067
3094
|
await this.sessionRefresh(session);
|
3095
|
+
}
|
3096
|
+
|
3097
|
+
return this.apiClient
|
3098
|
+
.generateWebhook(session.token, request)
|
3099
|
+
.then((response: any) => {
|
3100
|
+
return Promise.resolve(response);
|
3101
|
+
});
|
2068
3102
|
}
|
2069
3103
|
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2073
|
-
|
3104
|
+
//**list webhook belong to the channel */
|
3105
|
+
async listWebhookByChannelId(
|
3106
|
+
session: Session,
|
3107
|
+
channel_id: string,
|
3108
|
+
clan_id: string
|
3109
|
+
): Promise<ApiWebhookListResponse> {
|
3110
|
+
if (
|
3111
|
+
this.autoRefreshSession &&
|
3112
|
+
session.refresh_token &&
|
3113
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3114
|
+
) {
|
3115
|
+
await this.sessionRefresh(session);
|
3116
|
+
}
|
2074
3117
|
|
2075
|
-
|
2076
|
-
|
2077
|
-
|
2078
|
-
|
2079
|
-
|
3118
|
+
return this.apiClient
|
3119
|
+
.listWebhookByChannelId(session.token, channel_id, clan_id)
|
3120
|
+
.then((response: ApiWebhookListResponse) => {
|
3121
|
+
return Promise.resolve(response);
|
3122
|
+
});
|
2080
3123
|
}
|
2081
3124
|
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
3125
|
+
//**update webhook name by id */
|
3126
|
+
async updateWebhookById(
|
3127
|
+
session: Session,
|
3128
|
+
id: string,
|
3129
|
+
request: MezonUpdateWebhookByIdBody
|
3130
|
+
) {
|
3131
|
+
if (
|
3132
|
+
this.autoRefreshSession &&
|
3133
|
+
session.refresh_token &&
|
3134
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3135
|
+
) {
|
3136
|
+
await this.sessionRefresh(session);
|
3137
|
+
}
|
2086
3138
|
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
3139
|
+
return this.apiClient
|
3140
|
+
.updateWebhookById(session.token, id, request)
|
3141
|
+
.then((response: any) => {
|
3142
|
+
return response !== undefined;
|
3143
|
+
});
|
2092
3144
|
}
|
2093
3145
|
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
3146
|
+
//**disabled webhook by id */
|
3147
|
+
async deleteWebhookById(session: Session, id: string) {
|
3148
|
+
if (
|
3149
|
+
this.autoRefreshSession &&
|
3150
|
+
session.refresh_token &&
|
3151
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3152
|
+
) {
|
3153
|
+
await this.sessionRefresh(session);
|
3154
|
+
}
|
2098
3155
|
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
3156
|
+
return this.apiClient
|
3157
|
+
.deleteWebhookById(session.token, id)
|
3158
|
+
.then((response: any) => {
|
3159
|
+
return response !== undefined;
|
3160
|
+
});
|
2104
3161
|
}
|
2105
3162
|
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
3163
|
+
//**check duplicate clan name */
|
3164
|
+
async checkDuplicateClanName(
|
3165
|
+
session: Session,
|
3166
|
+
clan_name: string
|
3167
|
+
): Promise<ApiCheckDuplicateClanNameResponse> {
|
3168
|
+
if (
|
3169
|
+
this.autoRefreshSession &&
|
3170
|
+
session.refresh_token &&
|
3171
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3172
|
+
) {
|
3173
|
+
await this.sessionRefresh(session);
|
3174
|
+
}
|
2110
3175
|
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
3176
|
+
return this.apiClient
|
3177
|
+
.checkDuplicateClanName(session.token, clan_name)
|
3178
|
+
.then((response: any) => {
|
3179
|
+
return Promise.resolve(response);
|
3180
|
+
});
|
2116
3181
|
}
|
2117
3182
|
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
3183
|
+
//**Add a new sticker */
|
3184
|
+
async addClanSticker(session: Session, request: ApiClanStickerAddRequest) {
|
3185
|
+
if (
|
3186
|
+
this.autoRefreshSession &&
|
3187
|
+
session.refresh_token &&
|
3188
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3189
|
+
) {
|
3190
|
+
await this.sessionRefresh(session);
|
3191
|
+
}
|
2122
3192
|
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
3193
|
+
return this.apiClient
|
3194
|
+
.addClanSticker(session.token, request)
|
3195
|
+
.then((response: any) => {
|
3196
|
+
return response !== undefined;
|
3197
|
+
});
|
2128
3198
|
}
|
2129
3199
|
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
3200
|
+
//**Delete a sticker by ID*/
|
3201
|
+
async deleteClanStickerById(session: Session, id: string, clan_id: string) {
|
3202
|
+
if (
|
3203
|
+
this.autoRefreshSession &&
|
3204
|
+
session.refresh_token &&
|
3205
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3206
|
+
) {
|
3207
|
+
await this.sessionRefresh(session);
|
3208
|
+
}
|
2134
3209
|
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
3210
|
+
return this.apiClient
|
3211
|
+
.deleteClanStickerById(session.token, id, clan_id)
|
3212
|
+
.then((response: any) => {
|
3213
|
+
return response !== undefined;
|
3214
|
+
});
|
2140
3215
|
}
|
2141
3216
|
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
3217
|
+
//**Update a sticker by ID*/
|
3218
|
+
async updateClanStickerById(
|
3219
|
+
session: Session,
|
3220
|
+
id: string,
|
3221
|
+
request: MezonUpdateClanStickerByIdBody
|
3222
|
+
) {
|
3223
|
+
if (
|
3224
|
+
this.autoRefreshSession &&
|
3225
|
+
session.refresh_token &&
|
3226
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3227
|
+
) {
|
3228
|
+
await this.sessionRefresh(session);
|
3229
|
+
}
|
2146
3230
|
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
3231
|
+
return this.apiClient
|
3232
|
+
.updateClanStickerById(session.token, id, request)
|
3233
|
+
.then((response: any) => {
|
3234
|
+
return response !== undefined;
|
3235
|
+
});
|
2152
3236
|
}
|
2153
3237
|
|
2154
|
-
|
2155
|
-
|
2156
|
-
|
2157
|
-
|
3238
|
+
//** update the category of a channel */
|
3239
|
+
async changeChannelCategory(
|
3240
|
+
session: Session,
|
3241
|
+
id: string,
|
3242
|
+
request: MezonChangeChannelCategoryBody
|
3243
|
+
) {
|
3244
|
+
if (
|
3245
|
+
this.autoRefreshSession &&
|
3246
|
+
session.refresh_token &&
|
3247
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3248
|
+
) {
|
3249
|
+
await this.sessionRefresh(session);
|
3250
|
+
}
|
2158
3251
|
|
2159
|
-
|
2160
|
-
|
2161
|
-
|
2162
|
-
|
2163
|
-
|
3252
|
+
return this.apiClient
|
3253
|
+
.changeChannelCategory(session.token, id, request)
|
3254
|
+
.then((response: any) => {
|
3255
|
+
return response !== undefined;
|
3256
|
+
});
|
2164
3257
|
}
|
2165
3258
|
|
2166
|
-
|
2167
|
-
|
2168
|
-
|
2169
|
-
|
3259
|
+
/** */
|
3260
|
+
async setRoleChannelPermission(
|
3261
|
+
session: Session,
|
3262
|
+
request: ApiUpdateRoleChannelRequest
|
3263
|
+
): Promise<boolean> {
|
3264
|
+
if (
|
3265
|
+
this.autoRefreshSession &&
|
3266
|
+
session.refresh_token &&
|
3267
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3268
|
+
) {
|
3269
|
+
await this.sessionRefresh(session);
|
3270
|
+
}
|
2170
3271
|
|
2171
|
-
|
2172
|
-
|
2173
|
-
|
2174
|
-
|
2175
|
-
|
3272
|
+
return this.apiClient
|
3273
|
+
.setRoleChannelPermission(session.token, request)
|
3274
|
+
.then((response: any) => {
|
3275
|
+
return response !== undefined;
|
3276
|
+
});
|
2176
3277
|
}
|
2177
3278
|
|
2178
|
-
|
2179
|
-
|
2180
|
-
|
2181
|
-
|
3279
|
+
async addApp(session: Session, request: ApiAddAppRequest): Promise<boolean> {
|
3280
|
+
if (
|
3281
|
+
this.autoRefreshSession &&
|
3282
|
+
session.refresh_token &&
|
3283
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3284
|
+
) {
|
3285
|
+
await this.sessionRefresh(session);
|
3286
|
+
}
|
2182
3287
|
|
2183
|
-
|
2184
|
-
|
2185
|
-
|
2186
|
-
|
2187
|
-
|
3288
|
+
return this.apiClient
|
3289
|
+
.addApp(session.token, request)
|
3290
|
+
.then((response: any) => {
|
3291
|
+
return response !== undefined;
|
3292
|
+
});
|
2188
3293
|
}
|
2189
3294
|
|
2190
|
-
|
2191
|
-
|
2192
|
-
|
2193
|
-
|
3295
|
+
async getApp(session: Session, id: string): Promise<ApiApp> {
|
3296
|
+
if (
|
3297
|
+
this.autoRefreshSession &&
|
3298
|
+
session.refresh_token &&
|
3299
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3300
|
+
) {
|
3301
|
+
await this.sessionRefresh(session);
|
3302
|
+
}
|
2194
3303
|
|
2195
|
-
|
2196
|
-
|
2197
|
-
|
2198
|
-
session.isexpired((Date.now() + this.expiredTimespanMs)/1000)) {
|
2199
|
-
await this.sessionRefresh(session);
|
3304
|
+
return this.apiClient.getApp(session.token, id).then((response: ApiApp) => {
|
3305
|
+
return Promise.resolve(response);
|
3306
|
+
});
|
2200
3307
|
}
|
2201
3308
|
|
2202
|
-
|
2203
|
-
|
2204
|
-
|
2205
|
-
|
3309
|
+
async listApps(session: Session): Promise<ApiAppList> {
|
3310
|
+
if (
|
3311
|
+
this.autoRefreshSession &&
|
3312
|
+
session.refresh_token &&
|
3313
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3314
|
+
) {
|
3315
|
+
await this.sessionRefresh(session);
|
3316
|
+
}
|
2206
3317
|
|
2207
|
-
|
2208
|
-
|
2209
|
-
|
2210
|
-
|
2211
|
-
|
3318
|
+
return this.apiClient
|
3319
|
+
.listApps(session.token)
|
3320
|
+
.then((response: ApiAppList) => {
|
3321
|
+
return Promise.resolve(response);
|
3322
|
+
});
|
2212
3323
|
}
|
2213
3324
|
|
2214
|
-
|
2215
|
-
|
2216
|
-
|
2217
|
-
|
3325
|
+
async addAppToClan(session: Session, appId: string, clanId: string) {
|
3326
|
+
if (
|
3327
|
+
this.autoRefreshSession &&
|
3328
|
+
session.refresh_token &&
|
3329
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3330
|
+
) {
|
3331
|
+
await this.sessionRefresh(session);
|
3332
|
+
}
|
2218
3333
|
|
2219
|
-
|
2220
|
-
|
2221
|
-
|
2222
|
-
|
2223
|
-
|
3334
|
+
return this.apiClient
|
3335
|
+
.addAppToClan(session.token, appId, clanId)
|
3336
|
+
.then((response: ApiAppList) => {
|
3337
|
+
return response !== undefined;
|
3338
|
+
});
|
2224
3339
|
}
|
2225
|
-
|
2226
|
-
return this.apiClient.setRoleChannelPermission(session.token, request).then((response: any) => {
|
2227
|
-
return response !== undefined;
|
2228
|
-
});
|
2229
|
-
}
|
2230
3340
|
|
2231
|
-
async
|
2232
|
-
|
2233
|
-
|
2234
|
-
|
3341
|
+
async getSystemMessagesList(
|
3342
|
+
session: Session
|
3343
|
+
): Promise<ApiSystemMessagesList> {
|
3344
|
+
if (
|
3345
|
+
this.autoRefreshSession &&
|
3346
|
+
session.refresh_token &&
|
3347
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3348
|
+
) {
|
3349
|
+
await this.sessionRefresh(session);
|
3350
|
+
}
|
3351
|
+
|
3352
|
+
return this.apiClient
|
3353
|
+
.getSystemMessagesList(session.token)
|
3354
|
+
.then((response: ApiSystemMessagesList) => {
|
3355
|
+
return Promise.resolve(response);
|
3356
|
+
});
|
2235
3357
|
}
|
2236
3358
|
|
2237
|
-
|
2238
|
-
|
2239
|
-
|
2240
|
-
|
3359
|
+
async getSystemMessageByClanId(
|
3360
|
+
session: Session,
|
3361
|
+
clanId: string
|
3362
|
+
): Promise<ApiSystemMessage> {
|
3363
|
+
if (
|
3364
|
+
this.autoRefreshSession &&
|
3365
|
+
session.refresh_token &&
|
3366
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3367
|
+
) {
|
3368
|
+
await this.sessionRefresh(session);
|
3369
|
+
}
|
2241
3370
|
|
2242
|
-
|
2243
|
-
|
2244
|
-
|
2245
|
-
|
3371
|
+
return this.apiClient
|
3372
|
+
.getSystemMessageByClanId(session.token, clanId)
|
3373
|
+
.then((response: ApiSystemMessage) => {
|
3374
|
+
return Promise.resolve(response);
|
3375
|
+
});
|
2246
3376
|
}
|
2247
3377
|
|
2248
|
-
|
2249
|
-
|
2250
|
-
|
2251
|
-
|
3378
|
+
async createSystemMessage(
|
3379
|
+
session: Session,
|
3380
|
+
request: ApiSystemMessageRequest
|
3381
|
+
): Promise<any> {
|
3382
|
+
if (
|
3383
|
+
this.autoRefreshSession &&
|
3384
|
+
session.refresh_token &&
|
3385
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3386
|
+
) {
|
3387
|
+
await this.sessionRefresh(session);
|
3388
|
+
}
|
2252
3389
|
|
2253
|
-
|
2254
|
-
|
2255
|
-
|
2256
|
-
|
3390
|
+
return this.apiClient
|
3391
|
+
.createSystemMessage(session.token, request)
|
3392
|
+
.then((response: any) => {
|
3393
|
+
return Promise.resolve(response);
|
3394
|
+
});
|
2257
3395
|
}
|
2258
3396
|
|
2259
|
-
|
2260
|
-
|
2261
|
-
|
2262
|
-
|
3397
|
+
async updateSystemMessage(
|
3398
|
+
session: Session,
|
3399
|
+
clanId: string,
|
3400
|
+
request: MezonUpdateSystemMessageBody
|
3401
|
+
): Promise<any> {
|
3402
|
+
if (
|
3403
|
+
this.autoRefreshSession &&
|
3404
|
+
session.refresh_token &&
|
3405
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3406
|
+
) {
|
3407
|
+
await this.sessionRefresh(session);
|
3408
|
+
}
|
2263
3409
|
|
2264
|
-
|
2265
|
-
|
2266
|
-
|
2267
|
-
|
3410
|
+
return this.apiClient
|
3411
|
+
.updateSystemMessage(session.token, clanId, request)
|
3412
|
+
.then((response: any) => {
|
3413
|
+
return Promise.resolve(response);
|
3414
|
+
});
|
2268
3415
|
}
|
2269
3416
|
|
2270
|
-
|
2271
|
-
|
2272
|
-
|
2273
|
-
|
3417
|
+
async deleteSystemMessage(session: Session, clanId: string): Promise<any> {
|
3418
|
+
if (
|
3419
|
+
this.autoRefreshSession &&
|
3420
|
+
session.refresh_token &&
|
3421
|
+
session.isexpired((Date.now() + this.expiredTimespanMs) / 1000)
|
3422
|
+
) {
|
3423
|
+
await this.sessionRefresh(session);
|
3424
|
+
}
|
2274
3425
|
|
2275
|
-
|
3426
|
+
return this.apiClient
|
3427
|
+
.deleteSystemMessage(session.token, clanId)
|
3428
|
+
.then((response: any) => {
|
3429
|
+
return Promise.resolve(response);
|
3430
|
+
});
|
3431
|
+
}
|
3432
|
+
}
|