mezon-js 2.13.64 → 2.13.66

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/api.gen.ts CHANGED
@@ -11757,5 +11757,40 @@ export class MezonApi {
11757
11757
  ]);
11758
11758
  }
11759
11759
 
11760
+ /** */
11761
+ reportMessageAbuse(bearerToken: string,
11762
+ messageId?:string,
11763
+ abuseType?:string,
11764
+ options: any = {}): Promise<any> {
11765
+
11766
+ const urlPath = "/v2/message/report";
11767
+ const queryParams = new Map<string, any>();
11768
+ queryParams.set("message_id", messageId);
11769
+ queryParams.set("abuse_type", abuseType);
11770
+
11771
+ let bodyJson : string = "";
11772
+
11773
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
11774
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
11775
+ if (bearerToken) {
11776
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
11777
+ }
11778
+
11779
+ return Promise.race([
11780
+ fetch(fullUrl, fetchOptions).then((response) => {
11781
+ if (response.status == 204) {
11782
+ return response;
11783
+ } else if (response.status >= 200 && response.status < 300) {
11784
+ return response.json();
11785
+ } else {
11786
+ throw response;
11787
+ }
11788
+ }),
11789
+ new Promise((_, reject) =>
11790
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
11791
+ ),
11792
+ ]);
11793
+ }
11794
+
11760
11795
  }
11761
11796
 
package/client.ts CHANGED
@@ -4987,4 +4987,23 @@ export class Client {
4987
4987
  return Promise.resolve(response);
4988
4988
  });
4989
4989
  }
4990
+
4991
+ async reportMessageAbuse(session: Session,
4992
+ messageId?:string,
4993
+ abuseType?:string
4994
+ ) : Promise<any> {
4995
+ if (
4996
+ this.autoRefreshSession &&
4997
+ session.refresh_token &&
4998
+ session.isexpired(Date.now() / 1000)
4999
+ ) {
5000
+ await this.sessionRefresh(session);
5001
+ }
5002
+
5003
+ return this.apiClient
5004
+ .reportMessageAbuse(session.token, messageId, abuseType)
5005
+ .then((response: any) => {
5006
+ return response !== undefined;
5007
+ });
5008
+ }
4990
5009
  }
package/dist/api.gen.d.ts CHANGED
@@ -2405,4 +2405,6 @@ export declare class MezonApi {
2405
2405
  updateUsername(bearerToken: string, body: ApiUpdateUsernameRequest, options?: any): Promise<ApiSession>;
2406
2406
  /** Ban a set of users from a channel. */
2407
2407
  isBanned(bearerToken: string, channelId: string, options?: any): Promise<ApiIsBannedResponse>;
2408
+ /** */
2409
+ reportMessageAbuse(bearerToken: string, messageId?: string, abuseType?: string, options?: any): Promise<any>;
2408
2410
  }
package/dist/client.d.ts CHANGED
@@ -533,4 +533,5 @@ export declare class Client {
533
533
  isFollower(session: Session, req: ApiIsFollowerRequest): Promise<ApiIsFollowerResponse>;
534
534
  transferOwnership(session: Session, req: ApiTransferOwnershipRequest): Promise<any>;
535
535
  isBanned(session: Session, channelId: string): Promise<ApiIsBannedResponse>;
536
+ reportMessageAbuse(session: Session, messageId?: string, abuseType?: string): Promise<any>;
536
537
  }
@@ -7208,6 +7208,33 @@ var MezonApi = class {
7208
7208
  )
7209
7209
  ]);
7210
7210
  }
7211
+ /** */
7212
+ reportMessageAbuse(bearerToken, messageId, abuseType, options = {}) {
7213
+ const urlPath = "/v2/message/report";
7214
+ const queryParams = /* @__PURE__ */ new Map();
7215
+ queryParams.set("message_id", messageId);
7216
+ queryParams.set("abuse_type", abuseType);
7217
+ let bodyJson = "";
7218
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
7219
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
7220
+ if (bearerToken) {
7221
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
7222
+ }
7223
+ return Promise.race([
7224
+ fetch(fullUrl, fetchOptions).then((response) => {
7225
+ if (response.status == 204) {
7226
+ return response;
7227
+ } else if (response.status >= 200 && response.status < 300) {
7228
+ return response.json();
7229
+ } else {
7230
+ throw response;
7231
+ }
7232
+ }),
7233
+ new Promise(
7234
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
7235
+ )
7236
+ ]);
7237
+ }
7211
7238
  };
7212
7239
 
7213
7240
  // session.ts
@@ -8433,13 +8460,14 @@ var _DefaultSocket = class _DefaultSocket {
8433
8460
  return response.active_archived_thread;
8434
8461
  });
8435
8462
  }
8436
- checkDuplicateName(name, condition_id, type) {
8463
+ checkDuplicateName(name, condition_id, type, clan_id) {
8437
8464
  return __async(this, null, function* () {
8438
8465
  const response = yield this.send({
8439
8466
  check_name_existed_event: {
8440
8467
  name,
8441
8468
  condition_id,
8442
- type
8469
+ type,
8470
+ clan_id
8443
8471
  }
8444
8472
  });
8445
8473
  return response.check_name_existed_event;
@@ -11278,4 +11306,14 @@ var Client = class {
11278
11306
  });
11279
11307
  });
11280
11308
  }
11309
+ reportMessageAbuse(session, messageId, abuseType) {
11310
+ return __async(this, null, function* () {
11311
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
11312
+ yield this.sessionRefresh(session);
11313
+ }
11314
+ return this.apiClient.reportMessageAbuse(session.token, messageId, abuseType).then((response) => {
11315
+ return response !== void 0;
11316
+ });
11317
+ });
11318
+ }
11281
11319
  };
@@ -7173,6 +7173,33 @@ var MezonApi = class {
7173
7173
  )
7174
7174
  ]);
7175
7175
  }
7176
+ /** */
7177
+ reportMessageAbuse(bearerToken, messageId, abuseType, options = {}) {
7178
+ const urlPath = "/v2/message/report";
7179
+ const queryParams = /* @__PURE__ */ new Map();
7180
+ queryParams.set("message_id", messageId);
7181
+ queryParams.set("abuse_type", abuseType);
7182
+ let bodyJson = "";
7183
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
7184
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
7185
+ if (bearerToken) {
7186
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
7187
+ }
7188
+ return Promise.race([
7189
+ fetch(fullUrl, fetchOptions).then((response) => {
7190
+ if (response.status == 204) {
7191
+ return response;
7192
+ } else if (response.status >= 200 && response.status < 300) {
7193
+ return response.json();
7194
+ } else {
7195
+ throw response;
7196
+ }
7197
+ }),
7198
+ new Promise(
7199
+ (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
7200
+ )
7201
+ ]);
7202
+ }
7176
7203
  };
7177
7204
 
7178
7205
  // session.ts
@@ -8398,13 +8425,14 @@ var _DefaultSocket = class _DefaultSocket {
8398
8425
  return response.active_archived_thread;
8399
8426
  });
8400
8427
  }
8401
- checkDuplicateName(name, condition_id, type) {
8428
+ checkDuplicateName(name, condition_id, type, clan_id) {
8402
8429
  return __async(this, null, function* () {
8403
8430
  const response = yield this.send({
8404
8431
  check_name_existed_event: {
8405
8432
  name,
8406
8433
  condition_id,
8407
- type
8434
+ type,
8435
+ clan_id
8408
8436
  }
8409
8437
  });
8410
8438
  return response.check_name_existed_event;
@@ -11243,6 +11271,16 @@ var Client = class {
11243
11271
  });
11244
11272
  });
11245
11273
  }
11274
+ reportMessageAbuse(session, messageId, abuseType) {
11275
+ return __async(this, null, function* () {
11276
+ if (this.autoRefreshSession && session.refresh_token && session.isexpired(Date.now() / 1e3)) {
11277
+ yield this.sessionRefresh(session);
11278
+ }
11279
+ return this.apiClient.reportMessageAbuse(session.token, messageId, abuseType).then((response) => {
11280
+ return response !== void 0;
11281
+ });
11282
+ });
11283
+ }
11246
11284
  };
11247
11285
  export {
11248
11286
  ChannelStreamMode,
package/dist/socket.d.ts CHANGED
@@ -573,6 +573,7 @@ export interface CheckNameExistedEvent {
573
573
  exist: boolean;
574
574
  condition_id: string;
575
575
  type: number;
576
+ clan_id: string;
576
577
  }
577
578
  /** */
578
579
  export interface ClanSticker {
@@ -966,7 +967,7 @@ export interface Socket {
966
967
  setHeartbeatTimeoutMs(ms: number): void;
967
968
  getHeartbeatTimeoutMs(): number;
968
969
  onreconnect: (evt: Event) => void;
969
- checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
970
+ checkDuplicateName(name: string, condition_id: string, type: number, clan_id: string): Promise<CheckNameExistedEvent>;
970
971
  handleMessageButtonClick: (message_id: string, channel_id: string, button_id: string, sender_id: string, user_id: string, extra_data: string) => Promise<MessageButtonClicked>;
971
972
  handleDropdownBoxSelected: (message_id: string, channel_id: string, selectbox_id: string, sender_id: string, user_id: string, value: Array<string>) => Promise<DropdownBoxSelected>;
972
973
  writeVoiceReaction: (emojis: Array<string>, channel_id: string) => Promise<VoiceReactionSend>;
@@ -1196,7 +1197,7 @@ export declare class DefaultSocket implements Socket {
1196
1197
  writeLastPinMessage(clan_id: string, channel_id: string, mode: number, is_public: boolean, message_id: string, timestamp_seconds: number, operation: number, message_sender_avatar: string, message_sender_id: string, message_sender_username: string, message_content: string, message_attachment: string, message_created_time: string): Promise<LastPinMessageEvent>;
1197
1198
  writeCustomStatus(clan_id: string, status: string, time_reset: number, no_clear: boolean): Promise<CustomStatusEvent>;
1198
1199
  writeActiveArchivedThread(clan_id: string, channel_id: string): Promise<void>;
1199
- checkDuplicateName(name: string, condition_id: string, type: number): Promise<CheckNameExistedEvent>;
1200
+ checkDuplicateName(name: string, condition_id: string, type: number, clan_id: string): Promise<CheckNameExistedEvent>;
1200
1201
  writeVoiceReaction(emojis: Array<string>, channel_id: string): Promise<VoiceReactionSend>;
1201
1202
  forwardWebrtcSignaling(receiver_id: string, data_type: number, json_data: string, channel_id: string, caller_id: string): Promise<WebrtcSignalingFwd>;
1202
1203
  makeCallPush(receiver_id: string, json_data: string, channel_id: string, caller_id: string): Promise<IncomingCallPush>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.13.64",
3
+ "version": "2.13.66",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -876,6 +876,7 @@ export interface CheckNameExistedEvent {
876
876
  exist: boolean;
877
877
  condition_id: string;
878
878
  type: number;
879
+ clan_id: string;
879
880
  }
880
881
 
881
882
  /** */
@@ -1616,7 +1617,8 @@ export interface Socket {
1616
1617
  checkDuplicateName(
1617
1618
  name: string,
1618
1619
  condition_id: string,
1619
- type: number
1620
+ type: number,
1621
+ clan_id: string,
1620
1622
  ): Promise<CheckNameExistedEvent>;
1621
1623
 
1622
1624
  handleMessageButtonClick: (
@@ -3127,13 +3129,15 @@ export class DefaultSocket implements Socket {
3127
3129
  async checkDuplicateName(
3128
3130
  name: string,
3129
3131
  condition_id: string,
3130
- type: number
3132
+ type: number,
3133
+ clan_id: string,
3131
3134
  ): Promise<CheckNameExistedEvent> {
3132
3135
  const response = await this.send({
3133
3136
  check_name_existed_event: {
3134
3137
  name: name,
3135
3138
  condition_id: condition_id,
3136
3139
  type: type,
3140
+ clan_id: clan_id
3137
3141
  },
3138
3142
  });
3139
3143
  return response.check_name_existed_event;