mezon-js 2.13.91 → 2.13.92

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/client.ts CHANGED
@@ -327,7 +327,7 @@ import {
327
327
  decodeAttachments,
328
328
  decodeRefs,
329
329
  decodeReactions,
330
- decodeNotificationContent,
330
+ decodeNotificationFcm,
331
331
  } from "mezon-js-protobuf";
332
332
 
333
333
  const DEFAULT_HOST = "127.0.0.1";
@@ -376,8 +376,8 @@ export enum WebrtcSignalingType {
376
376
  export class Client {
377
377
  /** The low level API client for Mezon server. */
378
378
  private readonly gatewayClient: GatewayMezonApi;
379
- private readonly grpcTransport: Transport;
380
- private readonly mezonClient: RPCClient<typeof MezonService>;
379
+ private grpcTransport: Transport;
380
+ private mezonClient: RPCClient<typeof MezonService>;
381
381
 
382
382
  /** thre refreshTokenPromise */
383
383
  private refreshTokenPromise: Promise<Session> | null = null;
@@ -434,7 +434,13 @@ export class Client {
434
434
 
435
435
  const scheme = useSSL ? "https://" : "http://";
436
436
  const basePath = `${scheme}${host}:${port}`;
437
- return this.gatewayClient.setBasePath(basePath);
437
+
438
+ this.gatewayClient.setBasePath(basePath);
439
+ this.grpcTransport = createGrpcWebTransport({
440
+ baseUrl: basePath,
441
+ useBinaryFormat: true,
442
+ });
443
+ this.mezonClient = createClient(MezonService, this.grpcTransport);
438
444
  }
439
445
 
440
446
  //#region Mezon Gateway APIs
@@ -2260,7 +2266,7 @@ export class Client {
2260
2266
  var content;
2261
2267
  try {
2262
2268
  content =
2263
- decodeNotificationContent(n.content) ||
2269
+ decodeNotificationFcm(n.content) ||
2264
2270
  safeJSONParse((n.content as unknown as string) || "{}");
2265
2271
  } catch (e) {
2266
2272
  console.log("error parse content", e);
package/dist/client.d.ts CHANGED
@@ -59,8 +59,8 @@ export declare class Client {
59
59
  readonly autoRefreshSession: boolean;
60
60
  /** The low level API client for Mezon server. */
61
61
  private readonly gatewayClient;
62
- private readonly grpcTransport;
63
- private readonly mezonClient;
62
+ private grpcTransport;
63
+ private mezonClient;
64
64
  /** thre refreshTokenPromise */
65
65
  private refreshTokenPromise;
66
66
  host: string;
@@ -59,8 +59,8 @@ export declare class Client {
59
59
  readonly autoRefreshSession: boolean;
60
60
  /** The low level API client for Mezon server. */
61
61
  private readonly gatewayClient;
62
- private readonly grpcTransport;
63
- private readonly mezonClient;
62
+ private grpcTransport;
63
+ private mezonClient;
64
64
  /** thre refreshTokenPromise */
65
65
  private refreshTokenPromise;
66
66
  host: string;
@@ -73,12 +73,31 @@ export interface Friends {
73
73
  /** Cursor for the next page of results, if any. */
74
74
  cursor?: string;
75
75
  }
76
+ export interface NotificationFcmContent {
77
+ title?: string;
78
+ link?: string;
79
+ content?: string;
80
+ channel_id?: string;
81
+ sender_id?: string;
82
+ avatar?: string;
83
+ clan_id?: string;
84
+ attachment_link?: string;
85
+ display_name?: string;
86
+ create_time_seconds?: number;
87
+ update_time_seconds?: number;
88
+ username?: string;
89
+ mention_ids?: string[];
90
+ position_s?: number[];
91
+ position_e?: number[];
92
+ attachment_type?: string;
93
+ has_more_attachment?: boolean;
94
+ }
76
95
  /** A notification in the server. */
77
96
  export interface Notification {
78
97
  /** Category code for this notification. */
79
98
  code?: number;
80
99
  /** Content of the notification in string. */
81
- content?: string;
100
+ content?: NotificationFcmContent;
82
101
  /** The UNIX time when the notification was created. */
83
102
  createTimeSeconds?: number;
84
103
  /** ID of the Notification. */
@@ -896,6 +915,9 @@ export interface ApiEventManagement {
896
915
  eventStatus?: number;
897
916
  repeatType?: number;
898
917
  isPrivate?: boolean;
918
+ startTimeSeconds?: number;
919
+ endTimeSeconds?: number;
920
+ createTimeSeconds?: number;
899
921
  meetRoom?: ApiGenerateMezonMeetResponse;
900
922
  }
901
923
  /** */
@@ -1170,7 +1192,7 @@ export interface ApiMessageRef {
1170
1192
  ref_type?: number;
1171
1193
  message_sender_id?: string;
1172
1194
  message_sender_username?: string;
1173
- mesages_sender_avatar?: string;
1195
+ message_sender_avatar?: string;
1174
1196
  message_sender_clan_nick?: string;
1175
1197
  message_sender_display_name?: string;
1176
1198
  content?: string;
@@ -22174,6 +22174,320 @@ var SearchThreadRequest = {
22174
22174
  return message;
22175
22175
  }
22176
22176
  };
22177
+ function createBaseDirectFcmProto() {
22178
+ return {
22179
+ title: "",
22180
+ link: "",
22181
+ content: "",
22182
+ channel_id: "",
22183
+ sender_id: "",
22184
+ avatar: "",
22185
+ clan_id: "",
22186
+ attachment_link: "",
22187
+ display_name: "",
22188
+ create_time_seconds: 0,
22189
+ update_time_seconds: 0,
22190
+ username: "",
22191
+ mention_ids: [],
22192
+ position_s: [],
22193
+ position_e: [],
22194
+ attachment_type: "",
22195
+ has_more_attachment: false
22196
+ };
22197
+ }
22198
+ var DirectFcmProto = {
22199
+ encode(message, writer = import_minimal3.default.Writer.create()) {
22200
+ if (message.title !== "") {
22201
+ writer.uint32(10).string(message.title);
22202
+ }
22203
+ if (message.link !== "") {
22204
+ writer.uint32(18).string(message.link);
22205
+ }
22206
+ if (message.content !== "") {
22207
+ writer.uint32(26).string(message.content);
22208
+ }
22209
+ if (message.channel_id !== "") {
22210
+ writer.uint32(34).string(message.channel_id);
22211
+ }
22212
+ if (message.sender_id !== "") {
22213
+ writer.uint32(42).string(message.sender_id);
22214
+ }
22215
+ if (message.avatar !== "") {
22216
+ writer.uint32(50).string(message.avatar);
22217
+ }
22218
+ if (message.clan_id !== "") {
22219
+ writer.uint32(58).string(message.clan_id);
22220
+ }
22221
+ if (message.attachment_link !== "") {
22222
+ writer.uint32(66).string(message.attachment_link);
22223
+ }
22224
+ if (message.display_name !== "") {
22225
+ writer.uint32(74).string(message.display_name);
22226
+ }
22227
+ if (message.create_time_seconds !== 0) {
22228
+ writer.uint32(80).int32(message.create_time_seconds);
22229
+ }
22230
+ if (message.update_time_seconds !== 0) {
22231
+ writer.uint32(88).int32(message.update_time_seconds);
22232
+ }
22233
+ if (message.username !== "") {
22234
+ writer.uint32(98).string(message.username);
22235
+ }
22236
+ for (const v of message.mention_ids) {
22237
+ writer.uint32(106).string(v);
22238
+ }
22239
+ writer.uint32(114).fork();
22240
+ for (const v of message.position_s) {
22241
+ writer.int32(v);
22242
+ }
22243
+ writer.ldelim();
22244
+ writer.uint32(122).fork();
22245
+ for (const v of message.position_e) {
22246
+ writer.int32(v);
22247
+ }
22248
+ writer.ldelim();
22249
+ if (message.attachment_type !== "") {
22250
+ writer.uint32(130).string(message.attachment_type);
22251
+ }
22252
+ if (message.has_more_attachment !== false) {
22253
+ writer.uint32(136).bool(message.has_more_attachment);
22254
+ }
22255
+ return writer;
22256
+ },
22257
+ decode(input, length) {
22258
+ const reader = input instanceof import_minimal3.default.Reader ? input : import_minimal3.default.Reader.create(input);
22259
+ let end = length === void 0 ? reader.len : reader.pos + length;
22260
+ const message = createBaseDirectFcmProto();
22261
+ while (reader.pos < end) {
22262
+ const tag = reader.uint32();
22263
+ switch (tag >>> 3) {
22264
+ case 1:
22265
+ if (tag !== 10) {
22266
+ break;
22267
+ }
22268
+ message.title = reader.string();
22269
+ continue;
22270
+ case 2:
22271
+ if (tag !== 18) {
22272
+ break;
22273
+ }
22274
+ message.link = reader.string();
22275
+ continue;
22276
+ case 3:
22277
+ if (tag !== 26) {
22278
+ break;
22279
+ }
22280
+ message.content = reader.string();
22281
+ continue;
22282
+ case 4:
22283
+ if (tag !== 34) {
22284
+ break;
22285
+ }
22286
+ message.channel_id = reader.string();
22287
+ continue;
22288
+ case 5:
22289
+ if (tag !== 42) {
22290
+ break;
22291
+ }
22292
+ message.sender_id = reader.string();
22293
+ continue;
22294
+ case 6:
22295
+ if (tag !== 50) {
22296
+ break;
22297
+ }
22298
+ message.avatar = reader.string();
22299
+ continue;
22300
+ case 7:
22301
+ if (tag !== 58) {
22302
+ break;
22303
+ }
22304
+ message.clan_id = reader.string();
22305
+ continue;
22306
+ case 8:
22307
+ if (tag !== 66) {
22308
+ break;
22309
+ }
22310
+ message.attachment_link = reader.string();
22311
+ continue;
22312
+ case 9:
22313
+ if (tag !== 74) {
22314
+ break;
22315
+ }
22316
+ message.display_name = reader.string();
22317
+ continue;
22318
+ case 10:
22319
+ if (tag !== 80) {
22320
+ break;
22321
+ }
22322
+ message.create_time_seconds = reader.int32();
22323
+ continue;
22324
+ case 11:
22325
+ if (tag !== 88) {
22326
+ break;
22327
+ }
22328
+ message.update_time_seconds = reader.int32();
22329
+ continue;
22330
+ case 12:
22331
+ if (tag !== 98) {
22332
+ break;
22333
+ }
22334
+ message.username = reader.string();
22335
+ continue;
22336
+ case 13:
22337
+ if (tag !== 106) {
22338
+ break;
22339
+ }
22340
+ message.mention_ids.push(reader.string());
22341
+ continue;
22342
+ case 14:
22343
+ if (tag === 112) {
22344
+ message.position_s.push(reader.int32());
22345
+ continue;
22346
+ }
22347
+ if (tag === 114) {
22348
+ const end2 = reader.uint32() + reader.pos;
22349
+ while (reader.pos < end2) {
22350
+ message.position_s.push(reader.int32());
22351
+ }
22352
+ continue;
22353
+ }
22354
+ break;
22355
+ case 15:
22356
+ if (tag === 120) {
22357
+ message.position_e.push(reader.int32());
22358
+ continue;
22359
+ }
22360
+ if (tag === 122) {
22361
+ const end2 = reader.uint32() + reader.pos;
22362
+ while (reader.pos < end2) {
22363
+ message.position_e.push(reader.int32());
22364
+ }
22365
+ continue;
22366
+ }
22367
+ break;
22368
+ case 16:
22369
+ if (tag !== 130) {
22370
+ break;
22371
+ }
22372
+ message.attachment_type = reader.string();
22373
+ continue;
22374
+ case 17:
22375
+ if (tag !== 136) {
22376
+ break;
22377
+ }
22378
+ message.has_more_attachment = reader.bool();
22379
+ continue;
22380
+ }
22381
+ if ((tag & 7) === 4 || tag === 0) {
22382
+ break;
22383
+ }
22384
+ reader.skipType(tag & 7);
22385
+ }
22386
+ return message;
22387
+ },
22388
+ fromJSON(object) {
22389
+ return {
22390
+ title: isSet2(object.title) ? globalThis.String(object.title) : "",
22391
+ link: isSet2(object.link) ? globalThis.String(object.link) : "",
22392
+ content: isSet2(object.content) ? globalThis.String(object.content) : "",
22393
+ channel_id: isSet2(object.channel_id) ? globalThis.String(object.channel_id) : "",
22394
+ sender_id: isSet2(object.sender_id) ? globalThis.String(object.sender_id) : "",
22395
+ avatar: isSet2(object.avatar) ? globalThis.String(object.avatar) : "",
22396
+ clan_id: isSet2(object.clan_id) ? globalThis.String(object.clan_id) : "",
22397
+ attachment_link: isSet2(object.attachment_link) ? globalThis.String(object.attachment_link) : "",
22398
+ display_name: isSet2(object.display_name) ? globalThis.String(object.display_name) : "",
22399
+ create_time_seconds: isSet2(object.create_time_seconds) ? globalThis.Number(object.create_time_seconds) : 0,
22400
+ update_time_seconds: isSet2(object.update_time_seconds) ? globalThis.Number(object.update_time_seconds) : 0,
22401
+ username: isSet2(object.username) ? globalThis.String(object.username) : "",
22402
+ mention_ids: globalThis.Array.isArray(object == null ? void 0 : object.mention_ids) ? object.mention_ids.map((e) => globalThis.String(e)) : [],
22403
+ position_s: globalThis.Array.isArray(object == null ? void 0 : object.position_s) ? object.position_s.map((e) => globalThis.Number(e)) : [],
22404
+ position_e: globalThis.Array.isArray(object == null ? void 0 : object.position_e) ? object.position_e.map((e) => globalThis.Number(e)) : [],
22405
+ attachment_type: isSet2(object.attachment_type) ? globalThis.String(object.attachment_type) : "",
22406
+ has_more_attachment: isSet2(object.has_more_attachment) ? globalThis.Boolean(object.has_more_attachment) : false
22407
+ };
22408
+ },
22409
+ toJSON(message) {
22410
+ var _a, _b, _c;
22411
+ const obj = {};
22412
+ if (message.title !== "") {
22413
+ obj.title = message.title;
22414
+ }
22415
+ if (message.link !== "") {
22416
+ obj.link = message.link;
22417
+ }
22418
+ if (message.content !== "") {
22419
+ obj.content = message.content;
22420
+ }
22421
+ if (message.channel_id !== "") {
22422
+ obj.channel_id = message.channel_id;
22423
+ }
22424
+ if (message.sender_id !== "") {
22425
+ obj.sender_id = message.sender_id;
22426
+ }
22427
+ if (message.avatar !== "") {
22428
+ obj.avatar = message.avatar;
22429
+ }
22430
+ if (message.clan_id !== "") {
22431
+ obj.clan_id = message.clan_id;
22432
+ }
22433
+ if (message.attachment_link !== "") {
22434
+ obj.attachment_link = message.attachment_link;
22435
+ }
22436
+ if (message.display_name !== "") {
22437
+ obj.display_name = message.display_name;
22438
+ }
22439
+ if (message.create_time_seconds !== 0) {
22440
+ obj.create_time_seconds = Math.round(message.create_time_seconds);
22441
+ }
22442
+ if (message.update_time_seconds !== 0) {
22443
+ obj.update_time_seconds = Math.round(message.update_time_seconds);
22444
+ }
22445
+ if (message.username !== "") {
22446
+ obj.username = message.username;
22447
+ }
22448
+ if ((_a = message.mention_ids) == null ? void 0 : _a.length) {
22449
+ obj.mention_ids = message.mention_ids;
22450
+ }
22451
+ if ((_b = message.position_s) == null ? void 0 : _b.length) {
22452
+ obj.position_s = message.position_s.map((e) => Math.round(e));
22453
+ }
22454
+ if ((_c = message.position_e) == null ? void 0 : _c.length) {
22455
+ obj.position_e = message.position_e.map((e) => Math.round(e));
22456
+ }
22457
+ if (message.attachment_type !== "") {
22458
+ obj.attachment_type = message.attachment_type;
22459
+ }
22460
+ if (message.has_more_attachment !== false) {
22461
+ obj.has_more_attachment = message.has_more_attachment;
22462
+ }
22463
+ return obj;
22464
+ },
22465
+ create(base) {
22466
+ return DirectFcmProto.fromPartial(base != null ? base : {});
22467
+ },
22468
+ fromPartial(object) {
22469
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
22470
+ const message = createBaseDirectFcmProto();
22471
+ message.title = (_a = object.title) != null ? _a : "";
22472
+ message.link = (_b = object.link) != null ? _b : "";
22473
+ message.content = (_c = object.content) != null ? _c : "";
22474
+ message.channel_id = (_d = object.channel_id) != null ? _d : "";
22475
+ message.sender_id = (_e = object.sender_id) != null ? _e : "";
22476
+ message.avatar = (_f = object.avatar) != null ? _f : "";
22477
+ message.clan_id = (_g = object.clan_id) != null ? _g : "";
22478
+ message.attachment_link = (_h = object.attachment_link) != null ? _h : "";
22479
+ message.display_name = (_i = object.display_name) != null ? _i : "";
22480
+ message.create_time_seconds = (_j = object.create_time_seconds) != null ? _j : 0;
22481
+ message.update_time_seconds = (_k = object.update_time_seconds) != null ? _k : 0;
22482
+ message.username = (_l = object.username) != null ? _l : "";
22483
+ message.mention_ids = ((_m = object.mention_ids) == null ? void 0 : _m.map((e) => e)) || [];
22484
+ message.position_s = ((_n = object.position_s) == null ? void 0 : _n.map((e) => e)) || [];
22485
+ message.position_e = ((_o = object.position_e) == null ? void 0 : _o.map((e) => e)) || [];
22486
+ message.attachment_type = (_p = object.attachment_type) != null ? _p : "";
22487
+ message.has_more_attachment = (_q = object.has_more_attachment) != null ? _q : false;
22488
+ return message;
22489
+ }
22490
+ };
22177
22491
  function createBaseMessageMentionList() {
22178
22492
  return { mentions: [] };
22179
22493
  }
@@ -34638,15 +34952,9 @@ function decodeReactions(data) {
34638
34952
  function decodeNotificationFcm(data) {
34639
34953
  const buffer = data;
34640
34954
  const uintBuffer = new Uint8Array(buffer);
34641
- const noti = Notification.decode(uintBuffer);
34955
+ const noti = DirectFcmProto.decode(uintBuffer);
34642
34956
  return noti;
34643
34957
  }
34644
- function decodeNotificationContent(data) {
34645
- const uint8Array = new Uint8Array(data);
34646
- const decoder = new TextDecoder("utf-8");
34647
- const notiContent = decoder.decode(uint8Array);
34648
- return notiContent;
34649
- }
34650
34958
 
34651
34959
  // socket.ts
34652
34960
  function createChannelMessageFromEvent(message) {
@@ -35674,19 +35982,19 @@ var _DefaultSocket = class _DefaultSocket {
35674
35982
  const response = yield this.send({
35675
35983
  message_reaction_event: {
35676
35984
  id,
35677
- clanId,
35678
- channelId,
35985
+ clan_id: clanId,
35986
+ channel_id: channelId,
35679
35987
  mode,
35680
- isPublic,
35681
- messageId,
35682
- emojiId,
35988
+ is_public: isPublic,
35989
+ message_id: messageId,
35990
+ emoji_id: emojiId,
35683
35991
  emoji,
35684
35992
  count,
35685
- messageSenderId,
35993
+ message_sender_id: messageSenderId,
35686
35994
  action: action_delete,
35687
- topicId,
35688
- emojiRecentId,
35689
- senderName
35995
+ topic_id: topicId,
35996
+ emoji_recent_id: emojiRecentId,
35997
+ sender_name: senderName
35690
35998
  }
35691
35999
  });
35692
36000
  return mapToCamelCase(response.message_reaction_event);
@@ -36592,7 +36900,12 @@ var Client = class {
36592
36900
  this.useSSL = useSSL;
36593
36901
  const scheme = useSSL ? "https://" : "http://";
36594
36902
  const basePath = `${scheme}${host}:${port}`;
36595
- return this.gatewayClient.setBasePath(basePath);
36903
+ this.gatewayClient.setBasePath(basePath);
36904
+ this.grpcTransport = createGrpcWebTransport({
36905
+ baseUrl: basePath,
36906
+ useBinaryFormat: true
36907
+ });
36908
+ this.mezonClient = createClient(Mezon, this.grpcTransport);
36596
36909
  }
36597
36910
  //#region Mezon Gateway APIs
36598
36911
  /** Authenticate a user with a custom id against the server. */
@@ -37831,7 +38144,7 @@ var Client = class {
37831
38144
  notificationList.notifications.forEach((n) => {
37832
38145
  var content;
37833
38146
  try {
37834
- content = decodeNotificationContent(n.content) || safeJSONParse(n.content || "{}");
38147
+ content = decodeNotificationFcm(n.content) || safeJSONParse(n.content || "{}");
37835
38148
  } catch (e) {
37836
38149
  console.log("error parse content", e);
37837
38150
  }