podchat-browser 11.3.4 → 11.4.3

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/src/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ 'use strict';
2
2
 
3
3
  (function () {
4
4
  /*
@@ -13535,25 +13535,22 @@
13535
13535
 
13536
13536
  if(stackArr.length < wantedCount) {
13537
13537
  stepCount = wantedCount - stackArr.length < stepCount ? wantedCount - stackArr.length : stepCount;
13538
+ //setTimeout(function () {
13538
13539
  resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData));
13540
+ //}, 1000)
13539
13541
  } else {
13540
13542
  resolve(stackArr);
13541
13543
  }
13542
13544
  });
13543
- /*returnData.result = result;*/
13544
- /*var messageContent = result.result,
13545
- messageLength = messageContent.length,
13546
- resultData = {
13547
- participants: formatDataToMakeAssistantHistoryList(messageContent),
13548
- contentCount: result.contentCount,
13549
- hasNext: (sendData.content.offset + sendData.content.count < result.contentCount && messageLength > 0),
13550
- nextOffset: sendData.content.offset * 1 + messageLength * 1
13551
- };
13552
-
13553
- returnData.result = resultData;*/
13554
13545
  } else {
13555
- consoleLogging && console.log("[SDK][exportChat] Problem in one step... . Rerunning the request.", wantedCount, stepCount, stackArr.length, sendData, result);
13556
- resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData))
13546
+ if(result.errorCode !== 21) {
13547
+ consoleLogging && console.log("[SDK][exportChat] Problem in one step... . Rerunning the request.", wantedCount, stepCount, stackArr.length, sendData, result);
13548
+ setTimeout(function () {
13549
+ resolve(requestExportChat(stackArr, wantedCount, stepCount, stackArr.length, sendData))
13550
+ }, 2000)
13551
+ } else {
13552
+ reject(result)
13553
+ }
13557
13554
  }
13558
13555
  }
13559
13556
  });
@@ -13592,9 +13589,10 @@
13592
13589
  offset = params.offset;
13593
13590
  }
13594
13591
 
13595
- if (params.messageType && typeof params.messageType.toUpperCase() !== 'undefined' && chatMessageTypes[params.messageType.toUpperCase()] > 0) {
13596
- sendData.content.messageType = chatMessageTypes[params.messageType.toUpperCase()];
13597
- }
13592
+ // if (params.messageType && typeof params.messageType.toUpperCase() !== 'undefined' && chatMessageTypes[params.messageType.toUpperCase()] > 0) {
13593
+ // sendData.content.messageType = chatMessageTypes[params.messageType.toUpperCase()];
13594
+ // }
13595
+ sendData.content.messageType = 1;
13598
13596
 
13599
13597
  if(wantedCount < stepCount)
13600
13598
  stepCount = wantedCount;
@@ -13607,7 +13605,47 @@
13607
13605
  responseType = params.responseType !== null ? params.responseType : "blob",
13608
13606
  autoStartDownload = params.autoStartDownload !== null ? params.autoStartDownload : true
13609
13607
 
13610
- var blob = new Blob([Utility.convertToCSV(result)], { type: 'text/csv;charset=utf-8;' });
13608
+ var str = ''
13609
+ , universalBOM = "\uFEFF";
13610
+
13611
+ console.log(result);
13612
+ str += "تاریخ " + ',';
13613
+ str += " ساعت " + ',';
13614
+ str += "نام فرستنده" + ',';
13615
+ str += "نام کاربری فرستنده" + ',';
13616
+ str += "متن پیام" + ',';
13617
+ str += '\r\n';
13618
+ var line = '', radif = 1;
13619
+ for (var i = 0; i < result.length; i++) {
13620
+ line = '';
13621
+
13622
+ if(result[i].messageType !== 1) {
13623
+ continue;
13624
+ }
13625
+
13626
+ var sender = '';
13627
+ if(result[i].participant.contactName) {
13628
+ sender = result[i].participant.contactName + ',';
13629
+ } else {
13630
+ if(result[i].participant.firstName) {
13631
+ sender = result[i].participant.firstName + ' ';
13632
+ }
13633
+ if(result[i].participant.lastName) {
13634
+ sender += result[i].participant.lastName;
13635
+ }
13636
+ sender += ','
13637
+ }
13638
+
13639
+ line += new Date(result[i].time).toLocaleDateString('fa-IR') + ',';
13640
+ line += new Date(result[i].time).toLocaleTimeString('fa-IR') + ',';
13641
+ line += sender;
13642
+ line += result[i].participant.username + ',';
13643
+ line += result[i].message.replaceAll(",", ".").replace(/(\r\n|\n|\r)/gm, " ") + ',';
13644
+
13645
+ str += line + '\r\n';
13646
+ radif++;
13647
+ }
13648
+ var blob = new Blob([str], { type: 'text/csv;charset=utf-8;' });
13611
13649
  chatEvents.fireEvent('threadEvents', {
13612
13650
  type: 'EXPORT_CHAT',
13613
13651
  subType: 'DONE',
@@ -13630,7 +13668,7 @@
13630
13668
  url = URL.createObjectURL(blob);
13631
13669
  //if (link.download !== undefined) { // feature detection
13632
13670
  // Browsers that support HTML5 download attribute
13633
- link.setAttribute("href", url);
13671
+ link.setAttribute("href", 'data:text/csv; charset=utf-8,' + encodeURIComponent(universalBOM + str));
13634
13672
  link.setAttribute("download", exportedFilename);
13635
13673
  if(autoStartDownload) {
13636
13674
  link.style.visibility = 'hidden';
@@ -13653,7 +13691,9 @@
13653
13691
  }
13654
13692
  //}
13655
13693
  callback = undefined;
13656
- });
13694
+ })/*.catch(function (result) {
13695
+ consoleLogging && console.log(result);
13696
+ });*/
13657
13697
  }
13658
13698
 
13659
13699
  this.startCall = callModule.startCall;