Built motion from commit 6a09e18b.|2.6.11
[motion2.git] / server / api / chatInteraction / chatInteraction.controller.js
index 96ee80b..20d75a3 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xc49c=['where','i.ChatWebsiteId\x20IN\x20?','concat','createdAt','parse','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20=\x200','tag','isArray','filter','replace','isNumeric','i.id\x20LIKE\x20?','MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','group','Sequelize','QueryTypes','SELECT','clone','i.id','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','unreadMessages','contactName','DESC','i.ChatWebsiteId\x20IS\x20NOT\x20NULL','user','getChatWebsites','i.ChatWebsiteId\x20IS\x20NULL','role','agent','sequelize','toString','keyBy','merge','a.key','a.mandatoryDisposition','Account.mandatoryDisposition','CASE\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','i.*','Contact.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','ui.ChatInteractionId\x20IN\x20?','groupBy','all','rows','show','includeAll','include','options','create','body','params','describe','createVidaooSession','ChatWebsite','findOne','vidaooApiKey','vidaooEscalation','POST','MotionCWB:','follow','ValidationError','Error\x20in\x20Vidaoo\x20configuration','join_url','out','ChatMessage','Unable\x20to\x20create\x20Vidaoo\x20session','customUpdate','abandon','abandonInteraction,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','Interaction\x20already\x20assigned','closed','disposition','attachmentUpload','file','originalname','basename','filename','Attachment','Unauthorized','attachId','download','join','server/files/attachments/','root','format','transcript-%s.txt','now','pathTranscript','Messages','CmContact','agentAlias','System','customer','%s%d','Visitor','agentIdentifier','website_alias','agent_fullname','[%s]\x20%s:\x20%s\x0a','MM/DD/YYYY\x20HH:mm:ss','direction','secret','MailAccount','MailServerOut','Smtp','service','host','port','secure','authentication','auth','pass','SendMail','\x22%s\x22\x20<%s>','mailTranscript','Mail\x20Transcript','Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a','addMessage','ids','omit','nolimit','ChatInteractionId','$gte','YYYY-MM-DD\x20HH:mm:ss','findAll','getMyMessages','alias','addTags','setTags','Tag','emit','removeTags','unix','files','tmp','server','attachments','transcript-%d-%s.zip','firstName','Account','Owner','get','mkdirSync','10px','40px','30px','<hr\x20class=\x22separator\x22/>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22footer\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22left\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>%s</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22center\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>{{page}}/{{pages}}</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22right\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>%s</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>','%s\x20#%d','Chat','YYYY-MM-DD','N.A.','osName','referer','customerIp','tail','existsSync','pipe','createWriteStream','lastName','renderFile','views','downloadInteraction.html','transcript-','.pdf','log','err','unlinkSync','html-pdf','moment','bluebird','mustache','path','ejs','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','jayson/promise','client','http','request','ChatInteraction,\x20%s,\x20%s','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','message','result','sendStatus','status','end','json','count','offset','limit','set','apply','reject','update','then','destroy','stack','name','send','Users','fullname','TagIds','Tags','split','forEach','push','catch','ChatInteraction','rawAttributes','type','map','keys','filters','intersection','model','query','attributes','fields','length','hasOwnProperty','order','sort','pick','field','color','from','tools_tags','select','u.fullname','ui.ChatInteractionId','user_has_chat_interactions','users','u.id\x20=\x20ui.UserId','chat_interactions','left_join','o.id\x20=\x20i.UserId','a.id\x20=\x20i.ChatWebsiteId','chat_messages','me.ChatInteractionId\x20=\x20i.id','chat_interaction_has_tags','it.ChatInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','find','value','having','`\x20=\x200','`\x20>\x200','Contact','operator','$substring','getFullTextValue','ContactId','buildExpression','text','start','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','User','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','some','compact','isEmpty','ChatWebsiteId'];(function(_0x3af069,_0x397260){var _0x4f82db=function(_0x26e13f){while(--_0x26e13f){_0x3af069['push'](_0x3af069['shift']());}};_0x4f82db(++_0x397260);}(_0xc49c,0xb5));var _0xcc49=function(_0x392ab8,_0x4c5858){_0x392ab8=_0x392ab8-0x0;var _0x3d86d9=_0xc49c[_0x392ab8];return _0x3d86d9;};'use strict';var pdf=require(_0xcc49('0x0'));var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xcc49('0x1'));var BPromise=require(_0xcc49('0x2'));var Mustache=require(_0xcc49('0x3'));var util=require('util');var path=require(_0xcc49('0x4'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xcc49('0x5'));var fs=require('fs');var _=require('lodash');var squel=require(_0xcc49('0x6'));var crypto=require('crypto');var jsforce=require(_0xcc49('0x7'));var deskjs=require(_0xcc49('0x8'));var toCsv=require(_0xcc49('0x9'));var querystring=require(_0xcc49('0xa'));var Papa=require(_0xcc49('0xb'));var Redis=require(_0xcc49('0xc'));var authService=require(_0xcc49('0xd'));var qs=require(_0xcc49('0xe'));var as=require(_0xcc49('0xf'));var hardwareService=require(_0xcc49('0x10'));var logger=require(_0xcc49('0x11'))(_0xcc49('0x12'));var utils=require(_0xcc49('0x13'));var config=require(_0xcc49('0x14'));var licenseUtil=require(_0xcc49('0x15'));var db=require(_0xcc49('0x16'))['db'];config['redis']=_['defaults'](config[_0xcc49('0x17')],{'host':_0xcc49('0x18'),'port':0x18eb});var socket=require(_0xcc49('0x19'))(new Redis(config[_0xcc49('0x17')]));require('./chatInteraction.socket')['register'](socket);var jayson=require(_0xcc49('0x1a'));var client=jayson[_0xcc49('0x1b')]['http']({'port':0x232b});var client9004=jayson[_0xcc49('0x1b')][_0xcc49('0x1c')]({'port':0x232c});function respondWithRpcPromise(_0x2ba18b,_0x3b9b14,_0x49de27,_0x5d3799){return new BPromise(function(_0x7cb23,_0xa82e6b){var _0x50cf7d=_0x5d3799||client;return _0x50cf7d[_0xcc49('0x1d')](_0x2ba18b,_0x49de27)['then'](function(_0x50edcf){logger['info'](_0xcc49('0x1e'),_0x3b9b14,'request\x20sent');logger[_0xcc49('0x1f')](_0xcc49('0x20'),_0x3b9b14,_0xcc49('0x21'),JSON[_0xcc49('0x22')](_0x50edcf));if(_0x50edcf[_0xcc49('0x23')]){if(_0x50edcf[_0xcc49('0x23')][_0xcc49('0x24')]===0x1f4){logger[_0xcc49('0x23')](_0xcc49('0x1e'),_0x3b9b14,_0x50edcf[_0xcc49('0x23')]['message']);return _0xa82e6b(_0x50edcf[_0xcc49('0x23')][_0xcc49('0x25')]);}logger[_0xcc49('0x23')](_0xcc49('0x1e'),_0x3b9b14,_0x50edcf[_0xcc49('0x23')][_0xcc49('0x25')]);return _0x7cb23(_0x50edcf[_0xcc49('0x23')][_0xcc49('0x25')]);}else{logger['info'](_0xcc49('0x1e'),_0x3b9b14,'request\x20sent');_0x7cb23(_0x50edcf[_0xcc49('0x26')]['message']);}})['catch'](function(_0xbfa35d){logger[_0xcc49('0x23')](_0xcc49('0x1e'),_0x3b9b14,_0xbfa35d);_0xa82e6b(_0xbfa35d);});});}function respondWithStatusCode(_0x285d5b,_0x31ea78){_0x31ea78=_0x31ea78||0xcc;return function(_0x12037b){if(_0x12037b){return _0x285d5b[_0xcc49('0x27')](_0x31ea78);}return _0x285d5b[_0xcc49('0x28')](_0x31ea78)[_0xcc49('0x29')]();};}function respondWithResult(_0xd72626,_0x572eeb){_0x572eeb=_0x572eeb||0xc8;return function(_0x2a6aac){if(_0x2a6aac){return _0xd72626[_0xcc49('0x28')](_0x572eeb)[_0xcc49('0x2a')](_0x2a6aac);}};}function respondWithFilteredResult(_0x2bd2a0,_0x2630b5){return function(_0x38e821){if(_0x38e821){var _0x36d257=_0x38e821[_0xcc49('0x2b')],_0x284c42=_0x2630b5['offset'],_0x2e27ee=_0x2630b5[_0xcc49('0x2c')]+_0x2630b5[_0xcc49('0x2d')],_0x3971d3;if(_0x2e27ee>=_0x36d257){_0x2e27ee=_0x36d257;_0x3971d3=0xc8;}else{_0x3971d3=0xce;}_0x2bd2a0[_0xcc49('0x28')](_0x3971d3);return _0x2bd2a0[_0xcc49('0x2e')]('Content-Range',_0x284c42+'-'+_0x2e27ee+'/'+_0x36d257)[_0xcc49('0x2a')](_0x38e821);}return null;};}function patchUpdates(_0x3bd6f8){return function(_0x4be9a7){try{jsonpatch[_0xcc49('0x2f')](_0x4be9a7,_0x3bd6f8,!![]);}catch(_0x710027){return BPromise[_0xcc49('0x30')](_0x710027);}return _0x4be9a7['save']();};}function saveUpdates(_0x3a3782,_0x30073b){return function(_0x152113){if(_0x152113){return _0x152113[_0xcc49('0x31')](_0x3a3782)[_0xcc49('0x32')](function(_0x878693){return _0x878693;});}return null;};}function removeEntity(_0x2cf5ce,_0x1b21c2){return function(_0x1cc579){if(_0x1cc579){return _0x1cc579[_0xcc49('0x33')]()[_0xcc49('0x32')](function(){_0x2cf5ce[_0xcc49('0x28')](0xcc)[_0xcc49('0x29')]();});}};}function handleEntityNotFound(_0x31a40c,_0x2aaa5d){return function(_0x40eeaa){if(!_0x40eeaa){_0x31a40c[_0xcc49('0x27')](0x194);}return _0x40eeaa;};}function handleError(_0x50e186,_0x51e928){_0x51e928=_0x51e928||0x1f4;return function(_0x1b0bc4){logger[_0xcc49('0x23')](_0x1b0bc4[_0xcc49('0x34')]);if(_0x1b0bc4[_0xcc49('0x35')]){delete _0x1b0bc4[_0xcc49('0x35')];}_0x50e186[_0xcc49('0x28')](_0x51e928)[_0xcc49('0x36')](_0x1b0bc4);};}function getInteractionUsers(_0x5b15b4,_0x4f6f41){return new BPromise(function(_0x3a8796,_0xc09de4){try{if(_0x4f6f41[_0x5b15b4['id']]){_0x5b15b4[_0xcc49('0x37')]=_['map'](_0x4f6f41[_0x5b15b4['id']],function(_0x3b9977){return{'id':_0x3b9977['id'],'fullname':_0x3b9977[_0xcc49('0x38')]};});}}catch(_0x584cd2){_0xc09de4(_0x584cd2);}_0x3a8796(_0x5b15b4);});}function getInteractionTags(_0x1b01fa,_0x1d46a){return new BPromise(function(_0x5f4c4d,_0x257752){try{if(_0x1b01fa[_0xcc49('0x39')]){_0x1b01fa[_0xcc49('0x3a')]=[];_0x1b01fa[_0xcc49('0x39')][_0xcc49('0x3b')](',')[_0xcc49('0x3c')](function(_0x4b0937){_0x1b01fa[_0xcc49('0x3a')][_0xcc49('0x3d')](_0x1d46a[_0x4b0937]);});}delete _0x1b01fa[_0xcc49('0x39')];}catch(_0x1075d1){_0x257752(_0x1075d1);}_0x5f4c4d(_0x1b01fa);});}function updateChatInteraction(_0x182e54,_0x65409f,_0x588875){return new BPromise(function(_0x435f77,_0x5c41e9){return getInteractionUsers(_0x182e54,_0x588875)[_0xcc49('0x32')](function(_0x55d87d){return getInteractionTags(_0x55d87d,_0x65409f);})['then'](function(_0xee2056){_0x435f77(_0xee2056);})[_0xcc49('0x3e')](function(_0x1ed879){_0x5c41e9(_0x1ed879);});});}exports['index']=function(_0x59babc,_0x591823){var _0x130062={},_0x1ff3c4={},_0x544424={'count':0x0,'rows':[]};var _0x1208e2=_['map'](db[_0xcc49('0x3f')][_0xcc49('0x40')],function(_0x40d6d9){return{'name':_0x40d6d9['fieldName'],'type':_0x40d6d9[_0xcc49('0x41')]['key']};});_0x1ff3c4['model']=_[_0xcc49('0x42')](_0x1208e2,'name');_0x1ff3c4['query']=_[_0xcc49('0x43')](_0x59babc['query']);_0x1ff3c4[_0xcc49('0x44')]=_[_0xcc49('0x45')](_0x1ff3c4[_0xcc49('0x46')],_0x1ff3c4[_0xcc49('0x47')]);_0x130062[_0xcc49('0x48')]=_[_0xcc49('0x45')](_0x1ff3c4[_0xcc49('0x46')],qs[_0xcc49('0x49')](_0x59babc['query'][_0xcc49('0x49')]));_0x130062[_0xcc49('0x48')]=_0x130062[_0xcc49('0x48')][_0xcc49('0x4a')]?_0x130062[_0xcc49('0x48')]:_0x1ff3c4[_0xcc49('0x46')];if(!_0x59babc[_0xcc49('0x47')][_0xcc49('0x4b')]('nolimit')){_0x130062['limit']=qs[_0xcc49('0x2d')](_0x59babc[_0xcc49('0x47')][_0xcc49('0x2d')]);_0x130062[_0xcc49('0x2c')]=qs[_0xcc49('0x2c')](_0x59babc[_0xcc49('0x47')][_0xcc49('0x2c')]);}_0x130062[_0xcc49('0x4c')]=qs[_0xcc49('0x4d')](_0x59babc['query'][_0xcc49('0x4d')]);_0x130062['where']=qs[_0xcc49('0x44')](_[_0xcc49('0x4e')](_0x59babc['query'],_0x1ff3c4[_0xcc49('0x44')]),_0x1208e2);var _0x12b7e4=[];var _0x4d8314=squel['select']()['field']('id')[_0xcc49('0x4f')](_0xcc49('0x35'))['field'](_0xcc49('0x50'))[_0xcc49('0x51')](_0xcc49('0x52'));var _0x1f9aae=squel[_0xcc49('0x53')]()[_0xcc49('0x4f')]('u.id')['field'](_0xcc49('0x54'))['field'](_0xcc49('0x55'))[_0xcc49('0x51')](_0xcc49('0x56'),'ui')['left_join'](_0xcc49('0x57'),'u',_0xcc49('0x58'));var _0x48485d=squel[_0xcc49('0x53')]()['from'](_0xcc49('0x59'),'i')['left_join']('cm_contacts','c','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL')[_0xcc49('0x5a')](_0xcc49('0x57'),'o',_0xcc49('0x5b'))[_0xcc49('0x5a')]('chat_websites','a',_0xcc49('0x5c'))[_0xcc49('0x5a')](_0xcc49('0x5d'),'me',_0xcc49('0x5e'))[_0xcc49('0x5a')](_0xcc49('0x5f'),'it',_0xcc49('0x60'))[_0xcc49('0x5a')]('tools_tags','t',_0xcc49('0x61'));var _0xb776cd=squel[_0xcc49('0x62')]();var _0x4fe360=[];var _0x24a3ad=squel[_0xcc49('0x62')]();var _0x559c63;if(_0x59babc[_0xcc49('0x47')][_0xcc49('0x63')]){_0x559c63=as[_0xcc49('0x64')](_0x59babc[_0xcc49('0x47')][_0xcc49('0x63')]);var _0x5d8a6c=_0x559c63[_0xcc49('0x65')];for(var _0x1129e7=0x0;_0x1129e7<_0x559c63[_0xcc49('0x66')]['length'];_0x1129e7++){var _0x279952=_0x559c63[_0xcc49('0x66')][_0x1129e7];var _0x2c9e8b='i';var _0x1b156d=_[_0xcc49('0x67')](_0x1208e2,[_0xcc49('0x35'),_0x279952[_0xcc49('0x4f')]]);if(!_0x1b156d){switch(_0x279952[_0xcc49('0x4f')]){case'unreadMessages':if(_0x279952[_0xcc49('0x68')]==0x1){_0x48485d[_0xcc49('0x69')]('`'+_0x279952[_0xcc49('0x4f')]+_0xcc49('0x6a'));}else{_0x48485d['having']('`'+_0x279952[_0xcc49('0x4f')]+_0xcc49('0x6b'));}break;case _0xcc49('0x6c'):if(_0x279952[_0xcc49('0x6d')]===_0xcc49('0x6e')){if(_0x279952[_0xcc49('0x68')]['split']('\x20')[_0xcc49('0x4a')]>0x1){_0xb776cd[_0x5d8a6c]('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0xcc49('0x6f')](_0x279952['value']),null);}else{var _0x19448f='%'+_0x279952[_0xcc49('0x68')]+'%';_0xb776cd[_0x5d8a6c]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x19448f,_0x19448f,_0x19448f);}}else{_0x1b156d=_['find'](_0x1208e2,[_0xcc49('0x35'),_0xcc49('0x70')]);_0x279952[_0xcc49('0x4f')]='ContactId';_0x5e53e0=as[_0xcc49('0x71')](_0x2c9e8b,_0x1b156d[_0xcc49('0x41')],_0x279952);_0xb776cd[_0x5d8a6c](_0x5e53e0[_0xcc49('0x72')],_0x5e53e0[_0xcc49('0x68')][_0xcc49('0x73')],_0x5e53e0[_0xcc49('0x68')][_0xcc49('0x29')]);}break;case'Tag':var _0x16512d=_0x279952[_0xcc49('0x68')]['split'](',')[_0xcc49('0x42')](function(_0x49bc83){return Number(_0x49bc83);});_0x16512d[_0xcc49('0x3c')](function(_0x23c366){_0x24a3ad['or'](_0xcc49('0x74'),'%,'+_0x23c366+',%');});_0x4fe360=_['union'](_0x4fe360,_0x16512d);break;case _0xcc49('0x75'):if(_0x279952[_0xcc49('0x6d')]===_0xcc49('0x6e')){_0xb776cd[_0x5d8a6c](_0xcc49('0x76'),'%'+_0x279952[_0xcc49('0x68')]+'%',null);}else{_0x1b156d=_[_0xcc49('0x67')](_0x1208e2,[_0xcc49('0x35'),'UserId']);_0x279952[_0xcc49('0x4f')]=_0xcc49('0x77');_0x5e53e0=as[_0xcc49('0x71')](_0x2c9e8b,_0x1b156d[_0xcc49('0x41')],_0x279952);_0xb776cd[_0x5d8a6c](_0x5e53e0[_0xcc49('0x72')],_0x5e53e0[_0xcc49('0x68')]['start'],_0x5e53e0['value'][_0xcc49('0x29')]);}break;case'body':_0x5e53e0=as[_0xcc49('0x71')]('me',null,_0x279952);_0xb776cd[_0x5d8a6c](_0x5e53e0[_0xcc49('0x72')],_0x5e53e0['value'][_0xcc49('0x73')],_0x5e53e0[_0xcc49('0x68')][_0xcc49('0x29')]);break;}}else{var _0x5e53e0=as['buildExpression'](_0x2c9e8b,_0x1b156d['type'],_0x279952);_0xb776cd[_0x5d8a6c](_0x5e53e0[_0xcc49('0x72')],_0x5e53e0[_0xcc49('0x68')][_0xcc49('0x73')],_0x5e53e0['value'][_0xcc49('0x29')]);}}}else{var _0x5a1e27=_(_0x59babc[_0xcc49('0x47')])[_0xcc49('0x43')]()[_0xcc49('0x42')](function(_0x3ea005){return _[_0xcc49('0x78')](_0x1208e2,[_0xcc49('0x35'),_0x3ea005])?_0x3ea005:undefined;})[_0xcc49('0x79')]()['value']();if(!_[_0xcc49('0x7a')](_0x5a1e27)){_0x5a1e27['forEach'](function(_0x2e9627){if(_0x2e9627===_0xcc49('0x7b')){_0x48485d[_0xcc49('0x7c')](_0xcc49('0x7d'),[][_0xcc49('0x7e')](_0x59babc[_0xcc49('0x47')][_0x2e9627]));}else if(_0x2e9627===_0xcc49('0x7f')){var _0x284c86=JSON[_0xcc49('0x80')](_0x59babc[_0xcc49('0x47')][_0x2e9627])['$gte'];var _0x5eae43=JSON['parse'](_0x59babc['query'][_0x2e9627])[_0xcc49('0x81')];_0x48485d['where'](_0xcc49('0x82'),_0x284c86,_0x5eae43);}else{if(_0x59babc[_0xcc49('0x47')][_0x2e9627]===_0xcc49('0x83')){_0x48485d[_0xcc49('0x7c')]('i.'+_0x2e9627+_0xcc49('0x84'));}else{_0x48485d['where']('i.'+_0x2e9627+_0xcc49('0x85'),_0x59babc[_0xcc49('0x47')][_0x2e9627]);}}});}if(_0x59babc['query']['read']){if(_0x59babc[_0xcc49('0x47')][_0xcc49('0x86')]==0x1){_0x48485d[_0xcc49('0x69')](_0xcc49('0x87'));}else{_0x48485d[_0xcc49('0x69')]('`unreadMessages`\x20>\x200');}}if(_0x59babc[_0xcc49('0x47')][_0xcc49('0x88')]){_0x4fe360=_[_0xcc49('0x89')](_0x59babc[_0xcc49('0x47')][_0xcc49('0x88')])?_0x59babc[_0xcc49('0x47')][_0xcc49('0x88')]:new Array(_0x59babc['query'][_0xcc49('0x88')]);_0x4fe360[_0xcc49('0x3c')](function(_0x323e32){_0x24a3ad['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x323e32+',%');});}if(_0x59babc[_0xcc49('0x47')][_0xcc49('0x8a')]){var _0x4e900d=_0x59babc[_0xcc49('0x47')][_0xcc49('0x8a')][_0xcc49('0x8b')]('\x5c','\x5c\x5c')[_0xcc49('0x8b')](/'/g,'\x27\x27');if(qs[_0xcc49('0x8c')](_0x4e900d)){_0xb776cd['or'](_0xcc49('0x8d'),_0x4e900d+'%');}else{_0xb776cd['or'](_0xcc49('0x8e'),qs[_0xcc49('0x6f')](_0x4e900d))['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x4e900d+'%');}}}_0x48485d[_0xcc49('0x7c')](_0xb776cd);_0x48485d[_0xcc49('0x8f')]('i.id');var _0x481abb={'type':db[_0xcc49('0x90')][_0xcc49('0x91')][_0xcc49('0x92')],'raw':!![]};var _0x4b92b4=_0x48485d[_0xcc49('0x93')]();_0x4b92b4[_0xcc49('0x4f')](_0xcc49('0x94'));_0x4b92b4['field'](_0xcc49('0x95'),_0xcc49('0x96'));if(_0x130062[_0xcc49('0x4c')]){_0x130062[_0xcc49('0x4c')]['forEach'](function(_0x231baf){var _0x1789f7=_0x231baf[0x0]===_0xcc49('0x97')?_0x231baf[0x0]:'i.'+_0x231baf[0x0];_0x48485d['order'](_0x1789f7,_0x231baf[0x1]===_0xcc49('0x98')?![]:!![]);});}if(!_[_0xcc49('0x7a')](_0x4fe360)){_0x48485d[_0xcc49('0x69')](_0x24a3ad);_0x4b92b4[_0xcc49('0x7c')]('t.id\x20IN\x20?',_0x4fe360);}BPromise['resolve']()[_0xcc49('0x32')](function(){if(!_0x559c63){if(_0x59babc[_0xcc49('0x47')][_0xcc49('0x7b')])return;_0x4b92b4['where'](_0xcc49('0x99'));_0x48485d[_0xcc49('0x7c')](_0xcc49('0x99'));return;}if(_0x59babc['user']['role']!=='agent')return;return _0x59babc[_0xcc49('0x9a')][_0xcc49('0x9b')]({'attributes':['id'],'raw':!![]})['then'](function(_0x934f05){if(_[_0xcc49('0x7a')](_0x934f05)){_0x4b92b4[_0xcc49('0x7c')](_0xcc49('0x9c'));_0x48485d[_0xcc49('0x7c')](_0xcc49('0x9c'));}else{_0x4b92b4[_0xcc49('0x7c')](_0xcc49('0x7d'),_[_0xcc49('0x42')](_0x934f05,'id'));_0x48485d['where'](_0xcc49('0x7d'),_[_0xcc49('0x42')](_0x934f05,'id'));}});})[_0xcc49('0x32')](function(){if(_0x59babc[_0xcc49('0x9a')][_0xcc49('0x9d')]===_0xcc49('0x9e')&&!_0x559c63&&!_0x59babc[_0xcc49('0x47')][_0xcc49('0x7b')])return[];return db[_0xcc49('0x9f')][_0xcc49('0x47')](_0x4b92b4[_0xcc49('0xa0')](),_0x481abb);})[_0xcc49('0x32')](function(_0x1ae221){_0x544424['count']=_0x1ae221[_0xcc49('0x4a')];if(_0x544424[_0xcc49('0x2b')]===0x0)return[];return db['sequelize'][_0xcc49('0x47')](_0x4d8314['toString'](),_0x481abb)[_0xcc49('0x32')](function(_0x52bc35){_0x12b7e4=_[_0xcc49('0xa1')](_0x52bc35,'id');_0x481abb=_[_0xcc49('0xa2')](_0x481abb,{'model':db['ChatInteraction'],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x59babc[_0xcc49('0x47')][_0xcc49('0x49')]){_0x130062[_0xcc49('0x48')]['forEach'](function(_0x2ba951){_0x48485d['field']('i.'+_0x2ba951);});}else{_0x48485d[_0xcc49('0x4f')](_0xcc49('0x95'),_0xcc49('0x96'));_0x48485d[_0xcc49('0x4f')](_0xcc49('0xa3'),'Account.key');_0x48485d[_0xcc49('0x4f')](_0xcc49('0xa4'),_0xcc49('0xa5'));_0x48485d[_0xcc49('0x4f')](_0xcc49('0xa6'),_0xcc49('0x97'));_0x48485d[_0xcc49('0x4f')](_0xcc49('0xa7'));_0x48485d[_0xcc49('0x4f')]('c.firstName','Contact.firstName');_0x48485d[_0xcc49('0x4f')]('c.lastName',_0xcc49('0xa8'));_0x48485d[_0xcc49('0x4f')](_0xcc49('0xa9'),_0xcc49('0xaa'));_0x48485d[_0xcc49('0x4f')](_0xcc49('0xab'),_0xcc49('0xac'));_0x48485d[_0xcc49('0x4f')](_0xcc49('0xad'),_0xcc49('0xae'));_0x48485d['field'](_0xcc49('0xaf'),_0xcc49('0xb0'));_0x48485d[_0xcc49('0x4f')]('o.fullname','Owner.fullname');_0x48485d[_0xcc49('0x4f')]('o.internal','Owner.internal');_0x48485d[_0xcc49('0x4f')]('GROUP_CONCAT(DISTINCT\x20t.id)','TagIds');}if(_0x130062[_0xcc49('0x2d')])_0x48485d[_0xcc49('0x2d')](_0x130062['limit']);if(_0x130062[_0xcc49('0x2c')])_0x48485d[_0xcc49('0x2c')](_0x130062[_0xcc49('0x2c')]);return db[_0xcc49('0x9f')][_0xcc49('0x47')](_0x48485d[_0xcc49('0xa0')](),_0x481abb);})['then'](function(_0x38f364){_0x1f9aae[_0xcc49('0x7c')](_0xcc49('0xb1'),_[_0xcc49('0x42')](_0x38f364,'id'));return db[_0xcc49('0x9f')][_0xcc49('0x47')](_0x1f9aae[_0xcc49('0xa0')](),_0x481abb)[_0xcc49('0x32')](function(_0x4a4075){var _0x456790=_[_0xcc49('0xb2')](_0x4a4075,'ChatInteractionId');var _0x1b50b5=[];_0x38f364[_0xcc49('0x3c')](function(_0x4af7f1){_0x1b50b5['push'](updateChatInteraction(_0x4af7f1,_0x12b7e4,_0x456790));});return BPromise[_0xcc49('0xb3')](_0x1b50b5);});});})[_0xcc49('0x32')](function(_0x2578cb){_0x544424[_0xcc49('0xb4')]=_0x2578cb;return _0x544424;})[_0xcc49('0x32')](respondWithFilteredResult(_0x591823,_0x130062))['catch'](handleError(_0x591823,null));};exports[_0xcc49('0xb5')]=function(_0x5a4761,_0x368379){var _0x52c01c={'raw':![],'where':{'id':_0x5a4761['params']['id']}},_0x217067={};_0x217067[_0xcc49('0x46')]=_['keys'](db['ChatInteraction'][_0xcc49('0x40')]);_0x217067[_0xcc49('0x47')]=_['keys'](_0x5a4761[_0xcc49('0x47')]);_0x217067['filters']=_[_0xcc49('0x45')](_0x217067[_0xcc49('0x46')],_0x217067[_0xcc49('0x47')]);_0x52c01c[_0xcc49('0x48')]=_[_0xcc49('0x45')](_0x217067[_0xcc49('0x46')],qs[_0xcc49('0x49')](_0x5a4761[_0xcc49('0x47')][_0xcc49('0x49')]));_0x52c01c[_0xcc49('0x48')]=_0x52c01c[_0xcc49('0x48')][_0xcc49('0x4a')]?_0x52c01c['attributes']:_0x217067[_0xcc49('0x46')];if(_0x5a4761[_0xcc49('0x47')][_0xcc49('0xb6')]){_0x52c01c[_0xcc49('0xb7')]=[{'all':!![]}];}_0x52c01c=_[_0xcc49('0xa2')]({},_0x52c01c,_0x5a4761[_0xcc49('0xb8')]);return db[_0xcc49('0x3f')][_0xcc49('0x67')](_0x52c01c)[_0xcc49('0x32')](handleEntityNotFound(_0x368379,null))[_0xcc49('0x32')](respondWithResult(_0x368379,null))[_0xcc49('0x3e')](handleError(_0x368379,null));};exports[_0xcc49('0xb9')]=function(_0x5c0d9a,_0x577845){return db[_0xcc49('0x3f')][_0xcc49('0xb9')](_0x5c0d9a[_0xcc49('0xba')],{})[_0xcc49('0x32')](respondWithResult(_0x577845,0xc9))['catch'](handleError(_0x577845,null));};exports[_0xcc49('0x31')]=function(_0x10a4f9,_0x4d2792){if(_0x10a4f9[_0xcc49('0xba')]['id']){delete _0x10a4f9[_0xcc49('0xba')]['id'];}return db[_0xcc49('0x3f')]['find']({'where':{'id':_0x10a4f9[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x4d2792,null))['then'](saveUpdates(_0x10a4f9[_0xcc49('0xba')],null))[_0xcc49('0x32')](respondWithResult(_0x4d2792,null))[_0xcc49('0x3e')](handleError(_0x4d2792,null));};exports['destroy']=function(_0x12b56e,_0x33d9cf){return db[_0xcc49('0x3f')]['find']({'where':{'id':_0x12b56e[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x33d9cf,null))['then'](removeEntity(_0x33d9cf,null))[_0xcc49('0x3e')](handleError(_0x33d9cf,null));};exports['describe']=function(_0x40e6b8,_0x5f53fd){return db[_0xcc49('0x3f')][_0xcc49('0xbc')]()[_0xcc49('0x32')](respondWithResult(_0x5f53fd,null))[_0xcc49('0x3e')](handleError(_0x5f53fd,null));};exports[_0xcc49('0xbd')]=function(_0x24e835,_0x96531b){var _0x500869=_0x24e835[_0xcc49('0xbb')]['id'];var _0x16cb3b;var _0x548e00;var _0x42aa63;return db['ChatInteraction']['findOne']({'where':{'id':_0x500869}})['then'](function(_0x365829){_0x16cb3b=_0x365829;return db[_0xcc49('0xbe')][_0xcc49('0xbf')]({'where':{'id':_0x365829[_0xcc49('0x7b')]},'attributes':['id',_0xcc49('0xc0'),_0xcc49('0xc1')],'raw':!![]});})[_0xcc49('0x32')](function(_0x329fea){if(_0x329fea&&_0x329fea['vidaooApiKey']&&_0x329fea[_0xcc49('0xc1')]){_0x548e00=_0x329fea;var _0xc059dd={'rejectUnauthorized':![],'method':_0xcc49('0xc2'),'uri':'https://api-vidaoo.xcally.com/api/v1/sessions','headers':{'X-APIKEY':_0x329fea['vidaooApiKey']},'body':{'name':_0xcc49('0xc3')+_0x500869},'redirect':_0xcc49('0xc4'),'json':!![]};return rp(_0xc059dd);}else{throw new db[(_0xcc49('0x90'))][(_0xcc49('0xc5'))](_0xcc49('0xc6'));}})[_0xcc49('0x32')](function(_0x3495a0){_0x42aa63=_0x3495a0;if(_0x42aa63['id']){var _0x2f9c83={'body':_0x42aa63[_0xcc49('0xc7')],'ChatWebsiteId':_0x548e00['id'],'ChatInteractionId':_0x16cb3b['id'],'direction':_0xcc49('0xc8'),'UserId':_0x24e835[_0xcc49('0x9a')]['id']};return db[_0xcc49('0xc9')][_0xcc49('0xb9')](_0x2f9c83,{});}else{throw new db['Sequelize'][(_0xcc49('0xc5'))](_0xcc49('0xca'));}})[_0xcc49('0x32')](function(){return _0x16cb3b['updateAttributes']({'vidaooSessionId':_0x42aa63['id']});})[_0xcc49('0x32')](respondWithResult(_0x96531b,null))[_0xcc49('0x3e')](handleError(_0x96531b,null));};exports[_0xcc49('0xcb')]=function(_0xbb85f0,_0x52ac83){if(_0xbb85f0[_0xcc49('0xba')]['id']){delete _0xbb85f0[_0xcc49('0xba')]['id'];}return db[_0xcc49('0x3f')][_0xcc49('0x67')]({'where':{'id':_0xbb85f0[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x52ac83,null))[_0xcc49('0x32')](saveUpdates(_0xbb85f0['body'],null))[_0xcc49('0x32')](respondWithResult(_0x52ac83,null))[_0xcc49('0x3e')](handleError(_0x52ac83,null));};exports[_0xcc49('0xcc')]=function(_0x15bdd1,_0xd6bd72,_0x4596b9){if(_0x15bdd1[_0xcc49('0xba')]['id']){delete _0x15bdd1[_0xcc49('0xba')]['id'];}return db[_0xcc49('0x3f')][_0xcc49('0x67')]({'where':{'id':_0x15bdd1[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](function(_0x23ce0b){if(!_0x23ce0b){logger[_0xcc49('0x23')](_0xcc49('0xcd'),'abandon',0x194,_0xcc49('0xce'));_0xd6bd72[_0xcc49('0x27')](0x194);}else{if(_0x23ce0b[_0xcc49('0x77')]){throw new db['Sequelize']['ValidationError'](_0xcc49('0xcf'));}}return _0x23ce0b;})[_0xcc49('0x32')](function(_0x1d2dca){if(_0x1d2dca){return _0x1d2dca[_0xcc49('0x31')]({'closed':_0x15bdd1['body'][_0xcc49('0xd0')],'disposition':_0x15bdd1[_0xcc49('0xba')][_0xcc49('0xd1')]})[_0xcc49('0x32')](function(_0x2b8342){return _0x2b8342;});}})[_0xcc49('0x32')](function(_0x4bb6b0){return respondWithRpcPromise('AbandonInteraction',_0xcc49('0xcc'),_0x15bdd1[_0xcc49('0xba')],client9004);})[_0xcc49('0x32')](respondWithResult(_0xd6bd72,null))[_0xcc49('0x3e')](handleError(_0xd6bd72,null));};exports[_0xcc49('0xd2')]=function(_0x2ab632,_0x41a362,_0xf6a07a){_0x2ab632['body'][_0xcc49('0x35')]=_0x2ab632[_0xcc49('0xd3')][_0xcc49('0xd4')];_0x2ab632['body'][_0xcc49('0xd5')]=_0x2ab632[_0xcc49('0xd3')][_0xcc49('0xd6')];_0x2ab632['body'][_0xcc49('0x41')]=_0x2ab632[_0xcc49('0xd3')]['mimetype'];return db[_0xcc49('0xd7')]['create'](_0x2ab632[_0xcc49('0xba')])[_0xcc49('0x32')](respondWithResult(_0x41a362,0xc9))[_0xcc49('0x3e')](handleError(_0x41a362,null));};exports['attachmentDownload']=function(_0x1ec44c,_0x633aa6,_0x2b2a9e){return db['ChatInteraction']['findOne']({'where':{'id':_0x1ec44c[_0xcc49('0xbb')]['id']},'raw':!![]})[_0xcc49('0x32')](handleEntityNotFound(_0x633aa6,null))[_0xcc49('0x32')](function(_0x4ba0f7){if(_0x4ba0f7){if(_0x4ba0f7[_0xcc49('0xd0')]){return _0x633aa6['status'](0x193)['json']({'status':0x193,'message':_0xcc49('0xd8')});}return db[_0xcc49('0xd7')][_0xcc49('0xbf')]({'where':{'id':_0x1ec44c[_0xcc49('0x47')][_0xcc49('0xd9')]},'raw':!![]})[_0xcc49('0x32')](handleEntityNotFound(_0x633aa6,null));}})[_0xcc49('0x32')](function(_0x563b0c){if(_0x563b0c){return _0x633aa6[_0xcc49('0xda')](path[_0xcc49('0xdb')](config['root'],_0xcc49('0xdc'),_0x563b0c[_0xcc49('0xd5')]));}})['catch'](handleError(_0x633aa6,null));};exports['close']=function(_0x283c2f,_0x247b0e){var _0x2f4c55=null;var _0x4c6bd0=null;var _0x4a8430=null;var _0x45ba40=null;if(_0x283c2f[_0xcc49('0xba')]['id']){delete _0x283c2f['body']['id'];}if(_0x283c2f[_0xcc49('0xba')]['mailTranscript']){_0x45ba40=path[_0xcc49('0xdb')](config[_0xcc49('0xdd')],'server/files/chat/upload/',util[_0xcc49('0xde')](_0xcc49('0xdf'),Date[_0xcc49('0xe0')]()));_0x283c2f[_0xcc49('0xba')][_0xcc49('0xe1')]=_0x45ba40;}return db[_0xcc49('0x3f')]['find']({'where':{'id':_0x283c2f['params']['id']},'include':[{'model':db['ChatMessage'],'as':_0xcc49('0xe2'),'include':[{'model':db[_0xcc49('0x75')],'as':'User'}]}]})[_0xcc49('0x32')](handleEntityNotFound(_0x247b0e,null))['then'](saveUpdates(_0x283c2f['body'],null))[_0xcc49('0x32')](function(_0x56d217){if(_0x56d217){_0x2f4c55=_0x56d217;return db[_0xcc49('0xbe')][_0xcc49('0x67')]({'where':{'id':_0x2f4c55[_0xcc49('0x7b')]}});}})[_0xcc49('0x32')](function(_0x1de5b5){if(_0x1de5b5){_0x4a8430=_0x1de5b5;return db[_0xcc49('0xe3')][_0xcc49('0x67')]({'where':{'id':_0x2f4c55['ContactId']}});}})[_0xcc49('0x32')](function(_0x3dac1e){if(_0x3dac1e){_0x4c6bd0=_0x3dac1e;if(_0x45ba40){var _0x5d6fb2=null;for(var _0x1a58b1=0x1;_0x1a58b1<_0x2f4c55[_0xcc49('0xe2')][_0xcc49('0x4a')];++_0x1a58b1){_0x5d6fb2=_0x2f4c55[_0xcc49('0xe2')][_0x1a58b1];var _0x37b3ee=_0x5d6fb2['UserId']?util[_0xcc49('0xde')]('%s%d',_0x4a8430[_0xcc49('0xe4')],_0x5d6fb2[_0xcc49('0x77')]):_0xcc49('0xe5');var _0x562723=_0x283c2f[_0xcc49('0xba')][_0xcc49('0xe6')]||util['format'](_0xcc49('0xe7'),_0xcc49('0xe8'),_0x5d6fb2[_0xcc49('0x70')]);switch(_0x4a8430[_0xcc49('0xe9')]){case _0xcc49('0xea'):_0x37b3ee=_0x5d6fb2[_0xcc49('0x77')]?util[_0xcc49('0xde')]('%s%d',_0x4a8430[_0xcc49('0xe4')],_0x5d6fb2['UserId']):'System';break;case'agent_alias':_0x37b3ee=_0x5d6fb2[_0xcc49('0x77')]?_0x5d6fb2[_0xcc49('0x75')]['alias']||_0x5d6fb2[_0xcc49('0x75')][_0xcc49('0x38')]:_0xcc49('0xe5');break;case _0xcc49('0xeb'):_0x37b3ee=_0x5d6fb2['UserId']?_0x5d6fb2[_0xcc49('0x75')][_0xcc49('0x38')]:_0xcc49('0xe5');break;default:_0x37b3ee=_0x5d6fb2[_0xcc49('0x77')]?util[_0xcc49('0xde')]('%s%d',_0x4a8430[_0xcc49('0xe4')],_0x5d6fb2[_0xcc49('0x77')]):_0xcc49('0xe5');}var _0x52f62c=util[_0xcc49('0xde')](_0xcc49('0xec'),moment(_0x5d6fb2[_0xcc49('0x7f')])['format'](_0xcc49('0xed')),_0x5d6fb2[_0xcc49('0xee')]==='in'?_0x562723:_0x37b3ee,_0x5d6fb2[_0xcc49('0xba')]);if(!_0x5d6fb2[_0xcc49('0xef')]){fs['appendFileSync'](_0x45ba40,_0x52f62c);}}return db[_0xcc49('0xf0')][_0xcc49('0xbf')]({'where':{'service':!![]},'include':[{'model':db[_0xcc49('0xf1')],'as':_0xcc49('0xf2'),'raw':!![]}]});}}})[_0xcc49('0x32')](function(_0x24fa8d){if(_0x24fa8d&&_0x24fa8d['Smtp']&&_0x283c2f[_0xcc49('0xba')]){var _0x2a19c1={'tls':{'rejectUnauthorized':![]}};if(_0x24fa8d[_0xcc49('0xf2')][_0xcc49('0xf3')]){_0x2a19c1[_0xcc49('0xf3')]=_0x24fa8d[_0xcc49('0xf2')]['service'];}else{_0x2a19c1['host']=_0x24fa8d[_0xcc49('0xf2')][_0xcc49('0xf4')];_0x2a19c1['port']=_0x24fa8d[_0xcc49('0xf2')][_0xcc49('0xf5')];_0x2a19c1['secure']=_0x24fa8d[_0xcc49('0xf2')][_0xcc49('0xf6')];}if(_0x24fa8d['Smtp'][_0xcc49('0xf7')]){_0x2a19c1[_0xcc49('0xf8')]={'user':_0x24fa8d[_0xcc49('0xf2')][_0xcc49('0x9a')],'pass':_0x24fa8d['Smtp'][_0xcc49('0xf9')]};}return respondWithRpcPromise(_0xcc49('0xfa'),'sendMail',{'account':_0x2a19c1,'message':{'from':util[_0xcc49('0xde')](_0xcc49('0xfb'),_0x24fa8d[_0xcc49('0x35')],_0x24fa8d['email']||_0x24fa8d[_0xcc49('0xf2')][_0xcc49('0x9a')]),'to':_0x283c2f[_0xcc49('0xba')][_0xcc49('0xfc')],'subject':_0xcc49('0xfd'),'text':util[_0xcc49('0xde')](_0xcc49('0xfe'),_0x283c2f[_0xcc49('0xba')][_0xcc49('0xfc')]),'attachments':[{'path':_0x45ba40}]}})['then'](function(){return _0x2f4c55;})[_0xcc49('0x3e')](function(_0x3dfd41){console[_0xcc49('0x23')](_0x3dfd41);});}else{return _0x2f4c55;}})[_0xcc49('0x32')](respondWithStatusCode(_0x247b0e,0xc8))[_0xcc49('0x3e')](handleError(_0x247b0e,null));};exports[_0xcc49('0xff')]=function(_0x4fbd43,_0x3982b4,_0x42c42f){return db[_0xcc49('0xc9')]['find']({'where':{'id':_0x4fbd43[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x3982b4,null))[_0xcc49('0x32')](function(_0x45966b){if(_0x45966b){return _0x45966b[_0xcc49('0xff')](_0x4fbd43[_0xcc49('0xba')][_0xcc49('0x100')],_[_0xcc49('0x101')](_0x4fbd43['body'],[_0xcc49('0x100'),'id'])||{});}})[_0xcc49('0x32')](respondWithResult(_0x3982b4,null))[_0xcc49('0x3e')](handleError(_0x3982b4,null));};exports['getMessages']=function(_0x10004e,_0xd406ff,_0x15c211){var _0x2682ca={'raw':![],'where':{}};var _0x10ea5b={};var _0x26b2e6={'count':0x0,'rows':[]};return db[_0xcc49('0x3f')]['findOne']({'where':{'id':_0x10004e[_0xcc49('0xbb')]['id']}})['then'](handleEntityNotFound(_0xd406ff,null))['then'](function(_0x620a90){if(_0x620a90){_0x10ea5b[_0xcc49('0x46')]=_['keys'](db['ChatMessage'][_0xcc49('0x40')]);_0x10ea5b['query']=_[_0xcc49('0x43')](_0x10004e[_0xcc49('0x47')]);_0x10ea5b['filters']=_[_0xcc49('0x45')](_0x10ea5b[_0xcc49('0x46')],_0x10ea5b[_0xcc49('0x47')]);_0x2682ca[_0xcc49('0x48')]=_['intersection'](_0x10ea5b[_0xcc49('0x46')],qs[_0xcc49('0x49')](_0x10004e[_0xcc49('0x47')]['fields']));_0x2682ca[_0xcc49('0x48')]=_0x2682ca[_0xcc49('0x48')][_0xcc49('0x4a')]?_0x2682ca[_0xcc49('0x48')]:_0x10ea5b[_0xcc49('0x46')];if(!_0x10004e[_0xcc49('0x47')][_0xcc49('0x4b')](_0xcc49('0x102'))){_0x2682ca[_0xcc49('0x2d')]=qs[_0xcc49('0x2d')](_0x10004e[_0xcc49('0x47')][_0xcc49('0x2d')]);_0x2682ca['offset']=qs[_0xcc49('0x2c')](_0x10004e['query'][_0xcc49('0x2c')]);}_0x2682ca[_0xcc49('0x4c')]=qs[_0xcc49('0x4d')](_0x10004e[_0xcc49('0x47')][_0xcc49('0x4d')]);_0x2682ca[_0xcc49('0x7c')]=qs[_0xcc49('0x44')](_[_0xcc49('0x4e')](_0x10004e['query'],_0x10ea5b[_0xcc49('0x44')]));_0x2682ca[_0xcc49('0x7c')][_0xcc49('0x103')]=_0x620a90['id'];if(_0x10004e[_0xcc49('0x47')][_0xcc49('0x8a')]){_0x2682ca[_0xcc49('0x7c')]=_['merge'](_0x2682ca[_0xcc49('0x7c')],{'$or':_[_0xcc49('0x42')](_0x2682ca['attributes'],function(_0x5b56a3){var _0x400b61={};_0x400b61[_0x5b56a3]={'$like':'%'+_0x10004e[_0xcc49('0x47')][_0xcc49('0x8a')]+'%'};return _0x400b61;})});}if(_0x10004e[_0xcc49('0x47')][_0xcc49('0x104')]){var _0x244f99=_0x10004e[_0xcc49('0x47')]['$gte']['split'](',');var _0x57b06f={};_0x57b06f[_0x244f99[0x0]]={'$gte':moment(_0x244f99[0x1])[_0xcc49('0xde')](_0xcc49('0x105'))};_0x2682ca[_0xcc49('0x7c')]=_[_0xcc49('0xa2')](_0x2682ca[_0xcc49('0x7c')],_0x57b06f);}_0x2682ca=_[_0xcc49('0xa2')]({},_0x2682ca,_0x10004e['options']);return db[_0xcc49('0xc9')]['count']({'where':_0x2682ca['where']})['then'](function(_0x256062){_0x26b2e6[_0xcc49('0x2b')]=_0x256062;if(_0x10004e['query'][_0xcc49('0xb6')]){_0x2682ca[_0xcc49('0xb7')]=[{'all':!![]}];}return db[_0xcc49('0xc9')][_0xcc49('0x106')](_0x2682ca);})[_0xcc49('0x32')](function(_0x5db846){_0x26b2e6[_0xcc49('0xb4')]=_0x5db846;return _0x26b2e6;});}})[_0xcc49('0x32')](respondWithFilteredResult(_0xd406ff,_0x2682ca))[_0xcc49('0x3e')](handleError(_0xd406ff,null));};exports[_0xcc49('0x107')]=function(_0x4758aa,_0x2b3480,_0x31cce0){var _0x4db626={'where':{}},_0x3d6681={},_0x1f38ed={'count':0x0,'rows':[]};return db['ChatInteraction']['findOne']({'where':{'id':_0x4758aa[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x2b3480,null))[_0xcc49('0x32')](function(_0x3d12ba){if(_0x3d12ba){_0x3d6681['model']=_['keys'](db[_0xcc49('0xc9')][_0xcc49('0x40')]);_0x3d6681[_0xcc49('0x47')]=_[_0xcc49('0x43')](_0x4758aa['query']);_0x3d6681[_0xcc49('0x44')]=_[_0xcc49('0x45')](_0x3d6681[_0xcc49('0x46')],_0x3d6681[_0xcc49('0x47')]);_0x4db626['attributes']=_[_0xcc49('0x45')](_0x3d6681[_0xcc49('0x46')],qs[_0xcc49('0x49')](_0x4758aa['query']['fields']));_0x4db626['attributes']=_0x4db626[_0xcc49('0x48')][_0xcc49('0x4a')]?_0x4db626[_0xcc49('0x48')]:_0x3d6681['model'];if(!_0x4758aa[_0xcc49('0x47')]['hasOwnProperty'](_0xcc49('0x102'))){_0x4db626['limit']=qs[_0xcc49('0x2d')](_0x4758aa[_0xcc49('0x47')]['limit']);_0x4db626[_0xcc49('0x2c')]=qs['offset'](_0x4758aa[_0xcc49('0x47')][_0xcc49('0x2c')]);}_0x4db626[_0xcc49('0x4c')]=qs[_0xcc49('0x4d')](_0x4758aa['query']['sort']);_0x4db626['where']=qs[_0xcc49('0x44')](_[_0xcc49('0x4e')](_0x4758aa[_0xcc49('0x47')],_0x3d6681[_0xcc49('0x44')]));_0x4db626['where']['ChatInteractionId']=_0x3d12ba['id'];if(_0x4758aa['query']['filter']){_0x4db626['where']=_['merge'](_0x4db626['where'],{'$or':_['map'](_0x4db626[_0xcc49('0x48')],function(_0x225c90){var _0x4a24db={};_0x4a24db[_0x225c90]={'$like':'%'+_0x4758aa[_0xcc49('0x47')][_0xcc49('0x8a')]+'%'};return _0x4a24db;})});}_0x4db626[_0xcc49('0x7c')]['secret']=![];if(_0x4758aa[_0xcc49('0x47')]['id']){_0x4db626[_0xcc49('0x7c')]['id']={'$gt':_0x4758aa['query']['id']};}_0x4db626=_[_0xcc49('0xa2')]({},_0x4db626,_0x4758aa[_0xcc49('0xb8')]);return db[_0xcc49('0xc9')][_0xcc49('0x2b')]({'where':_0x4db626['where']})['then'](function(_0x2251d6){_0x1f38ed['count']=_0x2251d6;_0x4db626[_0xcc49('0xb7')]=[];if(_0x4758aa[_0xcc49('0x47')]['includeAgent']){_0x4db626['include']['push']({'model':db[_0xcc49('0x75')],'as':'User','attributes':['id',_0xcc49('0x38'),_0xcc49('0x108')]});}if(_0x4758aa[_0xcc49('0x47')][_0xcc49('0xb6')]){_0x4db626[_0xcc49('0xb7')]=[{'all':!![]}];}return db['ChatMessage']['findAll'](_0x4db626);})['then'](function(_0x433af2){_0x1f38ed[_0xcc49('0xb4')]=_0x433af2;return _0x1f38ed;});}})[_0xcc49('0x32')](respondWithFilteredResult(_0x2b3480,_0x4db626))[_0xcc49('0x3e')](handleError(_0x2b3480,null));};exports[_0xcc49('0x109')]=function(_0x344f30,_0x5b33ae,_0xdb548e){return db[_0xcc49('0x3f')]['find']({'where':{'id':_0x344f30[_0xcc49('0xbb')]['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x5b33ae,null))[_0xcc49('0x32')](function(_0xa39980){if(_0xa39980){return _0xa39980[_0xcc49('0x10a')](_0x344f30['body']['ids'],_[_0xcc49('0x101')](_0x344f30[_0xcc49('0xba')],[_0xcc49('0x100'),'id'])||{})['spread'](function(){return db[_0xcc49('0x10b')][_0xcc49('0x106')]({'attributes':['id',_0xcc49('0x35'),'color'],'where':{'id':_0x344f30[_0xcc49('0xba')][_0xcc49('0x100')]}});})[_0xcc49('0x32')](function(_0x13e4b5){socket[_0xcc49('0x10c')]('chatInteractionTags:save',{'id':Number(_0x344f30[_0xcc49('0xbb')]['id']),'tags':_0x13e4b5||[]});return{'id':Number(_0x344f30[_0xcc49('0xbb')]['id']),'tags':_0x13e4b5||[]};});}})[_0xcc49('0x32')](respondWithResult(_0x5b33ae,null))['catch'](handleError(_0x5b33ae,null));};exports[_0xcc49('0x10d')]=function(_0x28b047,_0x24fd74,_0x2a96e5){return db['ChatInteraction'][_0xcc49('0x67')]({'where':{'id':_0x28b047['params']['id']}})[_0xcc49('0x32')](handleEntityNotFound(_0x24fd74,null))['then'](function(_0x264790){if(_0x264790){return _0x264790[_0xcc49('0x10d')](_0x28b047[_0xcc49('0x47')][_0xcc49('0x100')]);}})[_0xcc49('0x32')](respondWithStatusCode(_0x24fd74,null))[_0xcc49('0x3e')](handleError(_0x24fd74,null));};exports[_0xcc49('0xda')]=function(_0x17275c,_0x374654){var _0x321c18=moment()[_0xcc49('0x10e')]()[_0xcc49('0xa0')]();var _0x30d441=path[_0xcc49('0xdb')](config['root'],'server',_0xcc49('0x10f'),_0xcc49('0x110'));var _0x390aca=path[_0xcc49('0xdb')](config[_0xcc49('0xdd')],_0xcc49('0x111'),_0xcc49('0x10f'),_0xcc49('0x112'));var _0xaf66bf=path[_0xcc49('0xdb')](_0x30d441,_0x321c18);var _0x3649b3=util[_0xcc49('0xde')](_0xcc49('0x113'),_0x17275c[_0xcc49('0xbb')]['id'],_0x321c18);var _0x40123e=path[_0xcc49('0xdb')](_0x30d441,_0x3649b3);var _0xe4f622=[];_0xe4f622[_0xcc49('0x3d')]({'model':db['User'],'as':_0xcc49('0x75'),'attributes':['id',_0xcc49('0x38')],'raw':!![]});_0xe4f622[_0xcc49('0x3d')]({'model':db[_0xcc49('0xe3')],'as':'Contact','attributes':['id',_0xcc49('0x114'),'lastName'],'raw':!![]});if(_0x17275c['query'][_0xcc49('0x112')]){_0xe4f622[_0xcc49('0x3d')]({'model':db[_0xcc49('0xd7')],'as':_0xcc49('0xd7'),'raw':!![]});}var _0x131000=[{'model':db[_0xcc49('0xc9')],'as':_0xcc49('0xe2'),'attributes':['id',_0xcc49('0xba'),_0xcc49('0x7f'),_0xcc49('0xee'),_0xcc49('0xef'),_0xcc49('0x86')],'include':_0xe4f622}];_0x131000[_0xcc49('0x3d')]({'model':db['ChatWebsite'],'as':_0xcc49('0x115'),'attributes':['id',_0xcc49('0x35')]});_0x131000['push']({'model':db[_0xcc49('0x75')],'as':_0xcc49('0x116'),'attributes':['id',_0xcc49('0x38')]});return db[_0xcc49('0x3f')][_0xcc49('0x67')]({'where':{'id':_0x17275c['params']['id']},'include':_0x131000})['then'](handleEntityNotFound(_0x374654,null))['then'](function(_0x13efa7){if(_0x13efa7){var _0x370bfe=_0x13efa7[_0xcc49('0x117')]({'plain':!![]});fs[_0xcc49('0x118')](_0xaf66bf);var _0x1e5554={'format':'A4','border':_0xcc49('0x119'),'header':{'height':_0xcc49('0x11a'),'contents':{'first':'<div\x20class=\x22header\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<h5>Interaction\x20Transcript</h5>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>'}},'footer':{'height':_0xcc49('0x11b'),'contents':{'default':util[_0xcc49('0xde')](_0xcc49('0x11c'),util[_0xcc49('0xde')](_0xcc49('0x11d'),_0xcc49('0x11e'),_0x370bfe['id']),moment()[_0xcc49('0xde')](_0xcc49('0x11f'))[_0xcc49('0xa0')]())}}};var _0x8bac70={'channel':'Chat','account':_0x370bfe[_0xcc49('0x115')]['name'],'agent':_0x370bfe['Owner']?_0x370bfe[_0xcc49('0x116')][_0xcc49('0x38')]:_0xcc49('0x120'),'createdAt':moment(_0x370bfe[_0xcc49('0x7f')])[_0xcc49('0xde')](_0xcc49('0x105'))[_0xcc49('0xa0')](),'closedAt':_0x370bfe[_0xcc49('0xd0')]?moment(_0x370bfe['closedAt'])[_0xcc49('0xde')](_0xcc49('0x105'))[_0xcc49('0xa0')]():'','disposition':_0x370bfe[_0xcc49('0xd1')],'chatInfo':{'browser':_0x370bfe['browserName'],'os':_0x370bfe[_0xcc49('0x121')],'referer':_0x370bfe[_0xcc49('0x122')],'customerIp':_0x370bfe[_0xcc49('0x123')],'customerPort':_0x370bfe['customerPort']?_0x370bfe['customerPort']:_0xcc49('0x120')},'messages':_(_0x370bfe[_0xcc49('0xe2')])[_0xcc49('0x124')]()[_0xcc49('0x8a')]({'secret':![]})[_0xcc49('0x42')](function(_0x5a2c60){if(_0x5a2c60[_0xcc49('0xd7')]){var _0x344493=path[_0xcc49('0xdb')](_0x390aca,_0x5a2c60['Attachment'][_0xcc49('0xd5')]);if(fs[_0xcc49('0x125')](_0x344493)){fs['createReadStream'](_0x344493)[_0xcc49('0x126')](fs[_0xcc49('0x127')](path[_0xcc49('0xdb')](_0xaf66bf,_0x5a2c60[_0xcc49('0xd7')][_0xcc49('0xd5')])));}}return{'date':moment(_0x5a2c60[_0xcc49('0x7f')])['format']('YYYY-MM-DD\x20HH:mm:ss')['toString'](),'sender':_0x5a2c60[_0xcc49('0xee')]===_0xcc49('0xc8')?_0x5a2c60['User']?_0x5a2c60['User'][_0xcc49('0x38')]:'System':_0x5a2c60[_0xcc49('0x6c')]['firstName']+(_0x5a2c60['Contact'][_0xcc49('0x128')]?'\x20'+_0x5a2c60[_0xcc49('0x6c')]['lastName']:''),'body':_0x5a2c60[_0xcc49('0xd7')]?_0x5a2c60[_0xcc49('0xd7')][_0xcc49('0xd5')]:_0x5a2c60[_0xcc49('0xba')],'direction':_0x5a2c60[_0xcc49('0xee')]===_0xcc49('0xc8')?'A':'C','secret':_0x5a2c60[_0xcc49('0xef')],'read':_0x5a2c60[_0xcc49('0x86')],'attachment':_0x5a2c60[_0xcc49('0xd7')]};})[_0xcc49('0x68')]()};return ejs[_0xcc49('0x129')](path[_0xcc49('0xdb')](config[_0xcc49('0xdd')],'server',_0xcc49('0x12a'),_0xcc49('0x12b')),{'interaction':_0x8bac70})['then'](function(_0xf8f18){return new BPromise(function(_0x72e360,_0x2c695e){pdf[_0xcc49('0xb9')](_0xf8f18,_0x1e5554)['toFile'](path[_0xcc49('0xdb')](_0xaf66bf,_0xcc49('0x12c')+_0x370bfe['id']+'-'+_0x321c18+_0xcc49('0x12d')),function(_0x3014af,_0xff15de){if(_0x3014af)return _0x2c695e(_0x3014af);_0x72e360(_0xff15de);});});})[_0xcc49('0x32')](function(){return new BPromise(function(_0x4a6b8a,_0x4effb5){zipdir(_0xaf66bf,{'saveTo':_0x40123e},function(_0x837548,_0x439003){if(_0x837548)return _0x4effb5(_0x837548);return _0x4a6b8a(_0x439003);});})[_0xcc49('0x32')](function(){return new BPromise(function(_0x2a2b9b,_0x2e8241){rimraf(_0xaf66bf,function(_0x5a34eb){if(_0x5a34eb)_0x2e8241(_0x5a34eb);return _0x2a2b9b();});});})[_0xcc49('0x32')](function(){return _0x374654[_0xcc49('0xda')](_0x40123e,_0x3649b3,function(_0x4aa390){if(_0x4aa390){console[_0xcc49('0x12e')](_0xcc49('0x12f'),_0x4aa390);}else{fs[_0xcc49('0x130')](_0x40123e);}});});});}else{return _0x374654['sendStatus'](0xc8);}})[_0xcc49('0x3e')](handleError(_0x374654,null));};
\ No newline at end of file
+var _0x5316=['updateAttributes','customUpdate','CmContact','abandon','UserId','Interaction\x20already\x20assigned','closed','disposition','AbandonInteraction','basename','filename','file','mimetype','Attachment','attachId','join','offline-chat/','download','close','root','server/files/chat/upload/','format','transcript-%s.txt','now','pathTranscript','Messages','User','ChatWebsite','ContactId','length','System','customer','Visitor','agentIdentifier','website_alias','%s%d','agentAlias','agent_alias','alias','agent_fullname','[%s]\x20%s:\x20%s\x0a','createdAt','MM/DD/YYYY\x20HH:mm:ss','direction','secret','appendFileSync','MailAccount','MailServerOut','Smtp','CloudProvider','getSmtpOptions','SendMail','sendMail','\x22%s\x22\x20<%s>','mailTranscript','Mail\x20Transcript','Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a','addMessage','ids','getMessages','nolimit','order','sort','where','filter','$gte','YYYY-MM-DD\x20HH:mm:ss','include','rows','getMyMessages','pick','ChatInteractionId','includeAgent','push','addTags','setTags','omit','Tag','color','emit','removeTags','toString','server','tmp','files','attachments','transcript-%d-%s.zip','Contact','firstName','Account','mkdirSync','Chat','Owner','N.A.','closedAt','browserName','osName','customerPort','tail','createWriteStream','lastName','value','views','downloadInteraction.ejs','.pdf','createPdfFromHTML','err','unlinkSync','zip-dir','request-promise','bluebird','mustache','util','path','ejs','ioredis','../../components/parsers/qs','../../components/export/pdf','../../config/logger','../../config/environment','redis','localhost','./chatInteraction.socket','register','jayson/promise','client','http','request','then','ChatInteraction,\x20%s,\x20%s','request\x20sent','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','info','message','catch','status','json','offset','undefined','limit','count','set','Content-Range','destroy','sendStatus','stack','name','merge','body','contact','agent','interaction','account','map','ChatInteraction','type','findAll','chat','query','show','model','rawAttributes','keys','filters','intersection','fields','attributes','includeAll','options','find','create','update','params','describe','findOne','ChatWebsiteId','vidaooApiKey','vidaooEscalation','vidaooMetadata','user','fullname','https://api-vidaoo.xcally.com/api/v1/meetings','email','vidaooNote','follow','isNull','parse','Sequelize','Error\x20in\x20Vidaoo\x20configuration','join_url','out','ChatMessage','ValidationError','Unable\x20to\x20create\x20Vidaoo\x20session'];(function(_0x4716ad,_0x43e86a){var _0x5f50ba=function(_0x107e7f){while(--_0x107e7f){_0x4716ad['push'](_0x4716ad['shift']());}};_0x5f50ba(++_0x43e86a);}(_0x5316,0x6c));var _0x6531=function(_0xdb47d8,_0x933e5b){_0xdb47d8=_0xdb47d8-0x0;var _0x5cdfd9=_0x5316[_0xdb47d8];return _0x5cdfd9;};'use strict';var rimraf=require('rimraf');var zipdir=require(_0x6531('0x0'));var rp=require(_0x6531('0x1'));var moment=require('moment');var BPromise=require(_0x6531('0x2'));var Mustache=require(_0x6531('0x3'));var util=require(_0x6531('0x4'));var path=require(_0x6531('0x5'));var ejs=require(_0x6531('0x6'));var fs=require('fs');var _=require('lodash');var Redis=require(_0x6531('0x7'));var interaction=require('../../components/interaction/service');var qs=require(_0x6531('0x8'));var pdf=require(_0x6531('0x9'));var logger=require(_0x6531('0xa'))('api');var config=require(_0x6531('0xb'));var db=require('../../mysqldb')['db'];config[_0x6531('0xc')]=_['defaults'](config[_0x6531('0xc')],{'host':_0x6531('0xd'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x6531('0xc')]));require(_0x6531('0xe'))[_0x6531('0xf')](socket);var jayson=require(_0x6531('0x10'));var client=jayson[_0x6531('0x11')][_0x6531('0x12')]({'port':0x232b});var client9004=jayson[_0x6531('0x11')][_0x6531('0x12')]({'port':0x232c});function respondWithRpcPromise(_0x4ef17b,_0x5994c5,_0x4ce8dc,_0x4f3d96){return new BPromise(function(_0x15694c,_0x47d6dc){var _0x330754=_0x4f3d96||client;return _0x330754[_0x6531('0x13')](_0x4ef17b,_0x4ce8dc)[_0x6531('0x14')](function(_0x2859af){logger['info'](_0x6531('0x15'),_0x5994c5,_0x6531('0x16'));logger[_0x6531('0x17')](_0x6531('0x18'),_0x5994c5,'request\x20sent',JSON[_0x6531('0x19')](_0x2859af));if(_0x2859af[_0x6531('0x1a')]){if(_0x2859af[_0x6531('0x1a')][_0x6531('0x1b')]===0x1f4){logger['error'](_0x6531('0x15'),_0x5994c5,_0x2859af[_0x6531('0x1a')]['message']);return _0x47d6dc(_0x2859af['error']['message']);}logger['error'](_0x6531('0x15'),_0x5994c5,_0x2859af[_0x6531('0x1a')]['message']);return _0x15694c(_0x2859af[_0x6531('0x1a')]['message']);}else{logger[_0x6531('0x1c')](_0x6531('0x15'),_0x5994c5,'request\x20sent');_0x15694c(_0x2859af['result'][_0x6531('0x1d')]);}})[_0x6531('0x1e')](function(_0x4049fc){logger[_0x6531('0x1a')](_0x6531('0x15'),_0x5994c5,_0x4049fc);_0x47d6dc(_0x4049fc);});});}function respondWithStatusCode(_0x282af1,_0xef9308){_0xef9308=_0xef9308||0xcc;return function(_0xe5c47c){if(_0xe5c47c){return _0x282af1['sendStatus'](_0xef9308);}return _0x282af1[_0x6531('0x1f')](_0xef9308)['end']();};}function respondWithResult(_0x34184a,_0xf9dab9){_0xf9dab9=_0xf9dab9||0xc8;return function(_0x322a97){if(_0x322a97){return _0x34184a[_0x6531('0x1f')](_0xf9dab9)[_0x6531('0x20')](_0x322a97);}};}function respondWithFilteredResult(_0x3e9c40,_0x43eed9){return function(_0x5a3767){if(_0x5a3767){var _0x347950=typeof _0x43eed9[_0x6531('0x21')]===_0x6531('0x22')&&typeof _0x43eed9[_0x6531('0x23')]===_0x6531('0x22');var _0x317652=_0x5a3767['count'];var _0x417368=_0x347950?0x0:_0x43eed9[_0x6531('0x21')];var _0x2056e2=_0x347950?_0x5a3767[_0x6531('0x24')]:_0x43eed9['offset']+_0x43eed9['limit'];var _0x1415d0;if(_0x2056e2>=_0x317652){_0x2056e2=_0x317652;_0x1415d0=0xc8;}else{_0x1415d0=0xce;}_0x3e9c40['status'](_0x1415d0);return _0x3e9c40[_0x6531('0x25')](_0x6531('0x26'),_0x417368+'-'+_0x2056e2+'/'+_0x317652)[_0x6531('0x20')](_0x5a3767);}return null;};}function saveUpdates(_0x55951e){return function(_0x40d72f){if(_0x40d72f){return _0x40d72f['update'](_0x55951e)[_0x6531('0x14')](function(_0x1659d5){return _0x1659d5;});}return null;};}function removeEntity(_0x59bdaa){return function(_0x3d7c86){if(_0x3d7c86){return _0x3d7c86[_0x6531('0x27')]()[_0x6531('0x14')](function(){_0x59bdaa[_0x6531('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2bec87){return function(_0x3a8097){if(!_0x3a8097){_0x2bec87[_0x6531('0x28')](0x194);}return _0x3a8097;};}function handleError(_0x8713ee,_0x4127c1){_0x4127c1=_0x4127c1||0x1f4;return function(_0x16d7ab){logger['error'](_0x16d7ab[_0x6531('0x29')]);if(_0x16d7ab['name']){delete _0x16d7ab[_0x6531('0x2a')];}_0x8713ee[_0x6531('0x1f')](_0x4127c1)['send'](_0x16d7ab);};}function getMustacheRender(_0x41e0a3,_0x67ed4){return Mustache['render'](_0x41e0a3,_[_0x6531('0x2b')](_0x67ed4[_0x6531('0x2c')],{'contact':_0x67ed4[_0x6531('0x2d')],'message':_0x67ed4[_0x6531('0x1d')],'agent':_0x67ed4[_0x6531('0x2e')],'interaction':_0x67ed4[_0x6531('0x2f')],'account':_0x67ed4[_0x6531('0x30')]}))||'';}exports['index']=function(_0x42a8e2,_0x40627d){var _0x5b1959={};var _0x36089e=_[_0x6531('0x31')](db[_0x6531('0x32')]['rawAttributes'],function(_0x3a81cc){return{'name':_0x3a81cc['fieldName'],'type':_0x3a81cc[_0x6531('0x33')]['key']};});_0x5b1959=qs['getOptions'](_0x36089e,_0x42a8e2);return interaction[_0x6531('0x34')](_0x6531('0x35'),_0x42a8e2[_0x6531('0x36')],_0x42a8e2['user'],_0x5b1959,_0x36089e)['then'](respondWithFilteredResult(_0x40627d,_0x5b1959))[_0x6531('0x1e')](handleError(_0x40627d,null));};exports[_0x6531('0x37')]=function(_0x4fcb7a,_0x4eb7fd){var _0x2d3db4={'raw':![],'where':{'id':_0x4fcb7a['params']['id']}},_0x2e8058={};_0x2e8058[_0x6531('0x38')]=_['keys'](db[_0x6531('0x32')][_0x6531('0x39')]);_0x2e8058[_0x6531('0x36')]=_[_0x6531('0x3a')](_0x4fcb7a[_0x6531('0x36')]);_0x2e8058[_0x6531('0x3b')]=_[_0x6531('0x3c')](_0x2e8058[_0x6531('0x38')],_0x2e8058['query']);_0x2d3db4['attributes']=_[_0x6531('0x3c')](_0x2e8058[_0x6531('0x38')],qs[_0x6531('0x3d')](_0x4fcb7a[_0x6531('0x36')][_0x6531('0x3d')]));_0x2d3db4['attributes']=_0x2d3db4[_0x6531('0x3e')]['length']?_0x2d3db4[_0x6531('0x3e')]:_0x2e8058[_0x6531('0x38')];if(_0x4fcb7a['query'][_0x6531('0x3f')]){_0x2d3db4['include']=[{'all':!![]}];}_0x2d3db4=_[_0x6531('0x2b')]({},_0x2d3db4,_0x4fcb7a[_0x6531('0x40')]);return db[_0x6531('0x32')][_0x6531('0x41')](_0x2d3db4)['then'](handleEntityNotFound(_0x4eb7fd,null))[_0x6531('0x14')](respondWithResult(_0x4eb7fd,null))['catch'](handleError(_0x4eb7fd,null));};exports[_0x6531('0x42')]=function(_0xa5ab28,_0x2139b5){return db[_0x6531('0x32')][_0x6531('0x42')](_0xa5ab28[_0x6531('0x2c')],{})[_0x6531('0x14')](respondWithResult(_0x2139b5,0xc9))['catch'](handleError(_0x2139b5,null));};exports[_0x6531('0x43')]=function(_0x1799c1,_0x270687){if(_0x1799c1[_0x6531('0x2c')]['id']){delete _0x1799c1['body']['id'];}return db['ChatInteraction'][_0x6531('0x41')]({'where':{'id':_0x1799c1['params']['id']}})[_0x6531('0x14')](handleEntityNotFound(_0x270687,null))['then'](saveUpdates(_0x1799c1[_0x6531('0x2c')],null))['then'](respondWithResult(_0x270687,null))[_0x6531('0x1e')](handleError(_0x270687,null));};exports['destroy']=function(_0x39c149,_0x3f38ae){return db['ChatInteraction']['find']({'where':{'id':_0x39c149[_0x6531('0x44')]['id']}})[_0x6531('0x14')](handleEntityNotFound(_0x3f38ae,null))[_0x6531('0x14')](removeEntity(_0x3f38ae,null))[_0x6531('0x1e')](handleError(_0x3f38ae,null));};exports[_0x6531('0x45')]=function(_0x51045b,_0x18e720){return db[_0x6531('0x32')]['describe']()['then'](respondWithResult(_0x18e720,null))[_0x6531('0x1e')](handleError(_0x18e720,null));};exports['createVidaooSession']=function(_0x1b54df,_0x4613e0){var _0x569a75=_0x1b54df['params']['id'];var _0x14b874;var _0x1133d7;var _0x280546;return db['ChatInteraction'][_0x6531('0x46')]({'where':{'id':_0x569a75}})[_0x6531('0x14')](function(_0x53908d){_0x14b874=_0x53908d;return db['ChatWebsite']['findOne']({'where':{'id':_0x53908d[_0x6531('0x47')]},'attributes':['id',_0x6531('0x48'),_0x6531('0x49'),'vidaooTopic','vidaooNote',_0x6531('0x4a')],'raw':!![]});})[_0x6531('0x14')](function(_0x5320f3){if(_0x5320f3&&_0x5320f3[_0x6531('0x48')]&&_0x5320f3['vidaooEscalation']){_0x1133d7=_0x5320f3;var _0x1ed396={'interaction':{'id':_0x569a75},'agent':{'id':_0x1b54df[_0x6531('0x4b')]['id'],'name':_0x1b54df[_0x6531('0x4b')]['name'],'fullname':_0x1b54df[_0x6531('0x4b')][_0x6531('0x4c')],'email':_0x1b54df['user']['email']},'contact':_0x1b54df[_0x6531('0x2c')][_0x6531('0x2d')],'account':_0x1b54df[_0x6531('0x2c')]['account']};var _0x1e3d5d={'rejectUnauthorized':![],'method':'POST','url':_0x6531('0x4d'),'headers':{'X-APIKEY':_0x5320f3[_0x6531('0x48')]},'body':{'duration':null,'scheduledAt':null,'participants':[_0x1b54df[_0x6531('0x4b')][_0x6531('0x4e')]],'buttons':null,'topic':_0x1133d7['vidaooTopic'],'note':_['isNull'](_0x1133d7[_0x6531('0x4f')])?null:getMustacheRender(_0x1133d7[_0x6531('0x4f')],_0x1ed396),'metadata':null},'redirect':_0x6531('0x50'),'json':!![]};try{if(!_[_0x6531('0x51')](_0x1133d7[_0x6531('0x4a')])){var _0x4e675a=getMustacheRender(_0x1133d7[_0x6531('0x4a')],_0x1ed396);var _0x2a3f15=JSON[_0x6531('0x52')](_0x4e675a);_0x1e3d5d[_0x6531('0x2c')]['metadata']=_0x2a3f15;}}catch(_0x4aa15b){throw new db[(_0x6531('0x53'))]['ValidationError']('Error\x20in\x20conversion\x20vidaooMetadata');}return rp(_0x1e3d5d);}else{throw new db[(_0x6531('0x53'))]['ValidationError'](_0x6531('0x54'));}})[_0x6531('0x14')](function(_0xd365d7){_0x280546=_0xd365d7;if(_0x280546['id']){var _0x59e605={'body':_0x280546[_0x6531('0x55')],'ChatWebsiteId':_0x1133d7['id'],'ChatInteractionId':_0x14b874['id'],'direction':_0x6531('0x56'),'UserId':_0x1b54df[_0x6531('0x4b')]['id']};return db[_0x6531('0x57')][_0x6531('0x42')](_0x59e605,{});}else{throw new db['Sequelize'][(_0x6531('0x58'))](_0x6531('0x59'));}})[_0x6531('0x14')](function(){return _0x14b874[_0x6531('0x5a')]({'vidaooSessionId':_0x280546['id']});})[_0x6531('0x14')](respondWithResult(_0x4613e0,null))[_0x6531('0x1e')](handleError(_0x4613e0,null));};exports[_0x6531('0x5b')]=function(_0x167f7d,_0x35b530){if(_0x167f7d[_0x6531('0x2c')]['id']){delete _0x167f7d[_0x6531('0x2c')]['id'];}return db[_0x6531('0x32')][_0x6531('0x41')]({'where':{'id':_0x167f7d[_0x6531('0x44')]['id']},'include':[{'model':db[_0x6531('0x5c')],'as':'Contact'}]})[_0x6531('0x14')](handleEntityNotFound(_0x35b530,null))[_0x6531('0x14')](saveUpdates(_0x167f7d[_0x6531('0x2c')],null))[_0x6531('0x14')](respondWithResult(_0x35b530,null))[_0x6531('0x1e')](handleError(_0x35b530,null));};exports[_0x6531('0x5d')]=function(_0x378d11,_0xd9e9d9){if(_0x378d11[_0x6531('0x2c')]['id']){delete _0x378d11[_0x6531('0x2c')]['id'];}return db[_0x6531('0x32')][_0x6531('0x41')]({'where':{'id':_0x378d11['params']['id']}})[_0x6531('0x14')](function(_0x281fa4){if(!_0x281fa4){logger[_0x6531('0x1a')]('abandonInteraction,\x20%s,\x20%s,\x20%s',_0x6531('0x5d'),0x194,'entity\x20not\x20found');_0xd9e9d9[_0x6531('0x28')](0x194);}else{if(_0x281fa4[_0x6531('0x5e')]){throw new db[(_0x6531('0x53'))][(_0x6531('0x58'))](_0x6531('0x5f'));}}return _0x281fa4;})[_0x6531('0x14')](function(_0x2ea28e){if(_0x2ea28e){return _0x2ea28e[_0x6531('0x43')]({'closed':_0x378d11[_0x6531('0x2c')][_0x6531('0x60')],'disposition':_0x378d11[_0x6531('0x2c')][_0x6531('0x61')]})[_0x6531('0x14')](function(_0x10b046){return _0x10b046;});}})[_0x6531('0x14')](function(){return respondWithRpcPromise(_0x6531('0x62'),'abandon',_0x378d11[_0x6531('0x2c')],client9004);})[_0x6531('0x14')](respondWithResult(_0xd9e9d9,null))[_0x6531('0x1e')](handleError(_0xd9e9d9,null));};exports['attachmentUpload']=function(_0x512fc4,_0x13450d){_0x512fc4[_0x6531('0x2c')][_0x6531('0x2a')]=_0x512fc4['file']['originalname'];_0x512fc4['body'][_0x6531('0x63')]=_0x512fc4['file'][_0x6531('0x64')];_0x512fc4[_0x6531('0x2c')][_0x6531('0x33')]=_0x512fc4[_0x6531('0x65')][_0x6531('0x66')];return db[_0x6531('0x67')]['create'](_0x512fc4[_0x6531('0x2c')])['then'](respondWithResult(_0x13450d,0xc9))[_0x6531('0x1e')](handleError(_0x13450d,null));};exports['attachmentDownload']=function(_0x17b5ff,_0x2544c7){return db[_0x6531('0x32')][_0x6531('0x46')]({'where':{'id':_0x17b5ff[_0x6531('0x44')]['id']},'raw':!![]})[_0x6531('0x14')](handleEntityNotFound(_0x2544c7,null))[_0x6531('0x14')](function(_0x3ad9a7){if(_0x3ad9a7){if(_0x3ad9a7['closed']){return _0x2544c7[_0x6531('0x1f')](0x193)[_0x6531('0x20')]({'status':0x193,'message':'Unauthorized'});}return db[_0x6531('0x67')][_0x6531('0x46')]({'where':{'id':_0x17b5ff[_0x6531('0x36')][_0x6531('0x68')]},'raw':!![]})['then'](handleEntityNotFound(_0x2544c7,null));}})[_0x6531('0x14')](function(_0x29de44){if(_0x29de44){var _0x2d717c=_0x29de44['ChatOfflineMessageId']!==null;var _0x529826=path[_0x6531('0x69')](config['root'],'server/files/attachments/');if(_0x2d717c){_0x529826=path['join'](_0x529826,_0x6531('0x6a'));}var _0x5b769d=path[_0x6531('0x69')](_0x529826,_0x29de44[_0x6531('0x63')]);return _0x2544c7[_0x6531('0x6b')](_0x5b769d);}})[_0x6531('0x1e')](handleError(_0x2544c7,null));};exports[_0x6531('0x6c')]=function(_0x2abb1c,_0x3125ba){var _0x522967=null;var _0xba7c11=null;var _0x2c6b75=null;if(_0x2abb1c[_0x6531('0x2c')]['id']){delete _0x2abb1c[_0x6531('0x2c')]['id'];}if(_0x2abb1c[_0x6531('0x2c')]['mailTranscript']){_0x2c6b75=path[_0x6531('0x69')](config[_0x6531('0x6d')],_0x6531('0x6e'),util[_0x6531('0x6f')](_0x6531('0x70'),Date[_0x6531('0x71')]()));_0x2abb1c[_0x6531('0x2c')][_0x6531('0x72')]=_0x2c6b75;}return db[_0x6531('0x32')][_0x6531('0x41')]({'where':{'id':_0x2abb1c[_0x6531('0x44')]['id']},'include':[{'model':db[_0x6531('0x57')],'as':_0x6531('0x73'),'include':[{'model':db[_0x6531('0x74')],'as':'User'}]}]})[_0x6531('0x14')](handleEntityNotFound(_0x3125ba,null))['then'](saveUpdates(_0x2abb1c[_0x6531('0x2c')],null))[_0x6531('0x14')](function(_0x3f7ad2){if(_0x3f7ad2){_0x522967=_0x3f7ad2;return db[_0x6531('0x75')][_0x6531('0x41')]({'where':{'id':_0x522967[_0x6531('0x47')]}});}})['then'](function(_0x1b0ec7){if(_0x1b0ec7){_0xba7c11=_0x1b0ec7;return db['CmContact'][_0x6531('0x41')]({'where':{'id':_0x522967[_0x6531('0x76')]}});}})[_0x6531('0x14')](function(_0x5e7c2c){if(_0x5e7c2c){if(_0x2c6b75){var _0x3dc904=null;for(var _0xb2e2e8=0x1;_0xb2e2e8<_0x522967['Messages'][_0x6531('0x77')];++_0xb2e2e8){_0x3dc904=_0x522967['Messages'][_0xb2e2e8];var _0x5c4fa3=_0x3dc904[_0x6531('0x5e')]?util[_0x6531('0x6f')]('%s%d',_0xba7c11['agentAlias'],_0x3dc904['UserId']):_0x6531('0x78');var _0x25c9b1=_0x2abb1c[_0x6531('0x2c')][_0x6531('0x79')]||util['format']('%s%d',_0x6531('0x7a'),_0x3dc904[_0x6531('0x76')]);switch(_0xba7c11[_0x6531('0x7b')]){case _0x6531('0x7c'):_0x5c4fa3=_0x3dc904['UserId']?util[_0x6531('0x6f')](_0x6531('0x7d'),_0xba7c11[_0x6531('0x7e')],_0x3dc904[_0x6531('0x5e')]):_0x6531('0x78');break;case _0x6531('0x7f'):_0x5c4fa3=_0x3dc904[_0x6531('0x5e')]?_0x3dc904[_0x6531('0x74')][_0x6531('0x80')]||_0x3dc904[_0x6531('0x74')][_0x6531('0x4c')]:'System';break;case _0x6531('0x81'):_0x5c4fa3=_0x3dc904['UserId']?_0x3dc904[_0x6531('0x74')][_0x6531('0x4c')]:_0x6531('0x78');break;default:_0x5c4fa3=_0x3dc904['UserId']?util[_0x6531('0x6f')](_0x6531('0x7d'),_0xba7c11[_0x6531('0x7e')],_0x3dc904[_0x6531('0x5e')]):'System';}var _0xfe2a7f=util[_0x6531('0x6f')](_0x6531('0x82'),moment(_0x3dc904[_0x6531('0x83')])[_0x6531('0x6f')](_0x6531('0x84')),_0x3dc904[_0x6531('0x85')]==='in'?_0x25c9b1:_0x5c4fa3,_0x3dc904[_0x6531('0x2c')]);if(!_0x3dc904[_0x6531('0x86')]){fs[_0x6531('0x87')](_0x2c6b75,_0xfe2a7f);}}return db[_0x6531('0x88')]['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x6531('0x89')],'as':_0x6531('0x8a'),'raw':!![],'include':[{'model':db[_0x6531('0x8b')],'as':_0x6531('0x8b'),'raw':!![]}]}]});}}})[_0x6531('0x14')](function(_0x107c18){if(!_0x107c18||!_0x107c18[_0x6531('0x8a')]||!_0x2abb1c[_0x6531('0x2c')])return _0x522967;var _0x47c286=_0x107c18[_0x6531('0x8c')]();return respondWithRpcPromise(_0x6531('0x8d'),_0x6531('0x8e'),{'account':_0x47c286,'message':{'from':util[_0x6531('0x6f')](_0x6531('0x8f'),_0x107c18[_0x6531('0x2a')],_0x107c18[_0x6531('0x4e')]||_0x107c18[_0x6531('0x8a')]['user']),'to':_0x2abb1c[_0x6531('0x2c')][_0x6531('0x90')],'subject':_0x6531('0x91'),'text':util[_0x6531('0x6f')](_0x6531('0x92'),_0x2abb1c['body']['mailTranscript']),'attachments':[{'path':_0x2c6b75}]}})[_0x6531('0x14')](function(){return _0x522967;})[_0x6531('0x1e')](function(_0x48a0b5){logger[_0x6531('0x1a')](_0x48a0b5);});})[_0x6531('0x14')](respondWithStatusCode(_0x3125ba,0xc8))[_0x6531('0x1e')](handleError(_0x3125ba,null));};exports[_0x6531('0x93')]=function(_0x64e56e,_0x321ea0){return db['ChatMessage'][_0x6531('0x41')]({'where':{'id':_0x64e56e[_0x6531('0x44')]['id']}})[_0x6531('0x14')](handleEntityNotFound(_0x321ea0,null))['then'](function(_0x184e7f){if(_0x184e7f){return _0x184e7f['addMessage'](_0x64e56e['body'][_0x6531('0x94')],_['omit'](_0x64e56e[_0x6531('0x2c')],[_0x6531('0x94'),'id'])||{});}})[_0x6531('0x14')](respondWithResult(_0x321ea0,null))[_0x6531('0x1e')](handleError(_0x321ea0,null));};exports[_0x6531('0x95')]=function(_0x549459,_0x35c7cd){var _0x1db446={'raw':![],'where':{}};var _0x2c5d23={};var _0x819075={'count':0x0,'rows':[]};return db[_0x6531('0x32')][_0x6531('0x46')]({'where':{'id':_0x549459[_0x6531('0x44')]['id']}})[_0x6531('0x14')](handleEntityNotFound(_0x35c7cd,null))[_0x6531('0x14')](function(_0x543a92){if(_0x543a92){_0x2c5d23[_0x6531('0x38')]=_[_0x6531('0x3a')](db[_0x6531('0x57')][_0x6531('0x39')]);_0x2c5d23['query']=_['keys'](_0x549459[_0x6531('0x36')]);_0x2c5d23['filters']=_[_0x6531('0x3c')](_0x2c5d23['model'],_0x2c5d23[_0x6531('0x36')]);_0x1db446[_0x6531('0x3e')]=_[_0x6531('0x3c')](_0x2c5d23[_0x6531('0x38')],qs[_0x6531('0x3d')](_0x549459[_0x6531('0x36')][_0x6531('0x3d')]));_0x1db446['attributes']=_0x1db446[_0x6531('0x3e')]['length']?_0x1db446[_0x6531('0x3e')]:_0x2c5d23[_0x6531('0x38')];if(!_0x549459[_0x6531('0x36')]['hasOwnProperty'](_0x6531('0x96'))){_0x1db446['limit']=qs[_0x6531('0x23')](_0x549459[_0x6531('0x36')][_0x6531('0x23')]);_0x1db446[_0x6531('0x21')]=qs[_0x6531('0x21')](_0x549459[_0x6531('0x36')]['offset']);}_0x1db446[_0x6531('0x97')]=qs[_0x6531('0x98')](_0x549459[_0x6531('0x36')]['sort']);_0x1db446[_0x6531('0x99')]=qs[_0x6531('0x3b')](_['pick'](_0x549459[_0x6531('0x36')],_0x2c5d23['filters']));_0x1db446['where']['ChatInteractionId']=_0x543a92['id'];if(_0x549459[_0x6531('0x36')][_0x6531('0x9a')]){_0x1db446['where']=_[_0x6531('0x2b')](_0x1db446['where'],{'$or':_[_0x6531('0x31')](_0x1db446['attributes'],function(_0x384a4e){var _0x4df2f1={};_0x4df2f1[_0x384a4e]={'$like':'%'+_0x549459[_0x6531('0x36')][_0x6531('0x9a')]+'%'};return _0x4df2f1;})});}if(_0x549459['query'][_0x6531('0x9b')]){var _0x2af11a=_0x549459[_0x6531('0x36')][_0x6531('0x9b')]['split'](',');var _0x396b88={};_0x396b88[_0x2af11a[0x0]]={'$gte':moment(_0x2af11a[0x1])[_0x6531('0x6f')](_0x6531('0x9c'))};_0x1db446[_0x6531('0x99')]=_['merge'](_0x1db446['where'],_0x396b88);}_0x1db446=_[_0x6531('0x2b')]({},_0x1db446,_0x549459[_0x6531('0x40')]);return db[_0x6531('0x57')][_0x6531('0x24')]({'where':_0x1db446[_0x6531('0x99')]})[_0x6531('0x14')](function(_0x109c5b){_0x819075[_0x6531('0x24')]=_0x109c5b;if(_0x549459[_0x6531('0x36')]['includeAll']){_0x1db446[_0x6531('0x9d')]=[{'all':!![]}];}return db[_0x6531('0x57')][_0x6531('0x34')](_0x1db446);})[_0x6531('0x14')](function(_0x1e4b23){_0x819075[_0x6531('0x9e')]=_0x1e4b23;return _0x819075;});}})[_0x6531('0x14')](respondWithFilteredResult(_0x35c7cd,_0x1db446))[_0x6531('0x1e')](handleError(_0x35c7cd,null));};exports[_0x6531('0x9f')]=function(_0x3c88a4,_0x298b44){var _0x251d8d={'where':{}},_0x4b068d={},_0x339496={'count':0x0,'rows':[]};return db['ChatInteraction'][_0x6531('0x46')]({'where':{'id':_0x3c88a4[_0x6531('0x44')]['id']}})[_0x6531('0x14')](handleEntityNotFound(_0x298b44,null))[_0x6531('0x14')](function(_0x514024){if(_0x514024){_0x4b068d[_0x6531('0x38')]=_['keys'](db[_0x6531('0x57')][_0x6531('0x39')]);_0x4b068d['query']=_[_0x6531('0x3a')](_0x3c88a4[_0x6531('0x36')]);_0x4b068d[_0x6531('0x3b')]=_['intersection'](_0x4b068d[_0x6531('0x38')],_0x4b068d['query']);_0x251d8d[_0x6531('0x3e')]=_[_0x6531('0x3c')](_0x4b068d[_0x6531('0x38')],qs[_0x6531('0x3d')](_0x3c88a4[_0x6531('0x36')][_0x6531('0x3d')]));_0x251d8d[_0x6531('0x3e')]=_0x251d8d[_0x6531('0x3e')][_0x6531('0x77')]?_0x251d8d[_0x6531('0x3e')]:_0x4b068d['model'];if(!_0x3c88a4['query']['hasOwnProperty'](_0x6531('0x96'))){_0x251d8d[_0x6531('0x23')]=qs[_0x6531('0x23')](_0x3c88a4[_0x6531('0x36')]['limit']);_0x251d8d[_0x6531('0x21')]=qs[_0x6531('0x21')](_0x3c88a4['query'][_0x6531('0x21')]);}_0x251d8d[_0x6531('0x97')]=qs[_0x6531('0x98')](_0x3c88a4[_0x6531('0x36')][_0x6531('0x98')]);_0x251d8d['where']=qs['filters'](_[_0x6531('0xa0')](_0x3c88a4[_0x6531('0x36')],_0x4b068d[_0x6531('0x3b')]));_0x251d8d[_0x6531('0x99')][_0x6531('0xa1')]=_0x514024['id'];if(_0x3c88a4[_0x6531('0x36')][_0x6531('0x9a')]){_0x251d8d[_0x6531('0x99')]=_[_0x6531('0x2b')](_0x251d8d[_0x6531('0x99')],{'$or':_[_0x6531('0x31')](_0x251d8d[_0x6531('0x3e')],function(_0x2fb1c8){var _0x5c8501={};_0x5c8501[_0x2fb1c8]={'$like':'%'+_0x3c88a4['query']['filter']+'%'};return _0x5c8501;})});}_0x251d8d[_0x6531('0x99')][_0x6531('0x86')]=![];if(_0x3c88a4['query']['id']){_0x251d8d['where']['id']={'$gt':_0x3c88a4[_0x6531('0x36')]['id']};}_0x251d8d=_[_0x6531('0x2b')]({},_0x251d8d,_0x3c88a4['options']);return db[_0x6531('0x57')][_0x6531('0x24')]({'where':_0x251d8d['where']})[_0x6531('0x14')](function(_0x1098b4){_0x339496[_0x6531('0x24')]=_0x1098b4;_0x251d8d[_0x6531('0x9d')]=[];if(_0x3c88a4[_0x6531('0x36')][_0x6531('0xa2')]){_0x251d8d['include'][_0x6531('0xa3')]({'model':db[_0x6531('0x74')],'as':_0x6531('0x74'),'attributes':['id',_0x6531('0x4c'),'alias']});}if(_0x3c88a4['query'][_0x6531('0x3f')]){_0x251d8d[_0x6531('0x9d')]=[{'all':!![]}];}return db[_0x6531('0x57')][_0x6531('0x34')](_0x251d8d);})[_0x6531('0x14')](function(_0xe46052){_0x339496[_0x6531('0x9e')]=_0xe46052;return _0x339496;});}})['then'](respondWithFilteredResult(_0x298b44,_0x251d8d))['catch'](handleError(_0x298b44,null));};exports[_0x6531('0xa4')]=function(_0xddfa5e,_0x468725){return db[_0x6531('0x32')][_0x6531('0x41')]({'where':{'id':_0xddfa5e['params']['id']}})['then'](handleEntityNotFound(_0x468725,null))[_0x6531('0x14')](function(_0x417e3e){if(_0x417e3e){return _0x417e3e[_0x6531('0xa5')](_0xddfa5e['body'][_0x6531('0x94')],_[_0x6531('0xa6')](_0xddfa5e[_0x6531('0x2c')],[_0x6531('0x94'),'id'])||{})['spread'](function(){return db[_0x6531('0xa7')][_0x6531('0x34')]({'attributes':['id','name',_0x6531('0xa8')],'where':{'id':_0xddfa5e[_0x6531('0x2c')][_0x6531('0x94')]}});})[_0x6531('0x14')](function(_0x1249c1){socket[_0x6531('0xa9')]('chatInteractionTags:save',{'id':Number(_0xddfa5e[_0x6531('0x44')]['id']),'tags':_0x1249c1||[]});return{'id':Number(_0xddfa5e[_0x6531('0x44')]['id']),'tags':_0x1249c1||[]};});}})[_0x6531('0x14')](respondWithResult(_0x468725,null))['catch'](handleError(_0x468725,null));};exports[_0x6531('0xaa')]=function(_0x1b1ffb,_0x301e13){return db['ChatInteraction'][_0x6531('0x41')]({'where':{'id':_0x1b1ffb[_0x6531('0x44')]['id']}})[_0x6531('0x14')](handleEntityNotFound(_0x301e13,null))['then'](function(_0x424d07){if(_0x424d07){return _0x424d07[_0x6531('0xaa')](_0x1b1ffb[_0x6531('0x36')][_0x6531('0x94')]);}})[_0x6531('0x14')](respondWithStatusCode(_0x301e13,null))[_0x6531('0x1e')](handleError(_0x301e13,null));};exports[_0x6531('0x6b')]=function(_0x27d245,_0x1119b8){var _0x46a656=moment()['unix']()[_0x6531('0xab')]();var _0x577378=path[_0x6531('0x69')](config['root'],_0x6531('0xac'),'files',_0x6531('0xad'));var _0x54990a=path[_0x6531('0x69')](config['root'],_0x6531('0xac'),_0x6531('0xae'),_0x6531('0xaf'));var _0x392deb=path[_0x6531('0x69')](_0x577378,_0x46a656);var _0x1cc140=util['format'](_0x6531('0xb0'),_0x27d245[_0x6531('0x44')]['id'],_0x46a656);var _0x3b8843=path[_0x6531('0x69')](_0x577378,_0x1cc140);var _0x5afa77=[];_0x5afa77[_0x6531('0xa3')]({'model':db[_0x6531('0x74')],'as':_0x6531('0x74'),'attributes':['id',_0x6531('0x4c')],'raw':!![]});_0x5afa77[_0x6531('0xa3')]({'model':db['CmContact'],'as':_0x6531('0xb1'),'attributes':['id',_0x6531('0xb2'),'lastName'],'raw':!![]});if(_0x27d245[_0x6531('0x36')][_0x6531('0xaf')]){_0x5afa77[_0x6531('0xa3')]({'model':db[_0x6531('0x67')],'as':'Attachment','raw':!![]});}var _0x276c0c=[{'model':db[_0x6531('0x57')],'as':_0x6531('0x73'),'attributes':['id',_0x6531('0x2c'),_0x6531('0x83'),'direction',_0x6531('0x86'),'read'],'include':_0x5afa77}];_0x276c0c[_0x6531('0xa3')]({'model':db[_0x6531('0x75')],'as':_0x6531('0xb3'),'attributes':['id',_0x6531('0x2a')]});_0x276c0c[_0x6531('0xa3')]({'model':db[_0x6531('0x74')],'as':'Owner','attributes':['id',_0x6531('0x4c')]});return db[_0x6531('0x32')][_0x6531('0x41')]({'where':{'id':_0x27d245[_0x6531('0x44')]['id']},'include':_0x276c0c})[_0x6531('0x14')](handleEntityNotFound(_0x1119b8,null))[_0x6531('0x14')](function(_0x4cd39b){if(_0x4cd39b){var _0x317531=_0x4cd39b['get']({'plain':!![]});fs[_0x6531('0xb4')](_0x392deb);var _0x3ca22a={'channel':_0x6531('0xb5'),'account':_0x317531[_0x6531('0xb3')][_0x6531('0x2a')],'agent':_0x317531[_0x6531('0xb6')]?_0x317531[_0x6531('0xb6')][_0x6531('0x4c')]:_0x6531('0xb7'),'createdAt':moment(_0x317531[_0x6531('0x83')])[_0x6531('0x6f')](_0x6531('0x9c'))[_0x6531('0xab')](),'closedAt':_0x317531[_0x6531('0x60')]?moment(_0x317531[_0x6531('0xb8')])['format'](_0x6531('0x9c'))[_0x6531('0xab')]():'','disposition':_0x317531[_0x6531('0x61')],'chatInfo':{'browser':_0x317531[_0x6531('0xb9')],'os':_0x317531[_0x6531('0xba')],'referer':_0x317531['referer'],'customerIp':_0x317531['customerIp'],'customerPort':_0x317531[_0x6531('0xbb')]?_0x317531[_0x6531('0xbb')]:_0x6531('0xb7')},'messages':_(_0x317531[_0x6531('0x73')])[_0x6531('0xbc')]()['filter']({'secret':![]})[_0x6531('0x31')](function(_0x5e3222){if(_0x5e3222[_0x6531('0x67')]){var _0x7f302c=path[_0x6531('0x69')](_0x54990a,_0x5e3222[_0x6531('0x67')][_0x6531('0x63')]);if(fs['existsSync'](_0x7f302c)){fs['createReadStream'](_0x7f302c)['pipe'](fs[_0x6531('0xbd')](path[_0x6531('0x69')](_0x392deb,_0x5e3222[_0x6531('0x67')][_0x6531('0x63')])));}}return{'date':moment(_0x5e3222['createdAt'])[_0x6531('0x6f')](_0x6531('0x9c'))[_0x6531('0xab')](),'sender':_0x5e3222[_0x6531('0x85')]===_0x6531('0x56')?_0x5e3222[_0x6531('0x74')]?_0x5e3222[_0x6531('0x74')][_0x6531('0x4c')]:_0x6531('0x78'):_0x5e3222[_0x6531('0xb1')][_0x6531('0xb2')]+(_0x5e3222[_0x6531('0xb1')][_0x6531('0xbe')]?'\x20'+_0x5e3222['Contact'][_0x6531('0xbe')]:''),'body':_0x5e3222[_0x6531('0x67')]?_0x5e3222['Attachment'][_0x6531('0x63')]:_0x5e3222[_0x6531('0x2c')],'direction':_0x5e3222[_0x6531('0x85')]===_0x6531('0x56')?'A':'C','secret':_0x5e3222[_0x6531('0x86')],'read':_0x5e3222['read'],'attachment':_0x5e3222[_0x6531('0x67')]};})[_0x6531('0xbf')]()};return ejs['renderFile'](path[_0x6531('0x69')](config[_0x6531('0x6d')],'server',_0x6531('0xc0'),_0x6531('0xc1')),{'interaction':_0x3ca22a})[_0x6531('0x14')](function(_0x5be33c){var _0x455b14=path[_0x6531('0x69')](_0x392deb,'transcript-'+_0x317531['id']+'-'+_0x46a656+_0x6531('0xc2'));var _0x10f816={'path':_0x455b14,'channel':_0x6531('0xb5'),'interactionId':_0x317531['id']};return pdf[_0x6531('0xc3')](_0x5be33c,_0x10f816);})[_0x6531('0x14')](function(){return new Promise(function(_0x29499d,_0x411eeb){zipdir(_0x392deb,{'saveTo':_0x3b8843},function(_0x540f18,_0x2e5711){if(_0x540f18)return _0x411eeb(_0x540f18);return _0x29499d(_0x2e5711);});})[_0x6531('0x14')](function(){return new BPromise(function(_0x24ab58,_0x1824c0){rimraf(_0x392deb,function(_0x228245){if(_0x228245)_0x1824c0(_0x228245);return _0x24ab58();});});})[_0x6531('0x14')](function(){return _0x1119b8[_0x6531('0x6b')](_0x3b8843,_0x1cc140,function(_0x484369){if(_0x484369){logger[_0x6531('0x1a')](_0x6531('0xc4'),_0x484369);}else{fs[_0x6531('0xc5')](_0x3b8843);}});});});}else{return _0x1119b8['sendStatus'](0xc8);}})[_0x6531('0x1e')](handleError(_0x1119b8,null));};
\ No newline at end of file