podchat-browser 12.2.1-snapshot.1 → 12.2.1-snapshot.2

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.
@@ -333,6 +333,18 @@
333
333
  // console.log({calls});
334
334
  // });
335
335
 
336
+ // chatAgent.getCallsToJoin({
337
+ // type: 'video', //Optional
338
+ // name: 'فرهاد', //Optional
339
+ // count: 50, //Optional
340
+ // offset: 0, //Optional,
341
+ // threadIds: [] //Optional
342
+ // }, function (calls) {
343
+ // console.log({calls});
344
+ // });
345
+
346
+
347
+
336
348
  // chatAgent.deleteFromCallList({
337
349
  // contactType: 'default',
338
350
  // callIds: [6900, 6901, 6902]
@@ -2220,6 +2232,7 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
2220
2232
  <hr>
2221
2233
  <br>
2222
2234
 
2235
+ <!--
2223
2236
  <form method="POST" action="https://sandbox.pod.ir:8043/srv/basic-platform/nzh/addContacts">
2224
2237
  <fieldset>
2225
2238
  <legend>Add Contact</legend>
@@ -2246,7 +2259,51 @@ Thread: <input type="text" id="threadInput" autocomplete="on" width="500">
2246
2259
  <button type="submit">Add Contact</button>
2247
2260
  </fieldset>
2248
2261
  </form>
2249
-
2262
+ -->
2263
+ <form method="POST" >
2264
+ <fieldset>
2265
+ <legend>Add Contact New</legend>
2266
+ <label for="firstNameAdd">firstName : </label>
2267
+ <input type="text" name="firstName" id="firstNameAdd" value="">
2268
+ <br>
2269
+ <label for="lastNameAdd">lastName : </label>
2270
+ <input type="text" name="lastName" id="lastNameAdd" value="">
2271
+ <br>
2272
+ <label for="cellphoneNumberAdd">cellphoneNumber : </label>
2273
+ <input type="text" name="cellphoneNumber" id="cellphoneNumberAdd" value="">
2274
+ <br>
2275
+ <label for="userNameAdd">username : </label>
2276
+ <input type="text" name="userName" id="userNameAdd" value="">
2277
+ <br>
2278
+ <label for="emailAdd">email : </label>
2279
+ <input type="text" name="email" id="emailAdd" value="">
2280
+ <br>
2281
+ <input type="hidden" name="_token_issuer_" value="1">
2282
+ <button id="newAddContacts" type="submit">Add Contact</button>
2283
+ </fieldset>
2284
+ </form>
2285
+ <script>
2286
+ document.getElementById("newAddContacts").addEventListener("click", function (event) {
2287
+ event.preventDefault();
2288
+ var firstName = document.getElementById("firstNameAdd");
2289
+ var lastName = document.getElementById("lastNameAdd");
2290
+ var email = document.getElementById("emailAdd");
2291
+ var cellphoneNumber = document.getElementById("cellphoneNumberAdd");
2292
+ var username = document.getElementById("userNameAdd");
2293
+
2294
+ chatAgent.newAddContacts({
2295
+ contacts: [
2296
+ {
2297
+ firstName,
2298
+ lastName,
2299
+ email,
2300
+ cellphoneNumber,
2301
+ username
2302
+ }
2303
+ ]
2304
+ });
2305
+ });
2306
+ </script>
2250
2307
 
2251
2308
  <br>
2252
2309
  <hr>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "podchat-browser",
3
- "version": "12.2.1-snapshot.1",
3
+ "version": "12.2.1-snapshot.2",
4
4
  "description": "Javascript SDK to use POD's Chat Service - Browser Only",
5
5
  "main": "./src/chat.js",
6
6
  "scripts": {
@@ -132,6 +132,7 @@
132
132
  END_SCREEN_SHARE: 124,
133
133
  DELETE_FROM_CALL_HISTORY: 125,
134
134
  DESTINATED_RECORD_CALL: 126,
135
+ GET_CALLS_TO_JOIN: 129,
135
136
  MUTUAL_GROUPS: 130,
136
137
  CREATE_TAG: 140,
137
138
  EDIT_TAG: 141,
@@ -2414,6 +2415,15 @@
2414
2415
  restartMediaOnKeyFrame("screenShare", [4000,8000,12000,25000]);
2415
2416
 
2416
2417
  break;
2418
+
2419
+ /**
2420
+ * Type 129 Get Calls To Join
2421
+ */
2422
+ case chatMessageVOTypes.GET_CALLS_TO_JOIN:
2423
+ if (chatMessaging.messagesCallbacks[uniqueId]) {
2424
+ chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount));
2425
+ }
2426
+ break;
2417
2427
  }
2418
2428
  }
2419
2429
 
@@ -2899,8 +2909,8 @@
2899
2909
  content.callIds = params.callIds;
2900
2910
  }
2901
2911
 
2902
- if (typeof params.threadId === 'string') {
2903
- content.threadId = params.threadId;
2912
+ if (typeof params.threadId === 'number' && +params.threadId > 0) {
2913
+ content.threadId = +params.threadId;
2904
2914
  }
2905
2915
 
2906
2916
  if (typeof params.contactType === 'string') {
@@ -2927,6 +2937,62 @@
2927
2937
  });
2928
2938
  };
2929
2939
 
2940
+ this.getCallsToJoin = function (params, callback) {
2941
+ var getCallListData = {
2942
+ chatMessageVOType: chatMessageVOTypes.GET_CALLS_TO_JOIN,
2943
+ pushMsgType: 3,
2944
+ token: token
2945
+ }, content = {};
2946
+
2947
+ if (params) {
2948
+ if (typeof params.count === 'number' && params.count >= 0) {
2949
+ content.count = +params.count;
2950
+ } else {
2951
+ content.count = 50;
2952
+ }
2953
+
2954
+ if (typeof params.offset === 'number' && params.offset >= 0) {
2955
+ content.offset = +params.offset;
2956
+ } else {
2957
+ content.offset = 0;
2958
+ }
2959
+
2960
+ if (typeof params.creatorSsoId === 'number' && params.creatorSsoId > 0) {
2961
+ content.creatorSsoId = +params.creatorSsoId;
2962
+ }
2963
+
2964
+ if (typeof params.name === 'string') {
2965
+ content.name = params.name;
2966
+ }
2967
+
2968
+ if (typeof params.type === 'string' && callTypes.hasOwnProperty(params.type.toUpperCase())) {
2969
+ content.type = callTypes[params.type.toUpperCase()];
2970
+ }
2971
+
2972
+ if (Array.isArray(params.threadIds)) {
2973
+ content.threadIds = params.threadIds;
2974
+ }
2975
+
2976
+ if (typeof params.uniqueId === 'string') {
2977
+ content.uniqueId = params.uniqueId;
2978
+ }
2979
+
2980
+ getCallListData.content = JSON.stringify(content);
2981
+ } else {
2982
+ chatEvents.fireEvent('error', {
2983
+ code: 999,
2984
+ message: 'Invalid params'
2985
+ });
2986
+ return;
2987
+ }
2988
+
2989
+ return chatMessaging.sendMessage(getCallListData, {
2990
+ onResult: function (result) {
2991
+ callback && callback(result);
2992
+ }
2993
+ });
2994
+ };
2995
+
2930
2996
  this.deleteFromCallList = function (params, callback) {
2931
2997
  var sendData = {
2932
2998
  chatMessageVOType: chatMessageVOTypes.DELETE_FROM_CALL_HISTORY,
package/src/chat.js CHANGED
@@ -192,6 +192,7 @@
192
192
  END_SCREEN_SHARE: 124,
193
193
  DELETE_FROM_CALL_HISTORY: 125,
194
194
  DESTINATED_RECORD_CALL: 126,
195
+ GET_CALLS_TO_JOIN: 129,
195
196
  MUTUAL_GROUPS: 130,
196
197
  CREATE_TAG: 140,
197
198
  EDIT_TAG: 141,
@@ -201,6 +202,7 @@
201
202
  GET_TAG_LIST: 145,
202
203
  DELETE_MESSAGE_THREAD: 151,
203
204
  EXPORT_CHAT: 152,
205
+ ADD_CONTACTS: 200,
204
206
  ERROR: 999
205
207
  },
206
208
  inviteeVOidTypes = {
@@ -2958,6 +2960,7 @@
2958
2960
  case chatMessageVOTypes.CALL_SESSION_CREATED:
2959
2961
  case chatMessageVOTypes.CANCEL_GROUP_CALL:
2960
2962
  case chatMessageVOTypes.DESTINATED_RECORD_CALL:
2963
+ case chatMessageVOTypes.GET_CALLS_TO_JOIN:
2961
2964
  callModule.handleChatMessages(type, chatMessageVOTypes, messageContent, contentCount, threadId, uniqueId);
2962
2965
  break;
2963
2966
 
@@ -3262,6 +3265,15 @@
3262
3265
 
3263
3266
  break;
3264
3267
 
3268
+ /**
3269
+ * Type 200 Adding a user to contacts list
3270
+ */
3271
+ case chatMessageVOTypes.ADD_CONTACTS:
3272
+ if (chatMessaging.messagesCallbacks[uniqueId]) {
3273
+ chatMessaging.messagesCallbacks[uniqueId](Utility.createReturnData(false, '', 0, messageContent, contentCount, uniqueId));
3274
+ }
3275
+ break;
3276
+
3265
3277
  /**
3266
3278
  * Type 999 All unknown errors
3267
3279
  */
@@ -12052,6 +12064,196 @@
12052
12064
  });
12053
12065
  };
12054
12066
 
12067
+ this.newAddContacts = function (params, callback) {
12068
+ var addContactsData = {
12069
+ chatMessageVOType: chatMessageVOTypes.ADD_CONTACTS,
12070
+ content: {},
12071
+ pushMsgType: 3,
12072
+ token: token,
12073
+ typeCode: generalTypeCode
12074
+ },
12075
+ AddContactVO = {},
12076
+ firstNameList = [],
12077
+ lastNameList = [],
12078
+ cellPhoneNumberList = [],
12079
+ emailList = [],
12080
+ usernameList = [],
12081
+ uniqueIdList = [];
12082
+
12083
+ if (params) {
12084
+ for(var item in params.contacts) {
12085
+ if (typeof params.contacts[item].firstName === 'string') {
12086
+ firstNameList.push(params.contacts[item].firstName);
12087
+ } else {
12088
+ firstNameList.push('');
12089
+ }
12090
+
12091
+ if (typeof params.contacts[item].lastName === 'string') {
12092
+ lastNameList.push(params.contacts[item].lastName)
12093
+ } else {
12094
+ lastNameList.push('');
12095
+ }
12096
+
12097
+ if (typeof params.contacts[item].cellphoneNumber === 'string') {
12098
+ cellPhoneNumberList.push(params.contacts[item].cellphoneNumber)
12099
+ // data.cellphoneNumber = params.cellphoneNumber;
12100
+ } else {
12101
+ cellPhoneNumberList.push('');
12102
+ // data.cellphoneNumber = '';
12103
+ }
12104
+
12105
+ if (typeof params.contacts[item].email === 'string') {
12106
+ emailList.push(params.contacts[item].email);
12107
+ // data.email = params.email;
12108
+ } else {
12109
+ emailList.push('');
12110
+ // data.email = '';
12111
+ }
12112
+
12113
+ if (typeof params.contacts[item].username === 'string') {
12114
+ usernameList.push(params.contacts[item].username);
12115
+ // data.username = params.username;
12116
+ }
12117
+
12118
+ uniqueIdList.push(Utility.generateUUID());
12119
+ // data.uniqueId = Utility.generateUUID();
12120
+ }
12121
+
12122
+ AddContactVO = {
12123
+ uniqueIdList: uniqueIdList,
12124
+ emailList: emailList,
12125
+ usernameList: usernameList,
12126
+ firstNameList: firstNameList,
12127
+ lastNameList: lastNameList
12128
+ };
12129
+ }
12130
+
12131
+ addContactsData.content = AddContactVO;
12132
+
12133
+ return chatMessaging.sendMessage(addContactsData, {
12134
+ onResult: function (result) {
12135
+ console.log(result);
12136
+ var responseData = JSON.parse(result.result.responseText);
12137
+
12138
+ var returnData = {
12139
+ hasError: responseData.hasError,
12140
+ cache: false,
12141
+ errorMessage: responseData.message,
12142
+ errorCode: responseData.errorCode
12143
+ };
12144
+
12145
+ if (typeof result.result == 'object') {
12146
+ var messageContent = responseData.result,
12147
+ messageLength = responseData.result.length,
12148
+ resultData = {
12149
+ contacts: [],
12150
+ contentCount: messageLength
12151
+ },
12152
+ contactData;
12153
+
12154
+ for (var i = 0; i < messageLength; i++) {
12155
+ contactData = formatDataToMakeContact(messageContent[i]);
12156
+ if (contactData) {
12157
+ resultData.contacts.push(contactData);
12158
+ }
12159
+ }
12160
+
12161
+ returnData.result = resultData;
12162
+
12163
+ /**
12164
+ * Add Contacts into cache database #cache
12165
+ */
12166
+ if (canUseCache && cacheSecret.length > 0) {
12167
+ if (db) {
12168
+ var cacheData = [];
12169
+
12170
+ for (var i = 0; i < resultData.contacts.length; i++) {
12171
+ try {
12172
+ var tempData = {},
12173
+ salt = Utility.generateUUID();
12174
+ tempData.id = resultData.contacts[i].id;
12175
+ tempData.owner = chatMessaging.userInfo.id;
12176
+ tempData.uniqueId = resultData.contacts[i].uniqueId;
12177
+ tempData.userId = Utility.crypt(resultData.contacts[i].userId, cacheSecret, salt);
12178
+ tempData.cellphoneNumber = Utility.crypt(resultData.contacts[i].cellphoneNumber, cacheSecret, salt);
12179
+ tempData.email = Utility.crypt(resultData.contacts[i].email, cacheSecret, salt);
12180
+ tempData.firstName = Utility.crypt(resultData.contacts[i].firstName, cacheSecret, salt);
12181
+ tempData.lastName = Utility.crypt(resultData.contacts[i].lastName, cacheSecret, salt);
12182
+ tempData.expireTime = new Date().getTime() + cacheExpireTime;
12183
+ tempData.data = Utility.crypt(JSON.stringify(unsetNotSeenDuration(resultData.contacts[i])), cacheSecret, salt);
12184
+ tempData.salt = salt;
12185
+
12186
+ cacheData.push(tempData);
12187
+ } catch (error) {
12188
+ chatEvents.fireEvent('error', {
12189
+ code: error.code,
12190
+ message: error.message,
12191
+ error: error
12192
+ });
12193
+ }
12194
+ }
12195
+
12196
+ db.contacts.bulkPut(cacheData)
12197
+ .catch(function (error) {
12198
+ chatEvents.fireEvent('error', {
12199
+ code: error.code,
12200
+ message: error.message,
12201
+ error: error
12202
+ });
12203
+ });
12204
+ } else {
12205
+ chatEvents.fireEvent('error', {
12206
+ code: 6601,
12207
+ message: CHAT_ERRORS[6601],
12208
+ error: null
12209
+ });
12210
+ }
12211
+ }
12212
+
12213
+ // }
12214
+ callback && callback(returnData);
12215
+ }
12216
+ //callback && callback(result);
12217
+ }
12218
+ });
12219
+
12220
+ /* var requestParams = {
12221
+ url: SERVICE_ADDRESSES.PLATFORM_ADDRESS + SERVICES_PATH.ADD_CONTACTS,
12222
+ method: 'POST',
12223
+ data: data,
12224
+ headers: {
12225
+ '_token_': token,
12226
+ '_token_issuer_': 1
12227
+ }
12228
+ }; */
12229
+
12230
+ /*httpRequest(requestParams, function (result) {
12231
+ if (!result.hasError) {
12232
+ var responseData = JSON.parse(result.result.responseText);
12233
+
12234
+ var returnData = {
12235
+ hasError: responseData.hasError,
12236
+ cache: false,
12237
+ errorMessage: responseData.message,
12238
+ errorCode: responseData.errorCode
12239
+ };
12240
+
12241
+ if (!responseData.hasError) {*/
12242
+
12243
+
12244
+
12245
+
12246
+ //} else {
12247
+ /* chatEvents.fireEvent('error', {
12248
+ code: result.errorCode,
12249
+ message: result.errorMessage,
12250
+ error: result
12251
+ });
12252
+ */
12253
+ //}
12254
+ //});
12255
+ };
12256
+
12055
12257
  this.updateContacts = function (params, callback) {
12056
12258
  var data = {};
12057
12259
 
@@ -13721,6 +13923,8 @@
13721
13923
 
13722
13924
  this.getCallsList = callModule.getCallsList;
13723
13925
 
13926
+ this.getCallsToJoin = callModule.getCallsToJoin;
13927
+
13724
13928
  this.deleteFromCallList = callModule.deleteFromCallList;
13725
13929
 
13726
13930
  this.getCallParticipants = callModule.getCallParticipants;