Built motion from commit f738f9592c388b9f9eb3948f400a5c9d717a3561. Version 3.0.0...
[motion-next.git] / server / api / chatInteraction / chatInteraction.controller.js
index fba9dc1..2834148 100644 (file)
@@ -1 +1 @@
-const a80_0x1944=['like','ids','UserId','AbandonInteraction','c.mobile','secure','ejs','host','replace','get','unix','port','ContactId','count','customUpdate','lastName','website_alias','ui.ChatInteractionId','expr','Tag','CmContact','Visitor','authentication','addMessage','findOne','Contact.lastName','o.id\x20=\x20i.UserId','i.id','t.id\x20IN\x20?','N.A.','destroy','fields','renderFile','u.id\x20=\x20ui.UserId','offset','includeAgent','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','basename','$substring','mkdirSync','includeAll','ChatMessage','customerIp','status','i.ChatWebsiteId\x20IN\x20?','log','file','DESC','text','referer','sqlOperator','index','`\x20=\x200','isEmpty','sort','tag','transcript-','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','util','unlinkSync','http','c.firstName','all','select','mimetype','split','rawAttributes','server','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','40px','YYYY-MM-DD\x20HH:mm:ss','code','./chatInteraction.socket','filters','ChatWebsiteId','Tags','parseSearch','downloadInteraction.html','moment','lodash','journey','createReadStream','30px','update','`unreadMessages`\x20=\x200','conditions','closedAt','close','limit','client','$gte','abandonInteraction,\x20%s,\x20%s,\x20%s','keyBy','unreadMessages','secret','removeTags','closed','groupBy','getChatWebsites','intersection','\x20=\x20?','clone','Contact','Owner.internal','start','$lte','../../config/logger','omit','root','MM/DD/YYYY\x20HH:mm:ss','tail','end','key','user','chat_websites','params','result','attributes','format','vidaooApiKey','Account','keys','include','transcript-%s.txt','o.internal','createWriteStream','ChatInteractionId','attachmentDownload','setTags','Interaction\x20already\x20assigned','api','cm_contacts','send','getMessages','pass','fullname','Contact.firstName','group','Messages','Attachment','concat','field','i.*','type','a.id\x20=\x20i.ChatWebsiteId','me.ChatInteractionId\x20=\x20i.id','out','../../components/parsers/advancedSearch','server/files/chat/upload/','c.fax','service','addTags','error','MotionCWB:','buildExpression','ChatInteraction','describe','MailAccount','Owner','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','findAll','browserName','options','chat_messages','squel','operator','from','follow','toString','email','o.fullname','undefined','customerPort','then','`unreadMessages`\x20>\x200','ui.ChatInteractionId\x20IN\x20?','users','files','createdAt','agentAlias','request\x20sent','.pdf','body','https://api-vidaoo.xcally.com/api/v1/sessions','pipe','parse','\x22%s\x22\x20<%s>','%s%d','YYYY-MM-DD','attachmentUpload','direction','stringify','Account.key','c.email','originalname','MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','join_url','compact','info','union','err','toFile','show','Account.mandatoryDisposition','sequelize','some','json','10px','catch','Content-Range','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','auth','firstName','request','search','c.lastName','ChatInteraction,\x20%s,\x20%s','osName','create','value','entity\x20not\x20found','a.key','html-pdf','Contact.mobile','u.fullname','nolimit','read','model','[%s]\x20%s:\x20%s\x0a','download','forEach','now','attachments','i.ChatWebsiteId\x20IS\x20NOT\x20NULL','ChatWebsite','length','TagIds','t.id\x20=\x20it.TagId','tools_tags','i.id\x20LIKE\x20?','createVidaooSession','merge','chat_interaction_has_tags','order','name','<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>','%s\x20#%d','filename','u.id','ChatInteraction,\x20%s,\x20%s,\x20%s','having','sendStatus','filter','query','abandon','Contact.fax','GROUP_CONCAT(DISTINCT\x20t.id)','System','i.ChatWebsiteId\x20IS\x20NULL','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','zip-dir','join','map','files/attachments/','register','color','push','\x20IS\x20NULL','rows','message','emit','isNumeric','Users','where','Smtp','User','chat_interactions','mailTranscript','alias','find','left_join','../../rediscache'];(function(_0x2337b4,_0x5f58e9){const _0x19448d=function(_0x4a11e8){while(--_0x4a11e8){_0x2337b4['push'](_0x2337b4['shift']());}};_0x19448d(++_0x5f58e9);}(a80_0x1944,0xc2));const a80_0x4a11=function(_0x2337b4,_0x5f58e9){_0x2337b4=_0x2337b4-0x180;let _0x19448d=a80_0x1944[_0x2337b4];return _0x19448d;};const a80_0x1391de=a80_0x4a11;'use strict';const pdf=require(a80_0x1391de(0x19c)),rimraf=require('rimraf'),zipdir=require(a80_0x1391de(0x1c2)),rp=require('request-promise-native'),moment=require(a80_0x1391de(0x226)),util=require(a80_0x1391de(0x212)),path=require('path'),ejs=require(a80_0x1391de(0x1de)),fs=require('fs'),_=require(a80_0x1391de(0x227)),squel=require(a80_0x1391de(0x27c)),{getSocket}=require(a80_0x1391de(0x1d7)),qs=require('../../components/parsers/qs'),as=require(a80_0x1391de(0x26b)),logger=require(a80_0x1391de(0x242))(a80_0x1391de(0x25a)),config=require('../../config/environment'),{db}=require('../../mysqldb'),{Op,ValidationError,QueryTypes}=require(a80_0x1391de(0x18a)),socket=getSocket();require(a80_0x1391de(0x220))[a80_0x1391de(0x1c6)](socket);const jayson=require('jayson/promise'),client=jayson['client'][a80_0x1391de(0x214)]({'port':0x232b}),client9004=jayson[a80_0x1391de(0x231)][a80_0x1391de(0x214)]({'port':0x232c});function respondWithRpcPromise(_0x239394,_0x155d46,_0x174c99,_0x102683){return new Promise(function(_0x2ece04,_0xb7c2e9){const _0x591bba=a80_0x4a11,_0x1388e5=_0x102683||client;return _0x1388e5[_0x591bba(0x193)](_0x239394,_0x174c99)[_0x591bba(0x285)](function(_0xf09684){const _0x456ba0=_0x591bba;logger[_0x456ba0(0x184)](_0x456ba0(0x196),_0x155d46,'request\x20sent'),logger['debug'](_0x456ba0(0x1b7),_0x155d46,_0x456ba0(0x28c),JSON[_0x456ba0(0x297)](_0xf09684));if(_0xf09684[_0x456ba0(0x270)]){if(_0xf09684[_0x456ba0(0x270)][_0x456ba0(0x21f)]===0x1f4)return logger[_0x456ba0(0x270)](_0x456ba0(0x196),_0x155d46,_0xf09684[_0x456ba0(0x270)][_0x456ba0(0x1cb)]),_0xb7c2e9(_0xf09684[_0x456ba0(0x270)][_0x456ba0(0x1cb)]);return logger[_0x456ba0(0x270)](_0x456ba0(0x196),_0x155d46,_0xf09684[_0x456ba0(0x270)][_0x456ba0(0x1cb)]),_0x2ece04(_0xf09684[_0x456ba0(0x270)]['message']);}else logger[_0x456ba0(0x184)](_0x456ba0(0x196),_0x155d46,'request\x20sent'),_0x2ece04(_0xf09684[_0x456ba0(0x24c)][_0x456ba0(0x1cb)]);})['catch'](function(_0x336a3b){const _0x259d71=_0x591bba;logger[_0x259d71(0x270)]('ChatInteraction,\x20%s,\x20%s',_0x155d46,_0x336a3b),_0xb7c2e9(_0x336a3b);});});}function respondWithStatusCode(_0xb51e86,_0xf11bd9){return _0xf11bd9=_0xf11bd9||0xcc,function(_0x304e66){const _0x5daa8b=a80_0x4a11;if(_0x304e66)return _0xb51e86[_0x5daa8b(0x1b9)](_0xf11bd9);return _0xb51e86[_0x5daa8b(0x203)](_0xf11bd9)[_0x5daa8b(0x247)]();};}function respondWithResult(_0x48e514,_0x40ac81){return _0x40ac81=_0x40ac81||0xc8,function(_0x45489c){const _0x2b2642=a80_0x4a11;if(_0x45489c)return _0x48e514[_0x2b2642(0x203)](_0x40ac81)[_0x2b2642(0x18c)](_0x45489c);};}function respondWithFilteredResult(_0x573536,_0x586e24){return function(_0x438473){const _0x566c4c=a80_0x4a11;if(_0x438473){const _0x2fe418=_0x438473[_0x566c4c(0x1e5)],_0x2fec00=_0x586e24[_0x566c4c(0x1fa)];let _0x2ddcb2=_0x586e24['offset']+_0x586e24[_0x566c4c(0x230)],_0x17e12a;return _0x2ddcb2>=_0x2fe418?(_0x2ddcb2=_0x2fe418,_0x17e12a=0xc8):_0x17e12a=0xce,_0x573536[_0x566c4c(0x203)](_0x17e12a),_0x573536['set'](_0x566c4c(0x18f),_0x2fec00+'-'+_0x2ddcb2+'/'+_0x2fe418)['json'](_0x438473);}return null;};}function saveUpdates(_0x4778dd){return function(_0xfbce69){const _0x3a60cc=a80_0x4a11;if(_0xfbce69)return _0xfbce69[_0x3a60cc(0x22b)](_0x4778dd)[_0x3a60cc(0x285)](function(_0x2749c2){return _0x2749c2;});return null;};}function removeEntity(_0x2e69a3){return function(_0x2e6fa4){const _0x2890f0=a80_0x4a11;if(_0x2e6fa4)return _0x2e6fa4[_0x2890f0(0x1f6)]()['then'](function(){const _0x1ace21=_0x2890f0;_0x2e69a3['status'](0xcc)[_0x1ace21(0x247)]();});};}function handleEntityNotFound(_0x104013){return function(_0x5d5dda){const _0x12341d=a80_0x4a11;return!_0x5d5dda&&_0x104013[_0x12341d(0x1b9)](0x194),_0x5d5dda;};}function handleError(_0x2f9059,_0x17a8b7){return _0x17a8b7=_0x17a8b7||0x1f4,function(_0x8a9721){const _0x114383=a80_0x4a11;logger[_0x114383(0x270)](_0x8a9721['stack']),_0x8a9721[_0x114383(0x1b2)]&&delete _0x8a9721[_0x114383(0x1b2)],_0x2f9059['status'](_0x17a8b7)[_0x114383(0x25c)](_0x8a9721);};}function getInteractionUsers(_0x5b384a,_0x22d0f4){return new Promise(function(_0x103e5d,_0x4686d4){const _0x41c828=a80_0x4a11;try{_0x22d0f4[_0x5b384a['id']]&&(_0x5b384a[_0x41c828(0x1ce)]=_['map'](_0x22d0f4[_0x5b384a['id']],function(_0x4c0c7a){const _0x55f03d=_0x41c828;return{'id':_0x4c0c7a['id'],'fullname':_0x4c0c7a[_0x55f03d(0x25f)]};}));}catch(_0x19774c){_0x4686d4(_0x19774c);}_0x103e5d(_0x5b384a);});}function getInteractionTags(_0x31cc71,_0xd65097){return new Promise(function(_0x70f03d,_0x51d3a0){const _0x233e29=a80_0x4a11;try{_0x31cc71[_0x233e29(0x1aa)]&&(_0x31cc71[_0x233e29(0x223)]=[],_0x31cc71[_0x233e29(0x1aa)][_0x233e29(0x219)](',')[_0x233e29(0x1a4)](function(_0x5ea0c9){const _0x3402dd=_0x233e29;_0x31cc71[_0x3402dd(0x223)][_0x3402dd(0x1c8)](_0xd65097[_0x5ea0c9]);})),delete _0x31cc71[_0x233e29(0x1aa)];}catch(_0x1aee89){_0x51d3a0(_0x1aee89);}_0x70f03d(_0x31cc71);});}function updateChatInteraction(_0x84b0d6,_0x4c8c38,_0x513511){return new Promise(function(_0x5283a9,_0x165536){const _0x5e645a=a80_0x4a11;return getInteractionUsers(_0x84b0d6,_0x513511)[_0x5e645a(0x285)](function(_0x5617f5){return getInteractionTags(_0x5617f5,_0x4c8c38);})[_0x5e645a(0x285)](function(_0x30fdd4){_0x5283a9(_0x30fdd4);})['catch'](function(_0x58c8a4){_0x165536(_0x58c8a4);});});}exports[a80_0x1391de(0x20b)]=function(_0x4151c5,_0x38a537){const _0x512058=a80_0x1391de,_0x54ed0e={},_0x368f71={},_0x53521a={'count':0x0,'rows':[]},_0x85560f=_[_0x512058(0x1c4)](db[_0x512058(0x273)]['rawAttributes'],function(_0x1d1130){const _0x538c55=_0x512058;return{'name':_0x1d1130['fieldName'],'type':_0x1d1130[_0x538c55(0x267)][_0x538c55(0x248)]};});_0x368f71[_0x512058(0x1a1)]=_['map'](_0x85560f,_0x512058(0x1b2)),_0x368f71[_0x512058(0x1bb)]=_[_0x512058(0x251)](_0x4151c5[_0x512058(0x1bb)]),_0x368f71['filters']=_[_0x512058(0x23b)](_0x368f71[_0x512058(0x1a1)],_0x368f71[_0x512058(0x1bb)]),_0x54ed0e[_0x512058(0x24d)]=_[_0x512058(0x23b)](_0x368f71[_0x512058(0x1a1)],qs[_0x512058(0x1f7)](_0x4151c5[_0x512058(0x1bb)][_0x512058(0x1f7)])),_0x54ed0e['attributes']=_0x54ed0e['attributes']['length']?_0x54ed0e[_0x512058(0x24d)]:_0x368f71['model'];typeof _0x4151c5[_0x512058(0x1bb)][_0x512058(0x19f)]==='undefined'&&(_0x54ed0e[_0x512058(0x230)]=qs[_0x512058(0x230)](_0x4151c5[_0x512058(0x1bb)]['limit']),_0x54ed0e[_0x512058(0x1fa)]=qs[_0x512058(0x1fa)](_0x4151c5[_0x512058(0x1bb)][_0x512058(0x1fa)]));_0x54ed0e[_0x512058(0x1b1)]=qs['sort'](_0x4151c5[_0x512058(0x1bb)][_0x512058(0x20e)]),_0x54ed0e[_0x512058(0x1cf)]=qs['filters'](_['pick'](_0x4151c5[_0x512058(0x1bb)],_0x368f71['filters']),_0x85560f);let _0x1804e2=[];const _0x146efd=squel[_0x512058(0x217)]()['field']('id')[_0x512058(0x265)](_0x512058(0x1b2))['field'](_0x512058(0x1c7))['from'](_0x512058(0x1ac)),_0x1110cf=squel[_0x512058(0x217)]()[_0x512058(0x265)](_0x512058(0x1b6))['field'](_0x512058(0x19e))['field'](_0x512058(0x1e9))[_0x512058(0x27e)]('user_has_chat_interactions','ui')[_0x512058(0x1d6)](_0x512058(0x288),'u',_0x512058(0x1f9)),_0x5f25ee=squel[_0x512058(0x217)]()[_0x512058(0x27e)](_0x512058(0x1d2),'i')[_0x512058(0x1d6)](_0x512058(0x25b),'c',_0x512058(0x21c))[_0x512058(0x1d6)](_0x512058(0x288),'o',_0x512058(0x1f2))[_0x512058(0x1d6)](_0x512058(0x24a),'a',_0x512058(0x268))['left_join'](_0x512058(0x27b),'me',_0x512058(0x269))[_0x512058(0x1d6)](_0x512058(0x1b0),'it','it.ChatInteractionId\x20=\x20i.id')['left_join'](_0x512058(0x1ac),'t',_0x512058(0x1ab)),_0x3f257d=squel[_0x512058(0x1ea)]();let _0x26bc8a=[];const _0x392803=squel[_0x512058(0x1ea)]();let _0x2f7e4e;if(_0x4151c5[_0x512058(0x1bb)][_0x512058(0x194)]){_0x2f7e4e=as[_0x512058(0x224)](_0x4151c5[_0x512058(0x1bb)][_0x512058(0x194)]);const _0x4fbc64=_0x2f7e4e[_0x512058(0x20a)];for(let _0x2a1ee5=0x0;_0x2a1ee5<_0x2f7e4e[_0x512058(0x22d)][_0x512058(0x1a9)];_0x2a1ee5++){const _0xbad295=_0x2f7e4e[_0x512058(0x22d)][_0x2a1ee5],_0x2a0817='i';let _0x17da48,_0x286a6f=_[_0x512058(0x1d5)](_0x85560f,[_0x512058(0x1b2),_0xbad295[_0x512058(0x265)]]);if(!_0x286a6f)switch(_0xbad295[_0x512058(0x265)]){case _0x512058(0x235):_0xbad295['value']==0x1?_0x5f25ee['having']('`'+_0xbad295[_0x512058(0x265)]+_0x512058(0x20c)):_0x5f25ee[_0x512058(0x1b8)]('`'+_0xbad295['field']+'`\x20>\x200');break;case _0x512058(0x23e):if(_0xbad295[_0x512058(0x27d)]==='$substring'){if(_0xbad295[_0x512058(0x199)][_0x512058(0x219)]('\x20')['length']>0x1)_0x3f257d[_0x4fbc64](_0x512058(0x1fc),qs['getFullTextValue'](_0xbad295[_0x512058(0x199)]),null);else{const _0x7a243c='%'+_0xbad295[_0x512058(0x199)]+'%';_0x3f257d[_0x4fbc64](_0x512058(0x277),_0x7a243c,_0x7a243c,_0x7a243c);}}else _0x286a6f=_[_0x512058(0x1d5)](_0x85560f,['name','ContactId']),_0xbad295[_0x512058(0x265)]=_0x512058(0x1e4),_0x17da48=as['buildExpression'](_0x2a0817,_0x286a6f[_0x512058(0x267)],_0xbad295),_0x3f257d[_0x4fbc64](_0x17da48[_0x512058(0x208)],_0x17da48[_0x512058(0x199)][_0x512058(0x240)],_0x17da48[_0x512058(0x199)][_0x512058(0x247)]);break;case _0x512058(0x1eb):{const _0x2d00dc=_0xbad295[_0x512058(0x199)][_0x512058(0x219)](',')[_0x512058(0x1c4)](function(_0x14df84){return Number(_0x14df84);});_0x2d00dc[_0x512058(0x1a4)](function(_0x4cce94){const _0xd2ff23=_0x512058;_0x392803['or'](_0xd2ff23(0x190),'%,'+_0x4cce94+',%');}),_0x26bc8a=_[_0x512058(0x185)](_0x26bc8a,_0x2d00dc);}break;case _0x512058(0x1d1):_0xbad295[_0x512058(0x27d)]===_0x512058(0x1fe)?_0x3f257d[_0x4fbc64](_0x512058(0x211),'%'+_0xbad295[_0x512058(0x199)]+'%',null):(_0x286a6f=_[_0x512058(0x1d5)](_0x85560f,[_0x512058(0x1b2),'UserId']),_0xbad295['field']=_0x512058(0x1da),_0x17da48=as[_0x512058(0x272)](_0x2a0817,_0x286a6f['type'],_0xbad295),_0x3f257d[_0x4fbc64](_0x17da48[_0x512058(0x208)],_0x17da48[_0x512058(0x199)]['start'],_0x17da48[_0x512058(0x199)][_0x512058(0x247)]));break;case _0x512058(0x28e):_0x17da48=as[_0x512058(0x272)]('me',null,_0xbad295),_0x3f257d[_0x4fbc64](_0x17da48[_0x512058(0x208)],_0x17da48[_0x512058(0x199)]['start'],_0x17da48[_0x512058(0x199)][_0x512058(0x247)]);break;}else _0x17da48=as[_0x512058(0x272)](_0x2a0817,_0x286a6f[_0x512058(0x267)],_0xbad295),_0x3f257d[_0x4fbc64](_0x17da48[_0x512058(0x208)],_0x17da48['value'][_0x512058(0x240)],_0x17da48[_0x512058(0x199)][_0x512058(0x247)]);}}else{const _0x1688d6=_(_0x4151c5[_0x512058(0x1bb)])[_0x512058(0x251)]()[_0x512058(0x1c4)](function(_0x3a3fde){const _0x4718c6=_0x512058;return _[_0x4718c6(0x18b)](_0x85560f,['name',_0x3a3fde])?_0x3a3fde:undefined;})[_0x512058(0x183)]()[_0x512058(0x199)]();!_[_0x512058(0x20d)](_0x1688d6)&&_0x1688d6[_0x512058(0x1a4)](function(_0x2512e2){const _0x1a3042=_0x512058;if(_0x2512e2===_0x1a3042(0x222))_0x5f25ee[_0x1a3042(0x1cf)](_0x1a3042(0x204),[][_0x1a3042(0x264)](_0x4151c5[_0x1a3042(0x1bb)][_0x2512e2]));else{if(_0x2512e2===_0x1a3042(0x28a)){const _0xc1312c=JSON['parse'](_0x4151c5['query'][_0x2512e2])['$gte'],_0x1f405b=JSON[_0x1a3042(0x291)](_0x4151c5[_0x1a3042(0x1bb)][_0x2512e2])[_0x1a3042(0x241)];_0x5f25ee[_0x1a3042(0x1cf)]('i.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0xc1312c,_0x1f405b);}else _0x4151c5[_0x1a3042(0x1bb)][_0x2512e2]==='null'?_0x5f25ee[_0x1a3042(0x1cf)]('i.'+_0x2512e2+_0x1a3042(0x1c9)):_0x5f25ee[_0x1a3042(0x1cf)]('i.'+_0x2512e2+_0x1a3042(0x23c),_0x4151c5[_0x1a3042(0x1bb)][_0x2512e2]);}});_0x4151c5['query'][_0x512058(0x1a0)]&&(_0x4151c5[_0x512058(0x1bb)][_0x512058(0x1a0)]==0x1?_0x5f25ee[_0x512058(0x1b8)](_0x512058(0x22c)):_0x5f25ee[_0x512058(0x1b8)](_0x512058(0x286)));_0x4151c5[_0x512058(0x1bb)]['tag']&&(_0x26bc8a=_['isArray'](_0x4151c5[_0x512058(0x1bb)][_0x512058(0x20f)])?_0x4151c5['query'][_0x512058(0x20f)]:new Array(_0x4151c5['query']['tag']),_0x26bc8a[_0x512058(0x1a4)](function(_0x5217f1){const _0x40a30f=_0x512058;_0x392803['or'](_0x40a30f(0x190),'%,'+_0x5217f1+',%');}));if(_0x4151c5['query']['filter']){const _0x5a0f2a=_0x4151c5[_0x512058(0x1bb)][_0x512058(0x1ba)][_0x512058(0x1e0)]('\x5c','\x5c\x5c')[_0x512058(0x1e0)](/'/g,'\x27\x27');qs[_0x512058(0x1cd)](_0x5a0f2a)?_0x3f257d['or'](_0x512058(0x1ad),_0x5a0f2a+'%'):_0x3f257d['or'](_0x512058(0x181),qs['getFullTextValue'](_0x5a0f2a))['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x5a0f2a+'%');}}_0x5f25ee[_0x512058(0x1cf)](_0x3f257d),_0x5f25ee[_0x512058(0x261)](_0x512058(0x1f3));let _0x161514={'type':QueryTypes['SELECT'],'raw':!![]};const _0x4cbac5=_0x5f25ee[_0x512058(0x23d)]();_0x4cbac5['field'](_0x512058(0x1f3)),_0x4cbac5['field'](_0x512058(0x1c1),'unreadMessages'),_0x54ed0e[_0x512058(0x1b1)]&&_0x54ed0e[_0x512058(0x1b1)][_0x512058(0x1a4)](function(_0x34a0eb){const _0x4038b1=_0x512058;_0x5f25ee[_0x4038b1(0x1b1)]('i.'+_0x34a0eb[0x0],_0x34a0eb[0x1]===_0x4038b1(0x207)?![]:!![]);}),!_[_0x512058(0x20d)](_0x26bc8a)&&(_0x5f25ee[_0x512058(0x1b8)](_0x392803),_0x4cbac5[_0x512058(0x1cf)](_0x512058(0x1f4),_0x26bc8a)),Promise['resolve']()[_0x512058(0x285)](function(){const _0x7fbdb3=_0x512058;if(!_0x2f7e4e){if(_0x4151c5[_0x7fbdb3(0x1bb)][_0x7fbdb3(0x222)]||_0x4151c5[_0x7fbdb3(0x1bb)][_0x7fbdb3(0x228)])return;_0x4cbac5[_0x7fbdb3(0x1cf)](_0x7fbdb3(0x1a7)),_0x5f25ee['where'](_0x7fbdb3(0x1a7));return;}return _0x4151c5[_0x7fbdb3(0x249)][_0x7fbdb3(0x23a)]({'attributes':['id'],'raw':!![]})['then'](function(_0x446775){const _0x206c95=_0x7fbdb3;_['isEmpty'](_0x446775)?(_0x4cbac5['where'](_0x206c95(0x1c0)),_0x5f25ee[_0x206c95(0x1cf)]('i.ChatWebsiteId\x20IS\x20NULL')):(_0x4cbac5[_0x206c95(0x1cf)](_0x206c95(0x204),_[_0x206c95(0x1c4)](_0x446775,'id')),_0x5f25ee[_0x206c95(0x1cf)](_0x206c95(0x204),_[_0x206c95(0x1c4)](_0x446775,'id')));});})['then'](function(){const _0x1b1dc1=_0x512058;db[_0x1b1dc1(0x18a)][_0x1b1dc1(0x1bb)](_0x4cbac5[_0x1b1dc1(0x280)](),_0x161514)[_0x1b1dc1(0x285)](function(_0x14cb02){const _0x406c52=_0x1b1dc1;_0x53521a[_0x406c52(0x1e5)]=_0x14cb02['length'];if(_0x53521a[_0x406c52(0x1e5)]===0x0)return[];return db[_0x406c52(0x18a)]['query'](_0x146efd['toString'](),_0x161514)[_0x406c52(0x285)](function(_0x3dc3c2){const _0x11a6e1=_0x406c52;_0x1804e2=_[_0x11a6e1(0x234)](_0x3dc3c2,'id'),_0x161514=_[_0x11a6e1(0x1af)](_0x161514,{'model':db['ChatInteraction'],'mapToModel':!![],'raw':!![],'nest':!![]});_0x4151c5[_0x11a6e1(0x1bb)][_0x11a6e1(0x1f7)]?_0x54ed0e[_0x11a6e1(0x24d)][_0x11a6e1(0x1a4)](function(_0x43f7b8){const _0x3047d6=_0x11a6e1;_0x5f25ee[_0x3047d6(0x265)]('i.'+_0x43f7b8);}):(_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x1c1),_0x11a6e1(0x235)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x19b),_0x11a6e1(0x298)),_0x5f25ee[_0x11a6e1(0x265)]('a.mandatoryDisposition',_0x11a6e1(0x189)),_0x5f25ee['field'](_0x11a6e1(0x266)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x215),_0x11a6e1(0x260)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x195),_0x11a6e1(0x1f1)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x299),'Contact.email'),_0x5f25ee[_0x11a6e1(0x265)]('c.phone','Contact.phone'),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x1dc),_0x11a6e1(0x19d)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x26d),_0x11a6e1(0x1bd)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x282),'Owner.fullname'),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x254),_0x11a6e1(0x23f)),_0x5f25ee[_0x11a6e1(0x265)](_0x11a6e1(0x1be),_0x11a6e1(0x1aa)));if(_0x54ed0e['limit'])_0x5f25ee[_0x11a6e1(0x230)](_0x54ed0e[_0x11a6e1(0x230)]);if(_0x54ed0e[_0x11a6e1(0x1fa)])_0x5f25ee[_0x11a6e1(0x1fa)](_0x54ed0e[_0x11a6e1(0x1fa)]);return db[_0x11a6e1(0x18a)][_0x11a6e1(0x1bb)](_0x5f25ee[_0x11a6e1(0x280)](),_0x161514);})[_0x406c52(0x285)](function(_0x270a9a){const _0x14299d=_0x406c52;return _0x1110cf[_0x14299d(0x1cf)](_0x14299d(0x287),_[_0x14299d(0x1c4)](_0x270a9a,'id')),db[_0x14299d(0x18a)][_0x14299d(0x1bb)](_0x1110cf[_0x14299d(0x280)](),_0x161514)[_0x14299d(0x285)](function(_0x1bcd94){const _0xab0be9=_0x14299d,_0xededa5=_[_0xab0be9(0x239)](_0x1bcd94,'ChatInteractionId'),_0x2c4cf6=[];return _0x270a9a[_0xab0be9(0x1a4)](function(_0x3183b0){const _0x49af96=_0xab0be9;_0x2c4cf6[_0x49af96(0x1c8)](updateChatInteraction(_0x3183b0,_0x1804e2,_0xededa5));}),Promise[_0xab0be9(0x216)](_0x2c4cf6);});});})[_0x1b1dc1(0x285)](function(_0x3190e1){const _0x50e694=_0x1b1dc1;return _0x53521a[_0x50e694(0x1ca)]=_0x3190e1,_0x53521a;})[_0x1b1dc1(0x285)](respondWithFilteredResult(_0x38a537,_0x54ed0e));})[_0x512058(0x18e)](handleError(_0x38a537,null));},exports[a80_0x1391de(0x188)]=function(_0x8430ef,_0x17c8cb){const _0x28f20b=a80_0x1391de;let _0x55e090={'raw':![],'where':{'id':_0x8430ef[_0x28f20b(0x24b)]['id']}};const _0x33c172={};return _0x33c172[_0x28f20b(0x1a1)]=_[_0x28f20b(0x251)](db[_0x28f20b(0x273)][_0x28f20b(0x21a)]),_0x33c172[_0x28f20b(0x1bb)]=_[_0x28f20b(0x251)](_0x8430ef[_0x28f20b(0x1bb)]),_0x33c172[_0x28f20b(0x221)]=_[_0x28f20b(0x23b)](_0x33c172[_0x28f20b(0x1a1)],_0x33c172[_0x28f20b(0x1bb)]),_0x55e090[_0x28f20b(0x24d)]=_[_0x28f20b(0x23b)](_0x33c172[_0x28f20b(0x1a1)],qs[_0x28f20b(0x1f7)](_0x8430ef[_0x28f20b(0x1bb)]['fields'])),_0x55e090['attributes']=_0x55e090['attributes'][_0x28f20b(0x1a9)]?_0x55e090[_0x28f20b(0x24d)]:_0x33c172[_0x28f20b(0x1a1)],_0x8430ef[_0x28f20b(0x1bb)][_0x28f20b(0x200)]&&(_0x55e090[_0x28f20b(0x252)]=[{'all':!![]}]),_0x55e090=_[_0x28f20b(0x1af)]({},_0x55e090,_0x8430ef['options']),db[_0x28f20b(0x273)][_0x28f20b(0x1f0)](_0x55e090)[_0x28f20b(0x285)](handleEntityNotFound(_0x17c8cb,null))['then'](respondWithResult(_0x17c8cb,null))[_0x28f20b(0x18e)](handleError(_0x17c8cb,null));},exports[a80_0x1391de(0x198)]=function(_0x1ba0c1,_0x5db3f6){const _0x5d7c30=a80_0x1391de;return db['ChatInteraction']['create'](_0x1ba0c1[_0x5d7c30(0x28e)],{})['then'](respondWithResult(_0x5db3f6,0xc9))['catch'](handleError(_0x5db3f6,null));},exports[a80_0x1391de(0x22b)]=function(_0x1f64f0,_0x5cd30f){const _0x5362bf=a80_0x1391de;return _0x1f64f0[_0x5362bf(0x28e)]['id']&&delete _0x1f64f0[_0x5362bf(0x28e)]['id'],db[_0x5362bf(0x273)][_0x5362bf(0x1f0)]({'where':{'id':_0x1f64f0[_0x5362bf(0x24b)]['id']}})[_0x5362bf(0x285)](handleEntityNotFound(_0x5cd30f,null))[_0x5362bf(0x285)](saveUpdates(_0x1f64f0[_0x5362bf(0x28e)],null))['then'](respondWithResult(_0x5cd30f,null))[_0x5362bf(0x18e)](handleError(_0x5cd30f,null));},exports[a80_0x1391de(0x1f6)]=function(_0x2b2cd2,_0x3ad928){const _0x5013b6=a80_0x1391de;return db['ChatInteraction'][_0x5013b6(0x1f0)]({'where':{'id':_0x2b2cd2[_0x5013b6(0x24b)]['id']}})['then'](handleEntityNotFound(_0x3ad928,null))[_0x5013b6(0x285)](removeEntity(_0x3ad928,null))[_0x5013b6(0x18e)](handleError(_0x3ad928,null));},exports[a80_0x1391de(0x274)]=function(_0x5b67f4,_0x13dce1){const _0x1d15f7=a80_0x1391de;return db[_0x1d15f7(0x273)]['describe']()[_0x1d15f7(0x285)](respondWithResult(_0x13dce1,null))[_0x1d15f7(0x18e)](handleError(_0x13dce1,null));},exports[a80_0x1391de(0x1ae)]=function(_0x289f86,_0x3b6a98){const _0x512be8=a80_0x1391de,_0x13cc19=_0x289f86[_0x512be8(0x24b)]['id'];let _0x47a3b3,_0x274b47,_0x58b2fb;return db['ChatInteraction']['findOne']({'where':{'id':_0x13cc19}})[_0x512be8(0x285)](function(_0x58c659){const _0x293665=_0x512be8;return _0x47a3b3=_0x58c659,db[_0x293665(0x1a8)]['findOne']({'where':{'id':_0x58c659[_0x293665(0x222)]},'attributes':['id',_0x293665(0x24f),'vidaooEscalation'],'raw':!![]});})[_0x512be8(0x285)](function(_0x1d58df){const _0x2a5edc=_0x512be8;if(_0x1d58df&&_0x1d58df[_0x2a5edc(0x24f)]&&_0x1d58df['vidaooEscalation']){_0x274b47=_0x1d58df;const _0x52a5c5={'rejectUnauthorized':![],'method':'POST','uri':_0x2a5edc(0x28f),'headers':{'X-APIKEY':_0x1d58df[_0x2a5edc(0x24f)]},'body':{'name':_0x2a5edc(0x271)+_0x13cc19},'redirect':_0x2a5edc(0x27f),'json':!![]};return rp(_0x52a5c5);}else throw new ValidationError('Error\x20in\x20Vidaoo\x20configuration');})[_0x512be8(0x285)](function(_0xd461c8){const _0x266dd9=_0x512be8;_0x58b2fb=_0xd461c8;if(_0x58b2fb['id']){const _0x1dd778={'body':_0x58b2fb[_0x266dd9(0x182)],'ChatWebsiteId':_0x274b47['id'],'ChatInteractionId':_0x47a3b3['id'],'direction':_0x266dd9(0x26a),'UserId':_0x289f86[_0x266dd9(0x249)]['id']};return db[_0x266dd9(0x201)]['create'](_0x1dd778,{});}else throw new ValidationError('Unable\x20to\x20create\x20Vidaoo\x20session');})[_0x512be8(0x285)](function(){return _0x47a3b3['update']({'vidaooSessionId':_0x58b2fb['id']});})[_0x512be8(0x285)](respondWithResult(_0x3b6a98,null))['catch'](handleError(_0x3b6a98,null));},exports[a80_0x1391de(0x1e6)]=function(_0x2c9f16,_0x51091a){const _0x5a8bc5=a80_0x1391de;return _0x2c9f16[_0x5a8bc5(0x28e)]['id']&&delete _0x2c9f16[_0x5a8bc5(0x28e)]['id'],db[_0x5a8bc5(0x273)]['findOne']({'where':{'id':_0x2c9f16[_0x5a8bc5(0x24b)]['id']}})[_0x5a8bc5(0x285)](handleEntityNotFound(_0x51091a,null))[_0x5a8bc5(0x285)](saveUpdates(_0x2c9f16['body'],null))['then'](respondWithResult(_0x51091a,null))[_0x5a8bc5(0x18e)](handleError(_0x51091a,null));},exports[a80_0x1391de(0x1bc)]=function(_0x1bdb28,_0x36ed62){const _0x41c8d7=a80_0x1391de;return _0x1bdb28[_0x41c8d7(0x28e)]['id']&&delete _0x1bdb28[_0x41c8d7(0x28e)]['id'],db['ChatInteraction'][_0x41c8d7(0x1f0)]({'where':{'id':_0x1bdb28['params']['id']}})[_0x41c8d7(0x285)](function(_0x52a1aa){const _0x3ee24b=_0x41c8d7;if(!_0x52a1aa)logger[_0x3ee24b(0x270)](_0x3ee24b(0x233),_0x3ee24b(0x1bc),0x194,_0x3ee24b(0x19a)),_0x36ed62['sendStatus'](0x194);else{if(_0x52a1aa[_0x3ee24b(0x1da)])throw new ValidationError(_0x3ee24b(0x259));}return _0x52a1aa;})[_0x41c8d7(0x285)](function(_0x83d42f){const _0x2f6ade=_0x41c8d7;if(_0x83d42f)return _0x83d42f['update']({'closed':_0x1bdb28[_0x2f6ade(0x28e)][_0x2f6ade(0x238)],'disposition':_0x1bdb28[_0x2f6ade(0x28e)]['disposition']})[_0x2f6ade(0x285)](function(_0x2bed7d){return _0x2bed7d;});})[_0x41c8d7(0x285)](function(){const _0x1e0d36=_0x41c8d7;return respondWithRpcPromise(_0x1e0d36(0x1db),_0x1e0d36(0x1bc),_0x1bdb28['body'],client9004);})['then'](respondWithResult(_0x36ed62,null))['catch'](handleError(_0x36ed62,null));},exports[a80_0x1391de(0x295)]=function(_0x150de9,_0x870884){const _0x4f7e2d=a80_0x1391de;return _0x150de9[_0x4f7e2d(0x28e)][_0x4f7e2d(0x1b2)]=_0x150de9[_0x4f7e2d(0x206)][_0x4f7e2d(0x180)],_0x150de9[_0x4f7e2d(0x28e)][_0x4f7e2d(0x1fd)]=_0x150de9['file'][_0x4f7e2d(0x1b5)],_0x150de9[_0x4f7e2d(0x28e)][_0x4f7e2d(0x267)]=_0x150de9[_0x4f7e2d(0x206)][_0x4f7e2d(0x218)],db[_0x4f7e2d(0x263)]['create'](_0x150de9[_0x4f7e2d(0x28e)])[_0x4f7e2d(0x285)](respondWithResult(_0x870884,0xc9))[_0x4f7e2d(0x18e)](handleError(_0x870884,null));},exports[a80_0x1391de(0x257)]=function(_0x2e6661,_0x99a652){const _0x254592=a80_0x1391de;return db['ChatInteraction'][_0x254592(0x1f0)]({'where':{'id':_0x2e6661[_0x254592(0x24b)]['id']},'raw':!![]})[_0x254592(0x285)](handleEntityNotFound(_0x99a652,null))['then'](function(_0x47c454){const _0x5dfa2a=_0x254592;if(_0x47c454){if(_0x47c454[_0x5dfa2a(0x238)])return _0x99a652[_0x5dfa2a(0x203)](0x193)['json']({'status':0x193,'message':'Unauthorized'});return db['Attachment']['findOne']({'where':{'id':_0x2e6661[_0x5dfa2a(0x1bb)]['attachId']},'raw':!![]})[_0x5dfa2a(0x285)](handleEntityNotFound(_0x99a652,null));}})[_0x254592(0x285)](function(_0x442b96){const _0x52468b=_0x254592;if(_0x442b96)return _0x99a652[_0x52468b(0x1a3)](path[_0x52468b(0x1c3)](config['root'],_0x52468b(0x1c5),_0x442b96[_0x52468b(0x1fd)]));})[_0x254592(0x18e)](handleError(_0x99a652,null));},exports[a80_0x1391de(0x22f)]=function(_0x3c5274,_0x53be73){const _0xc3af99=a80_0x1391de;let _0x436a9e=null,_0x416a05=null,_0x531dfc=null;return _0x3c5274['body']['id']&&delete _0x3c5274[_0xc3af99(0x28e)]['id'],_0x3c5274[_0xc3af99(0x28e)][_0xc3af99(0x1d3)]&&(_0x531dfc=path[_0xc3af99(0x1c3)](config[_0xc3af99(0x244)],_0xc3af99(0x26c),util[_0xc3af99(0x24e)](_0xc3af99(0x253),Date[_0xc3af99(0x1a5)]())),_0x3c5274[_0xc3af99(0x28e)]['pathTranscript']=_0x531dfc),db[_0xc3af99(0x273)][_0xc3af99(0x1f0)]({'where':{'id':_0x3c5274['params']['id']},'include':[{'model':db['ChatMessage'],'as':'Messages','include':[{'model':db[_0xc3af99(0x1d1)],'as':_0xc3af99(0x1d1)}]}]})[_0xc3af99(0x285)](handleEntityNotFound(_0x53be73,null))[_0xc3af99(0x285)](saveUpdates(_0x3c5274[_0xc3af99(0x28e)],null))[_0xc3af99(0x285)](function(_0x25d8c3){const _0x27eeb7=_0xc3af99;if(_0x25d8c3)return _0x436a9e=_0x25d8c3,db[_0x27eeb7(0x1a8)][_0x27eeb7(0x1f0)]({'where':{'id':_0x436a9e['ChatWebsiteId']}});})[_0xc3af99(0x285)](function(_0x461691){const _0x447c68=_0xc3af99;if(_0x461691)return _0x416a05=_0x461691,db[_0x447c68(0x1ec)][_0x447c68(0x1f0)]({'where':{'id':_0x436a9e['ContactId']}});})[_0xc3af99(0x285)](function(_0x3827fd){const _0x2c4515=_0xc3af99;if(_0x3827fd){if(_0x531dfc){let _0x5ff09a=null;for(let _0xb38c8=0x1;_0xb38c8<_0x436a9e[_0x2c4515(0x262)][_0x2c4515(0x1a9)];++_0xb38c8){_0x5ff09a=_0x436a9e[_0x2c4515(0x262)][_0xb38c8];let _0x377399=_0x5ff09a[_0x2c4515(0x1da)]?util[_0x2c4515(0x24e)]('%s%d',_0x416a05['agentAlias'],_0x5ff09a[_0x2c4515(0x1da)]):_0x2c4515(0x1bf);const _0x291af6=_0x3c5274[_0x2c4515(0x28e)]['customer']||util[_0x2c4515(0x24e)](_0x2c4515(0x293),_0x2c4515(0x1ed),_0x5ff09a[_0x2c4515(0x1e4)]);switch(_0x416a05['agentIdentifier']){case _0x2c4515(0x1e8):_0x377399=_0x5ff09a[_0x2c4515(0x1da)]?util[_0x2c4515(0x24e)](_0x2c4515(0x293),_0x416a05[_0x2c4515(0x28b)],_0x5ff09a['UserId']):_0x2c4515(0x1bf);break;case'agent_alias':_0x377399=_0x5ff09a['UserId']?_0x5ff09a[_0x2c4515(0x1d1)][_0x2c4515(0x1d4)]||_0x5ff09a[_0x2c4515(0x1d1)][_0x2c4515(0x25f)]:_0x2c4515(0x1bf);break;case'agent_fullname':_0x377399=_0x5ff09a['UserId']?_0x5ff09a['User'][_0x2c4515(0x25f)]:'System';break;default:_0x377399=_0x5ff09a[_0x2c4515(0x1da)]?util[_0x2c4515(0x24e)](_0x2c4515(0x293),_0x416a05[_0x2c4515(0x28b)],_0x5ff09a[_0x2c4515(0x1da)]):_0x2c4515(0x1bf);}const _0x2c5ecc=util[_0x2c4515(0x24e)](_0x2c4515(0x1a2),moment(_0x5ff09a[_0x2c4515(0x28a)])['format'](_0x2c4515(0x245)),_0x5ff09a[_0x2c4515(0x296)]==='in'?_0x291af6:_0x377399,_0x5ff09a[_0x2c4515(0x28e)]);!_0x5ff09a['secret']&&fs['appendFileSync'](_0x531dfc,_0x2c5ecc);}return db[_0x2c4515(0x275)][_0x2c4515(0x1f0)]({'where':{'service':!![]},'include':[{'model':db['MailServerOut'],'as':_0x2c4515(0x1d0),'raw':!![]}]});}}})[_0xc3af99(0x285)](function(_0x460453){const _0x3c82eb=_0xc3af99;if(_0x460453&&_0x460453[_0x3c82eb(0x1d0)]&&_0x3c5274[_0x3c82eb(0x28e)]){const _0x51646f={'tls':{'rejectUnauthorized':![]}};return _0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x26e)]?_0x51646f[_0x3c82eb(0x26e)]=_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x26e)]:(_0x51646f['host']=_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x1df)],_0x51646f['port']=_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x1e3)],_0x51646f[_0x3c82eb(0x1dd)]=_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x1dd)]),_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x1ee)]&&(_0x51646f[_0x3c82eb(0x191)]={'user':_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x249)],'pass':_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x25e)]}),respondWithRpcPromise('SendMail','sendMail',{'account':_0x51646f,'message':{'from':util[_0x3c82eb(0x24e)](_0x3c82eb(0x292),_0x460453['name'],_0x460453[_0x3c82eb(0x281)]||_0x460453[_0x3c82eb(0x1d0)][_0x3c82eb(0x249)]),'to':_0x3c5274[_0x3c82eb(0x28e)][_0x3c82eb(0x1d3)],'subject':'Mail\x20Transcript','text':util[_0x3c82eb(0x24e)]('Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a',_0x3c5274[_0x3c82eb(0x28e)][_0x3c82eb(0x1d3)]),'attachments':[{'path':_0x531dfc}]}})['then'](function(){return _0x436a9e;})['catch'](function(_0x255e86){const _0x427e0c=_0x3c82eb;console[_0x427e0c(0x270)](_0x255e86);});}else return _0x436a9e;})[_0xc3af99(0x285)](respondWithStatusCode(_0x53be73,0xc8))[_0xc3af99(0x18e)](handleError(_0x53be73,null));},exports['addMessage']=function(_0x1ed996,_0x554469){const _0x5619fc=a80_0x1391de;return db['ChatMessage']['findOne']({'where':{'id':_0x1ed996[_0x5619fc(0x24b)]['id']}})[_0x5619fc(0x285)](function(_0x1357f5){const _0xc72ca5=_0x5619fc;if(_0x1357f5)return _0x1357f5[_0xc72ca5(0x1ef)](_0x1ed996['body'][_0xc72ca5(0x1d9)],{'through':_[_0xc72ca5(0x243)](_0x1ed996[_0xc72ca5(0x28e)],['ids','id'])});})[_0x5619fc(0x285)](respondWithResult(_0x554469,null))[_0x5619fc(0x18e)](handleError(_0x554469,null));},exports[a80_0x1391de(0x25d)]=function(_0x552357,_0x2f0195){const _0x44716d=a80_0x1391de;let _0x3a8b4d={'raw':![],'where':{}};const _0x5396a7={},_0x3fe7dd={'count':0x0,'rows':[]};return db[_0x44716d(0x273)]['findOne']({'where':{'id':_0x552357['params']['id']}})[_0x44716d(0x285)](handleEntityNotFound(_0x2f0195,null))[_0x44716d(0x285)](function(_0x572ddd){const _0x22ff4c=_0x44716d;if(_0x572ddd){_0x5396a7[_0x22ff4c(0x1a1)]=_[_0x22ff4c(0x251)](db[_0x22ff4c(0x201)]['rawAttributes']),_0x5396a7[_0x22ff4c(0x1bb)]=_[_0x22ff4c(0x251)](_0x552357[_0x22ff4c(0x1bb)]),_0x5396a7[_0x22ff4c(0x221)]=_[_0x22ff4c(0x23b)](_0x5396a7['model'],_0x5396a7[_0x22ff4c(0x1bb)]),_0x3a8b4d['attributes']=_[_0x22ff4c(0x23b)](_0x5396a7[_0x22ff4c(0x1a1)],qs[_0x22ff4c(0x1f7)](_0x552357[_0x22ff4c(0x1bb)][_0x22ff4c(0x1f7)])),_0x3a8b4d[_0x22ff4c(0x24d)]=_0x3a8b4d['attributes']['length']?_0x3a8b4d['attributes']:_0x5396a7[_0x22ff4c(0x1a1)];typeof _0x552357['query'][_0x22ff4c(0x19f)]===_0x22ff4c(0x283)&&(_0x3a8b4d['limit']=qs[_0x22ff4c(0x230)](_0x552357[_0x22ff4c(0x1bb)][_0x22ff4c(0x230)]),_0x3a8b4d[_0x22ff4c(0x1fa)]=qs[_0x22ff4c(0x1fa)](_0x552357[_0x22ff4c(0x1bb)]['offset']));_0x3a8b4d['order']=qs['sort'](_0x552357[_0x22ff4c(0x1bb)][_0x22ff4c(0x20e)]),_0x3a8b4d[_0x22ff4c(0x1cf)]=qs[_0x22ff4c(0x221)](_['pick'](_0x552357[_0x22ff4c(0x1bb)],_0x5396a7[_0x22ff4c(0x221)])),_0x3a8b4d['where'][_0x22ff4c(0x256)]=_0x572ddd['id'];_0x552357[_0x22ff4c(0x1bb)]['filter']&&(_0x3a8b4d[_0x22ff4c(0x1cf)]=_['merge'](_0x3a8b4d[_0x22ff4c(0x1cf)],{[Op['or']]:_['map'](_0x3a8b4d['attributes'],function(_0x2b79fd){const _0xf127d6=_0x22ff4c,_0x30c9a9={};return _0x30c9a9[_0x2b79fd]={[Op[_0xf127d6(0x1d8)]]:'%'+_0x552357[_0xf127d6(0x1bb)][_0xf127d6(0x1ba)]+'%'},_0x30c9a9;})}));if(_0x552357['query'][_0x22ff4c(0x232)]){const _0x3fd71b=_0x552357[_0x22ff4c(0x1bb)][_0x22ff4c(0x232)][_0x22ff4c(0x219)](','),_0x539328={};_0x539328[_0x3fd71b[0x0]]={[Op['gte']]:moment(_0x3fd71b[0x1])[_0x22ff4c(0x24e)](_0x22ff4c(0x21e))},_0x3a8b4d['where']=_[_0x22ff4c(0x1af)](_0x3a8b4d['where'],_0x539328);}return _0x3a8b4d=_['merge']({},_0x3a8b4d,_0x552357[_0x22ff4c(0x27a)]),db[_0x22ff4c(0x201)][_0x22ff4c(0x1e5)]({'where':_0x3a8b4d[_0x22ff4c(0x1cf)]})[_0x22ff4c(0x285)](function(_0x5e6836){const _0x1ac4a5=_0x22ff4c;return _0x3fe7dd[_0x1ac4a5(0x1e5)]=_0x5e6836,_0x552357['query'][_0x1ac4a5(0x200)]&&(_0x3a8b4d['include']=[{'all':!![]}]),db[_0x1ac4a5(0x201)][_0x1ac4a5(0x278)](_0x3a8b4d);})[_0x22ff4c(0x285)](function(_0x1f66a7){const _0x372d96=_0x22ff4c;return _0x3fe7dd[_0x372d96(0x1ca)]=_0x1f66a7,_0x3fe7dd;});}})['then'](respondWithFilteredResult(_0x2f0195,_0x3a8b4d))[_0x44716d(0x18e)](handleError(_0x2f0195,null));},exports['getMyMessages']=function(_0x75e3e2,_0x2ea460){const _0x20430d=a80_0x1391de;let _0x572593={'where':{}};const _0x428da8={},_0x1d3196={'count':0x0,'rows':[]};return db[_0x20430d(0x273)][_0x20430d(0x1f0)]({'where':{'id':_0x75e3e2['params']['id']}})[_0x20430d(0x285)](handleEntityNotFound(_0x2ea460,null))[_0x20430d(0x285)](function(_0x4ae773){const _0x8881ed=_0x20430d;if(_0x4ae773)return _0x428da8[_0x8881ed(0x1a1)]=_[_0x8881ed(0x251)](db[_0x8881ed(0x201)][_0x8881ed(0x21a)]),_0x428da8[_0x8881ed(0x1bb)]=_[_0x8881ed(0x251)](_0x75e3e2['query']),_0x428da8[_0x8881ed(0x221)]=_['intersection'](_0x428da8[_0x8881ed(0x1a1)],_0x428da8['query']),_0x572593[_0x8881ed(0x24d)]=_['intersection'](_0x428da8[_0x8881ed(0x1a1)],qs['fields'](_0x75e3e2[_0x8881ed(0x1bb)][_0x8881ed(0x1f7)])),_0x572593[_0x8881ed(0x24d)]=_0x572593['attributes'][_0x8881ed(0x1a9)]?_0x572593[_0x8881ed(0x24d)]:_0x428da8['model'],typeof _0x75e3e2['query'][_0x8881ed(0x19f)]===_0x8881ed(0x283)&&(_0x572593[_0x8881ed(0x230)]=qs['limit'](_0x75e3e2[_0x8881ed(0x1bb)]['limit']),_0x572593[_0x8881ed(0x1fa)]=qs[_0x8881ed(0x1fa)](_0x75e3e2['query'][_0x8881ed(0x1fa)])),_0x572593[_0x8881ed(0x1b1)]=qs[_0x8881ed(0x20e)](_0x75e3e2['query'][_0x8881ed(0x20e)]),_0x572593['where']=qs[_0x8881ed(0x221)](_['pick'](_0x75e3e2[_0x8881ed(0x1bb)],_0x428da8[_0x8881ed(0x221)])),_0x572593[_0x8881ed(0x1cf)][_0x8881ed(0x256)]=_0x4ae773['id'],_0x75e3e2[_0x8881ed(0x1bb)][_0x8881ed(0x1ba)]&&(_0x572593[_0x8881ed(0x1cf)]=_[_0x8881ed(0x1af)](_0x572593[_0x8881ed(0x1cf)],{[Op['or']]:_[_0x8881ed(0x1c4)](_0x572593[_0x8881ed(0x24d)],function(_0x3ec06f){const _0x3022b8=_0x8881ed,_0x39e6d={};return _0x39e6d[_0x3ec06f]={[Op[_0x3022b8(0x1d8)]]:'%'+_0x75e3e2[_0x3022b8(0x1bb)]['filter']+'%'},_0x39e6d;})})),_0x572593['where']['secret']=![],_0x75e3e2['query']['id']&&(_0x572593[_0x8881ed(0x1cf)]['id']={[Op['gt']]:_0x75e3e2[_0x8881ed(0x1bb)]['id']}),_0x572593=_[_0x8881ed(0x1af)]({},_0x572593,_0x75e3e2['options']),db[_0x8881ed(0x201)][_0x8881ed(0x1e5)]({'where':_0x572593[_0x8881ed(0x1cf)]})[_0x8881ed(0x285)](function(_0x5bbb4a){const _0x5df6dc=_0x8881ed;return _0x1d3196['count']=_0x5bbb4a,_0x572593[_0x5df6dc(0x252)]=[],_0x75e3e2[_0x5df6dc(0x1bb)][_0x5df6dc(0x1fb)]&&_0x572593['include'][_0x5df6dc(0x1c8)]({'model':db[_0x5df6dc(0x1d1)],'as':_0x5df6dc(0x1d1),'attributes':['id',_0x5df6dc(0x25f),_0x5df6dc(0x1d4)]}),_0x75e3e2[_0x5df6dc(0x1bb)][_0x5df6dc(0x200)]&&(_0x572593[_0x5df6dc(0x252)]=[{'all':!![]}]),db['ChatMessage'][_0x5df6dc(0x278)](_0x572593);})['then'](function(_0x22b5dc){const _0x174db6=_0x8881ed;return _0x1d3196[_0x174db6(0x1ca)]=_0x22b5dc,_0x1d3196;});})[_0x20430d(0x285)](respondWithFilteredResult(_0x2ea460,_0x572593))['catch'](handleError(_0x2ea460,null));},exports[a80_0x1391de(0x26f)]=function(_0xc65936,_0x2e4692){const _0x38e8f3=a80_0x1391de;return db[_0x38e8f3(0x273)][_0x38e8f3(0x1f0)]({'where':{'id':_0xc65936[_0x38e8f3(0x24b)]['id']}})[_0x38e8f3(0x285)](function(_0x40ab9a){const _0x12e779=_0x38e8f3;if(_0x40ab9a)return _0x40ab9a[_0x12e779(0x258)](_0xc65936[_0x12e779(0x28e)][_0x12e779(0x1d9)],{'through':_[_0x12e779(0x243)](_0xc65936[_0x12e779(0x28e)],[_0x12e779(0x1d9),'id'])})[_0x12e779(0x285)](function(){const _0x2d221b=_0x12e779;return db[_0x2d221b(0x1eb)][_0x2d221b(0x278)]({'attributes':['id',_0x2d221b(0x1b2),_0x2d221b(0x1c7)],'where':{'id':_0xc65936[_0x2d221b(0x28e)][_0x2d221b(0x1d9)]}});})[_0x12e779(0x285)](function(_0x18ca71){const _0xbd94bf=_0x12e779;return socket[_0xbd94bf(0x1cc)]('chatInteractionTags:save',{'id':Number(_0xc65936[_0xbd94bf(0x24b)]['id']),'tags':_0x18ca71||[]}),{'id':Number(_0xc65936[_0xbd94bf(0x24b)]['id']),'tags':_0x18ca71||[]};});})[_0x38e8f3(0x285)](respondWithResult(_0x2e4692,null))[_0x38e8f3(0x18e)](handleError(_0x2e4692,null));},exports['removeTags']=function(_0x46dfe8,_0x44f6a9){const _0x4a9140=a80_0x1391de;return db['ChatInteraction']['findOne']({'where':{'id':_0x46dfe8[_0x4a9140(0x24b)]['id']}})[_0x4a9140(0x285)](handleEntityNotFound(_0x44f6a9,null))[_0x4a9140(0x285)](function(_0x8c1e39){const _0x59e2f5=_0x4a9140;if(_0x8c1e39)return _0x8c1e39[_0x59e2f5(0x237)](_0x46dfe8[_0x59e2f5(0x1bb)]['ids']);})[_0x4a9140(0x285)](respondWithStatusCode(_0x44f6a9,null))[_0x4a9140(0x18e)](handleError(_0x44f6a9,null));},exports[a80_0x1391de(0x1a3)]=function(_0x3ca3e3,_0x5d0ee3){const _0x585b5c=a80_0x1391de,_0x2ef2d0=moment()[_0x585b5c(0x1e2)]()[_0x585b5c(0x280)](),_0x17c2aa=path[_0x585b5c(0x1c3)](config[_0x585b5c(0x244)],_0x585b5c(0x289),'tmp'),_0x410d09=path['join'](config[_0x585b5c(0x244)],_0x585b5c(0x21b),_0x585b5c(0x289),'attachments'),_0x6ce737=path['join'](_0x17c2aa,_0x2ef2d0),_0x54e260=util[_0x585b5c(0x24e)]('transcript-%d-%s.zip',_0x3ca3e3[_0x585b5c(0x24b)]['id'],_0x2ef2d0),_0x290c13=path[_0x585b5c(0x1c3)](_0x17c2aa,_0x54e260),_0xdf5bce=[];_0xdf5bce[_0x585b5c(0x1c8)]({'model':db[_0x585b5c(0x1d1)],'as':_0x585b5c(0x1d1),'attributes':['id',_0x585b5c(0x25f)],'raw':!![]}),_0xdf5bce['push']({'model':db[_0x585b5c(0x1ec)],'as':_0x585b5c(0x23e),'attributes':['id',_0x585b5c(0x192),_0x585b5c(0x1e7)],'raw':!![]});_0x3ca3e3['query'][_0x585b5c(0x1a6)]&&_0xdf5bce[_0x585b5c(0x1c8)]({'model':db['Attachment'],'as':'Attachment','raw':!![]});const _0x22f709=[{'model':db[_0x585b5c(0x201)],'as':_0x585b5c(0x262),'attributes':['id',_0x585b5c(0x28e),_0x585b5c(0x28a),_0x585b5c(0x296),'secret',_0x585b5c(0x1a0)],'include':_0xdf5bce}];return _0x22f709[_0x585b5c(0x1c8)]({'model':db['ChatWebsite'],'as':'Account','attributes':['id',_0x585b5c(0x1b2)]}),_0x22f709[_0x585b5c(0x1c8)]({'model':db['User'],'as':_0x585b5c(0x276),'attributes':['id','fullname']}),db[_0x585b5c(0x273)][_0x585b5c(0x1f0)]({'where':{'id':_0x3ca3e3['params']['id']},'include':_0x22f709})['then'](handleEntityNotFound(_0x5d0ee3,null))['then'](function(_0x191fc0){const _0x4fef05=_0x585b5c;if(_0x191fc0){const _0x5104bb=_0x191fc0[_0x4fef05(0x1e1)]({'plain':!![]});fs[_0x4fef05(0x1ff)](_0x6ce737);const _0x4cf12e={'format':'A4','border':_0x4fef05(0x18d),'header':{'height':_0x4fef05(0x21d),'contents':{'first':_0x4fef05(0x1b3)}},'footer':{'height':_0x4fef05(0x22a),'contents':{'default':util[_0x4fef05(0x24e)]('<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>',util[_0x4fef05(0x24e)](_0x4fef05(0x1b4),'Chat',_0x5104bb['id']),moment()[_0x4fef05(0x24e)](_0x4fef05(0x294))['toString']())}}},_0x4c5d29={'channel':'Chat','account':_0x5104bb[_0x4fef05(0x250)]['name'],'agent':_0x5104bb[_0x4fef05(0x276)]?_0x5104bb[_0x4fef05(0x276)][_0x4fef05(0x25f)]:_0x4fef05(0x1f5),'createdAt':moment(_0x5104bb['createdAt'])['format'](_0x4fef05(0x21e))['toString'](),'closedAt':_0x5104bb[_0x4fef05(0x238)]?moment(_0x5104bb[_0x4fef05(0x22e)])['format'](_0x4fef05(0x21e))[_0x4fef05(0x280)]():'','disposition':_0x5104bb['disposition'],'chatInfo':{'browser':_0x5104bb[_0x4fef05(0x279)],'os':_0x5104bb[_0x4fef05(0x197)],'referer':_0x5104bb[_0x4fef05(0x209)],'customerIp':_0x5104bb[_0x4fef05(0x202)],'customerPort':_0x5104bb[_0x4fef05(0x284)]?_0x5104bb[_0x4fef05(0x284)]:_0x4fef05(0x1f5)},'messages':_(_0x5104bb['Messages'])[_0x4fef05(0x246)]()[_0x4fef05(0x1ba)]({'secret':![]})[_0x4fef05(0x1c4)](function(_0x2b547d){const _0x277fc5=_0x4fef05;if(_0x2b547d[_0x277fc5(0x263)]){const _0x33f72d=path[_0x277fc5(0x1c3)](_0x410d09,_0x2b547d[_0x277fc5(0x263)][_0x277fc5(0x1fd)]);fs['existsSync'](_0x33f72d)&&fs[_0x277fc5(0x229)](_0x33f72d)[_0x277fc5(0x290)](fs[_0x277fc5(0x255)](path['join'](_0x6ce737,_0x2b547d[_0x277fc5(0x263)][_0x277fc5(0x1fd)])));}return{'date':moment(_0x2b547d[_0x277fc5(0x28a)])[_0x277fc5(0x24e)]('YYYY-MM-DD\x20HH:mm:ss')[_0x277fc5(0x280)](),'sender':_0x2b547d[_0x277fc5(0x296)]===_0x277fc5(0x26a)?_0x2b547d[_0x277fc5(0x1d1)]?_0x2b547d['User'][_0x277fc5(0x25f)]:_0x277fc5(0x1bf):_0x2b547d[_0x277fc5(0x23e)][_0x277fc5(0x192)]+(_0x2b547d['Contact'][_0x277fc5(0x1e7)]?'\x20'+_0x2b547d[_0x277fc5(0x23e)][_0x277fc5(0x1e7)]:''),'body':_0x2b547d[_0x277fc5(0x263)]?_0x2b547d['Attachment'][_0x277fc5(0x1fd)]:_0x2b547d[_0x277fc5(0x28e)],'direction':_0x2b547d[_0x277fc5(0x296)]===_0x277fc5(0x26a)?'A':'C','secret':_0x2b547d[_0x277fc5(0x236)],'read':_0x2b547d[_0x277fc5(0x1a0)],'attachment':_0x2b547d[_0x277fc5(0x263)]};})[_0x4fef05(0x199)]()};return ejs[_0x4fef05(0x1f8)](path[_0x4fef05(0x1c3)](config[_0x4fef05(0x244)],_0x4fef05(0x21b),'views',_0x4fef05(0x225)),{'interaction':_0x4c5d29})[_0x4fef05(0x285)](function(_0x35bcf7){return new Promise(function(_0x316f1e,_0x50d451){const _0x9a694b=a80_0x4a11;pdf[_0x9a694b(0x198)](_0x35bcf7,_0x4cf12e)[_0x9a694b(0x187)](path[_0x9a694b(0x1c3)](_0x6ce737,_0x9a694b(0x210)+_0x5104bb['id']+'-'+_0x2ef2d0+_0x9a694b(0x28d)),function(_0x338573,_0x333b6d){if(_0x338573)return _0x50d451(_0x338573);_0x316f1e(_0x333b6d);});});})[_0x4fef05(0x285)](function(){const _0x5c1975=_0x4fef05;return new Promise(function(_0x345b3f,_0x52cf89){zipdir(_0x6ce737,{'saveTo':_0x290c13},function(_0x3e3d46,_0x4d1c3b){if(_0x3e3d46)return _0x52cf89(_0x3e3d46);return _0x345b3f(_0x4d1c3b);});})['then'](function(){return new Promise(function(_0x2743b5,_0x413f1d){rimraf(_0x6ce737,function(_0x4257b4){if(_0x4257b4)_0x413f1d(_0x4257b4);return _0x2743b5();});});})[_0x5c1975(0x285)](function(){const _0x48609f=_0x5c1975;return _0x5d0ee3[_0x48609f(0x1a3)](_0x290c13,_0x54e260,function(_0x58b532){const _0x15783f=_0x48609f;_0x58b532?console[_0x15783f(0x205)](_0x15783f(0x186),_0x58b532):fs[_0x15783f(0x213)](_0x290c13);});});});}else return _0x5d0ee3['sendStatus'](0xc8);})['catch'](handleError(_0x5d0ee3,null));};
\ No newline at end of file
+const a80_0xb5da=['index','push','count','`unreadMessages`\x20=\x200','sendMail','10px','u.id\x20=\x20ui.UserId','stringify','ids','join_url','include','vidaooEscalation','fullname','map','type','files/attachments/','json','osName','<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>','Smtp','c.lastName','../../config/logger','ChatMessage','unreadMessages','mimetype','Contact.fax','ChatInteraction','squel','../../rediscache','merge','chat_messages','rows','lodash','User','Messages','UserId','users','gte','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','u.fullname','service','$lte','tag','out','customerIp','length','../../components/parsers/advancedSearch','secret','ChatInteraction,\x20%s,\x20%s,\x20%s','views','mkdirSync','TagIds','browserName','ChatInteraction,\x20%s,\x20%s','findOne','keys','N.A.','includeAll','offset','group','pathTranscript','agent_alias','value','sequelize','user_has_chat_interactions','[%s]\x20%s:\x20%s\x0a','key','limit','Owner.internal','40px','attachmentUpload','color','order','moment','Tag','nolimit','abandonInteraction,\x20%s,\x20%s,\x20%s','Contact.firstName','findAll','transcript-','ContactId','options','it.ChatInteractionId\x20=\x20i.id','ejs','text','entity\x20not\x20found','attributes','format','Interaction\x20already\x20assigned','cm_contacts','email','server','root','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','renderFile','name','i.*','host','operator','find','Content-Range','fieldName','null','all','sort','u.id','split','Account','concat','Chat','message','me.ChatInteractionId\x20=\x20i.id','fields','parseSearch','user','journey','log','ChatInteractionId','contactName','read','body','SELECT','keyBy','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','firstName','resolve','undefined','chat_interactions','forEach','transcript-%d-%s.zip','chatInteractionTags:save','POST','follow','addTags','createVidaooSession','pick','files','Unauthorized','YYYY-MM-DD\x20HH:mm:ss','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','authentication','a.mandatoryDisposition','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','omit','buildExpression','union','customerPort','Contact.mobile','isArray','Tags','tools_tags','port','then','c.firstName','set','update','secure','left_join','rimraf','getChatWebsites','o.internal','ui.ChatInteractionId','unix','intersection','a.key','register','<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>','close','tmp','t.id\x20=\x20it.TagId','query','AbandonInteraction','../../components/parsers/qs','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','t.id\x20IN\x20?','basename','status','c.phone','end','groupBy','debug','CmContact','agentAlias','sendStatus','filter','getFullTextValue','referer','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','start','unlinkSync','ChatWebsite','direction','error','i.ChatWebsiteId\x20IS\x20NOT\x20NULL','toString','join','Error\x20in\x20Vidaoo\x20configuration','getMessages','vidaooApiKey','compact','attachId','client','`\x20>\x200','SendMail','o.id\x20=\x20i.UserId','i.id','Attachment','parse','%s\x20#%d','Owner','having','code','closedAt','like','result','get','createdAt','create','filters','MotionCWB:','where','setTags','GROUP_CONCAT(DISTINCT\x20t.id)','conditions','toFile','info','request\x20sent','sqlOperator','Visitor','stack','isEmpty','Contact.email','pipe','select','disposition','file','some','params','model','alias','closed','show','./chatInteraction.socket','util','http','\x20=\x20?','ChatWebsiteId','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','$gte','DESC','\x22%s\x22\x20<%s>','`\x20=\x200','chat_websites','i.ChatWebsiteId\x20IN\x20?','isNumeric','destroy','%s%d','expr','api','rawAttributes','downloadInteraction.html','Owner.fullname','appendFileSync','zip-dir','search','removeTags','i.id\x20LIKE\x20?','mailTranscript','catch','field','emit','abandon','MailServerOut','System','replace','download','attachments','jayson/promise','Contact','i.ChatWebsiteId\x20IS\x20NULL','chat_interaction_has_tags','describe','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','from','website_alias','lastName','30px'];(function(_0x3a98f5,_0x25b98b){const _0xb5dada=function(_0x3da583){while(--_0x3da583){_0x3a98f5['push'](_0x3a98f5['shift']());}};_0xb5dada(++_0x25b98b);}(a80_0xb5da,0x1ab));const a80_0x3da5=function(_0x3a98f5,_0x25b98b){_0x3a98f5=_0x3a98f5-0xea;let _0xb5dada=a80_0xb5da[_0x3a98f5];return _0xb5dada;};const a80_0x4a36e5=a80_0x3da5;'use strict';const pdf=require('html-pdf'),rimraf=require(a80_0x4a36e5(0xfc)),zipdir=require(a80_0x4a36e5(0x165)),rp=require('request-promise-native'),moment=require(a80_0x4a36e5(0x1c6)),util=require(a80_0x4a36e5(0x151)),path=require('path'),ejs=require(a80_0x4a36e5(0x1d0)),fs=require('fs'),_=require(a80_0x4a36e5(0x19d)),squel=require(a80_0x4a36e5(0x198)),{getSocket}=require(a80_0x4a36e5(0x199)),qs=require(a80_0x4a36e5(0x10a)),as=require(a80_0x4a36e5(0x1ab)),logger=require(a80_0x4a36e5(0x192))(a80_0x4a36e5(0x160)),config=require('../../config/environment'),{db}=require('../../mysqldb'),{Op,ValidationError,QueryTypes}=require(a80_0x4a36e5(0x1bc)),socket=getSocket();require(a80_0x4a36e5(0x150))[a80_0x4a36e5(0x103)](socket);const jayson=require(a80_0x4a36e5(0x173)),client=jayson[a80_0x4a36e5(0x127)][a80_0x4a36e5(0x152)]({'port':0x232b}),client9004=jayson[a80_0x4a36e5(0x127)]['http']({'port':0x232c});function respondWithRpcPromise(_0x484e9d,_0x5d6cb4,_0x3146c1,_0x5e74f1){return new Promise(function(_0xa44e9c,_0x1c8bf6){const _0x13cf3a=a80_0x3da5,_0x43bae7=_0x5e74f1||client;return _0x43bae7['request'](_0x484e9d,_0x3146c1)[_0x13cf3a(0xf6)](function(_0x54c139){const _0x49aad9=_0x13cf3a;logger[_0x49aad9(0x13f)](_0x49aad9(0x1b2),_0x5d6cb4,_0x49aad9(0x140)),logger[_0x49aad9(0x112)](_0x49aad9(0x1ad),_0x5d6cb4,_0x49aad9(0x140),JSON[_0x49aad9(0x184)](_0x54c139));if(_0x54c139[_0x49aad9(0x11e)]){if(_0x54c139[_0x49aad9(0x11e)][_0x49aad9(0x131)]===0x1f4)return logger[_0x49aad9(0x11e)](_0x49aad9(0x1b2),_0x5d6cb4,_0x54c139[_0x49aad9(0x11e)][_0x49aad9(0x1eb)]),_0x1c8bf6(_0x54c139['error'][_0x49aad9(0x1eb)]);return logger[_0x49aad9(0x11e)]('ChatInteraction,\x20%s,\x20%s',_0x5d6cb4,_0x54c139[_0x49aad9(0x11e)][_0x49aad9(0x1eb)]),_0xa44e9c(_0x54c139[_0x49aad9(0x11e)][_0x49aad9(0x1eb)]);}else logger[_0x49aad9(0x13f)](_0x49aad9(0x1b2),_0x5d6cb4,_0x49aad9(0x140)),_0xa44e9c(_0x54c139[_0x49aad9(0x134)][_0x49aad9(0x1eb)]);})[_0x13cf3a(0x16a)](function(_0x539f81){const _0x5544c4=_0x13cf3a;logger[_0x5544c4(0x11e)](_0x5544c4(0x1b2),_0x5d6cb4,_0x539f81),_0x1c8bf6(_0x539f81);});});}function respondWithStatusCode(_0x89c1b0,_0x572bf){return _0x572bf=_0x572bf||0xcc,function(_0x152672){const _0x4980af=a80_0x3da5;if(_0x152672)return _0x89c1b0[_0x4980af(0x115)](_0x572bf);return _0x89c1b0[_0x4980af(0x10e)](_0x572bf)[_0x4980af(0x110)]();};}function respondWithResult(_0x3b8047,_0x4ef17d){return _0x4ef17d=_0x4ef17d||0xc8,function(_0x39f16f){if(_0x39f16f)return _0x3b8047['status'](_0x4ef17d)['json'](_0x39f16f);};}function respondWithFilteredResult(_0x689f4f,_0x1bc48d){return function(_0x17d54c){const _0x2086a5=a80_0x3da5;if(_0x17d54c){const _0x503435=_0x17d54c[_0x2086a5(0x17f)],_0x5b488f=_0x1bc48d['offset'];let _0x553747=_0x1bc48d[_0x2086a5(0x1b7)]+_0x1bc48d[_0x2086a5(0x1c0)],_0xa92a2d;return _0x553747>=_0x503435?(_0x553747=_0x503435,_0xa92a2d=0xc8):_0xa92a2d=0xce,_0x689f4f[_0x2086a5(0x10e)](_0xa92a2d),_0x689f4f[_0x2086a5(0xf8)](_0x2086a5(0x1e1),_0x5b488f+'-'+_0x553747+'/'+_0x503435)[_0x2086a5(0x18d)](_0x17d54c);}return null;};}function saveUpdates(_0x574192){return function(_0x259119){const _0x1288ad=a80_0x3da5;if(_0x259119)return _0x259119[_0x1288ad(0xf9)](_0x574192)[_0x1288ad(0xf6)](function(_0x2a924c){return _0x2a924c;});return null;};}function removeEntity(_0x2dc61c){return function(_0x4d3077){const _0x3cd333=a80_0x3da5;if(_0x4d3077)return _0x4d3077['destroy']()[_0x3cd333(0xf6)](function(){const _0x5f778a=_0x3cd333;_0x2dc61c[_0x5f778a(0x10e)](0xcc)[_0x5f778a(0x110)]();});};}function handleEntityNotFound(_0x22080a){return function(_0x58194d){return!_0x58194d&&_0x22080a['sendStatus'](0x194),_0x58194d;};}function handleError(_0x2ba1e2,_0x397c76){return _0x397c76=_0x397c76||0x1f4,function(_0x172a94){const _0x1df91c=a80_0x3da5;logger[_0x1df91c(0x11e)](_0x172a94[_0x1df91c(0x143)]),_0x172a94[_0x1df91c(0x1dc)]&&delete _0x172a94[_0x1df91c(0x1dc)],_0x2ba1e2[_0x1df91c(0x10e)](_0x397c76)['send'](_0x172a94);};}function getInteractionUsers(_0x44b47b,_0x44c174){return new Promise(function(_0x5c94a0,_0x359614){const _0x253c05=a80_0x3da5;try{_0x44c174[_0x44b47b['id']]&&(_0x44b47b['Users']=_[_0x253c05(0x18a)](_0x44c174[_0x44b47b['id']],function(_0x5a0952){const _0x38b26a=_0x253c05;return{'id':_0x5a0952['id'],'fullname':_0x5a0952[_0x38b26a(0x189)]};}));}catch(_0x48169a){_0x359614(_0x48169a);}_0x5c94a0(_0x44b47b);});}function getInteractionTags(_0x41cfae,_0x4899c9){return new Promise(function(_0xade397,_0x103f63){const _0x251568=a80_0x3da5;try{_0x41cfae[_0x251568(0x1b0)]&&(_0x41cfae[_0x251568(0xf3)]=[],_0x41cfae[_0x251568(0x1b0)][_0x251568(0x1e7)](',')['forEach'](function(_0x1905fc){const _0x126750=_0x251568;_0x41cfae[_0x126750(0xf3)][_0x126750(0x17e)](_0x4899c9[_0x1905fc]);})),delete _0x41cfae['TagIds'];}catch(_0x4e86ff){_0x103f63(_0x4e86ff);}_0xade397(_0x41cfae);});}function updateChatInteraction(_0x550511,_0x2da7c9,_0x3c8c4d){return new Promise(function(_0x3684c9,_0x346c91){const _0x4b38be=a80_0x3da5;return getInteractionUsers(_0x550511,_0x3c8c4d)[_0x4b38be(0xf6)](function(_0x47f21e){return getInteractionTags(_0x47f21e,_0x2da7c9);})[_0x4b38be(0xf6)](function(_0x147780){_0x3684c9(_0x147780);})[_0x4b38be(0x16a)](function(_0xe81a4b){_0x346c91(_0xe81a4b);});});}exports[a80_0x4a36e5(0x17d)]=function(_0x5b6a51,_0x49dc03){const _0x5ae447=a80_0x4a36e5,_0x25f681={},_0x1a3b9d={},_0x5864af={'count':0x0,'rows':[]},_0x193a1f=_[_0x5ae447(0x18a)](db[_0x5ae447(0x197)][_0x5ae447(0x161)],function(_0x4bbccb){const _0x4c9fe5=_0x5ae447;return{'name':_0x4bbccb[_0x4c9fe5(0x1e2)],'type':_0x4bbccb['type'][_0x4c9fe5(0x1bf)]};});_0x1a3b9d[_0x5ae447(0x14c)]=_[_0x5ae447(0x18a)](_0x193a1f,_0x5ae447(0x1dc)),_0x1a3b9d[_0x5ae447(0x108)]=_[_0x5ae447(0x1b4)](_0x5b6a51[_0x5ae447(0x108)]),_0x1a3b9d[_0x5ae447(0x138)]=_[_0x5ae447(0x101)](_0x1a3b9d[_0x5ae447(0x14c)],_0x1a3b9d[_0x5ae447(0x108)]),_0x25f681['attributes']=_[_0x5ae447(0x101)](_0x1a3b9d[_0x5ae447(0x14c)],qs[_0x5ae447(0x1ed)](_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x1ed)])),_0x25f681[_0x5ae447(0x1d3)]=_0x25f681['attributes'][_0x5ae447(0x1aa)]?_0x25f681['attributes']:_0x1a3b9d[_0x5ae447(0x14c)];typeof _0x5b6a51[_0x5ae447(0x108)]['nolimit']===_0x5ae447(0x1fb)&&(_0x25f681['limit']=qs[_0x5ae447(0x1c0)](_0x5b6a51['query'][_0x5ae447(0x1c0)]),_0x25f681[_0x5ae447(0x1b7)]=qs['offset'](_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x1b7)]));_0x25f681['order']=qs[_0x5ae447(0x1e5)](_0x5b6a51['query']['sort']),_0x25f681[_0x5ae447(0x13a)]=qs[_0x5ae447(0x138)](_[_0x5ae447(0x204)](_0x5b6a51[_0x5ae447(0x108)],_0x1a3b9d[_0x5ae447(0x138)]),_0x193a1f);let _0x2596f2=[];const _0x4a0438=squel['select']()[_0x5ae447(0x16b)]('id')['field'](_0x5ae447(0x1dc))[_0x5ae447(0x16b)](_0x5ae447(0x1c4))['from'](_0x5ae447(0xf4)),_0x39aee6=squel[_0x5ae447(0x147)]()[_0x5ae447(0x16b)](_0x5ae447(0x1e6))[_0x5ae447(0x16b)](_0x5ae447(0x1a4))[_0x5ae447(0x16b)](_0x5ae447(0xff))[_0x5ae447(0x179)](_0x5ae447(0x1bd),'ui')[_0x5ae447(0xfb)](_0x5ae447(0x1a1),'u',_0x5ae447(0x183)),_0x50efe0=squel[_0x5ae447(0x147)]()[_0x5ae447(0x179)](_0x5ae447(0x1fc),'i')[_0x5ae447(0xfb)](_0x5ae447(0x1d6),'c',_0x5ae447(0x178))[_0x5ae447(0xfb)](_0x5ae447(0x1a1),'o',_0x5ae447(0x12a))[_0x5ae447(0xfb)](_0x5ae447(0x15a),'a','a.id\x20=\x20i.ChatWebsiteId')[_0x5ae447(0xfb)](_0x5ae447(0x19b),'me',_0x5ae447(0x1ec))['left_join'](_0x5ae447(0x176),'it',_0x5ae447(0x1cf))[_0x5ae447(0xfb)](_0x5ae447(0xf4),'t',_0x5ae447(0x107)),_0x1f99d0=squel[_0x5ae447(0x15f)]();let _0x544547=[];const _0x5d282e=squel[_0x5ae447(0x15f)]();let _0x470e08;if(_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x166)]){_0x470e08=as[_0x5ae447(0x1ee)](_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x166)]);const _0x49ad97=_0x470e08[_0x5ae447(0x141)];for(let _0x12d414=0x0;_0x12d414<_0x470e08[_0x5ae447(0x13d)][_0x5ae447(0x1aa)];_0x12d414++){const _0x270b4f=_0x470e08[_0x5ae447(0x13d)][_0x12d414],_0x5e1a9b='i';let _0x1ad97a,_0x7f31b8=_[_0x5ae447(0x1e0)](_0x193a1f,[_0x5ae447(0x1dc),_0x270b4f['field']]);if(!_0x7f31b8)switch(_0x270b4f[_0x5ae447(0x16b)]){case'unreadMessages':_0x270b4f['value']==0x1?_0x50efe0['having']('`'+_0x270b4f[_0x5ae447(0x16b)]+_0x5ae447(0x159)):_0x50efe0[_0x5ae447(0x130)]('`'+_0x270b4f[_0x5ae447(0x16b)]+_0x5ae447(0x128));break;case _0x5ae447(0x174):if(_0x270b4f[_0x5ae447(0x1df)]==='$substring'){if(_0x270b4f[_0x5ae447(0x1bb)]['split']('\x20')['length']>0x1)_0x1f99d0[_0x49ad97](_0x5ae447(0x155),qs[_0x5ae447(0x117)](_0x270b4f[_0x5ae447(0x1bb)]),null);else{const _0x4f7162='%'+_0x270b4f[_0x5ae447(0x1bb)]+'%';_0x1f99d0[_0x49ad97](_0x5ae447(0xec),_0x4f7162,_0x4f7162,_0x4f7162);}}else _0x7f31b8=_[_0x5ae447(0x1e0)](_0x193a1f,[_0x5ae447(0x1dc),_0x5ae447(0x1cd)]),_0x270b4f[_0x5ae447(0x16b)]=_0x5ae447(0x1cd),_0x1ad97a=as[_0x5ae447(0xee)](_0x5e1a9b,_0x7f31b8['type'],_0x270b4f),_0x1f99d0[_0x49ad97](_0x1ad97a[_0x5ae447(0x1d1)],_0x1ad97a[_0x5ae447(0x1bb)][_0x5ae447(0x11a)],_0x1ad97a[_0x5ae447(0x1bb)][_0x5ae447(0x110)]);break;case'Tag':{const _0x20c8ee=_0x270b4f[_0x5ae447(0x1bb)][_0x5ae447(0x1e7)](',')['map'](function(_0x110ce1){return Number(_0x110ce1);});_0x20c8ee[_0x5ae447(0x1fd)](function(_0x1c3924){const _0x416a73=_0x5ae447;_0x5d282e['or'](_0x416a73(0x208),'%,'+_0x1c3924+',%');}),_0x544547=_[_0x5ae447(0xef)](_0x544547,_0x20c8ee);}break;case _0x5ae447(0x19e):_0x270b4f[_0x5ae447(0x1df)]==='$substring'?_0x1f99d0[_0x49ad97](_0x5ae447(0x1a3),'%'+_0x270b4f[_0x5ae447(0x1bb)]+'%',null):(_0x7f31b8=_[_0x5ae447(0x1e0)](_0x193a1f,['name',_0x5ae447(0x1a0)]),_0x270b4f['field']=_0x5ae447(0x1a0),_0x1ad97a=as[_0x5ae447(0xee)](_0x5e1a9b,_0x7f31b8[_0x5ae447(0x18b)],_0x270b4f),_0x1f99d0[_0x49ad97](_0x1ad97a[_0x5ae447(0x1d1)],_0x1ad97a['value'][_0x5ae447(0x11a)],_0x1ad97a['value'][_0x5ae447(0x110)]));break;case _0x5ae447(0x1f5):_0x1ad97a=as['buildExpression']('me',null,_0x270b4f),_0x1f99d0[_0x49ad97](_0x1ad97a[_0x5ae447(0x1d1)],_0x1ad97a[_0x5ae447(0x1bb)][_0x5ae447(0x11a)],_0x1ad97a['value'][_0x5ae447(0x110)]);break;}else _0x1ad97a=as[_0x5ae447(0xee)](_0x5e1a9b,_0x7f31b8['type'],_0x270b4f),_0x1f99d0[_0x49ad97](_0x1ad97a[_0x5ae447(0x1d1)],_0x1ad97a[_0x5ae447(0x1bb)][_0x5ae447(0x11a)],_0x1ad97a[_0x5ae447(0x1bb)][_0x5ae447(0x110)]);}}else{const _0x1830e6=_(_0x5b6a51[_0x5ae447(0x108)])[_0x5ae447(0x1b4)]()['map'](function(_0x3be67f){const _0x2924cc=_0x5ae447;return _[_0x2924cc(0x14a)](_0x193a1f,[_0x2924cc(0x1dc),_0x3be67f])?_0x3be67f:undefined;})[_0x5ae447(0x125)]()[_0x5ae447(0x1bb)]();!_['isEmpty'](_0x1830e6)&&_0x1830e6[_0x5ae447(0x1fd)](function(_0x14f952){const _0x1e8375=_0x5ae447;if(_0x14f952===_0x1e8375(0x154))_0x50efe0[_0x1e8375(0x13a)](_0x1e8375(0x15b),[][_0x1e8375(0x1e9)](_0x5b6a51[_0x1e8375(0x108)][_0x14f952]));else{if(_0x14f952===_0x1e8375(0x136)){const _0x40178c=JSON[_0x1e8375(0x12d)](_0x5b6a51[_0x1e8375(0x108)][_0x14f952])[_0x1e8375(0x156)],_0x3f2e25=JSON[_0x1e8375(0x12d)](_0x5b6a51[_0x1e8375(0x108)][_0x14f952])[_0x1e8375(0x1a6)];_0x50efe0[_0x1e8375(0x13a)](_0x1e8375(0x119),_0x40178c,_0x3f2e25);}else _0x5b6a51[_0x1e8375(0x108)][_0x14f952]===_0x1e8375(0x1e3)?_0x50efe0[_0x1e8375(0x13a)]('i.'+_0x14f952+'\x20IS\x20NULL'):_0x50efe0[_0x1e8375(0x13a)]('i.'+_0x14f952+_0x1e8375(0x153),_0x5b6a51[_0x1e8375(0x108)][_0x14f952]);}});_0x5b6a51['query'][_0x5ae447(0x1f4)]&&(_0x5b6a51[_0x5ae447(0x108)]['read']==0x1?_0x50efe0[_0x5ae447(0x130)](_0x5ae447(0x180)):_0x50efe0[_0x5ae447(0x130)]('`unreadMessages`\x20>\x200'));_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x1a7)]&&(_0x544547=_[_0x5ae447(0xf2)](_0x5b6a51[_0x5ae447(0x108)]['tag'])?_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x1a7)]:new Array(_0x5b6a51['query'][_0x5ae447(0x1a7)]),_0x544547[_0x5ae447(0x1fd)](function(_0x444a08){const _0x35a2a9=_0x5ae447;_0x5d282e['or'](_0x35a2a9(0x208),'%,'+_0x444a08+',%');}));if(_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x116)]){const _0x2c37d5=_0x5b6a51[_0x5ae447(0x108)][_0x5ae447(0x116)][_0x5ae447(0x170)]('\x5c','\x5c\x5c')[_0x5ae447(0x170)](/'/g,'\x27\x27');qs[_0x5ae447(0x15c)](_0x2c37d5)?_0x1f99d0['or'](_0x5ae447(0x168),_0x2c37d5+'%'):_0x1f99d0['or']('MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs[_0x5ae447(0x117)](_0x2c37d5))['or'](_0x5ae447(0x1da),_0x2c37d5+'%');}}_0x50efe0[_0x5ae447(0x13a)](_0x1f99d0),_0x50efe0[_0x5ae447(0x1b8)](_0x5ae447(0x12b));let _0x2d828f={'type':QueryTypes[_0x5ae447(0x1f6)],'raw':!![]};const _0x5637d7=_0x50efe0['clone']();_0x5637d7[_0x5ae447(0x16b)](_0x5ae447(0x12b)),_0x5637d7[_0x5ae447(0x16b)](_0x5ae447(0x10b),_0x5ae447(0x194)),_0x25f681['order']&&_0x25f681[_0x5ae447(0x1c5)][_0x5ae447(0x1fd)](function(_0x45b6fa){const _0x300991=_0x5ae447,_0x35122c=_0x45b6fa[0x0]===_0x300991(0x1f3)?_0x45b6fa[0x0]:'i.'+_0x45b6fa[0x0];_0x50efe0[_0x300991(0x1c5)](_0x35122c,_0x45b6fa[0x1]===_0x300991(0x157)?![]:!![]);}),!_[_0x5ae447(0x144)](_0x544547)&&(_0x50efe0['having'](_0x5d282e),_0x5637d7['where'](_0x5ae447(0x10c),_0x544547)),Promise[_0x5ae447(0x1fa)]()['then'](function(){const _0x1474bc=_0x5ae447;if(!_0x470e08){if(_0x5b6a51[_0x1474bc(0x108)]['ChatWebsiteId']||_0x5b6a51[_0x1474bc(0x108)][_0x1474bc(0x1f0)])return;_0x5637d7['where'](_0x1474bc(0x11f)),_0x50efe0[_0x1474bc(0x13a)](_0x1474bc(0x11f));return;}return _0x5b6a51[_0x1474bc(0x1ef)][_0x1474bc(0xfd)]({'attributes':['id'],'raw':!![]})[_0x1474bc(0xf6)](function(_0x36288b){const _0x4c9c25=_0x1474bc;_[_0x4c9c25(0x144)](_0x36288b)?(_0x5637d7[_0x4c9c25(0x13a)](_0x4c9c25(0x175)),_0x50efe0['where']('i.ChatWebsiteId\x20IS\x20NULL')):(_0x5637d7['where']('i.ChatWebsiteId\x20IN\x20?',_[_0x4c9c25(0x18a)](_0x36288b,'id')),_0x50efe0[_0x4c9c25(0x13a)](_0x4c9c25(0x15b),_['map'](_0x36288b,'id')));});})[_0x5ae447(0xf6)](function(){const _0x35d81e=_0x5ae447;db[_0x35d81e(0x1bc)][_0x35d81e(0x108)](_0x5637d7[_0x35d81e(0x120)](),_0x2d828f)[_0x35d81e(0xf6)](function(_0x133022){const _0x5a4a4e=_0x35d81e;_0x5864af[_0x5a4a4e(0x17f)]=_0x133022['length'];if(_0x5864af['count']===0x0)return[];return db[_0x5a4a4e(0x1bc)][_0x5a4a4e(0x108)](_0x4a0438[_0x5a4a4e(0x120)](),_0x2d828f)[_0x5a4a4e(0xf6)](function(_0x3093ab){const _0x357155=_0x5a4a4e;_0x2596f2=_[_0x357155(0x1f7)](_0x3093ab,'id'),_0x2d828f=_[_0x357155(0x19a)](_0x2d828f,{'model':db[_0x357155(0x197)],'mapToModel':!![],'raw':!![],'nest':!![]});_0x5b6a51[_0x357155(0x108)]['fields']?_0x25f681[_0x357155(0x1d3)][_0x357155(0x1fd)](function(_0x14c10f){_0x50efe0['field']('i.'+_0x14c10f);}):(_0x50efe0[_0x357155(0x16b)](_0x357155(0x10b),_0x357155(0x194)),_0x50efe0[_0x357155(0x16b)](_0x357155(0x102),'Account.key'),_0x50efe0['field'](_0x357155(0xeb),'Account.mandatoryDisposition'),_0x50efe0[_0x357155(0x16b)](_0x357155(0x1f8),'contactName'),_0x50efe0[_0x357155(0x16b)](_0x357155(0x1dd)),_0x50efe0[_0x357155(0x16b)](_0x357155(0xf7),_0x357155(0x1ca)),_0x50efe0['field'](_0x357155(0x191),'Contact.lastName'),_0x50efe0[_0x357155(0x16b)]('c.email',_0x357155(0x145)),_0x50efe0[_0x357155(0x16b)](_0x357155(0x10f),'Contact.phone'),_0x50efe0[_0x357155(0x16b)]('c.mobile',_0x357155(0xf1)),_0x50efe0['field']('c.fax',_0x357155(0x196)),_0x50efe0[_0x357155(0x16b)]('o.fullname',_0x357155(0x163)),_0x50efe0['field'](_0x357155(0xfe),_0x357155(0x1c1)),_0x50efe0['field'](_0x357155(0x13c),_0x357155(0x1b0)));if(_0x25f681[_0x357155(0x1c0)])_0x50efe0[_0x357155(0x1c0)](_0x25f681[_0x357155(0x1c0)]);if(_0x25f681[_0x357155(0x1b7)])_0x50efe0[_0x357155(0x1b7)](_0x25f681[_0x357155(0x1b7)]);return db[_0x357155(0x1bc)][_0x357155(0x108)](_0x50efe0[_0x357155(0x120)](),_0x2d828f);})[_0x5a4a4e(0xf6)](function(_0x12fc74){const _0x31615b=_0x5a4a4e;return _0x39aee6[_0x31615b(0x13a)]('ui.ChatInteractionId\x20IN\x20?',_[_0x31615b(0x18a)](_0x12fc74,'id')),db[_0x31615b(0x1bc)][_0x31615b(0x108)](_0x39aee6['toString'](),_0x2d828f)['then'](function(_0x42dac8){const _0x4f5351=_0x31615b,_0x10d576=_[_0x4f5351(0x111)](_0x42dac8,_0x4f5351(0x1f2)),_0x3d2f69=[];return _0x12fc74['forEach'](function(_0x37e8b4){const _0xa601e7=_0x4f5351;_0x3d2f69[_0xa601e7(0x17e)](updateChatInteraction(_0x37e8b4,_0x2596f2,_0x10d576));}),Promise[_0x4f5351(0x1e4)](_0x3d2f69);});});})[_0x35d81e(0xf6)](function(_0x526328){const _0x238fd5=_0x35d81e;return _0x5864af[_0x238fd5(0x19c)]=_0x526328,_0x5864af;})[_0x35d81e(0xf6)](respondWithFilteredResult(_0x49dc03,_0x25f681));})[_0x5ae447(0x16a)](handleError(_0x49dc03,null));},exports[a80_0x4a36e5(0x14f)]=function(_0x43a74b,_0x446323){const _0x55ef46=a80_0x4a36e5;let _0x4cee0c={'raw':![],'where':{'id':_0x43a74b[_0x55ef46(0x14b)]['id']}};const _0x54d1e7={};return _0x54d1e7[_0x55ef46(0x14c)]=_[_0x55ef46(0x1b4)](db[_0x55ef46(0x197)][_0x55ef46(0x161)]),_0x54d1e7[_0x55ef46(0x108)]=_[_0x55ef46(0x1b4)](_0x43a74b['query']),_0x54d1e7[_0x55ef46(0x138)]=_['intersection'](_0x54d1e7[_0x55ef46(0x14c)],_0x54d1e7[_0x55ef46(0x108)]),_0x4cee0c[_0x55ef46(0x1d3)]=_[_0x55ef46(0x101)](_0x54d1e7[_0x55ef46(0x14c)],qs[_0x55ef46(0x1ed)](_0x43a74b[_0x55ef46(0x108)][_0x55ef46(0x1ed)])),_0x4cee0c[_0x55ef46(0x1d3)]=_0x4cee0c['attributes']['length']?_0x4cee0c['attributes']:_0x54d1e7[_0x55ef46(0x14c)],_0x43a74b['query'][_0x55ef46(0x1b6)]&&(_0x4cee0c[_0x55ef46(0x187)]=[{'all':!![]}]),_0x4cee0c=_['merge']({},_0x4cee0c,_0x43a74b[_0x55ef46(0x1ce)]),db[_0x55ef46(0x197)][_0x55ef46(0x1b3)](_0x4cee0c)[_0x55ef46(0xf6)](handleEntityNotFound(_0x446323,null))[_0x55ef46(0xf6)](respondWithResult(_0x446323,null))[_0x55ef46(0x16a)](handleError(_0x446323,null));},exports['create']=function(_0x4f13c7,_0x2bd105){const _0x30b04e=a80_0x4a36e5;return db[_0x30b04e(0x197)][_0x30b04e(0x137)](_0x4f13c7[_0x30b04e(0x1f5)],{})['then'](respondWithResult(_0x2bd105,0xc9))[_0x30b04e(0x16a)](handleError(_0x2bd105,null));},exports[a80_0x4a36e5(0xf9)]=function(_0x194868,_0xc54335){const _0x4d6a8c=a80_0x4a36e5;return _0x194868[_0x4d6a8c(0x1f5)]['id']&&delete _0x194868['body']['id'],db[_0x4d6a8c(0x197)][_0x4d6a8c(0x1b3)]({'where':{'id':_0x194868[_0x4d6a8c(0x14b)]['id']}})[_0x4d6a8c(0xf6)](handleEntityNotFound(_0xc54335,null))[_0x4d6a8c(0xf6)](saveUpdates(_0x194868[_0x4d6a8c(0x1f5)],null))[_0x4d6a8c(0xf6)](respondWithResult(_0xc54335,null))[_0x4d6a8c(0x16a)](handleError(_0xc54335,null));},exports[a80_0x4a36e5(0x15d)]=function(_0x35ef00,_0x6b1a9f){const _0x242663=a80_0x4a36e5;return db[_0x242663(0x197)][_0x242663(0x1b3)]({'where':{'id':_0x35ef00[_0x242663(0x14b)]['id']}})[_0x242663(0xf6)](handleEntityNotFound(_0x6b1a9f,null))['then'](removeEntity(_0x6b1a9f,null))['catch'](handleError(_0x6b1a9f,null));},exports[a80_0x4a36e5(0x177)]=function(_0x414882,_0x1ed47b){const _0x4db8df=a80_0x4a36e5;return db[_0x4db8df(0x197)][_0x4db8df(0x177)]()[_0x4db8df(0xf6)](respondWithResult(_0x1ed47b,null))['catch'](handleError(_0x1ed47b,null));},exports[a80_0x4a36e5(0x203)]=function(_0x1ed4b0,_0x57f3b7){const _0x143072=a80_0x4a36e5,_0xabb7b9=_0x1ed4b0[_0x143072(0x14b)]['id'];let _0x1d6f1c,_0x229d93,_0x4343b9;return db[_0x143072(0x197)]['findOne']({'where':{'id':_0xabb7b9}})[_0x143072(0xf6)](function(_0x2d4147){const _0x410713=_0x143072;return _0x1d6f1c=_0x2d4147,db['ChatWebsite'][_0x410713(0x1b3)]({'where':{'id':_0x2d4147['ChatWebsiteId']},'attributes':['id',_0x410713(0x124),_0x410713(0x188)],'raw':!![]});})[_0x143072(0xf6)](function(_0x1244c5){const _0x1a8cd9=_0x143072;if(_0x1244c5&&_0x1244c5[_0x1a8cd9(0x124)]&&_0x1244c5['vidaooEscalation']){_0x229d93=_0x1244c5;const _0x4ced43={'rejectUnauthorized':![],'method':_0x1a8cd9(0x200),'uri':'https://api-vidaoo.xcally.com/api/v1/sessions','headers':{'X-APIKEY':_0x1244c5['vidaooApiKey']},'body':{'name':_0x1a8cd9(0x139)+_0xabb7b9},'redirect':_0x1a8cd9(0x201),'json':!![]};return rp(_0x4ced43);}else throw new ValidationError(_0x1a8cd9(0x122));})[_0x143072(0xf6)](function(_0x5577ea){const _0x27d141=_0x143072;_0x4343b9=_0x5577ea;if(_0x4343b9['id']){const _0x4ca2b8={'body':_0x4343b9[_0x27d141(0x186)],'ChatWebsiteId':_0x229d93['id'],'ChatInteractionId':_0x1d6f1c['id'],'direction':_0x27d141(0x1a8),'UserId':_0x1ed4b0[_0x27d141(0x1ef)]['id']};return db[_0x27d141(0x193)]['create'](_0x4ca2b8,{});}else throw new ValidationError('Unable\x20to\x20create\x20Vidaoo\x20session');})[_0x143072(0xf6)](function(){return _0x1d6f1c['update']({'vidaooSessionId':_0x4343b9['id']});})[_0x143072(0xf6)](respondWithResult(_0x57f3b7,null))['catch'](handleError(_0x57f3b7,null));},exports['customUpdate']=function(_0x22aff0,_0x3c6dd6){const _0x1e28c5=a80_0x4a36e5;return _0x22aff0[_0x1e28c5(0x1f5)]['id']&&delete _0x22aff0[_0x1e28c5(0x1f5)]['id'],db[_0x1e28c5(0x197)]['findOne']({'where':{'id':_0x22aff0[_0x1e28c5(0x14b)]['id']}})[_0x1e28c5(0xf6)](handleEntityNotFound(_0x3c6dd6,null))['then'](saveUpdates(_0x22aff0[_0x1e28c5(0x1f5)],null))[_0x1e28c5(0xf6)](respondWithResult(_0x3c6dd6,null))[_0x1e28c5(0x16a)](handleError(_0x3c6dd6,null));},exports[a80_0x4a36e5(0x16d)]=function(_0x1b198d,_0x134a88){const _0x4cc458=a80_0x4a36e5;return _0x1b198d[_0x4cc458(0x1f5)]['id']&&delete _0x1b198d[_0x4cc458(0x1f5)]['id'],db[_0x4cc458(0x197)][_0x4cc458(0x1b3)]({'where':{'id':_0x1b198d[_0x4cc458(0x14b)]['id']}})[_0x4cc458(0xf6)](function(_0x40738a){const _0x568585=_0x4cc458;if(!_0x40738a)logger[_0x568585(0x11e)](_0x568585(0x1c9),'abandon',0x194,_0x568585(0x1d2)),_0x134a88['sendStatus'](0x194);else{if(_0x40738a['UserId'])throw new ValidationError(_0x568585(0x1d5));}return _0x40738a;})[_0x4cc458(0xf6)](function(_0x3648f1){const _0xc7c555=_0x4cc458;if(_0x3648f1)return _0x3648f1['update']({'closed':_0x1b198d[_0xc7c555(0x1f5)][_0xc7c555(0x14e)],'disposition':_0x1b198d[_0xc7c555(0x1f5)][_0xc7c555(0x148)]})['then'](function(_0x256b50){return _0x256b50;});})[_0x4cc458(0xf6)](function(){const _0x34689b=_0x4cc458;return respondWithRpcPromise(_0x34689b(0x109),_0x34689b(0x16d),_0x1b198d[_0x34689b(0x1f5)],client9004);})['then'](respondWithResult(_0x134a88,null))['catch'](handleError(_0x134a88,null));},exports[a80_0x4a36e5(0x1c3)]=function(_0xa47064,_0x10a87b){const _0x46139a=a80_0x4a36e5;return _0xa47064[_0x46139a(0x1f5)]['name']=_0xa47064[_0x46139a(0x149)]['originalname'],_0xa47064[_0x46139a(0x1f5)][_0x46139a(0x10d)]=_0xa47064[_0x46139a(0x149)]['filename'],_0xa47064['body'][_0x46139a(0x18b)]=_0xa47064['file'][_0x46139a(0x195)],db[_0x46139a(0x12c)][_0x46139a(0x137)](_0xa47064[_0x46139a(0x1f5)])['then'](respondWithResult(_0x10a87b,0xc9))[_0x46139a(0x16a)](handleError(_0x10a87b,null));},exports['attachmentDownload']=function(_0xa63b6f,_0x29a9be){const _0x5bfadb=a80_0x4a36e5;return db[_0x5bfadb(0x197)][_0x5bfadb(0x1b3)]({'where':{'id':_0xa63b6f['params']['id']},'raw':!![]})[_0x5bfadb(0xf6)](handleEntityNotFound(_0x29a9be,null))[_0x5bfadb(0xf6)](function(_0x3cb102){const _0x5f061b=_0x5bfadb;if(_0x3cb102){if(_0x3cb102[_0x5f061b(0x14e)])return _0x29a9be[_0x5f061b(0x10e)](0x193)['json']({'status':0x193,'message':_0x5f061b(0x206)});return db[_0x5f061b(0x12c)][_0x5f061b(0x1b3)]({'where':{'id':_0xa63b6f[_0x5f061b(0x108)][_0x5f061b(0x126)]},'raw':!![]})['then'](handleEntityNotFound(_0x29a9be,null));}})['then'](function(_0x2e70f6){const _0x5a7acc=_0x5bfadb;if(_0x2e70f6)return _0x29a9be[_0x5a7acc(0x171)](path[_0x5a7acc(0x121)](config[_0x5a7acc(0x1d9)],_0x5a7acc(0x18c),_0x2e70f6[_0x5a7acc(0x10d)]));})['catch'](handleError(_0x29a9be,null));},exports[a80_0x4a36e5(0x105)]=function(_0x34caef,_0x42f520){const _0x430a68=a80_0x4a36e5;let _0x497d20=null,_0x32a8bf=null,_0x403ad7=null;return _0x34caef['body']['id']&&delete _0x34caef[_0x430a68(0x1f5)]['id'],_0x34caef[_0x430a68(0x1f5)][_0x430a68(0x169)]&&(_0x403ad7=path[_0x430a68(0x121)](config[_0x430a68(0x1d9)],'server/files/chat/upload/',util['format']('transcript-%s.txt',Date['now']())),_0x34caef['body'][_0x430a68(0x1b9)]=_0x403ad7),db['ChatInteraction']['findOne']({'where':{'id':_0x34caef[_0x430a68(0x14b)]['id']},'include':[{'model':db[_0x430a68(0x193)],'as':_0x430a68(0x19f),'include':[{'model':db[_0x430a68(0x19e)],'as':_0x430a68(0x19e)}]}]})[_0x430a68(0xf6)](handleEntityNotFound(_0x42f520,null))['then'](saveUpdates(_0x34caef[_0x430a68(0x1f5)],null))[_0x430a68(0xf6)](function(_0x33fbc4){const _0x57d666=_0x430a68;if(_0x33fbc4)return _0x497d20=_0x33fbc4,db[_0x57d666(0x11c)][_0x57d666(0x1b3)]({'where':{'id':_0x497d20[_0x57d666(0x154)]}});})[_0x430a68(0xf6)](function(_0x1b9093){if(_0x1b9093)return _0x32a8bf=_0x1b9093,db['CmContact']['findOne']({'where':{'id':_0x497d20['ContactId']}});})[_0x430a68(0xf6)](function(_0x2deb1c){const _0x36eaed=_0x430a68;if(_0x2deb1c){if(_0x403ad7){let _0x3f7111=null;for(let _0x31efd2=0x1;_0x31efd2<_0x497d20[_0x36eaed(0x19f)]['length'];++_0x31efd2){_0x3f7111=_0x497d20[_0x36eaed(0x19f)][_0x31efd2];let _0x163960=_0x3f7111['UserId']?util['format'](_0x36eaed(0x15e),_0x32a8bf[_0x36eaed(0x114)],_0x3f7111[_0x36eaed(0x1a0)]):_0x36eaed(0x16f);const _0x14d537=_0x34caef[_0x36eaed(0x1f5)]['customer']||util['format'](_0x36eaed(0x15e),_0x36eaed(0x142),_0x3f7111[_0x36eaed(0x1cd)]);switch(_0x32a8bf['agentIdentifier']){case _0x36eaed(0x17a):_0x163960=_0x3f7111['UserId']?util[_0x36eaed(0x1d4)](_0x36eaed(0x15e),_0x32a8bf[_0x36eaed(0x114)],_0x3f7111[_0x36eaed(0x1a0)]):_0x36eaed(0x16f);break;case _0x36eaed(0x1ba):_0x163960=_0x3f7111['UserId']?_0x3f7111[_0x36eaed(0x19e)][_0x36eaed(0x14d)]||_0x3f7111['User'][_0x36eaed(0x189)]:_0x36eaed(0x16f);break;case'agent_fullname':_0x163960=_0x3f7111[_0x36eaed(0x1a0)]?_0x3f7111[_0x36eaed(0x19e)][_0x36eaed(0x189)]:'System';break;default:_0x163960=_0x3f7111['UserId']?util['format']('%s%d',_0x32a8bf['agentAlias'],_0x3f7111[_0x36eaed(0x1a0)]):_0x36eaed(0x16f);}const _0x33d167=util[_0x36eaed(0x1d4)](_0x36eaed(0x1be),moment(_0x3f7111[_0x36eaed(0x136)])[_0x36eaed(0x1d4)]('MM/DD/YYYY\x20HH:mm:ss'),_0x3f7111[_0x36eaed(0x11d)]==='in'?_0x14d537:_0x163960,_0x3f7111['body']);!_0x3f7111[_0x36eaed(0x1ac)]&&fs[_0x36eaed(0x164)](_0x403ad7,_0x33d167);}return db['MailAccount']['findOne']({'where':{'service':!![]},'include':[{'model':db[_0x36eaed(0x16e)],'as':_0x36eaed(0x190),'raw':!![]}]});}}})['then'](function(_0x1d8678){const _0x3b5770=_0x430a68;if(_0x1d8678&&_0x1d8678['Smtp']&&_0x34caef[_0x3b5770(0x1f5)]){const _0x446d55={'tls':{'rejectUnauthorized':![]}};return _0x1d8678['Smtp'][_0x3b5770(0x1a5)]?_0x446d55[_0x3b5770(0x1a5)]=_0x1d8678['Smtp'][_0x3b5770(0x1a5)]:(_0x446d55[_0x3b5770(0x1de)]=_0x1d8678[_0x3b5770(0x190)][_0x3b5770(0x1de)],_0x446d55['port']=_0x1d8678[_0x3b5770(0x190)][_0x3b5770(0xf5)],_0x446d55[_0x3b5770(0xfa)]=_0x1d8678['Smtp']['secure']),_0x1d8678[_0x3b5770(0x190)][_0x3b5770(0xea)]&&(_0x446d55['auth']={'user':_0x1d8678[_0x3b5770(0x190)][_0x3b5770(0x1ef)],'pass':_0x1d8678[_0x3b5770(0x190)]['pass']}),respondWithRpcPromise(_0x3b5770(0x129),_0x3b5770(0x181),{'account':_0x446d55,'message':{'from':util[_0x3b5770(0x1d4)](_0x3b5770(0x158),_0x1d8678[_0x3b5770(0x1dc)],_0x1d8678[_0x3b5770(0x1d7)]||_0x1d8678['Smtp'][_0x3b5770(0x1ef)]),'to':_0x34caef[_0x3b5770(0x1f5)][_0x3b5770(0x169)],'subject':'Mail\x20Transcript','text':util[_0x3b5770(0x1d4)]('Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a',_0x34caef[_0x3b5770(0x1f5)][_0x3b5770(0x169)]),'attachments':[{'path':_0x403ad7}]}})[_0x3b5770(0xf6)](function(){return _0x497d20;})[_0x3b5770(0x16a)](function(_0x1cc7d4){const _0x526707=_0x3b5770;console[_0x526707(0x11e)](_0x1cc7d4);});}else return _0x497d20;})['then'](respondWithStatusCode(_0x42f520,0xc8))[_0x430a68(0x16a)](handleError(_0x42f520,null));},exports['addMessage']=function(_0x3b8815,_0x12d6d0){const _0xe7350a=a80_0x4a36e5;return db[_0xe7350a(0x193)][_0xe7350a(0x1b3)]({'where':{'id':_0x3b8815[_0xe7350a(0x14b)]['id']}})[_0xe7350a(0xf6)](function(_0x8d1a6){const _0x484d04=_0xe7350a;if(_0x8d1a6)return _0x8d1a6['addMessage'](_0x3b8815['body']['ids'],{'through':_['omit'](_0x3b8815[_0x484d04(0x1f5)],[_0x484d04(0x185),'id'])});})['then'](respondWithResult(_0x12d6d0,null))['catch'](handleError(_0x12d6d0,null));},exports[a80_0x4a36e5(0x123)]=function(_0x407557,_0x167021){const _0x1b6eaf=a80_0x4a36e5;let _0x68d0ac={'raw':![],'where':{}};const _0x2af6b1={},_0x34c495={'count':0x0,'rows':[]};return db[_0x1b6eaf(0x197)][_0x1b6eaf(0x1b3)]({'where':{'id':_0x407557[_0x1b6eaf(0x14b)]['id']}})['then'](handleEntityNotFound(_0x167021,null))[_0x1b6eaf(0xf6)](function(_0x93c097){const _0x1a57cf=_0x1b6eaf;if(_0x93c097){_0x2af6b1[_0x1a57cf(0x14c)]=_[_0x1a57cf(0x1b4)](db['ChatMessage'][_0x1a57cf(0x161)]),_0x2af6b1[_0x1a57cf(0x108)]=_['keys'](_0x407557[_0x1a57cf(0x108)]),_0x2af6b1['filters']=_[_0x1a57cf(0x101)](_0x2af6b1[_0x1a57cf(0x14c)],_0x2af6b1[_0x1a57cf(0x108)]),_0x68d0ac['attributes']=_['intersection'](_0x2af6b1[_0x1a57cf(0x14c)],qs[_0x1a57cf(0x1ed)](_0x407557[_0x1a57cf(0x108)][_0x1a57cf(0x1ed)])),_0x68d0ac[_0x1a57cf(0x1d3)]=_0x68d0ac[_0x1a57cf(0x1d3)][_0x1a57cf(0x1aa)]?_0x68d0ac[_0x1a57cf(0x1d3)]:_0x2af6b1['model'];typeof _0x407557['query']['nolimit']===_0x1a57cf(0x1fb)&&(_0x68d0ac[_0x1a57cf(0x1c0)]=qs['limit'](_0x407557[_0x1a57cf(0x108)]['limit']),_0x68d0ac[_0x1a57cf(0x1b7)]=qs[_0x1a57cf(0x1b7)](_0x407557['query'][_0x1a57cf(0x1b7)]));_0x68d0ac[_0x1a57cf(0x1c5)]=qs['sort'](_0x407557[_0x1a57cf(0x108)][_0x1a57cf(0x1e5)]),_0x68d0ac[_0x1a57cf(0x13a)]=qs[_0x1a57cf(0x138)](_[_0x1a57cf(0x204)](_0x407557[_0x1a57cf(0x108)],_0x2af6b1[_0x1a57cf(0x138)])),_0x68d0ac[_0x1a57cf(0x13a)][_0x1a57cf(0x1f2)]=_0x93c097['id'];_0x407557[_0x1a57cf(0x108)][_0x1a57cf(0x116)]&&(_0x68d0ac[_0x1a57cf(0x13a)]=_[_0x1a57cf(0x19a)](_0x68d0ac[_0x1a57cf(0x13a)],{[Op['or']]:_[_0x1a57cf(0x18a)](_0x68d0ac[_0x1a57cf(0x1d3)],function(_0x3e1957){const _0x152442=_0x1a57cf,_0x41ae27={};return _0x41ae27[_0x3e1957]={[Op['like']]:'%'+_0x407557['query'][_0x152442(0x116)]+'%'},_0x41ae27;})}));if(_0x407557['query'][_0x1a57cf(0x156)]){const _0x2d3639=_0x407557['query'][_0x1a57cf(0x156)][_0x1a57cf(0x1e7)](','),_0x2f4c20={};_0x2f4c20[_0x2d3639[0x0]]={[Op[_0x1a57cf(0x1a2)]]:moment(_0x2d3639[0x1])['format'](_0x1a57cf(0x207))},_0x68d0ac['where']=_[_0x1a57cf(0x19a)](_0x68d0ac[_0x1a57cf(0x13a)],_0x2f4c20);}return _0x68d0ac=_[_0x1a57cf(0x19a)]({},_0x68d0ac,_0x407557[_0x1a57cf(0x1ce)]),db['ChatMessage'][_0x1a57cf(0x17f)]({'where':_0x68d0ac[_0x1a57cf(0x13a)]})['then'](function(_0x51c484){const _0x18d32a=_0x1a57cf;return _0x34c495[_0x18d32a(0x17f)]=_0x51c484,_0x407557[_0x18d32a(0x108)][_0x18d32a(0x1b6)]&&(_0x68d0ac[_0x18d32a(0x187)]=[{'all':!![]}]),db[_0x18d32a(0x193)]['findAll'](_0x68d0ac);})[_0x1a57cf(0xf6)](function(_0x4750a5){const _0x555fe0=_0x1a57cf;return _0x34c495[_0x555fe0(0x19c)]=_0x4750a5,_0x34c495;});}})['then'](respondWithFilteredResult(_0x167021,_0x68d0ac))['catch'](handleError(_0x167021,null));},exports['getMyMessages']=function(_0x2e58e0,_0x1f5c2a){const _0x42ca4a=a80_0x4a36e5;let _0x2d0263={'where':{}};const _0xee8aaa={},_0x35b10c={'count':0x0,'rows':[]};return db[_0x42ca4a(0x197)][_0x42ca4a(0x1b3)]({'where':{'id':_0x2e58e0[_0x42ca4a(0x14b)]['id']}})[_0x42ca4a(0xf6)](handleEntityNotFound(_0x1f5c2a,null))[_0x42ca4a(0xf6)](function(_0x1e08dc){const _0x323dac=_0x42ca4a;if(_0x1e08dc)return _0xee8aaa[_0x323dac(0x14c)]=_['keys'](db[_0x323dac(0x193)][_0x323dac(0x161)]),_0xee8aaa[_0x323dac(0x108)]=_[_0x323dac(0x1b4)](_0x2e58e0[_0x323dac(0x108)]),_0xee8aaa[_0x323dac(0x138)]=_[_0x323dac(0x101)](_0xee8aaa[_0x323dac(0x14c)],_0xee8aaa[_0x323dac(0x108)]),_0x2d0263['attributes']=_[_0x323dac(0x101)](_0xee8aaa[_0x323dac(0x14c)],qs[_0x323dac(0x1ed)](_0x2e58e0['query'][_0x323dac(0x1ed)])),_0x2d0263[_0x323dac(0x1d3)]=_0x2d0263['attributes'][_0x323dac(0x1aa)]?_0x2d0263[_0x323dac(0x1d3)]:_0xee8aaa['model'],typeof _0x2e58e0[_0x323dac(0x108)][_0x323dac(0x1c8)]===_0x323dac(0x1fb)&&(_0x2d0263[_0x323dac(0x1c0)]=qs[_0x323dac(0x1c0)](_0x2e58e0[_0x323dac(0x108)][_0x323dac(0x1c0)]),_0x2d0263[_0x323dac(0x1b7)]=qs[_0x323dac(0x1b7)](_0x2e58e0[_0x323dac(0x108)][_0x323dac(0x1b7)])),_0x2d0263[_0x323dac(0x1c5)]=qs[_0x323dac(0x1e5)](_0x2e58e0[_0x323dac(0x108)][_0x323dac(0x1e5)]),_0x2d0263[_0x323dac(0x13a)]=qs[_0x323dac(0x138)](_[_0x323dac(0x204)](_0x2e58e0['query'],_0xee8aaa[_0x323dac(0x138)])),_0x2d0263[_0x323dac(0x13a)][_0x323dac(0x1f2)]=_0x1e08dc['id'],_0x2e58e0[_0x323dac(0x108)][_0x323dac(0x116)]&&(_0x2d0263[_0x323dac(0x13a)]=_['merge'](_0x2d0263['where'],{[Op['or']]:_[_0x323dac(0x18a)](_0x2d0263[_0x323dac(0x1d3)],function(_0x6629d0){const _0x3c115a=_0x323dac,_0xf21c53={};return _0xf21c53[_0x6629d0]={[Op[_0x3c115a(0x133)]]:'%'+_0x2e58e0[_0x3c115a(0x108)]['filter']+'%'},_0xf21c53;})})),_0x2d0263[_0x323dac(0x13a)][_0x323dac(0x1ac)]=![],_0x2e58e0[_0x323dac(0x108)]['id']&&(_0x2d0263[_0x323dac(0x13a)]['id']={[Op['gt']]:_0x2e58e0[_0x323dac(0x108)]['id']}),_0x2d0263=_[_0x323dac(0x19a)]({},_0x2d0263,_0x2e58e0['options']),db['ChatMessage'][_0x323dac(0x17f)]({'where':_0x2d0263['where']})['then'](function(_0x5b33dc){const _0x594579=_0x323dac;return _0x35b10c['count']=_0x5b33dc,_0x2d0263[_0x594579(0x187)]=[],_0x2e58e0[_0x594579(0x108)]['includeAgent']&&_0x2d0263['include'][_0x594579(0x17e)]({'model':db['User'],'as':'User','attributes':['id',_0x594579(0x189),_0x594579(0x14d)]}),_0x2e58e0['query'][_0x594579(0x1b6)]&&(_0x2d0263[_0x594579(0x187)]=[{'all':!![]}]),db[_0x594579(0x193)]['findAll'](_0x2d0263);})['then'](function(_0x5f3490){const _0x37341=_0x323dac;return _0x35b10c[_0x37341(0x19c)]=_0x5f3490,_0x35b10c;});})[_0x42ca4a(0xf6)](respondWithFilteredResult(_0x1f5c2a,_0x2d0263))[_0x42ca4a(0x16a)](handleError(_0x1f5c2a,null));},exports[a80_0x4a36e5(0x202)]=function(_0x4c52a7,_0x1a28d2){const _0x133e0c=a80_0x4a36e5;return db[_0x133e0c(0x197)][_0x133e0c(0x1b3)]({'where':{'id':_0x4c52a7[_0x133e0c(0x14b)]['id']}})[_0x133e0c(0xf6)](function(_0x4bd912){const _0x51347d=_0x133e0c;if(_0x4bd912)return _0x4bd912[_0x51347d(0x13b)](_0x4c52a7[_0x51347d(0x1f5)][_0x51347d(0x185)],{'through':_[_0x51347d(0xed)](_0x4c52a7[_0x51347d(0x1f5)],[_0x51347d(0x185),'id'])})[_0x51347d(0xf6)](function(){const _0x532abf=_0x51347d;return db[_0x532abf(0x1c7)][_0x532abf(0x1cb)]({'attributes':['id','name','color'],'where':{'id':_0x4c52a7['body'][_0x532abf(0x185)]}});})[_0x51347d(0xf6)](function(_0x550704){const _0x471eb7=_0x51347d;return socket[_0x471eb7(0x16c)](_0x471eb7(0x1ff),{'id':Number(_0x4c52a7[_0x471eb7(0x14b)]['id']),'tags':_0x550704||[]}),{'id':Number(_0x4c52a7[_0x471eb7(0x14b)]['id']),'tags':_0x550704||[]};});})[_0x133e0c(0xf6)](respondWithResult(_0x1a28d2,null))[_0x133e0c(0x16a)](handleError(_0x1a28d2,null));},exports['removeTags']=function(_0x3ae02a,_0x32f1a4){const _0x2c12c3=a80_0x4a36e5;return db[_0x2c12c3(0x197)][_0x2c12c3(0x1b3)]({'where':{'id':_0x3ae02a['params']['id']}})['then'](handleEntityNotFound(_0x32f1a4,null))[_0x2c12c3(0xf6)](function(_0x3714a2){const _0x3a9476=_0x2c12c3;if(_0x3714a2)return _0x3714a2[_0x3a9476(0x167)](_0x3ae02a[_0x3a9476(0x108)]['ids']);})[_0x2c12c3(0xf6)](respondWithStatusCode(_0x32f1a4,null))[_0x2c12c3(0x16a)](handleError(_0x32f1a4,null));},exports[a80_0x4a36e5(0x171)]=function(_0xcc08da,_0x270fea){const _0x3180c0=a80_0x4a36e5,_0x3199a1=moment()[_0x3180c0(0x100)]()[_0x3180c0(0x120)](),_0xb472aa=path['join'](config[_0x3180c0(0x1d9)],_0x3180c0(0x205),_0x3180c0(0x106)),_0x280540=path[_0x3180c0(0x121)](config[_0x3180c0(0x1d9)],_0x3180c0(0x1d8),_0x3180c0(0x205),_0x3180c0(0x172)),_0x701334=path[_0x3180c0(0x121)](_0xb472aa,_0x3199a1),_0x5bda12=util[_0x3180c0(0x1d4)](_0x3180c0(0x1fe),_0xcc08da[_0x3180c0(0x14b)]['id'],_0x3199a1),_0x2a232d=path['join'](_0xb472aa,_0x5bda12),_0xf8a262=[];_0xf8a262[_0x3180c0(0x17e)]({'model':db[_0x3180c0(0x19e)],'as':'User','attributes':['id','fullname'],'raw':!![]}),_0xf8a262[_0x3180c0(0x17e)]({'model':db[_0x3180c0(0x113)],'as':_0x3180c0(0x174),'attributes':['id',_0x3180c0(0x1f9),_0x3180c0(0x17b)],'raw':!![]});_0xcc08da[_0x3180c0(0x108)][_0x3180c0(0x172)]&&_0xf8a262[_0x3180c0(0x17e)]({'model':db[_0x3180c0(0x12c)],'as':'Attachment','raw':!![]});const _0x3bcc63=[{'model':db[_0x3180c0(0x193)],'as':'Messages','attributes':['id',_0x3180c0(0x1f5),_0x3180c0(0x136),_0x3180c0(0x11d),'secret',_0x3180c0(0x1f4)],'include':_0xf8a262}];return _0x3bcc63['push']({'model':db['ChatWebsite'],'as':'Account','attributes':['id',_0x3180c0(0x1dc)]}),_0x3bcc63['push']({'model':db[_0x3180c0(0x19e)],'as':_0x3180c0(0x12f),'attributes':['id',_0x3180c0(0x189)]}),db['ChatInteraction'][_0x3180c0(0x1b3)]({'where':{'id':_0xcc08da[_0x3180c0(0x14b)]['id']},'include':_0x3bcc63})['then'](handleEntityNotFound(_0x270fea,null))[_0x3180c0(0xf6)](function(_0x52fc23){const _0x4d678a=_0x3180c0;if(_0x52fc23){const _0x39e503=_0x52fc23[_0x4d678a(0x135)]({'plain':!![]});fs[_0x4d678a(0x1af)](_0x701334);const _0x4da2d6={'format':'A4','border':_0x4d678a(0x182),'header':{'height':_0x4d678a(0x1c2),'contents':{'first':_0x4d678a(0x18f)}},'footer':{'height':_0x4d678a(0x17c),'contents':{'default':util[_0x4d678a(0x1d4)](_0x4d678a(0x104),util[_0x4d678a(0x1d4)](_0x4d678a(0x12e),_0x4d678a(0x1ea),_0x39e503['id']),moment()[_0x4d678a(0x1d4)]('YYYY-MM-DD')[_0x4d678a(0x120)]())}}},_0x2fb116={'channel':_0x4d678a(0x1ea),'account':_0x39e503[_0x4d678a(0x1e8)][_0x4d678a(0x1dc)],'agent':_0x39e503[_0x4d678a(0x12f)]?_0x39e503[_0x4d678a(0x12f)][_0x4d678a(0x189)]:_0x4d678a(0x1b5),'createdAt':moment(_0x39e503['createdAt'])['format']('YYYY-MM-DD\x20HH:mm:ss')[_0x4d678a(0x120)](),'closedAt':_0x39e503[_0x4d678a(0x14e)]?moment(_0x39e503[_0x4d678a(0x132)])[_0x4d678a(0x1d4)](_0x4d678a(0x207))[_0x4d678a(0x120)]():'','disposition':_0x39e503[_0x4d678a(0x148)],'chatInfo':{'browser':_0x39e503[_0x4d678a(0x1b1)],'os':_0x39e503[_0x4d678a(0x18e)],'referer':_0x39e503[_0x4d678a(0x118)],'customerIp':_0x39e503[_0x4d678a(0x1a9)],'customerPort':_0x39e503[_0x4d678a(0xf0)]?_0x39e503[_0x4d678a(0xf0)]:_0x4d678a(0x1b5)},'messages':_(_0x39e503[_0x4d678a(0x19f)])['tail']()[_0x4d678a(0x116)]({'secret':![]})['map'](function(_0x2a9687){const _0x5a238a=_0x4d678a;if(_0x2a9687[_0x5a238a(0x12c)]){const _0x4c47d8=path[_0x5a238a(0x121)](_0x280540,_0x2a9687[_0x5a238a(0x12c)][_0x5a238a(0x10d)]);fs['existsSync'](_0x4c47d8)&&fs['createReadStream'](_0x4c47d8)[_0x5a238a(0x146)](fs['createWriteStream'](path[_0x5a238a(0x121)](_0x701334,_0x2a9687[_0x5a238a(0x12c)][_0x5a238a(0x10d)])));}return{'date':moment(_0x2a9687[_0x5a238a(0x136)])[_0x5a238a(0x1d4)](_0x5a238a(0x207))[_0x5a238a(0x120)](),'sender':_0x2a9687[_0x5a238a(0x11d)]==='out'?_0x2a9687[_0x5a238a(0x19e)]?_0x2a9687['User'][_0x5a238a(0x189)]:_0x5a238a(0x16f):_0x2a9687[_0x5a238a(0x174)][_0x5a238a(0x1f9)]+(_0x2a9687['Contact'][_0x5a238a(0x17b)]?'\x20'+_0x2a9687['Contact'][_0x5a238a(0x17b)]:''),'body':_0x2a9687[_0x5a238a(0x12c)]?_0x2a9687[_0x5a238a(0x12c)][_0x5a238a(0x10d)]:_0x2a9687['body'],'direction':_0x2a9687['direction']===_0x5a238a(0x1a8)?'A':'C','secret':_0x2a9687[_0x5a238a(0x1ac)],'read':_0x2a9687[_0x5a238a(0x1f4)],'attachment':_0x2a9687['Attachment']};})[_0x4d678a(0x1bb)]()};return ejs[_0x4d678a(0x1db)](path[_0x4d678a(0x121)](config[_0x4d678a(0x1d9)],_0x4d678a(0x1d8),_0x4d678a(0x1ae),_0x4d678a(0x162)),{'interaction':_0x2fb116})['then'](function(_0x520d4b){return new Promise(function(_0x40ab6a,_0x3b9eda){const _0x2a6807=a80_0x3da5;pdf[_0x2a6807(0x137)](_0x520d4b,_0x4da2d6)[_0x2a6807(0x13e)](path[_0x2a6807(0x121)](_0x701334,_0x2a6807(0x1cc)+_0x39e503['id']+'-'+_0x3199a1+'.pdf'),function(_0x2a633d,_0x1ae47a){if(_0x2a633d)return _0x3b9eda(_0x2a633d);_0x40ab6a(_0x1ae47a);});});})[_0x4d678a(0xf6)](function(){const _0x5e17ea=_0x4d678a;return new Promise(function(_0x3dd86b,_0x17c104){zipdir(_0x701334,{'saveTo':_0x2a232d},function(_0x55a382,_0x5852ce){if(_0x55a382)return _0x17c104(_0x55a382);return _0x3dd86b(_0x5852ce);});})[_0x5e17ea(0xf6)](function(){return new Promise(function(_0x2cc728,_0x4bebf9){rimraf(_0x701334,function(_0x17f4ca){if(_0x17f4ca)_0x4bebf9(_0x17f4ca);return _0x2cc728();});});})[_0x5e17ea(0xf6)](function(){const _0x383d56=_0x5e17ea;return _0x270fea[_0x383d56(0x171)](_0x2a232d,_0x5bda12,function(_0x1dbb52){const _0x411b5c=_0x383d56;_0x1dbb52?console[_0x411b5c(0x1f1)]('err',_0x1dbb52):fs[_0x411b5c(0x11b)](_0x2a232d);});});});}else return _0x270fea[_0x4d678a(0x115)](0xc8);})[_0x3180c0(0x16a)](handleError(_0x270fea,null));};
\ No newline at end of file