mezon-js 2.7.70 → 2.7.73

Sign up to get free protection for your applications and to get access to all the features.
package/api.gen.ts CHANGED
@@ -484,16 +484,6 @@ export interface ApiClanDescProfile {
484
484
  profile_theme?: string;
485
485
  }
486
486
 
487
- /** */
488
- export interface ApiClanEmoji {
489
- //
490
- category?: string;
491
- //
492
- shortname?: string;
493
- //
494
- src?: string;
495
- }
496
-
497
487
  /** */
498
488
  export interface ApiClanEmojiCreateRequest {
499
489
  //
@@ -509,7 +499,21 @@ export interface ApiClanEmojiCreateRequest {
509
499
  /** */
510
500
  export interface ApiClanEmojiList {
511
501
  //
512
- emoji_list?: Array<ApiClanEmoji>;
502
+ emoji_list?: Array<ApiClanEmojiListResponse>;
503
+ }
504
+
505
+ /** */
506
+ export interface ApiClanEmojiListResponse {
507
+ //
508
+ category?: string;
509
+ //
510
+ creator_id?: string;
511
+ //
512
+ id?: string;
513
+ //
514
+ shortname?: string;
515
+ //
516
+ src?: string;
513
517
  }
514
518
 
515
519
  /** Get clan profile. */
@@ -3704,38 +3708,7 @@ export class MezonApi {
3704
3708
  ]);
3705
3709
  }
3706
3710
 
3707
- /** Get permission list */
3708
- listClanEmoji(bearerToken: string,
3709
- options: any = {}): Promise<ApiClanEmojiList> {
3710
-
3711
- const urlPath = "/v2/emoji";
3712
- const queryParams = new Map<string, any>();
3713
-
3714
- let bodyJson : string = "";
3715
-
3716
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
3717
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
3718
- if (bearerToken) {
3719
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
3720
- }
3721
-
3722
- return Promise.race([
3723
- fetch(fullUrl, fetchOptions).then((response) => {
3724
- if (response.status == 204) {
3725
- return response;
3726
- } else if (response.status >= 200 && response.status < 300) {
3727
- return response.json();
3728
- } else {
3729
- throw response;
3730
- }
3731
- }),
3732
- new Promise((_, reject) =>
3733
- setTimeout(reject, this.timeoutMs, "Request timed out.")
3734
- ),
3735
- ]);
3736
- }
3737
-
3738
- /** Post permission Emoji /v2/emoji/create */
3711
+ /** Post clan Emoji /v2/emoji/create */
3739
3712
  createClanEmoji(bearerToken: string,
3740
3713
  body:ApiClanEmojiCreateRequest,
3741
3714
  options: any = {}): Promise<any> {
package/dist/api.gen.d.ts CHANGED
@@ -277,12 +277,6 @@ export interface ApiClanDescProfile {
277
277
  profile_theme?: string;
278
278
  }
279
279
  /** */
280
- export interface ApiClanEmoji {
281
- category?: string;
282
- shortname?: string;
283
- src?: string;
284
- }
285
- /** */
286
280
  export interface ApiClanEmojiCreateRequest {
287
281
  category?: string;
288
282
  clan_id?: string;
@@ -291,7 +285,15 @@ export interface ApiClanEmojiCreateRequest {
291
285
  }
292
286
  /** */
293
287
  export interface ApiClanEmojiList {
294
- emoji_list?: Array<ApiClanEmoji>;
288
+ emoji_list?: Array<ApiClanEmojiListResponse>;
289
+ }
290
+ /** */
291
+ export interface ApiClanEmojiListResponse {
292
+ category?: string;
293
+ creator_id?: string;
294
+ id?: string;
295
+ shortname?: string;
296
+ src?: string;
295
297
  }
296
298
  /** Get clan profile. */
297
299
  export interface ApiClanProfile {
@@ -976,9 +978,7 @@ export declare class MezonApi {
976
978
  closeDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
977
979
  /** open direct message. */
978
980
  openDirectMess(bearerToken: string, body: ApiDeleteChannelDescRequest, options?: any): Promise<any>;
979
- /** Get permission list */
980
- listClanEmoji(bearerToken: string, options?: any): Promise<ApiClanEmojiList>;
981
- /** Post permission Emoji /v2/emoji/create */
981
+ /** Post clan Emoji /v2/emoji/create */
982
982
  createClanEmoji(bearerToken: string, body: ApiClanEmojiCreateRequest, options?: any): Promise<any>;
983
983
  /** Get emoji list by clan id */
984
984
  listClanEmojiByClanId(bearerToken: string, clanId: string, options?: any): Promise<ApiClanEmojiList>;
@@ -2387,32 +2387,7 @@ var MezonApi = class {
2387
2387
  )
2388
2388
  ]);
2389
2389
  }
2390
- /** Get permission list */
2391
- listClanEmoji(bearerToken, options = {}) {
2392
- const urlPath = "/v2/emoji";
2393
- const queryParams = /* @__PURE__ */ new Map();
2394
- let bodyJson = "";
2395
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2396
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
2397
- if (bearerToken) {
2398
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2399
- }
2400
- return Promise.race([
2401
- fetch(fullUrl, fetchOptions).then((response) => {
2402
- if (response.status == 204) {
2403
- return response;
2404
- } else if (response.status >= 200 && response.status < 300) {
2405
- return response.json();
2406
- } else {
2407
- throw response;
2408
- }
2409
- }),
2410
- new Promise(
2411
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
2412
- )
2413
- ]);
2414
- }
2415
- /** Post permission Emoji /v2/emoji/create */
2390
+ /** Post clan Emoji /v2/emoji/create */
2416
2391
  createClanEmoji(bearerToken, body, options = {}) {
2417
2392
  if (body === null || body === void 0) {
2418
2393
  throw new Error("'body' is a required parameter but is null or undefined.");
@@ -4538,6 +4513,10 @@ var _DefaultSocket = class _DefaultSocket {
4538
4513
  this.onchannelpresence(message.channel_presence_event);
4539
4514
  } else if (message.last_pin_message_event) {
4540
4515
  this.onpinmessage(message.last_pin_message_event);
4516
+ } else if (message.custom_status_event) {
4517
+ this.oncustomstatus(message.custom_status_event);
4518
+ } else if (message.user_channel_added_event) {
4519
+ this.onuserchanneladded(message.user_channel_added_event);
4541
4520
  } else {
4542
4521
  if (this.verbose && window && window.console) {
4543
4522
  console.log("Unrecognized message received: %o", message);
@@ -4620,6 +4599,11 @@ var _DefaultSocket = class _DefaultSocket {
4620
4599
  console.log(channelPresence);
4621
4600
  }
4622
4601
  }
4602
+ onuserchanneladded(user) {
4603
+ if (this.verbose && window && window.console) {
4604
+ console.log(user);
4605
+ }
4606
+ }
4623
4607
  onnotification(notification) {
4624
4608
  if (this.verbose && window && window.console) {
4625
4609
  console.log(notification);
@@ -4685,6 +4669,11 @@ var _DefaultSocket = class _DefaultSocket {
4685
4669
  console.log("Heartbeat timeout.");
4686
4670
  }
4687
4671
  }
4672
+ oncustomstatus(statusEvent) {
4673
+ if (this.verbose && window && window.console) {
4674
+ console.log(statusEvent);
4675
+ }
4676
+ }
4688
4677
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
4689
4678
  const untypedMessage = message;
4690
4679
  return new Promise((resolve, reject) => {
@@ -4722,11 +4711,12 @@ var _DefaultSocket = class _DefaultSocket {
4722
4711
  return response.clan_join;
4723
4712
  });
4724
4713
  }
4725
- joinChat(channel_id, mode, type, persistence, hidden) {
4714
+ joinChat(clan_id, channel_id, mode, type, persistence, hidden) {
4726
4715
  return __async(this, null, function* () {
4727
4716
  const response = yield this.send(
4728
4717
  {
4729
4718
  channel_join: {
4719
+ clan_id,
4730
4720
  channel_id,
4731
4721
  mode,
4732
4722
  type,
@@ -4738,14 +4728,15 @@ var _DefaultSocket = class _DefaultSocket {
4738
4728
  return response.channel;
4739
4729
  });
4740
4730
  }
4741
- leaveChat(channel_id, mode) {
4742
- return this.send({ channel_leave: { channel_id, mode } });
4731
+ leaveChat(clan_id, channel_id, mode) {
4732
+ return this.send({ channel_leave: { clan_id, channel_id, mode } });
4743
4733
  }
4744
- removeChatMessage(channel_id, mode, message_id) {
4734
+ removeChatMessage(clan_id, channel_id, mode, message_id) {
4745
4735
  return __async(this, null, function* () {
4746
4736
  const response = yield this.send(
4747
4737
  {
4748
4738
  channel_message_remove: {
4739
+ clan_id,
4749
4740
  channel_id,
4750
4741
  mode,
4751
4742
  message_id
@@ -4783,9 +4774,9 @@ var _DefaultSocket = class _DefaultSocket {
4783
4774
  unfollowUsers(user_ids) {
4784
4775
  return this.send({ status_unfollow: { user_ids } });
4785
4776
  }
4786
- updateChatMessage(channel_id, mode, message_id, content) {
4777
+ updateChatMessage(clan_id, channel_id, mode, message_id, content) {
4787
4778
  return __async(this, null, function* () {
4788
- const response = yield this.send({ channel_message_update: { channel_id, message_id, content, mode } });
4779
+ const response = yield this.send({ channel_message_update: { clan_id, channel_id, message_id, content, mode } });
4789
4780
  return response.channel_message_ack;
4790
4781
  });
4791
4782
  }
@@ -4798,27 +4789,27 @@ var _DefaultSocket = class _DefaultSocket {
4798
4789
  return response.channel_message_ack;
4799
4790
  });
4800
4791
  }
4801
- writeMessageReaction(id, channel_id, mode, message_id, emoji, count, message_sender_id, action_delete) {
4792
+ writeMessageReaction(id, clan_id, channel_id, mode, message_id, emoji, count, message_sender_id, action_delete) {
4802
4793
  return __async(this, null, function* () {
4803
- const response = yield this.send({ message_reaction_event: { id, channel_id, mode, message_id, emoji, count, message_sender_id, action: action_delete } });
4794
+ const response = yield this.send({ message_reaction_event: { id, clan_id, channel_id, mode, message_id, emoji, count, message_sender_id, action: action_delete } });
4804
4795
  return response.message_reaction_event;
4805
4796
  });
4806
4797
  }
4807
- writeMessageTyping(channel_id, mode) {
4798
+ writeMessageTyping(clan_id, channel_id, mode) {
4808
4799
  return __async(this, null, function* () {
4809
- const response = yield this.send({ message_typing_event: { channel_id, mode } });
4800
+ const response = yield this.send({ message_typing_event: { clan_id, channel_id, mode } });
4810
4801
  return response.message_typing_event;
4811
4802
  });
4812
4803
  }
4813
- writeLastSeenMessage(channel_id, mode, message_id, timestamp) {
4804
+ writeLastSeenMessage(clan_id, channel_id, mode, message_id, timestamp) {
4814
4805
  return __async(this, null, function* () {
4815
- const response = yield this.send({ last_seen_message_event: { channel_id, mode, message_id, timestamp } });
4806
+ const response = yield this.send({ last_seen_message_event: { clan_id, channel_id, mode, message_id, timestamp } });
4816
4807
  return response.last_seen_message_event;
4817
4808
  });
4818
4809
  }
4819
- writeLastPinMessage(channel_id, mode, message_id, timestamp, operation) {
4810
+ writeLastPinMessage(clan_id, channel_id, mode, message_id, timestamp, operation) {
4820
4811
  return __async(this, null, function* () {
4821
- const response = yield this.send({ last_pin_message_event: { channel_id, mode, message_id, timestamp, operation } });
4812
+ const response = yield this.send({ last_pin_message_event: { clan_id, channel_id, mode, message_id, timestamp, operation } });
4822
4813
  return response.last_pin_message_event;
4823
4814
  });
4824
4815
  }
@@ -4834,6 +4825,12 @@ var _DefaultSocket = class _DefaultSocket {
4834
4825
  return response.voice_leaved_event;
4835
4826
  });
4836
4827
  }
4828
+ writeCustomStatus(clan_id, status) {
4829
+ return __async(this, null, function* () {
4830
+ const response = yield this.send({ custom_status_event: { clan_id, status } });
4831
+ return response.last_pin_message_event;
4832
+ });
4833
+ }
4837
4834
  pingPong() {
4838
4835
  return __async(this, null, function* () {
4839
4836
  if (!this.adapter.isOpen()) {
@@ -2358,32 +2358,7 @@ var MezonApi = class {
2358
2358
  )
2359
2359
  ]);
2360
2360
  }
2361
- /** Get permission list */
2362
- listClanEmoji(bearerToken, options = {}) {
2363
- const urlPath = "/v2/emoji";
2364
- const queryParams = /* @__PURE__ */ new Map();
2365
- let bodyJson = "";
2366
- const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
2367
- const fetchOptions = buildFetchOptions("GET", options, bodyJson);
2368
- if (bearerToken) {
2369
- fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
2370
- }
2371
- return Promise.race([
2372
- fetch(fullUrl, fetchOptions).then((response) => {
2373
- if (response.status == 204) {
2374
- return response;
2375
- } else if (response.status >= 200 && response.status < 300) {
2376
- return response.json();
2377
- } else {
2378
- throw response;
2379
- }
2380
- }),
2381
- new Promise(
2382
- (_, reject) => setTimeout(reject, this.timeoutMs, "Request timed out.")
2383
- )
2384
- ]);
2385
- }
2386
- /** Post permission Emoji /v2/emoji/create */
2361
+ /** Post clan Emoji /v2/emoji/create */
2387
2362
  createClanEmoji(bearerToken, body, options = {}) {
2388
2363
  if (body === null || body === void 0) {
2389
2364
  throw new Error("'body' is a required parameter but is null or undefined.");
@@ -4509,6 +4484,10 @@ var _DefaultSocket = class _DefaultSocket {
4509
4484
  this.onchannelpresence(message.channel_presence_event);
4510
4485
  } else if (message.last_pin_message_event) {
4511
4486
  this.onpinmessage(message.last_pin_message_event);
4487
+ } else if (message.custom_status_event) {
4488
+ this.oncustomstatus(message.custom_status_event);
4489
+ } else if (message.user_channel_added_event) {
4490
+ this.onuserchanneladded(message.user_channel_added_event);
4512
4491
  } else {
4513
4492
  if (this.verbose && window && window.console) {
4514
4493
  console.log("Unrecognized message received: %o", message);
@@ -4591,6 +4570,11 @@ var _DefaultSocket = class _DefaultSocket {
4591
4570
  console.log(channelPresence);
4592
4571
  }
4593
4572
  }
4573
+ onuserchanneladded(user) {
4574
+ if (this.verbose && window && window.console) {
4575
+ console.log(user);
4576
+ }
4577
+ }
4594
4578
  onnotification(notification) {
4595
4579
  if (this.verbose && window && window.console) {
4596
4580
  console.log(notification);
@@ -4656,6 +4640,11 @@ var _DefaultSocket = class _DefaultSocket {
4656
4640
  console.log("Heartbeat timeout.");
4657
4641
  }
4658
4642
  }
4643
+ oncustomstatus(statusEvent) {
4644
+ if (this.verbose && window && window.console) {
4645
+ console.log(statusEvent);
4646
+ }
4647
+ }
4659
4648
  send(message, sendTimeout = _DefaultSocket.DefaultSendTimeoutMs) {
4660
4649
  const untypedMessage = message;
4661
4650
  return new Promise((resolve, reject) => {
@@ -4693,11 +4682,12 @@ var _DefaultSocket = class _DefaultSocket {
4693
4682
  return response.clan_join;
4694
4683
  });
4695
4684
  }
4696
- joinChat(channel_id, mode, type, persistence, hidden) {
4685
+ joinChat(clan_id, channel_id, mode, type, persistence, hidden) {
4697
4686
  return __async(this, null, function* () {
4698
4687
  const response = yield this.send(
4699
4688
  {
4700
4689
  channel_join: {
4690
+ clan_id,
4701
4691
  channel_id,
4702
4692
  mode,
4703
4693
  type,
@@ -4709,14 +4699,15 @@ var _DefaultSocket = class _DefaultSocket {
4709
4699
  return response.channel;
4710
4700
  });
4711
4701
  }
4712
- leaveChat(channel_id, mode) {
4713
- return this.send({ channel_leave: { channel_id, mode } });
4702
+ leaveChat(clan_id, channel_id, mode) {
4703
+ return this.send({ channel_leave: { clan_id, channel_id, mode } });
4714
4704
  }
4715
- removeChatMessage(channel_id, mode, message_id) {
4705
+ removeChatMessage(clan_id, channel_id, mode, message_id) {
4716
4706
  return __async(this, null, function* () {
4717
4707
  const response = yield this.send(
4718
4708
  {
4719
4709
  channel_message_remove: {
4710
+ clan_id,
4720
4711
  channel_id,
4721
4712
  mode,
4722
4713
  message_id
@@ -4754,9 +4745,9 @@ var _DefaultSocket = class _DefaultSocket {
4754
4745
  unfollowUsers(user_ids) {
4755
4746
  return this.send({ status_unfollow: { user_ids } });
4756
4747
  }
4757
- updateChatMessage(channel_id, mode, message_id, content) {
4748
+ updateChatMessage(clan_id, channel_id, mode, message_id, content) {
4758
4749
  return __async(this, null, function* () {
4759
- const response = yield this.send({ channel_message_update: { channel_id, message_id, content, mode } });
4750
+ const response = yield this.send({ channel_message_update: { clan_id, channel_id, message_id, content, mode } });
4760
4751
  return response.channel_message_ack;
4761
4752
  });
4762
4753
  }
@@ -4769,27 +4760,27 @@ var _DefaultSocket = class _DefaultSocket {
4769
4760
  return response.channel_message_ack;
4770
4761
  });
4771
4762
  }
4772
- writeMessageReaction(id, channel_id, mode, message_id, emoji, count, message_sender_id, action_delete) {
4763
+ writeMessageReaction(id, clan_id, channel_id, mode, message_id, emoji, count, message_sender_id, action_delete) {
4773
4764
  return __async(this, null, function* () {
4774
- const response = yield this.send({ message_reaction_event: { id, channel_id, mode, message_id, emoji, count, message_sender_id, action: action_delete } });
4765
+ const response = yield this.send({ message_reaction_event: { id, clan_id, channel_id, mode, message_id, emoji, count, message_sender_id, action: action_delete } });
4775
4766
  return response.message_reaction_event;
4776
4767
  });
4777
4768
  }
4778
- writeMessageTyping(channel_id, mode) {
4769
+ writeMessageTyping(clan_id, channel_id, mode) {
4779
4770
  return __async(this, null, function* () {
4780
- const response = yield this.send({ message_typing_event: { channel_id, mode } });
4771
+ const response = yield this.send({ message_typing_event: { clan_id, channel_id, mode } });
4781
4772
  return response.message_typing_event;
4782
4773
  });
4783
4774
  }
4784
- writeLastSeenMessage(channel_id, mode, message_id, timestamp) {
4775
+ writeLastSeenMessage(clan_id, channel_id, mode, message_id, timestamp) {
4785
4776
  return __async(this, null, function* () {
4786
- const response = yield this.send({ last_seen_message_event: { channel_id, mode, message_id, timestamp } });
4777
+ const response = yield this.send({ last_seen_message_event: { clan_id, channel_id, mode, message_id, timestamp } });
4787
4778
  return response.last_seen_message_event;
4788
4779
  });
4789
4780
  }
4790
- writeLastPinMessage(channel_id, mode, message_id, timestamp, operation) {
4781
+ writeLastPinMessage(clan_id, channel_id, mode, message_id, timestamp, operation) {
4791
4782
  return __async(this, null, function* () {
4792
- const response = yield this.send({ last_pin_message_event: { channel_id, mode, message_id, timestamp, operation } });
4783
+ const response = yield this.send({ last_pin_message_event: { clan_id, channel_id, mode, message_id, timestamp, operation } });
4793
4784
  return response.last_pin_message_event;
4794
4785
  });
4795
4786
  }
@@ -4805,6 +4796,12 @@ var _DefaultSocket = class _DefaultSocket {
4805
4796
  return response.voice_leaved_event;
4806
4797
  });
4807
4798
  }
4799
+ writeCustomStatus(clan_id, status) {
4800
+ return __async(this, null, function* () {
4801
+ const response = yield this.send({ custom_status_event: { clan_id, status } });
4802
+ return response.last_pin_message_event;
4803
+ });
4804
+ }
4808
4805
  pingPong() {
4809
4806
  return __async(this, null, function* () {
4810
4807
  if (!this.adapter.isOpen()) {
package/dist/socket.d.ts CHANGED
@@ -71,6 +71,14 @@ interface ChannelLeave {
71
71
  channel_label: string;
72
72
  };
73
73
  }
74
+ /** UserChannelAddedEvent */
75
+ export interface UserChannelAddedEvent {
76
+ channel_id: string;
77
+ user_id: string;
78
+ username: string;
79
+ avatar: string;
80
+ status: string;
81
+ }
74
82
  /** Last seen message by user */
75
83
  export interface LastPinMessageEvent {
76
84
  /** The channel this message belongs to. */
@@ -285,6 +293,12 @@ export interface VoiceJoinedEvent {
285
293
  voice_channel_id: string;
286
294
  last_screenshot: string;
287
295
  }
296
+ export interface CustomStatusEvent {
297
+ clan_id: string;
298
+ user_id: string;
299
+ username: string;
300
+ status: string;
301
+ }
288
302
  export interface ChannelUpdatedEvent {
289
303
  clan_id: string;
290
304
  category_id: string;
@@ -394,29 +408,29 @@ export interface Socket {
394
408
  /** Join clan chat */
395
409
  joinClanChat(clan_id: string): Promise<ClanJoin>;
396
410
  /** Join a chat channel on the server. */
397
- joinChat(channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
411
+ joinChat(clan_id: string, channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
398
412
  /** Leave a chat channel on the server. */
399
- leaveChat(channel_id: string, mode: number): Promise<void>;
413
+ leaveChat(clan_id: string, channel_id: string, mode: number): Promise<void>;
400
414
  /** Remove a chat message from a chat channel on the server. */
401
- removeChatMessage(channel_id: string, mode: number, message_id: string): Promise<ChannelMessageAck>;
415
+ removeChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string): Promise<ChannelMessageAck>;
402
416
  /** Execute an RPC function to the server. */
403
417
  rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
404
418
  /** Unfollow one or more users from their status updates. */
405
419
  unfollowUsers(user_ids: string[]): Promise<void>;
406
420
  /** Update a chat message on a chat channel in the server. */
407
- updateChatMessage(channel_id: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
421
+ updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
408
422
  /** Update the status for the current user online. */
409
423
  updateStatus(status?: string): Promise<void>;
410
424
  /** Send a chat message to a chat channel on the server. */
411
425
  writeChatMessage(clan_id: string, channel_id: string, mode: number, content?: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>, anonymous_message?: boolean, mention_everyone?: boolean, notifi_content?: any): Promise<ChannelMessageAck>;
412
426
  /** Send message typing */
413
- writeMessageTyping(channel_id: string, mode: number): Promise<MessageTypingEvent>;
427
+ writeMessageTyping(clan_id: string, channel_id: string, mode: number): Promise<MessageTypingEvent>;
414
428
  /** Send message reaction */
415
- writeMessageReaction(id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
429
+ writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
416
430
  /** Send last seen message */
417
- writeLastSeenMessage(channel_id: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent>;
431
+ writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent>;
418
432
  /** Send last pin message */
419
- writeLastPinMessage(channel_id: string, mode: number, message_id: string, timestamp: string, operation: number): Promise<LastPinMessageEvent>;
433
+ writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number): Promise<LastPinMessageEvent>;
420
434
  /** send voice joined */
421
435
  writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
422
436
  /** send voice leaved */
@@ -440,6 +454,7 @@ export interface Socket {
440
454
  * In any case, be aware that `onclose` will still fire if there is a heartbeat timeout in a potentially delayed manner.
441
455
  */
442
456
  onheartbeattimeout: () => void;
457
+ oncustomstatus: (statusEvent: CustomStatusEvent) => void;
443
458
  /** Receive channel message. */
444
459
  onchannelmessage: (channelMessage: ChannelMessageEvent) => void;
445
460
  /** Receive typing event */
@@ -450,6 +465,8 @@ export interface Socket {
450
465
  onchannelpresence: (channelPresence: ChannelPresenceEvent) => void;
451
466
  /** pin message event */
452
467
  onpinmessage: (pin: LastPinMessageEvent) => void;
468
+ /** Receive added user event */
469
+ onuserchanneladded: (user: UserChannelAddedEvent) => void;
453
470
  onvoicestarted: (voice: VoiceStartedEvent) => void;
454
471
  onvoiceended: (voice: VoiceEndedEvent) => void;
455
472
  onvoicejoined: (voiceParticipant: VoiceJoinedEvent) => void;
@@ -493,6 +510,7 @@ export declare class DefaultSocket implements Socket {
493
510
  onmessagereaction(messagereaction: MessageReactionEvent): void;
494
511
  onchannelmessage(channelMessage: ChannelMessageEvent): void;
495
512
  onchannelpresence(channelPresence: ChannelPresenceEvent): void;
513
+ onuserchanneladded(user: UserChannelAddedEvent): void;
496
514
  onnotification(notification: Notification): void;
497
515
  onstatuspresence(statusPresence: StatusPresenceEvent): void;
498
516
  onpinmessage(pin: LastPinMessageEvent): void;
@@ -506,25 +524,27 @@ export declare class DefaultSocket implements Socket {
506
524
  onstreampresence(streamPresence: StreamPresenceEvent): void;
507
525
  onstreamdata(streamData: StreamData): void;
508
526
  onheartbeattimeout(): void;
527
+ oncustomstatus(statusEvent: CustomStatusEvent): void;
509
528
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate | ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout?: number): Promise<any>;
510
529
  followUsers(userIds: string[]): Promise<Status>;
511
530
  joinClanChat(clan_id: string): Promise<ClanJoin>;
512
- joinChat(channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
513
- leaveChat(channel_id: string, mode: number): Promise<void>;
514
- removeChatMessage(channel_id: string, mode: number, message_id: string): Promise<ChannelMessageAck>;
531
+ joinChat(clan_id: string, channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel>;
532
+ leaveChat(clan_id: string, channel_id: string, mode: number): Promise<void>;
533
+ removeChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string): Promise<ChannelMessageAck>;
515
534
  removePartyMember(party_id: string, member: Presence): Promise<void>;
516
535
  rpc(id?: string, payload?: string, http_key?: string): Promise<ApiRpc>;
517
536
  sendPartyData(party_id: string, op_code: number, data: string | Uint8Array): Promise<void>;
518
537
  unfollowUsers(user_ids: string[]): Promise<void>;
519
- updateChatMessage(channel_id: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
538
+ updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string, content: any): Promise<ChannelMessageAck>;
520
539
  updateStatus(status?: string): Promise<void>;
521
540
  writeChatMessage(clan_id: string, channel_id: string, mode: number, content: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>, anonymous_message?: boolean, mention_everyone?: Boolean, notifi_content?: any): Promise<ChannelMessageAck>;
522
- writeMessageReaction(id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
523
- writeMessageTyping(channel_id: string, mode: number): Promise<MessageTypingEvent>;
524
- writeLastSeenMessage(channel_id: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent>;
525
- writeLastPinMessage(channel_id: string, mode: number, message_id: string, timestamp: string, operation: number): Promise<LastPinMessageEvent>;
541
+ writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean): Promise<MessageReactionEvent>;
542
+ writeMessageTyping(clan_id: string, channel_id: string, mode: number): Promise<MessageTypingEvent>;
543
+ writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string): Promise<LastSeenMessageEvent>;
544
+ writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number): Promise<LastPinMessageEvent>;
526
545
  writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string): Promise<VoiceJoinedEvent>;
527
546
  writeVoiceLeaved(id: string, clanId: string, voiceChannelId: string, voiceUserId: string): Promise<VoiceLeavedEvent>;
547
+ writeCustomStatus(clan_id: string, status: string): Promise<CustomStatusEvent>;
528
548
  private pingPong;
529
549
  }
530
550
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mezon-js",
3
- "version": "2.7.70",
3
+ "version": "2.7.73",
4
4
  "scripts": {
5
5
  "build": "npx tsc && npx rollup -c --bundleConfigAsCjs && node build.mjs"
6
6
  },
package/socket.ts CHANGED
@@ -88,6 +88,20 @@ interface ChannelLeave {
88
88
  };
89
89
  }
90
90
 
91
+ /** UserChannelAddedEvent */
92
+ export interface UserChannelAddedEvent {
93
+ // the channel id
94
+ channel_id: string;
95
+ // the user_id
96
+ user_id: string;
97
+ // the username
98
+ username: string;
99
+ // the avatar
100
+ avatar: string;
101
+ // the custom status
102
+ status: string;
103
+ }
104
+
91
105
  /** Last seen message by user */
92
106
  export interface LastPinMessageEvent {
93
107
  /** The channel this message belongs to. */
@@ -395,6 +409,16 @@ export interface VoiceJoinedEvent {
395
409
  last_screenshot: string;
396
410
  }
397
411
 
412
+ export interface CustomStatusEvent {
413
+ // the clan id
414
+ clan_id: string;
415
+ // the user id
416
+ user_id: string;
417
+ // username
418
+ username: string;
419
+ // the status
420
+ status: string;
421
+ }
398
422
 
399
423
  export interface ChannelUpdatedEvent {
400
424
  // clan id
@@ -539,13 +563,13 @@ export interface Socket {
539
563
  joinClanChat(clan_id: string) : Promise<ClanJoin>;
540
564
 
541
565
  /** Join a chat channel on the server. */
542
- joinChat(channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean) : Promise<Channel>;
566
+ joinChat(clan_id: string, channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean) : Promise<Channel>;
543
567
 
544
568
  /** Leave a chat channel on the server. */
545
- leaveChat(channel_id: string, mode: number) : Promise<void>;
569
+ leaveChat(clan_id: string, channel_id: string, mode: number) : Promise<void>;
546
570
 
547
571
  /** Remove a chat message from a chat channel on the server. */
548
- removeChatMessage(channel_id: string, mode: number, message_id: string) : Promise<ChannelMessageAck>;
572
+ removeChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string) : Promise<ChannelMessageAck>;
549
573
 
550
574
  /** Execute an RPC function to the server. */
551
575
  rpc(id?: string, payload?: string, http_key?: string) : Promise<ApiRpc>
@@ -554,7 +578,7 @@ export interface Socket {
554
578
  unfollowUsers(user_ids : string[]) : Promise<void>;
555
579
 
556
580
  /** Update a chat message on a chat channel in the server. */
557
- updateChatMessage(channel_id: string, mode: number, message_id : string, content: any) : Promise<ChannelMessageAck>;
581
+ updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id : string, content: any) : Promise<ChannelMessageAck>;
558
582
 
559
583
  /** Update the status for the current user online. */
560
584
  updateStatus(status? : string) : Promise<void>;
@@ -563,16 +587,16 @@ export interface Socket {
563
587
  writeChatMessage(clan_id: string, channel_id: string, mode: number, content?: any, mentions?: Array<ApiMessageMention>, attachments?: Array<ApiMessageAttachment>, references?: Array<ApiMessageRef>, anonymous_message?: boolean, mention_everyone?:boolean, notifi_content?: any) : Promise<ChannelMessageAck>;
564
588
 
565
589
  /** Send message typing */
566
- writeMessageTyping(channel_id: string, mode: number) : Promise<MessageTypingEvent>;
590
+ writeMessageTyping(clan_id: string, channel_id: string, mode: number) : Promise<MessageTypingEvent>;
567
591
 
568
592
  /** Send message reaction */
569
- writeMessageReaction(id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean) : Promise<MessageReactionEvent>;
593
+ writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean) : Promise<MessageReactionEvent>;
570
594
 
571
595
  /** Send last seen message */
572
- writeLastSeenMessage(channel_id: string, mode: number, message_id: string, timestamp: string) : Promise<LastSeenMessageEvent>;
596
+ writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string) : Promise<LastSeenMessageEvent>;
573
597
 
574
598
  /** Send last pin message */
575
- writeLastPinMessage(channel_id: string, mode: number, message_id: string, timestamp: string, operation: number) : Promise<LastPinMessageEvent>;
599
+ writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number) : Promise<LastPinMessageEvent>;
576
600
 
577
601
  /** send voice joined */
578
602
  writeVoiceJoined(id: string, clanId: string, clanName: string, voiceChannelId: string, voiceChannelLabel: string, participant: string, lastScreenshot: string) : Promise<VoiceJoinedEvent>;
@@ -606,6 +630,8 @@ export interface Socket {
606
630
  */
607
631
  onheartbeattimeout: () => void;
608
632
 
633
+ oncustomstatus: (statusEvent: CustomStatusEvent) => void;
634
+
609
635
  /** Receive channel message. */
610
636
  onchannelmessage: (channelMessage: ChannelMessageEvent) => void;
611
637
 
@@ -620,6 +646,9 @@ export interface Socket {
620
646
 
621
647
  /** pin message event */
622
648
  onpinmessage: (pin: LastPinMessageEvent) => void;
649
+
650
+ /** Receive added user event */
651
+ onuserchanneladded: (user: UserChannelAddedEvent) => void;
623
652
 
624
653
  // when someone start the voice room
625
654
  onvoicestarted: (voice: VoiceStartedEvent) => void;
@@ -774,6 +803,10 @@ export class DefaultSocket implements Socket {
774
803
  this.onchannelpresence(<ChannelPresenceEvent>message.channel_presence_event);
775
804
  } else if (message.last_pin_message_event) {
776
805
  this.onpinmessage(<LastPinMessageEvent>message.last_pin_message_event);
806
+ } else if (message.custom_status_event) {
807
+ this.oncustomstatus(<CustomStatusEvent>message.custom_status_event);
808
+ } else if (message.user_channel_added_event) {
809
+ this.onuserchanneladded(<UserChannelAddedEvent>message.user_channel_added_event);
777
810
  } else {
778
811
  if (this.verbose && window && window.console) {
779
812
  console.log("Unrecognized message received: %o", message);
@@ -871,6 +904,12 @@ export class DefaultSocket implements Socket {
871
904
  }
872
905
  }
873
906
 
907
+ onuserchanneladded(user: UserChannelAddedEvent) {
908
+ if (this.verbose && window && window.console) {
909
+ console.log(user);
910
+ }
911
+ }
912
+
874
913
  onnotification(notification: Notification) {
875
914
  if (this.verbose && window && window.console) {
876
915
  console.log(notification);
@@ -949,6 +988,12 @@ export class DefaultSocket implements Socket {
949
988
  }
950
989
  }
951
990
 
991
+ oncustomstatus(statusEvent: CustomStatusEvent) {
992
+ if (this.verbose && window && window.console) {
993
+ console.log(statusEvent);
994
+ }
995
+ }
996
+
952
997
  send(message: ChannelJoin | ChannelLeave | ChannelMessageSend | ChannelMessageUpdate |
953
998
  ChannelMessageRemove | MessageTypingEvent | LastSeenMessageEvent | Rpc | StatusFollow | StatusUnfollow | StatusUpdate | Ping, sendTimeout = DefaultSocket.DefaultSendTimeoutMs): Promise<any> {
954
999
  const untypedMessage = message as any;
@@ -993,10 +1038,11 @@ export class DefaultSocket implements Socket {
993
1038
  return response.clan_join;
994
1039
  }
995
1040
 
996
- async joinChat(channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel> {
1041
+ async joinChat(clan_id: string, channel_id: string, mode: number, type: number, persistence: boolean, hidden: boolean): Promise<Channel> {
997
1042
 
998
1043
  const response = await this.send({
999
1044
  channel_join: {
1045
+ clan_id: clan_id,
1000
1046
  channel_id: channel_id,
1001
1047
  mode: mode,
1002
1048
  type: type,
@@ -1009,14 +1055,15 @@ export class DefaultSocket implements Socket {
1009
1055
  return response.channel;
1010
1056
  }
1011
1057
 
1012
- leaveChat(channel_id: string, mode: number): Promise<void> {
1013
- return this.send({channel_leave: {channel_id: channel_id, mode:mode}});
1058
+ leaveChat(clan_id: string, channel_id: string, mode: number): Promise<void> {
1059
+ return this.send({channel_leave: {clan_id: clan_id, channel_id: channel_id, mode:mode}});
1014
1060
  }
1015
1061
 
1016
- async removeChatMessage(channel_id: string, mode: number, message_id: string): Promise<ChannelMessageAck> {
1062
+ async removeChatMessage(clan_id: string, channel_id: string, mode: number, message_id: string): Promise<ChannelMessageAck> {
1017
1063
  const response = await this.send(
1018
1064
  {
1019
1065
  channel_message_remove: {
1066
+ clan_id: clan_id,
1020
1067
  channel_id: channel_id,
1021
1068
  mode: mode,
1022
1069
  message_id: message_id
@@ -1055,8 +1102,8 @@ export class DefaultSocket implements Socket {
1055
1102
  return this.send({status_unfollow: {user_ids: user_ids}});
1056
1103
  }
1057
1104
 
1058
- async updateChatMessage(channel_id: string, mode: number, message_id : string, content: any): Promise<ChannelMessageAck> {
1059
- const response = await this.send({channel_message_update: {channel_id: channel_id, message_id: message_id, content: content, mode: mode}});
1105
+ async updateChatMessage(clan_id: string, channel_id: string, mode: number, message_id : string, content: any): Promise<ChannelMessageAck> {
1106
+ const response = await this.send({channel_message_update: {clan_id: clan_id, channel_id: channel_id, message_id: message_id, content: content, mode: mode}});
1060
1107
  return response.channel_message_ack;
1061
1108
  }
1062
1109
 
@@ -1069,23 +1116,23 @@ export class DefaultSocket implements Socket {
1069
1116
  return response.channel_message_ack;
1070
1117
  }
1071
1118
 
1072
- async writeMessageReaction(id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean) : Promise<MessageReactionEvent> {
1073
- const response = await this.send({message_reaction_event: {id: id, channel_id: channel_id, mode: mode, message_id: message_id, emoji: emoji, count: count, message_sender_id: message_sender_id, action: action_delete}});
1119
+ async writeMessageReaction(id: string, clan_id: string, channel_id: string, mode: number, message_id: string, emoji: string, count: number, message_sender_id: string, action_delete: boolean) : Promise<MessageReactionEvent> {
1120
+ const response = await this.send({message_reaction_event: {id: id, clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, emoji: emoji, count: count, message_sender_id: message_sender_id, action: action_delete}});
1074
1121
  return response.message_reaction_event
1075
1122
  }
1076
1123
 
1077
- async writeMessageTyping(channel_id: string, mode: number) : Promise<MessageTypingEvent> {
1078
- const response = await this.send({message_typing_event: {channel_id: channel_id, mode:mode}});
1124
+ async writeMessageTyping(clan_id: string, channel_id: string, mode: number) : Promise<MessageTypingEvent> {
1125
+ const response = await this.send({message_typing_event: {clan_id: clan_id, channel_id: channel_id, mode:mode}});
1079
1126
  return response.message_typing_event
1080
1127
  }
1081
1128
 
1082
- async writeLastSeenMessage(channel_id: string, mode: number, message_id: string, timestamp: string) : Promise<LastSeenMessageEvent> {
1083
- const response = await this.send({last_seen_message_event: {channel_id: channel_id, mode: mode, message_id: message_id, timestamp: timestamp}});
1129
+ async writeLastSeenMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string) : Promise<LastSeenMessageEvent> {
1130
+ const response = await this.send({last_seen_message_event: {clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, timestamp: timestamp}});
1084
1131
  return response.last_seen_message_event
1085
1132
  }
1086
1133
 
1087
- async writeLastPinMessage(channel_id: string, mode: number, message_id: string, timestamp: string, operation: number) : Promise<LastPinMessageEvent> {
1088
- const response = await this.send({last_pin_message_event: {channel_id: channel_id, mode: mode, message_id: message_id, timestamp: timestamp, operation: operation}});
1134
+ async writeLastPinMessage(clan_id: string, channel_id: string, mode: number, message_id: string, timestamp: string, operation: number) : Promise<LastPinMessageEvent> {
1135
+ const response = await this.send({last_pin_message_event: {clan_id: clan_id, channel_id: channel_id, mode: mode, message_id: message_id, timestamp: timestamp, operation: operation}});
1089
1136
  return response.last_pin_message_event
1090
1137
  }
1091
1138
 
@@ -1099,6 +1146,11 @@ export class DefaultSocket implements Socket {
1099
1146
  return response.voice_leaved_event
1100
1147
  }
1101
1148
 
1149
+ async writeCustomStatus(clan_id: string, status: string) : Promise<CustomStatusEvent> {
1150
+ const response = await this.send({custom_status_event: {clan_id: clan_id, status: status}});
1151
+ return response.last_pin_message_event
1152
+ }
1153
+
1102
1154
  private async pingPong() : Promise<void> {
1103
1155
  if (!this.adapter.isOpen()) {
1104
1156
  return;