podchat-browser 12.9.16 → 12.9.17-snapshot.0

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.
@@ -1 +1 @@
1
- {"version":"12.9.16","date":"۱۴۰۳/۱۰/۱۸","VersionInfo":"Release: true, Snapshot: false, Is For Test: false"}
1
+ {"version":"12.9.17-snapshot.0","date":"۱۴۰۳/۱۰/۲۴","VersionInfo":"Release: false, Snapshot: true, Is For Test: true"}
@@ -35,6 +35,8 @@ var _callServerManager = _interopRequireDefault(require("./lib/call/callServerMa
35
35
 
36
36
  var _inquiryCallParticipants = _interopRequireDefault(require("./lib/chat/call/inquiryCallParticipants"));
37
37
 
38
+ var _adminMethods = _interopRequireDefault(require("./lib/chat/call/adminMethods"));
39
+
38
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
39
41
 
40
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -51,6 +53,7 @@ function ChatCall(app, params) {
51
53
  var inquiryCallModule = new _inquiryCallParticipants["default"](app);
52
54
  app.call.inquiryCallParticipants = inquiryCallModule;
53
55
  app.call.deviceManager = new _deviceManager.DeviceManager(app);
56
+ app.call.adminMethods = new _adminMethods["default"](app);
54
57
  var callServerController = new _callServerManager["default"](app);
55
58
  var //Utility = params.Utility,
56
59
  currentModuleInstance = this,
@@ -73,15 +76,15 @@ function ChatCall(app, params) {
73
76
  }
74
77
  },
75
78
  // generalTypeCode = params.typeCode,
76
- currentCallParams = {},
77
- latestCallRequestId = null,
79
+ // currentCallParams = {},
80
+ latestCallRequestId = null,
78
81
  screenShareInfo = new screenShareStateManager(app),
79
82
  //shouldReconnectCallTimeout = null,
80
- screenShareState = {
81
- started: false,
82
- imOwner: false
83
- },
84
- callUsers = {},
83
+ // screenShareState = {
84
+ // started: false,
85
+ // imOwner: false
86
+ // },
87
+ callUsers = {},
85
88
  //callServerManager(),
86
89
  //callTopicHealthChecker = new peersHealthChecker(),
87
90
  //messageTtl = params.messageTtl || 10000,
@@ -297,7 +300,9 @@ function ChatCall(app, params) {
297
300
  callStatus: messageContent.callStatus,
298
301
  createTime: messageContent.createTime,
299
302
  sendKey: messageContent.sendKey,
300
- mute: messageContent.mute
303
+ mute: messageContent.mute,
304
+ video: messageContent.video,
305
+ raiseHand: messageContent.raiseHand
301
306
  }; // Add Chat Participant if exist
302
307
 
303
308
  if (messageContent.participantVO) {
@@ -1166,6 +1171,30 @@ function ChatCall(app, params) {
1166
1171
  uniqueId: uniqueId
1167
1172
  });
1168
1173
  break;
1174
+
1175
+ /**
1176
+ * Type 260 Switch call to restricted mode
1177
+ */
1178
+
1179
+ case _constants.chatMessageVOTypes.BAN_CALL_SESSION:
1180
+ app.adminMethods.onLimitCallActions(uniqueId, messageContent, contentCount, chatMessage, threadId);
1181
+ break;
1182
+
1183
+ /**
1184
+ * Type 261 Add permission to call participant
1185
+ */
1186
+
1187
+ case _constants.chatMessageVOTypes.SET_PERMISSION_TO_CALL_PARTICIPANT:
1188
+ app.adminMethods.onAddCallParticipantsPermission(uniqueId, messageContent, contentCount, chatMessage, threadId);
1189
+ break;
1190
+
1191
+ /**
1192
+ * Type 262 Remove permission from call participant
1193
+ */
1194
+
1195
+ case _constants.chatMessageVOTypes.REMOVE_PERMISSION_FROM_CALL_PARTICIPANT:
1196
+ app.adminMethods.onRemoveCallParticipantsPermission(uniqueId, messageContent, contentCount, chatMessage, threadId);
1197
+ break;
1169
1198
  }
1170
1199
  };
1171
1200
 
@@ -2908,6 +2937,18 @@ function ChatCall(app, params) {
2908
2937
  } // currentCall().users().get(callUserId)[mediaType + 'TopicManager']().stopStatusPrint();
2909
2938
 
2910
2939
  };
2940
+
2941
+ this.limitCallActions = function (params) {
2942
+ app.call.adminMethods.limitCallActions(params);
2943
+ };
2944
+
2945
+ this.addCAllParticipantsPermission = function (params) {
2946
+ app.call.adminMethods.addCAllParticipantsPermission(params);
2947
+ };
2948
+
2949
+ this.removeCallParticipantsPermission = function (params) {
2950
+ app.call.adminMethods.removeCallParticipantsPermission(params);
2951
+ };
2911
2952
  }
2912
2953
 
2913
2954
  var _default = ChatCall;
package/dist/node/chat.js CHANGED
@@ -79,7 +79,7 @@ function Chat(params) {
79
79
  queueSend = params.queueSend,
80
80
  queueConnectionTimeout = params.queueConnectionTimeout,
81
81
  config = {
82
- getHistoryCount: 50
82
+ getHistoryCount: 25
83
83
  },
84
84
  getUserInfoRetry = 5,
85
85
  getUserInfoRetryCount = 0,
@@ -2066,6 +2066,9 @@ function Chat(params) {
2066
2066
  case _constants.chatMessageVOTypes.CALL_RECORDING_FAILED:
2067
2067
  case _constants.chatMessageVOTypes.RAISE_HAND:
2068
2068
  case _constants.chatMessageVOTypes.LOWER_HAND:
2069
+ case _constants.chatMessageVOTypes.BAN_CALL_SESSION:
2070
+ case _constants.chatMessageVOTypes.SET_PERMISSION_TO_CALL_PARTICIPANT:
2071
+ case _constants.chatMessageVOTypes.REMOVE_PERMISSION_FROM_CALL_PARTICIPANT:
2069
2072
  callModule.handleChatMessages(chatMessage, type, messageContent, contentCount, threadId, uniqueId);
2070
2073
  break;
2071
2074
 
@@ -2995,6 +2998,10 @@ function Chat(params) {
2995
2998
  content.cellphoneNumber = params.cellphoneNumber;
2996
2999
  }
2997
3000
 
3001
+ if (typeof params.archived === 'boolean') {
3002
+ content.archived = params.archived;
3003
+ }
3004
+
2998
3005
  if (Array.isArray(params.threadIds)) {
2999
3006
  content.threadIds = params.threadIds;
3000
3007
  }
@@ -9200,8 +9207,7 @@ function Chat(params) {
9200
9207
  typeCode: params.typeCode,
9201
9208
  content: {
9202
9209
  offset: +params.offset > 0 ? +params.offset : offset,
9203
- count: +params.count > 0 ? +params.count : wantedCount //config.getHistoryCount,
9204
-
9210
+ count: +params.count > 0 ? +params.count : wantedCount
9205
9211
  },
9206
9212
  subjectId: params.threadId
9207
9213
  };
@@ -9392,6 +9398,9 @@ function Chat(params) {
9392
9398
  publicized.resetCallStream = callModule.resetCallStream;
9393
9399
  publicized.raiseHand = callModule.raiseHand;
9394
9400
  publicized.lowerHand = callModule.lowerHand;
9401
+ publicized.limitCallActions = callModule.limitCallActions;
9402
+ publicized.addCallParticipantsPermission = callModule.addCallParticipantsPermission;
9403
+ publicized.removeCAllParticipantsPermission = callModule.removeCallParticipantsPermission;
9395
9404
 
9396
9405
  publicized.getMutualGroups = function (params, callback) {
9397
9406
  var count = +params.count ? +params.count : 25,
@@ -9891,8 +9900,8 @@ function Chat(params) {
9891
9900
  publicized.stopPrintStatus = callModule.stopPrintStatus;
9892
9901
  publicized.startPrintStatus = callModule.startPrintStatus;
9893
9902
  publicized.addTypeCodeToBusiness = app.typeCodeApiMethods.addTypeCodeToBusiness;
9894
- publicized.registerTypeCodeInChat = app.typeCodeApiMethods.registerTypeCodeInChat;
9895
- publicized.registerTypeCodeInChat = app.typeCodeApiMethods.registerTypeCodeInChat;
9903
+ publicized.registerTypeCodeInChat = app.typeCodeApiMethods.registerTypeCodeInChat; // publicized.registerTypeCodeInChat = app.typeCodeApiMethods.registerTypeCodeInChat;
9904
+
9896
9905
  publicized.logger = app.logger;
9897
9906
  app.store.events.on(app.store.threads.eventsList.UNREAD_COUNT_UPDATED, function (thread) {
9898
9907
  app.chatEvents.fireEvent('threadEvents', {
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _constants = require("../../constants");
9
+
10
+ var _errorHandler = require("../../errorHandler");
11
+
12
+ function AdminMethods(app) {
13
+ var publicized = {
14
+ limitCallActions: function limitCallActions(params, callback) {
15
+ var call = app.call.currentCall();
16
+
17
+ if (!call) {
18
+ app.errorHandler.raiseError(_errorHandler.errorList.INVALID_CALLID, null, true, {});
19
+ return;
20
+ }
21
+
22
+ var sendDataContent = {};
23
+
24
+ if (params) {
25
+ if (typeof +params.callId === 'number' && params.callId > 0) {
26
+ sendDataContent.callId = +params.callId;
27
+ } else {
28
+ app.errorHandler.raiseError(_errorHandler.errorList.INVALID_CALLID, null, true, {});
29
+ return;
30
+ }
31
+ } else {
32
+ app.chatEvents.fireEvent('error', {
33
+ code: 999,
34
+ message: '[SDK] No params have been sent to resize the video call! Send an object like {width: 640, height: 480}'
35
+ });
36
+ return;
37
+ }
38
+
39
+ var sendData = {
40
+ chatMessageVOType: _constants.chatMessageVOTypes.BAN_CALL_SESSION,
41
+ typeCode: params.typeCode,
42
+ pushMsgType: 3,
43
+ subjectId: sendDataContent.callId,
44
+ token: app.sdkParams.token
45
+ };
46
+ return app.messenger.sendMessage(sendData);
47
+ },
48
+ addCallParticipantsPermission: function addCallParticipantsPermission(params, callback) {
49
+ var call = app.call.currentCall();
50
+
51
+ if (!call) {
52
+ app.errorHandler.raiseError(_errorHandler.errorList.INVALID_CALLID, null, true, {});
53
+ return;
54
+ }
55
+
56
+ var sendDataContent = {};
57
+
58
+ if (params) {
59
+ if (typeof +params.callId === 'number' && params.callId > 0) {
60
+ sendDataContent.callId = +params.callId;
61
+ } else {
62
+ app.errorHandler.raiseError(_errorHandler.errorList.INVALID_CALLID, null, true, {});
63
+ return;
64
+ }
65
+ } else {
66
+ app.chatEvents.fireEvent('error', {
67
+ code: 999,
68
+ message: '[SDK] No params have been sent to resize the video call! Send an object like {width: 640, height: 480}'
69
+ });
70
+ return;
71
+ }
72
+
73
+ var sendData = {
74
+ chatMessageVOType: _constants.chatMessageVOTypes.SET_PERMISSION_TO_CALL_PARTICIPANT,
75
+ typeCode: params.typeCode,
76
+ pushMsgType: 3,
77
+ subjectId: sendDataContent.callId,
78
+ token: app.sdkParams.token
79
+ };
80
+ return app.messenger.sendMessage(sendData, {
81
+ onResult: function onResult(result) {
82
+ callback && callback(result);
83
+ }
84
+ });
85
+ },
86
+ onLimitCallActions: function onLimitCallActions(uniqueId, messageContent, contentCount, chatMessage, threadId) {
87
+ app.chatEvents.fireEvent('callEvents', {
88
+ type: 'LIMIT_CALL_ACTIONS',
89
+ callId: threadId,
90
+ result: messageContent,
91
+ uniqueId: uniqueId
92
+ });
93
+ },
94
+ onAddCallParticipantsPermission: function onAddCallParticipantsPermission(uniqueId, messageContent, contentCount, chatMessage, threadId) {
95
+ app.chatEvents.fireEvent('callEvents', {
96
+ type: 'ADD_CALL_PARTICIPANTS_PERMISSION',
97
+ callId: threadId,
98
+ result: messageContent,
99
+ uniqueId: uniqueId
100
+ });
101
+ },
102
+ onRemoveCallParticipantsPermission: function onRemoveCallParticipantsPermission(uniqueId, messageContent, contentCount, chatMessage, threadId) {
103
+ app.chatEvents.fireEvent('callEvents', {
104
+ type: 'REMOVE_CALL_PARTICIPANTS_PERMISSION',
105
+ callId: threadId,
106
+ result: messageContent,
107
+ uniqueId: uniqueId
108
+ });
109
+ }
110
+ };
111
+ return publicized;
112
+ }
113
+
114
+ var _default = AdminMethods;
115
+ exports["default"] = _default;
@@ -312,6 +312,29 @@ function ThreadHistoryMethods(app) {
312
312
  }
313
313
 
314
314
  sendMessageParams.content.size = typeof params.size == 'number' && params.size <= 10 ? params.size : 10;
315
+ var memoryCache = false;
316
+
317
+ if (typeof params.cache === "boolean") {
318
+ memoryCache = params.cache;
319
+ }
320
+
321
+ if (memoryCache && app.store.history.canGetFromCache(params.threadId, sendMessageParams.content)) {
322
+ var retrnData = {
323
+ hasError: false,
324
+ cache: true,
325
+ errorMessage: null,
326
+ errorCode: 0
327
+ },
328
+ res = app.store.history.get(params.threadId).getRangeCacheData(sendMessageParams.content);
329
+ retrnData.result = {
330
+ history: res,
331
+ hasNext: true
332
+ };
333
+ callback && callback(retrnData);
334
+ callback = undefined;
335
+ return;
336
+ }
337
+
315
338
  return app.messenger.sendMessage(sendMessageParams, {
316
339
  onResult: function onResult(result) {
317
340
  var returnData = {
@@ -324,6 +347,11 @@ function ThreadHistoryMethods(app) {
324
347
  if (!returnData.hasError) {
325
348
  var messageContent = result.result;
326
349
  var history = (0, _dataFormatters.reformatThreadHistory)(params.threadId, messageContent);
350
+
351
+ if (memoryCache && app.store.history.isParamsValid(sendMessageParams.content)) {
352
+ app.store.history.saveList(params.threadId, sendMessageParams.content, JSON.parse(JSON.stringify(history)), true);
353
+ }
354
+
327
355
  returnData.result = {
328
356
  history: history,
329
357
  hasNext: true
@@ -335,9 +363,9 @@ function ThreadHistoryMethods(app) {
335
363
  });
336
364
  }
337
365
 
338
- function onGetHistoryByMessageIdRange(uniqueId, messageContent, contentCount, chatMessage) {
366
+ function onGetHistoryByMessageIdRange(uniqueId, threadId, messageContent, chatMessage) {
339
367
  if (app.store.messagesCallbacks[uniqueId]) {
340
- app.store.messagesCallbacks[uniqueId](_utility["default"].createReturnData(chatMessage.typeCode, chatMessage.ownerId, false, '', 0, messageContent, contentCount));
368
+ app.store.messagesCallbacks[uniqueId](_utility["default"].createReturnData(chatMessage.typeCode, chatMessage.ownerId, false, '', 0, messageContent, null));
341
369
  }
342
370
  }
343
371
 
@@ -152,6 +152,9 @@ var chatMessageVOTypes = {
152
152
  GET_HISTORY_BY_MESSAGE_ID_RANGE: 256,
153
153
  RAISE_HAND: 257,
154
154
  LOWER_HAND: 258,
155
+ BAN_CALL_SESSION: 260,
156
+ SET_PERMISSION_TO_CALL_PARTICIPANT: 261,
157
+ REMOVE_PERMISSION_FROM_CALL_PARTICIPANT: 262,
155
158
  ERROR: 999
156
159
  };
157
160
  exports.chatMessageVOTypes = chatMessageVOTypes;
@@ -80,6 +80,34 @@ function HistoryItem(threadId, params, list) {
80
80
 
81
81
  return true;
82
82
  },
83
+ getRangeCacheData: function getRangeCacheData(params) {
84
+ var resCachedData = [];
85
+ var cacheData = (0, _toConsumableArray2["default"])(config.list);
86
+ var size = params.size,
87
+ messageId = params.messageId;
88
+
89
+ if (size && messageId) {
90
+ var message = config.list.find(function (item) {
91
+ return item.id === messageId;
92
+ });
93
+
94
+ if (message.timeMiliSeconds) {
95
+ var fromTimeIndex = cacheData.findIndex(function (x) {
96
+ return x.timeMiliSeconds === message.timeMiliSeconds;
97
+ });
98
+
99
+ if (fromTimeIndex >= size) {
100
+ resCachedData = cacheData.slice(fromTimeIndex - size, fromTimeIndex + size + 1);
101
+
102
+ if (!this.checkSequence(resCachedData)) {
103
+ return [];
104
+ }
105
+ }
106
+ }
107
+ }
108
+
109
+ return resCachedData;
110
+ },
83
111
  getCacheData: function getCacheData(params) {
84
112
  var count = params.count,
85
113
  fromTime = params.fromTime,
@@ -139,6 +167,11 @@ function HistoryItem(threadId, params, list) {
139
167
  return resCachedData;
140
168
  },
141
169
  cacheHasEnoughData: function cacheHasEnoughData(params) {
170
+ // handle range history cache
171
+ if (params.size && params.messageId) {
172
+ return this.getRangeCacheData(params).length === params.size * 2 + 1;
173
+ }
174
+
142
175
  var cacheData = this.getCacheData(params);
143
176
  return cacheData.length == params.count;
144
177
  },