Built motion from commit (unavailable).|2.5.25
[motion2.git] / server / api / chatInteraction / chatInteraction.controller.js
index 8f1dd01..5867c97 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4de9=['mkdirSync','10px','<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>','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','Account','disposition','referer','customerIp','customerPort','N.A.','existsSync','createReadStream','lastName','renderFile','views','downloadInteraction.html','toFile','transcript-','.pdf','fast-json-patch','request-promise','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatInteraction.socket','jayson/promise','client','http','request','info','debug','ChatInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','ChatInteraction,\x20%s,\x20%s','result','catch','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','then','destroy','stack','name','send','Users','fullname','TagIds','Tags','split','forEach','index','map','ChatInteraction','rawAttributes','fieldName','type','key','model','keys','query','filters','intersection','fields','attributes','order','sort','where','pick','field','color','from','select','u.id','u.fullname','ui.ChatInteractionId','user_has_chat_interactions','users','u.id\x20=\x20ui.UserId','chat_interactions','left_join','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','chat_websites','a.id\x20=\x20i.ChatWebsiteId','chat_messages','me.ChatInteractionId\x20=\x20i.id','chat_interaction_has_tags','it.ChatInteractionId\x20=\x20i.id','tools_tags','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','length','find','unreadMessages','value','having','`\x20>\x200','Contact','operator','$substring','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','ContactId','buildExpression','text','start','User','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','body','compact','ChatWebsiteId','i.ChatWebsiteId\x20IN\x20?','concat','createdAt','parse','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','filter','replace','isNumeric','i.id\x20LIKE\x20?','MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','QueryTypes','clone','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','contactName','isEmpty','t.id\x20IN\x20?','resolve','i.ChatWebsiteId\x20IS\x20NOT\x20NULL','user','agent','getChatWebsites','i.ChatWebsiteId\x20IS\x20NULL','role','toString','sequelize','keyBy','merge','a.key','a.mandatoryDisposition','Account.mandatoryDisposition','i.*','c.firstName','Contact.firstName','c.lastName','Contact.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','o.fullname','Owner.fullname','o.internal','Owner.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.ChatInteractionId\x20IN\x20?','groupBy','ChatInteractionId','all','rows','show','params','include','create','describe','findOne','ChatWebsite','vidaooEscalation','vidaooApiKey','https://api-vidaoo.xcally.com/api/v1/sessions','MotionCWB:','follow','Sequelize','ValidationError','Error\x20in\x20Vidaoo\x20configuration','join_url','out','ChatMessage','Unable\x20to\x20create\x20Vidaoo\x20session','updateAttributes','customUpdate','abandon','abandonInteraction,\x20%s,\x20%s,\x20%s','entity\x20not\x20found','Interaction\x20already\x20assigned','closed','AbandonInteraction','attachmentUpload','file','originalname','basename','filename','mimetype','Attachment','attachmentDownload','Unauthorized','attachId','download','server/files/attachments/','close','mailTranscript','join','root','server/files/chat/upload/','format','transcript-%s.txt','now','pathTranscript','Messages','CmContact','%s%d','agentAlias','System','agentIdentifier','agent_alias','alias','agent_fullname','[%s]\x20%s:\x20%s\x0a','direction','appendFileSync','MailServerOut','Smtp','service','host','port','secure','authentication','auth','pass','sendMail','\x22%s\x22\x20<%s>','email','Mail\x20Transcript','Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a','ids','omit','getMessages','nolimit','$gte','YYYY-MM-DD\x20HH:mm:ss','options','getMyMessages','hasOwnProperty','secret','push','findAll','addTags','setTags','spread','Tag','emit','chatInteractionTags:save','removeTags','unix','files','tmp','server','attachments','Owner','get'];(function(_0x35fb3f,_0x5884f4){var _0x670e77=function(_0x288fa8){while(--_0x288fa8){_0x35fb3f['push'](_0x35fb3f['shift']());}};_0x670e77(++_0x5884f4);}(_0x4de9,0x158));var _0x94de=function(_0x4bb581,_0x6f7037){_0x4bb581=_0x4bb581-0x0;var _0x316bf5=_0x4de9[_0x4bb581];return _0x316bf5;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x94de('0x0'));var rp=require(_0x94de('0x1'));var moment=require('moment');var BPromise=require(_0x94de('0x2'));var Mustache=require(_0x94de('0x3'));var util=require('util');var path=require(_0x94de('0x4'));var sox=require(_0x94de('0x5'));var csv=require(_0x94de('0x6'));var ejs=require(_0x94de('0x7'));var fs=require('fs');var _=require(_0x94de('0x8'));var squel=require(_0x94de('0x9'));var crypto=require(_0x94de('0xa'));var jsforce=require(_0x94de('0xb'));var deskjs=require(_0x94de('0xc'));var toCsv=require(_0x94de('0x6'));var querystring=require(_0x94de('0xd'));var Papa=require(_0x94de('0xe'));var Redis=require('ioredis');var authService=require(_0x94de('0xf'));var qs=require(_0x94de('0x10'));var as=require(_0x94de('0x11'));var hardwareService=require(_0x94de('0x12'));var logger=require(_0x94de('0x13'))(_0x94de('0x14'));var utils=require(_0x94de('0x15'));var config=require(_0x94de('0x16'));var licenseUtil=require(_0x94de('0x17'));var db=require(_0x94de('0x18'))['db'];config[_0x94de('0x19')]=_[_0x94de('0x1a')](config[_0x94de('0x19')],{'host':_0x94de('0x1b'),'port':0x18eb});var socket=require(_0x94de('0x1c'))(new Redis(config[_0x94de('0x19')]));require(_0x94de('0x1d'))['register'](socket);var jayson=require(_0x94de('0x1e'));var client=jayson[_0x94de('0x1f')][_0x94de('0x20')]({'port':0x232b});var client9004=jayson[_0x94de('0x1f')][_0x94de('0x20')]({'port':0x232c});function respondWithRpcPromise(_0x147579,_0xcbe028,_0x2553a4,_0x370608){return new BPromise(function(_0x32c739,_0xf236b4){var _0x4fb48b=_0x370608||client;return _0x4fb48b[_0x94de('0x21')](_0x147579,_0x2553a4)['then'](function(_0x408f3f){logger[_0x94de('0x22')]('ChatInteraction,\x20%s,\x20%s',_0xcbe028,'request\x20sent');logger[_0x94de('0x23')](_0x94de('0x24'),_0xcbe028,_0x94de('0x25'),JSON['stringify'](_0x408f3f));if(_0x408f3f[_0x94de('0x26')]){if(_0x408f3f['error'][_0x94de('0x27')]===0x1f4){logger[_0x94de('0x26')]('ChatInteraction,\x20%s,\x20%s',_0xcbe028,_0x408f3f[_0x94de('0x26')][_0x94de('0x28')]);return _0xf236b4(_0x408f3f[_0x94de('0x26')]['message']);}logger['error'](_0x94de('0x29'),_0xcbe028,_0x408f3f[_0x94de('0x26')][_0x94de('0x28')]);return _0x32c739(_0x408f3f[_0x94de('0x26')]['message']);}else{logger[_0x94de('0x22')](_0x94de('0x29'),_0xcbe028,_0x94de('0x25'));_0x32c739(_0x408f3f[_0x94de('0x2a')]['message']);}})[_0x94de('0x2b')](function(_0x44a65e){logger['error'](_0x94de('0x29'),_0xcbe028,_0x44a65e);_0xf236b4(_0x44a65e);});});}function respondWithStatusCode(_0x3a81dd,_0x361c25){_0x361c25=_0x361c25||0xcc;return function(_0x3f3393){if(_0x3f3393){return _0x3a81dd[_0x94de('0x2c')](_0x361c25);}return _0x3a81dd[_0x94de('0x2d')](_0x361c25)[_0x94de('0x2e')]();};}function respondWithResult(_0x45ece4,_0x3da0fa){_0x3da0fa=_0x3da0fa||0xc8;return function(_0x2763f8){if(_0x2763f8){return _0x45ece4[_0x94de('0x2d')](_0x3da0fa)[_0x94de('0x2f')](_0x2763f8);}};}function respondWithFilteredResult(_0x50fa2b,_0x359026){return function(_0x584d49){if(_0x584d49){var _0x2707b5=_0x584d49[_0x94de('0x30')],_0x45f332=_0x359026[_0x94de('0x31')],_0x1c7943=_0x359026[_0x94de('0x31')]+_0x359026[_0x94de('0x32')],_0x6b3e29;if(_0x1c7943>=_0x2707b5){_0x1c7943=_0x2707b5;_0x6b3e29=0xc8;}else{_0x6b3e29=0xce;}_0x50fa2b[_0x94de('0x2d')](_0x6b3e29);return _0x50fa2b[_0x94de('0x33')]('Content-Range',_0x45f332+'-'+_0x1c7943+'/'+_0x2707b5)[_0x94de('0x2f')](_0x584d49);}return null;};}function patchUpdates(_0xa2af8f){return function(_0x10fe0a){try{jsonpatch[_0x94de('0x34')](_0x10fe0a,_0xa2af8f,!![]);}catch(_0x55726d){return BPromise[_0x94de('0x35')](_0x55726d);}return _0x10fe0a[_0x94de('0x36')]();};}function saveUpdates(_0x5b84a3,_0x5bab1a){return function(_0x3dfb27){if(_0x3dfb27){return _0x3dfb27[_0x94de('0x37')](_0x5b84a3)[_0x94de('0x38')](function(_0x224f89){return _0x224f89;});}return null;};}function removeEntity(_0xfb1444,_0x31a9ba){return function(_0x1ff14d){if(_0x1ff14d){return _0x1ff14d[_0x94de('0x39')]()[_0x94de('0x38')](function(){_0xfb1444['status'](0xcc)[_0x94de('0x2e')]();});}};}function handleEntityNotFound(_0x41d302,_0x1f5506){return function(_0xa53ad9){if(!_0xa53ad9){_0x41d302['sendStatus'](0x194);}return _0xa53ad9;};}function handleError(_0x172079,_0x204c4e){_0x204c4e=_0x204c4e||0x1f4;return function(_0x2541bb){logger[_0x94de('0x26')](_0x2541bb[_0x94de('0x3a')]);if(_0x2541bb['name']){delete _0x2541bb[_0x94de('0x3b')];}_0x172079[_0x94de('0x2d')](_0x204c4e)[_0x94de('0x3c')](_0x2541bb);};}function getInteractionUsers(_0x2c5be1,_0x255422){return new BPromise(function(_0x52bcc4,_0x5cd805){try{if(_0x255422[_0x2c5be1['id']]){_0x2c5be1[_0x94de('0x3d')]=_['map'](_0x255422[_0x2c5be1['id']],function(_0x2c75e2){return{'id':_0x2c75e2['id'],'fullname':_0x2c75e2[_0x94de('0x3e')]};});}}catch(_0x5d3131){_0x5cd805(_0x5d3131);}_0x52bcc4(_0x2c5be1);});}function getInteractionTags(_0x1a8ad0,_0x11b0b7){return new BPromise(function(_0x1527f7,_0x5517f6){try{if(_0x1a8ad0[_0x94de('0x3f')]){_0x1a8ad0[_0x94de('0x40')]=[];_0x1a8ad0[_0x94de('0x3f')][_0x94de('0x41')](',')[_0x94de('0x42')](function(_0x3bb7fb){_0x1a8ad0[_0x94de('0x40')]['push'](_0x11b0b7[_0x3bb7fb]);});}delete _0x1a8ad0['TagIds'];}catch(_0x2f5c61){_0x5517f6(_0x2f5c61);}_0x1527f7(_0x1a8ad0);});}function updateChatInteraction(_0x31e209,_0x510e9e,_0x3ec5a5){return new BPromise(function(_0x2ebe94,_0x58c95f){return getInteractionUsers(_0x31e209,_0x3ec5a5)[_0x94de('0x38')](function(_0x19adef){return getInteractionTags(_0x19adef,_0x510e9e);})['then'](function(_0x5080ad){_0x2ebe94(_0x5080ad);})[_0x94de('0x2b')](function(_0x1588c2){_0x58c95f(_0x1588c2);});});}exports[_0x94de('0x43')]=function(_0xa897fd,_0x31a1fa){var _0x233c68={},_0x3b2fd2={},_0x149bbe={'count':0x0,'rows':[]};var _0x4fa9f5=_[_0x94de('0x44')](db[_0x94de('0x45')][_0x94de('0x46')],function(_0xa41a1a){return{'name':_0xa41a1a[_0x94de('0x47')],'type':_0xa41a1a[_0x94de('0x48')][_0x94de('0x49')]};});_0x3b2fd2[_0x94de('0x4a')]=_[_0x94de('0x44')](_0x4fa9f5,_0x94de('0x3b'));_0x3b2fd2['query']=_[_0x94de('0x4b')](_0xa897fd[_0x94de('0x4c')]);_0x3b2fd2[_0x94de('0x4d')]=_[_0x94de('0x4e')](_0x3b2fd2[_0x94de('0x4a')],_0x3b2fd2[_0x94de('0x4c')]);_0x233c68['attributes']=_[_0x94de('0x4e')](_0x3b2fd2[_0x94de('0x4a')],qs[_0x94de('0x4f')](_0xa897fd['query'][_0x94de('0x4f')]));_0x233c68['attributes']=_0x233c68[_0x94de('0x50')]['length']?_0x233c68['attributes']:_0x3b2fd2[_0x94de('0x4a')];if(!_0xa897fd[_0x94de('0x4c')]['hasOwnProperty']('nolimit')){_0x233c68[_0x94de('0x32')]=qs[_0x94de('0x32')](_0xa897fd[_0x94de('0x4c')]['limit']);_0x233c68[_0x94de('0x31')]=qs[_0x94de('0x31')](_0xa897fd[_0x94de('0x4c')][_0x94de('0x31')]);}_0x233c68[_0x94de('0x51')]=qs[_0x94de('0x52')](_0xa897fd[_0x94de('0x4c')][_0x94de('0x52')]);_0x233c68[_0x94de('0x53')]=qs[_0x94de('0x4d')](_[_0x94de('0x54')](_0xa897fd[_0x94de('0x4c')],_0x3b2fd2[_0x94de('0x4d')]),_0x4fa9f5);var _0x4f5c86=[];var _0x101487=squel['select']()[_0x94de('0x55')]('id')[_0x94de('0x55')](_0x94de('0x3b'))['field'](_0x94de('0x56'))[_0x94de('0x57')]('tools_tags');var _0x4cd889=squel[_0x94de('0x58')]()[_0x94de('0x55')](_0x94de('0x59'))[_0x94de('0x55')](_0x94de('0x5a'))[_0x94de('0x55')](_0x94de('0x5b'))[_0x94de('0x57')](_0x94de('0x5c'),'ui')['left_join'](_0x94de('0x5d'),'u',_0x94de('0x5e'));var _0x46001a=squel['select']()[_0x94de('0x57')](_0x94de('0x5f'),'i')[_0x94de('0x60')](_0x94de('0x61'),'c',_0x94de('0x62'))['left_join'](_0x94de('0x5d'),'o',_0x94de('0x63'))[_0x94de('0x60')](_0x94de('0x64'),'a',_0x94de('0x65'))[_0x94de('0x60')](_0x94de('0x66'),'me',_0x94de('0x67'))[_0x94de('0x60')](_0x94de('0x68'),'it',_0x94de('0x69'))[_0x94de('0x60')](_0x94de('0x6a'),'t',_0x94de('0x6b'));var _0x342415=squel[_0x94de('0x6c')]();var _0x2162f8=[];var _0xbcf0bc=squel[_0x94de('0x6c')]();var _0x36bd04;if(_0xa897fd[_0x94de('0x4c')][_0x94de('0x6d')]){_0x36bd04=as[_0x94de('0x6e')](_0xa897fd[_0x94de('0x4c')][_0x94de('0x6d')]);var _0x313316=_0x36bd04[_0x94de('0x6f')];for(var _0x1cba30=0x0;_0x1cba30<_0x36bd04[_0x94de('0x70')][_0x94de('0x71')];_0x1cba30++){var _0x4cd7bc=_0x36bd04[_0x94de('0x70')][_0x1cba30];var _0x430a25='i';var _0x1ac48d=_[_0x94de('0x72')](_0x4fa9f5,[_0x94de('0x3b'),_0x4cd7bc['field']]);if(!_0x1ac48d){switch(_0x4cd7bc['field']){case _0x94de('0x73'):if(_0x4cd7bc[_0x94de('0x74')]==0x1){_0x46001a[_0x94de('0x75')]('`'+_0x4cd7bc[_0x94de('0x55')]+'`\x20=\x200');}else{_0x46001a['having']('`'+_0x4cd7bc[_0x94de('0x55')]+_0x94de('0x76'));}break;case _0x94de('0x77'):if(_0x4cd7bc[_0x94de('0x78')]===_0x94de('0x79')){if(_0x4cd7bc['value'][_0x94de('0x41')]('\x20')[_0x94de('0x71')]>0x1){_0x342415[_0x313316]('MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)',qs['getFullTextValue'](_0x4cd7bc[_0x94de('0x74')]),null);}else{var _0x286809='%'+_0x4cd7bc['value']+'%';_0x342415[_0x313316](_0x94de('0x7a'),_0x286809,_0x286809,_0x286809);}}else{_0x1ac48d=_['find'](_0x4fa9f5,['name',_0x94de('0x7b')]);_0x4cd7bc['field']=_0x94de('0x7b');_0x3d91b2=as[_0x94de('0x7c')](_0x430a25,_0x1ac48d[_0x94de('0x48')],_0x4cd7bc);_0x342415[_0x313316](_0x3d91b2[_0x94de('0x7d')],_0x3d91b2[_0x94de('0x74')][_0x94de('0x7e')],_0x3d91b2['value'][_0x94de('0x2e')]);}break;case'Tag':var _0x1fdd95=_0x4cd7bc[_0x94de('0x74')][_0x94de('0x41')](',')[_0x94de('0x44')](function(_0x3d88a2){return Number(_0x3d88a2);});_0x1fdd95[_0x94de('0x42')](function(_0x462005){_0xbcf0bc['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x462005+',%');});_0x2162f8=_['union'](_0x2162f8,_0x1fdd95);break;case _0x94de('0x7f'):if(_0x4cd7bc['operator']===_0x94de('0x79')){_0x342415[_0x313316](_0x94de('0x80'),'%'+_0x4cd7bc[_0x94de('0x74')]+'%',null);}else{_0x1ac48d=_[_0x94de('0x72')](_0x4fa9f5,[_0x94de('0x3b'),_0x94de('0x81')]);_0x4cd7bc[_0x94de('0x55')]='UserId';_0x3d91b2=as[_0x94de('0x7c')](_0x430a25,_0x1ac48d[_0x94de('0x48')],_0x4cd7bc);_0x342415[_0x313316](_0x3d91b2[_0x94de('0x7d')],_0x3d91b2['value'][_0x94de('0x7e')],_0x3d91b2['value']['end']);}break;case _0x94de('0x82'):_0x3d91b2=as['buildExpression']('me',null,_0x4cd7bc);_0x342415[_0x313316](_0x3d91b2[_0x94de('0x7d')],_0x3d91b2[_0x94de('0x74')][_0x94de('0x7e')],_0x3d91b2[_0x94de('0x74')][_0x94de('0x2e')]);break;}}else{var _0x3d91b2=as[_0x94de('0x7c')](_0x430a25,_0x1ac48d['type'],_0x4cd7bc);_0x342415[_0x313316](_0x3d91b2['text'],_0x3d91b2['value'][_0x94de('0x7e')],_0x3d91b2[_0x94de('0x74')]['end']);}}}else{var _0x4e3c5f=_(_0xa897fd[_0x94de('0x4c')])['keys']()[_0x94de('0x44')](function(_0x239e3f){return _['some'](_0x4fa9f5,['name',_0x239e3f])?_0x239e3f:undefined;})[_0x94de('0x83')]()[_0x94de('0x74')]();if(!_['isEmpty'](_0x4e3c5f)){_0x4e3c5f[_0x94de('0x42')](function(_0x2972b6){if(_0x2972b6===_0x94de('0x84')){_0x46001a[_0x94de('0x53')](_0x94de('0x85'),[][_0x94de('0x86')](_0xa897fd[_0x94de('0x4c')][_0x2972b6]));}else if(_0x2972b6===_0x94de('0x87')){var _0x44608d=JSON[_0x94de('0x88')](_0xa897fd[_0x94de('0x4c')][_0x2972b6])['$gte'];var _0x2a3d6b=JSON['parse'](_0xa897fd[_0x94de('0x4c')][_0x2972b6])['$lte'];_0x46001a['where'](_0x94de('0x89'),_0x44608d,_0x2a3d6b);}else{if(_0xa897fd[_0x94de('0x4c')][_0x2972b6]===_0x94de('0x8a')){_0x46001a[_0x94de('0x53')]('i.'+_0x2972b6+_0x94de('0x8b'));}else{_0x46001a[_0x94de('0x53')]('i.'+_0x2972b6+_0x94de('0x8c'),_0xa897fd['query'][_0x2972b6]);}}});}if(_0xa897fd[_0x94de('0x4c')][_0x94de('0x8d')]){if(_0xa897fd[_0x94de('0x4c')]['read']==0x1){_0x46001a[_0x94de('0x75')](_0x94de('0x8e'));}else{_0x46001a[_0x94de('0x75')](_0x94de('0x8f'));}}if(_0xa897fd[_0x94de('0x4c')][_0x94de('0x90')]){_0x2162f8=_['isArray'](_0xa897fd[_0x94de('0x4c')][_0x94de('0x90')])?_0xa897fd[_0x94de('0x4c')][_0x94de('0x90')]:new Array(_0xa897fd[_0x94de('0x4c')]['tag']);_0x2162f8[_0x94de('0x42')](function(_0x195253){_0xbcf0bc['or'](_0x94de('0x91'),'%,'+_0x195253+',%');});}if(_0xa897fd[_0x94de('0x4c')][_0x94de('0x92')]){var _0x22143a=_0xa897fd[_0x94de('0x4c')][_0x94de('0x92')][_0x94de('0x93')]('\x5c','\x5c\x5c')[_0x94de('0x93')](/'/g,'\x27\x27');if(qs[_0x94de('0x94')](_0x22143a)){_0x342415['or'](_0x94de('0x95'),_0x22143a+'%');}else{_0x342415['or'](_0x94de('0x96'),qs[_0x94de('0x97')](_0x22143a))['or'](_0x94de('0x98'),_0x22143a+'%');}}}_0x46001a['where'](_0x342415);_0x46001a[_0x94de('0x99')](_0x94de('0x9a'));var _0x5d0903={'type':db['Sequelize'][_0x94de('0x9b')]['SELECT'],'raw':!![]};var _0x4ff7ec=_0x46001a[_0x94de('0x9c')]();_0x4ff7ec[_0x94de('0x55')](_0x94de('0x9a'));_0x4ff7ec[_0x94de('0x55')](_0x94de('0x9d'),_0x94de('0x73'));if(_0x233c68[_0x94de('0x51')]){_0x233c68[_0x94de('0x51')][_0x94de('0x42')](function(_0xa33db1){var _0x3df422=_0xa33db1[0x0]===_0x94de('0x9e')?_0xa33db1[0x0]:'i.'+_0xa33db1[0x0];_0x46001a['order'](_0x3df422,_0xa33db1[0x1]==='DESC'?![]:!![]);});}if(!_[_0x94de('0x9f')](_0x2162f8)){_0x46001a['having'](_0xbcf0bc);_0x4ff7ec[_0x94de('0x53')](_0x94de('0xa0'),_0x2162f8);}BPromise[_0x94de('0xa1')]()[_0x94de('0x38')](function(){if(!_0x36bd04){if(_0xa897fd['query'][_0x94de('0x84')])return;_0x4ff7ec[_0x94de('0x53')](_0x94de('0xa2'));_0x46001a['where'](_0x94de('0xa2'));return;}if(_0xa897fd[_0x94de('0xa3')]['role']!==_0x94de('0xa4'))return;return _0xa897fd['user'][_0x94de('0xa5')]({'attributes':['id'],'raw':!![]})[_0x94de('0x38')](function(_0x435e9c){if(_[_0x94de('0x9f')](_0x435e9c)){_0x4ff7ec[_0x94de('0x53')](_0x94de('0xa6'));_0x46001a['where']('i.ChatWebsiteId\x20IS\x20NULL');}else{_0x4ff7ec[_0x94de('0x53')](_0x94de('0x85'),_[_0x94de('0x44')](_0x435e9c,'id'));_0x46001a['where'](_0x94de('0x85'),_['map'](_0x435e9c,'id'));}});})[_0x94de('0x38')](function(){if(_0xa897fd[_0x94de('0xa3')][_0x94de('0xa7')]==='agent'&&!_0x36bd04&&!_0xa897fd[_0x94de('0x4c')][_0x94de('0x84')])return[];return db['sequelize'][_0x94de('0x4c')](_0x4ff7ec[_0x94de('0xa8')](),_0x5d0903);})[_0x94de('0x38')](function(_0xb784dc){_0x149bbe['count']=_0xb784dc[_0x94de('0x71')];if(_0x149bbe[_0x94de('0x30')]===0x0)return[];return db[_0x94de('0xa9')][_0x94de('0x4c')](_0x101487[_0x94de('0xa8')](),_0x5d0903)[_0x94de('0x38')](function(_0x154953){_0x4f5c86=_[_0x94de('0xaa')](_0x154953,'id');_0x5d0903=_[_0x94de('0xab')](_0x5d0903,{'model':db['ChatInteraction'],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0xa897fd['query'][_0x94de('0x4f')]){_0x233c68[_0x94de('0x50')][_0x94de('0x42')](function(_0x27e88b){_0x46001a[_0x94de('0x55')]('i.'+_0x27e88b);});}else{_0x46001a[_0x94de('0x55')](_0x94de('0x9d'),'unreadMessages');_0x46001a['field'](_0x94de('0xac'),'Account.key');_0x46001a[_0x94de('0x55')](_0x94de('0xad'),_0x94de('0xae'));_0x46001a[_0x94de('0x55')]('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',_0x94de('0x9e'));_0x46001a[_0x94de('0x55')](_0x94de('0xaf'));_0x46001a[_0x94de('0x55')](_0x94de('0xb0'),_0x94de('0xb1'));_0x46001a[_0x94de('0x55')](_0x94de('0xb2'),_0x94de('0xb3'));_0x46001a['field'](_0x94de('0xb4'),_0x94de('0xb5'));_0x46001a['field'](_0x94de('0xb6'),_0x94de('0xb7'));_0x46001a[_0x94de('0x55')](_0x94de('0xb8'),_0x94de('0xb9'));_0x46001a[_0x94de('0x55')](_0x94de('0xba'),_0x94de('0xbb'));_0x46001a[_0x94de('0x55')](_0x94de('0xbc'),_0x94de('0xbd'));_0x46001a[_0x94de('0x55')](_0x94de('0xbe'),_0x94de('0xbf'));_0x46001a[_0x94de('0x55')](_0x94de('0xc0'),_0x94de('0x3f'));}if(_0x233c68[_0x94de('0x32')])_0x46001a[_0x94de('0x32')](_0x233c68['limit']);if(_0x233c68[_0x94de('0x31')])_0x46001a['offset'](_0x233c68[_0x94de('0x31')]);return db[_0x94de('0xa9')]['query'](_0x46001a[_0x94de('0xa8')](),_0x5d0903);})['then'](function(_0x3eafdf){_0x4cd889[_0x94de('0x53')](_0x94de('0xc1'),_['map'](_0x3eafdf,'id'));return db[_0x94de('0xa9')][_0x94de('0x4c')](_0x4cd889[_0x94de('0xa8')](),_0x5d0903)[_0x94de('0x38')](function(_0x179888){var _0x2647cf=_[_0x94de('0xc2')](_0x179888,_0x94de('0xc3'));var _0x2607c5=[];_0x3eafdf[_0x94de('0x42')](function(_0x56b23b){_0x2607c5['push'](updateChatInteraction(_0x56b23b,_0x4f5c86,_0x2647cf));});return BPromise[_0x94de('0xc4')](_0x2607c5);});});})[_0x94de('0x38')](function(_0x16a2d2){_0x149bbe[_0x94de('0xc5')]=_0x16a2d2;return _0x149bbe;})[_0x94de('0x38')](respondWithFilteredResult(_0x31a1fa,_0x233c68))['catch'](handleError(_0x31a1fa,null));};exports[_0x94de('0xc6')]=function(_0x5e579c,_0x3cdde2){var _0x17cfd0={'raw':![],'where':{'id':_0x5e579c[_0x94de('0xc7')]['id']}},_0x3a66d2={};_0x3a66d2[_0x94de('0x4a')]=_[_0x94de('0x4b')](db[_0x94de('0x45')][_0x94de('0x46')]);_0x3a66d2[_0x94de('0x4c')]=_['keys'](_0x5e579c[_0x94de('0x4c')]);_0x3a66d2[_0x94de('0x4d')]=_[_0x94de('0x4e')](_0x3a66d2[_0x94de('0x4a')],_0x3a66d2[_0x94de('0x4c')]);_0x17cfd0[_0x94de('0x50')]=_[_0x94de('0x4e')](_0x3a66d2['model'],qs[_0x94de('0x4f')](_0x5e579c[_0x94de('0x4c')][_0x94de('0x4f')]));_0x17cfd0['attributes']=_0x17cfd0[_0x94de('0x50')][_0x94de('0x71')]?_0x17cfd0[_0x94de('0x50')]:_0x3a66d2['model'];if(_0x5e579c[_0x94de('0x4c')]['includeAll']){_0x17cfd0[_0x94de('0xc8')]=[{'all':!![]}];}_0x17cfd0=_['merge']({},_0x17cfd0,_0x5e579c['options']);return db['ChatInteraction'][_0x94de('0x72')](_0x17cfd0)['then'](handleEntityNotFound(_0x3cdde2,null))['then'](respondWithResult(_0x3cdde2,null))['catch'](handleError(_0x3cdde2,null));};exports[_0x94de('0xc9')]=function(_0x4d9b35,_0x12c350){return db[_0x94de('0x45')][_0x94de('0xc9')](_0x4d9b35[_0x94de('0x82')],{})[_0x94de('0x38')](respondWithResult(_0x12c350,0xc9))[_0x94de('0x2b')](handleError(_0x12c350,null));};exports[_0x94de('0x37')]=function(_0x570181,_0x364acd){if(_0x570181['body']['id']){delete _0x570181[_0x94de('0x82')]['id'];}return db[_0x94de('0x45')]['find']({'where':{'id':_0x570181[_0x94de('0xc7')]['id']}})[_0x94de('0x38')](handleEntityNotFound(_0x364acd,null))['then'](saveUpdates(_0x570181[_0x94de('0x82')],null))[_0x94de('0x38')](respondWithResult(_0x364acd,null))[_0x94de('0x2b')](handleError(_0x364acd,null));};exports[_0x94de('0x39')]=function(_0x4c7b3e,_0x26f9b0){return db[_0x94de('0x45')][_0x94de('0x72')]({'where':{'id':_0x4c7b3e[_0x94de('0xc7')]['id']}})[_0x94de('0x38')](handleEntityNotFound(_0x26f9b0,null))[_0x94de('0x38')](removeEntity(_0x26f9b0,null))[_0x94de('0x2b')](handleError(_0x26f9b0,null));};exports[_0x94de('0xca')]=function(_0x54048b,_0x549049){return db[_0x94de('0x45')][_0x94de('0xca')]()[_0x94de('0x38')](respondWithResult(_0x549049,null))['catch'](handleError(_0x549049,null));};exports['createVidaooSession']=function(_0x573f14,_0x1d3615){var _0x5532b9=_0x573f14['params']['id'];var _0x1b515d;var _0xaa4de3;var _0x18bbd6;return db[_0x94de('0x45')][_0x94de('0xcb')]({'where':{'id':_0x5532b9}})[_0x94de('0x38')](function(_0x13e556){_0x1b515d=_0x13e556;return db[_0x94de('0xcc')][_0x94de('0xcb')]({'where':{'id':_0x13e556['ChatWebsiteId']},'attributes':['id','vidaooApiKey',_0x94de('0xcd')],'raw':!![]});})['then'](function(_0x3a4e23){if(_0x3a4e23&&_0x3a4e23[_0x94de('0xce')]&&_0x3a4e23['vidaooEscalation']){_0xaa4de3=_0x3a4e23;var _0x2bfc20={'rejectUnauthorized':![],'method':'POST','uri':_0x94de('0xcf'),'headers':{'X-APIKEY':_0x3a4e23[_0x94de('0xce')]},'body':{'name':_0x94de('0xd0')+_0x5532b9},'redirect':_0x94de('0xd1'),'json':!![]};return rp(_0x2bfc20);}else{throw new db[(_0x94de('0xd2'))][(_0x94de('0xd3'))](_0x94de('0xd4'));}})[_0x94de('0x38')](function(_0x5ba2e1){_0x18bbd6=_0x5ba2e1;if(_0x18bbd6['id']){var _0x57680b={'body':_0x18bbd6[_0x94de('0xd5')],'ChatWebsiteId':_0xaa4de3['id'],'ChatInteractionId':_0x1b515d['id'],'direction':_0x94de('0xd6'),'UserId':_0x573f14[_0x94de('0xa3')]['id']};return db[_0x94de('0xd7')][_0x94de('0xc9')](_0x57680b,{});}else{throw new db[(_0x94de('0xd2'))][(_0x94de('0xd3'))](_0x94de('0xd8'));}})[_0x94de('0x38')](function(){return _0x1b515d[_0x94de('0xd9')]({'vidaooSessionId':_0x18bbd6['id']});})[_0x94de('0x38')](respondWithResult(_0x1d3615,null))[_0x94de('0x2b')](handleError(_0x1d3615,null));};exports[_0x94de('0xda')]=function(_0x4d24bb,_0x4c1969){if(_0x4d24bb[_0x94de('0x82')]['id']){delete _0x4d24bb[_0x94de('0x82')]['id'];}return db[_0x94de('0x45')][_0x94de('0x72')]({'where':{'id':_0x4d24bb[_0x94de('0xc7')]['id']}})[_0x94de('0x38')](handleEntityNotFound(_0x4c1969,null))[_0x94de('0x38')](saveUpdates(_0x4d24bb[_0x94de('0x82')],null))[_0x94de('0x38')](respondWithResult(_0x4c1969,null))['catch'](handleError(_0x4c1969,null));};exports[_0x94de('0xdb')]=function(_0x5ad7bf,_0x51dde4,_0x373928){if(_0x5ad7bf[_0x94de('0x82')]['id']){delete _0x5ad7bf[_0x94de('0x82')]['id'];}return db['ChatInteraction'][_0x94de('0x72')]({'where':{'id':_0x5ad7bf['params']['id']}})[_0x94de('0x38')](function(_0x2c82c5){if(!_0x2c82c5){logger[_0x94de('0x26')](_0x94de('0xdc'),_0x94de('0xdb'),0x194,_0x94de('0xdd'));_0x51dde4[_0x94de('0x2c')](0x194);}else{if(_0x2c82c5[_0x94de('0x81')]){throw new db[(_0x94de('0xd2'))]['ValidationError'](_0x94de('0xde'));}}return _0x2c82c5;})[_0x94de('0x38')](function(_0x32b4a2){if(_0x32b4a2){return _0x32b4a2[_0x94de('0x37')]({'closed':_0x5ad7bf[_0x94de('0x82')][_0x94de('0xdf')],'disposition':_0x5ad7bf[_0x94de('0x82')]['disposition']})[_0x94de('0x38')](function(_0x3f8fa9){return _0x3f8fa9;});}})[_0x94de('0x38')](function(_0x546702){return respondWithRpcPromise(_0x94de('0xe0'),_0x94de('0xdb'),_0x5ad7bf[_0x94de('0x82')],client9004);})[_0x94de('0x38')](respondWithResult(_0x51dde4,null))[_0x94de('0x2b')](handleError(_0x51dde4,null));};exports[_0x94de('0xe1')]=function(_0x1f83b6,_0x55b673,_0x27acd8){_0x1f83b6[_0x94de('0x82')][_0x94de('0x3b')]=_0x1f83b6[_0x94de('0xe2')][_0x94de('0xe3')];_0x1f83b6[_0x94de('0x82')][_0x94de('0xe4')]=_0x1f83b6[_0x94de('0xe2')][_0x94de('0xe5')];_0x1f83b6[_0x94de('0x82')][_0x94de('0x48')]=_0x1f83b6[_0x94de('0xe2')][_0x94de('0xe6')];return db[_0x94de('0xe7')][_0x94de('0xc9')](_0x1f83b6[_0x94de('0x82')])[_0x94de('0x38')](respondWithResult(_0x55b673,0xc9))[_0x94de('0x2b')](handleError(_0x55b673,null));};exports[_0x94de('0xe8')]=function(_0x289c4c,_0x351341,_0x2dd08e){return db[_0x94de('0x45')][_0x94de('0xcb')]({'where':{'id':_0x289c4c[_0x94de('0xc7')]['id']},'raw':!![]})[_0x94de('0x38')](handleEntityNotFound(_0x351341,null))[_0x94de('0x38')](function(_0x17f28f){if(_0x17f28f){if(_0x17f28f[_0x94de('0xdf')]){return _0x351341[_0x94de('0x2d')](0x193)[_0x94de('0x2f')]({'status':0x193,'message':_0x94de('0xe9')});}return db[_0x94de('0xe7')][_0x94de('0xcb')]({'where':{'id':_0x289c4c[_0x94de('0x4c')][_0x94de('0xea')]},'raw':!![]})['then'](handleEntityNotFound(_0x351341,null));}})[_0x94de('0x38')](function(_0x36a657){if(_0x36a657){return _0x351341[_0x94de('0xeb')](path['join'](config['root'],_0x94de('0xec'),_0x36a657[_0x94de('0xe4')]));}})[_0x94de('0x2b')](handleError(_0x351341,null));};exports[_0x94de('0xed')]=function(_0x265c51,_0x4fd314){var _0x19b76d=null;var _0x3a19eb=null;var _0x26f22c=null;var _0x1d91b6=null;if(_0x265c51['body']['id']){delete _0x265c51[_0x94de('0x82')]['id'];}if(_0x265c51[_0x94de('0x82')][_0x94de('0xee')]){_0x1d91b6=path[_0x94de('0xef')](config[_0x94de('0xf0')],_0x94de('0xf1'),util[_0x94de('0xf2')](_0x94de('0xf3'),Date[_0x94de('0xf4')]()));_0x265c51[_0x94de('0x82')][_0x94de('0xf5')]=_0x1d91b6;}return db[_0x94de('0x45')][_0x94de('0x72')]({'where':{'id':_0x265c51[_0x94de('0xc7')]['id']},'include':[{'model':db['ChatMessage'],'as':_0x94de('0xf6'),'include':[{'model':db[_0x94de('0x7f')],'as':'User'}]}]})[_0x94de('0x38')](handleEntityNotFound(_0x4fd314,null))[_0x94de('0x38')](saveUpdates(_0x265c51[_0x94de('0x82')],null))[_0x94de('0x38')](function(_0x1e325b){if(_0x1e325b){_0x19b76d=_0x1e325b;return db['ChatWebsite'][_0x94de('0x72')]({'where':{'id':_0x19b76d[_0x94de('0x84')]}});}})[_0x94de('0x38')](function(_0x3d032b){if(_0x3d032b){_0x26f22c=_0x3d032b;return db[_0x94de('0xf7')][_0x94de('0x72')]({'where':{'id':_0x19b76d[_0x94de('0x7b')]}});}})['then'](function(_0x41e006){if(_0x41e006){_0x3a19eb=_0x41e006;if(_0x1d91b6){var _0x5f47f0=null;for(var _0x2fa623=0x1;_0x2fa623<_0x19b76d[_0x94de('0xf6')][_0x94de('0x71')];++_0x2fa623){_0x5f47f0=_0x19b76d[_0x94de('0xf6')][_0x2fa623];var _0x352d63=_0x5f47f0[_0x94de('0x81')]?util[_0x94de('0xf2')](_0x94de('0xf8'),_0x26f22c[_0x94de('0xf9')],_0x5f47f0['UserId']):_0x94de('0xfa');var _0x3137d2=_0x265c51[_0x94de('0x82')]['customer']||util['format']('%s%d','Visitor',_0x5f47f0[_0x94de('0x7b')]);switch(_0x26f22c[_0x94de('0xfb')]){case'website_alias':_0x352d63=_0x5f47f0[_0x94de('0x81')]?util[_0x94de('0xf2')](_0x94de('0xf8'),_0x26f22c[_0x94de('0xf9')],_0x5f47f0[_0x94de('0x81')]):_0x94de('0xfa');break;case _0x94de('0xfc'):_0x352d63=_0x5f47f0['UserId']?_0x5f47f0[_0x94de('0x7f')][_0x94de('0xfd')]||_0x5f47f0['User'][_0x94de('0x3e')]:_0x94de('0xfa');break;case _0x94de('0xfe'):_0x352d63=_0x5f47f0[_0x94de('0x81')]?_0x5f47f0['User'][_0x94de('0x3e')]:_0x94de('0xfa');break;default:_0x352d63=_0x5f47f0['UserId']?util[_0x94de('0xf2')](_0x94de('0xf8'),_0x26f22c[_0x94de('0xf9')],_0x5f47f0[_0x94de('0x81')]):'System';}var _0x114356=util['format'](_0x94de('0xff'),moment(_0x5f47f0['createdAt'])[_0x94de('0xf2')]('MM/DD/YYYY\x20HH:mm:ss'),_0x5f47f0[_0x94de('0x100')]==='in'?_0x3137d2:_0x352d63,_0x5f47f0['body']);if(!_0x5f47f0['secret']){fs[_0x94de('0x101')](_0x1d91b6,_0x114356);}}return db['MailAccount'][_0x94de('0xcb')]({'where':{'service':!![]},'include':[{'model':db[_0x94de('0x102')],'as':'Smtp','raw':!![]}]});}}})[_0x94de('0x38')](function(_0x105813){if(_0x105813&&_0x105813[_0x94de('0x103')]&&_0x265c51['body']){var _0x5d8a8c={'tls':{'rejectUnauthorized':![]}};if(_0x105813[_0x94de('0x103')][_0x94de('0x104')]){_0x5d8a8c[_0x94de('0x104')]=_0x105813['Smtp']['service'];}else{_0x5d8a8c[_0x94de('0x105')]=_0x105813[_0x94de('0x103')][_0x94de('0x105')];_0x5d8a8c[_0x94de('0x106')]=_0x105813[_0x94de('0x103')]['port'];_0x5d8a8c[_0x94de('0x107')]=_0x105813[_0x94de('0x103')][_0x94de('0x107')];}if(_0x105813[_0x94de('0x103')][_0x94de('0x108')]){_0x5d8a8c[_0x94de('0x109')]={'user':_0x105813['Smtp'][_0x94de('0xa3')],'pass':_0x105813[_0x94de('0x103')][_0x94de('0x10a')]};}return respondWithRpcPromise('SendMail',_0x94de('0x10b'),{'account':_0x5d8a8c,'message':{'from':util[_0x94de('0xf2')](_0x94de('0x10c'),_0x105813['name'],_0x105813[_0x94de('0x10d')]||_0x105813[_0x94de('0x103')]['user']),'to':_0x265c51[_0x94de('0x82')]['mailTranscript'],'subject':_0x94de('0x10e'),'text':util[_0x94de('0xf2')](_0x94de('0x10f'),_0x265c51[_0x94de('0x82')][_0x94de('0xee')]),'attachments':[{'path':_0x1d91b6}]}})[_0x94de('0x38')](function(){return _0x19b76d;})[_0x94de('0x2b')](function(_0x1ca08a){console[_0x94de('0x26')](_0x1ca08a);});}else{return _0x19b76d;}})[_0x94de('0x38')](respondWithStatusCode(_0x4fd314,0xc8))[_0x94de('0x2b')](handleError(_0x4fd314,null));};exports['addMessage']=function(_0x696c6e,_0x42dca3,_0x3b4411){return db[_0x94de('0xd7')]['find']({'where':{'id':_0x696c6e[_0x94de('0xc7')]['id']}})['then'](handleEntityNotFound(_0x42dca3,null))[_0x94de('0x38')](function(_0x3f388e){if(_0x3f388e){return _0x3f388e['addMessage'](_0x696c6e[_0x94de('0x82')][_0x94de('0x110')],_[_0x94de('0x111')](_0x696c6e[_0x94de('0x82')],[_0x94de('0x110'),'id'])||{});}})[_0x94de('0x38')](respondWithResult(_0x42dca3,null))[_0x94de('0x2b')](handleError(_0x42dca3,null));};exports[_0x94de('0x112')]=function(_0x3986dd,_0x10fbfd,_0x44d832){var _0x650761={'raw':![],'where':{}};var _0x5aa4f0={};var _0x53615f={'count':0x0,'rows':[]};return db[_0x94de('0x45')][_0x94de('0xcb')]({'where':{'id':_0x3986dd[_0x94de('0xc7')]['id']}})[_0x94de('0x38')](handleEntityNotFound(_0x10fbfd,null))[_0x94de('0x38')](function(_0x97764a){if(_0x97764a){_0x5aa4f0['model']=_[_0x94de('0x4b')](db[_0x94de('0xd7')]['rawAttributes']);_0x5aa4f0[_0x94de('0x4c')]=_[_0x94de('0x4b')](_0x3986dd['query']);_0x5aa4f0['filters']=_['intersection'](_0x5aa4f0['model'],_0x5aa4f0[_0x94de('0x4c')]);_0x650761[_0x94de('0x50')]=_[_0x94de('0x4e')](_0x5aa4f0[_0x94de('0x4a')],qs[_0x94de('0x4f')](_0x3986dd[_0x94de('0x4c')][_0x94de('0x4f')]));_0x650761['attributes']=_0x650761[_0x94de('0x50')]['length']?_0x650761[_0x94de('0x50')]:_0x5aa4f0[_0x94de('0x4a')];if(!_0x3986dd[_0x94de('0x4c')]['hasOwnProperty'](_0x94de('0x113'))){_0x650761[_0x94de('0x32')]=qs[_0x94de('0x32')](_0x3986dd[_0x94de('0x4c')][_0x94de('0x32')]);_0x650761[_0x94de('0x31')]=qs[_0x94de('0x31')](_0x3986dd[_0x94de('0x4c')]['offset']);}_0x650761[_0x94de('0x51')]=qs[_0x94de('0x52')](_0x3986dd[_0x94de('0x4c')][_0x94de('0x52')]);_0x650761['where']=qs[_0x94de('0x4d')](_[_0x94de('0x54')](_0x3986dd[_0x94de('0x4c')],_0x5aa4f0['filters']));_0x650761[_0x94de('0x53')]['ChatInteractionId']=_0x97764a['id'];if(_0x3986dd['query'][_0x94de('0x92')]){_0x650761[_0x94de('0x53')]=_[_0x94de('0xab')](_0x650761[_0x94de('0x53')],{'$or':_['map'](_0x650761[_0x94de('0x50')],function(_0x422f98){var _0x47064d={};_0x47064d[_0x422f98]={'$like':'%'+_0x3986dd[_0x94de('0x4c')][_0x94de('0x92')]+'%'};return _0x47064d;})});}if(_0x3986dd['query']['$gte']){var _0x18262a=_0x3986dd['query'][_0x94de('0x114')]['split'](',');var _0x409b72={};_0x409b72[_0x18262a[0x0]]={'$gte':moment(_0x18262a[0x1])[_0x94de('0xf2')](_0x94de('0x115'))};_0x650761[_0x94de('0x53')]=_[_0x94de('0xab')](_0x650761[_0x94de('0x53')],_0x409b72);}_0x650761=_[_0x94de('0xab')]({},_0x650761,_0x3986dd[_0x94de('0x116')]);return db[_0x94de('0xd7')]['count']({'where':_0x650761[_0x94de('0x53')]})[_0x94de('0x38')](function(_0x2ac505){_0x53615f['count']=_0x2ac505;if(_0x3986dd['query']['includeAll']){_0x650761['include']=[{'all':!![]}];}return db[_0x94de('0xd7')]['findAll'](_0x650761);})[_0x94de('0x38')](function(_0x381484){_0x53615f[_0x94de('0xc5')]=_0x381484;return _0x53615f;});}})[_0x94de('0x38')](respondWithFilteredResult(_0x10fbfd,_0x650761))[_0x94de('0x2b')](handleError(_0x10fbfd,null));};exports[_0x94de('0x117')]=function(_0x5df301,_0x4181df,_0x16e627){var _0x370db5={'where':{}},_0x37c44f={},_0x5b4fd1={'count':0x0,'rows':[]};return db[_0x94de('0x45')][_0x94de('0xcb')]({'where':{'id':_0x5df301[_0x94de('0xc7')]['id']}})['then'](handleEntityNotFound(_0x4181df,null))['then'](function(_0x2a41dd){if(_0x2a41dd){_0x37c44f[_0x94de('0x4a')]=_['keys'](db[_0x94de('0xd7')][_0x94de('0x46')]);_0x37c44f['query']=_[_0x94de('0x4b')](_0x5df301[_0x94de('0x4c')]);_0x37c44f[_0x94de('0x4d')]=_[_0x94de('0x4e')](_0x37c44f[_0x94de('0x4a')],_0x37c44f[_0x94de('0x4c')]);_0x370db5[_0x94de('0x50')]=_['intersection'](_0x37c44f[_0x94de('0x4a')],qs[_0x94de('0x4f')](_0x5df301['query']['fields']));_0x370db5['attributes']=_0x370db5['attributes'][_0x94de('0x71')]?_0x370db5['attributes']:_0x37c44f[_0x94de('0x4a')];if(!_0x5df301[_0x94de('0x4c')][_0x94de('0x118')](_0x94de('0x113'))){_0x370db5[_0x94de('0x32')]=qs[_0x94de('0x32')](_0x5df301[_0x94de('0x4c')]['limit']);_0x370db5[_0x94de('0x31')]=qs[_0x94de('0x31')](_0x5df301[_0x94de('0x4c')][_0x94de('0x31')]);}_0x370db5[_0x94de('0x51')]=qs['sort'](_0x5df301['query'][_0x94de('0x52')]);_0x370db5[_0x94de('0x53')]=qs[_0x94de('0x4d')](_[_0x94de('0x54')](_0x5df301[_0x94de('0x4c')],_0x37c44f['filters']));_0x370db5[_0x94de('0x53')]['ChatInteractionId']=_0x2a41dd['id'];if(_0x5df301['query'][_0x94de('0x92')]){_0x370db5[_0x94de('0x53')]=_['merge'](_0x370db5[_0x94de('0x53')],{'$or':_[_0x94de('0x44')](_0x370db5['attributes'],function(_0x4d0c51){var _0x155223={};_0x155223[_0x4d0c51]={'$like':'%'+_0x5df301[_0x94de('0x4c')][_0x94de('0x92')]+'%'};return _0x155223;})});}_0x370db5['where'][_0x94de('0x119')]=![];if(_0x5df301[_0x94de('0x4c')]['id']){_0x370db5[_0x94de('0x53')]['id']={'$gt':_0x5df301[_0x94de('0x4c')]['id']};}_0x370db5=_['merge']({},_0x370db5,_0x5df301[_0x94de('0x116')]);return db[_0x94de('0xd7')][_0x94de('0x30')]({'where':_0x370db5['where']})['then'](function(_0x249098){_0x5b4fd1[_0x94de('0x30')]=_0x249098;_0x370db5[_0x94de('0xc8')]=[];if(_0x5df301[_0x94de('0x4c')]['includeAgent']){_0x370db5[_0x94de('0xc8')][_0x94de('0x11a')]({'model':db[_0x94de('0x7f')],'as':_0x94de('0x7f'),'attributes':['id','fullname',_0x94de('0xfd')]});}if(_0x5df301[_0x94de('0x4c')]['includeAll']){_0x370db5[_0x94de('0xc8')]=[{'all':!![]}];}return db[_0x94de('0xd7')][_0x94de('0x11b')](_0x370db5);})[_0x94de('0x38')](function(_0xbcc442){_0x5b4fd1[_0x94de('0xc5')]=_0xbcc442;return _0x5b4fd1;});}})[_0x94de('0x38')](respondWithFilteredResult(_0x4181df,_0x370db5))[_0x94de('0x2b')](handleError(_0x4181df,null));};exports[_0x94de('0x11c')]=function(_0x102a78,_0x254a99,_0xd0d0a1){return db[_0x94de('0x45')][_0x94de('0x72')]({'where':{'id':_0x102a78[_0x94de('0xc7')]['id']}})[_0x94de('0x38')](handleEntityNotFound(_0x254a99,null))['then'](function(_0x28b448){if(_0x28b448){return _0x28b448[_0x94de('0x11d')](_0x102a78['body']['ids'],_[_0x94de('0x111')](_0x102a78[_0x94de('0x82')],['ids','id'])||{})[_0x94de('0x11e')](function(){return db[_0x94de('0x11f')][_0x94de('0x11b')]({'attributes':['id',_0x94de('0x3b'),_0x94de('0x56')],'where':{'id':_0x102a78[_0x94de('0x82')][_0x94de('0x110')]}});})[_0x94de('0x38')](function(_0x1aa0a2){socket[_0x94de('0x120')](_0x94de('0x121'),{'id':Number(_0x102a78[_0x94de('0xc7')]['id']),'tags':_0x1aa0a2||[]});return{'id':Number(_0x102a78['params']['id']),'tags':_0x1aa0a2||[]};});}})[_0x94de('0x38')](respondWithResult(_0x254a99,null))[_0x94de('0x2b')](handleError(_0x254a99,null));};exports['removeTags']=function(_0x203c62,_0x281e0a,_0x2ceae8){return db[_0x94de('0x45')]['find']({'where':{'id':_0x203c62[_0x94de('0xc7')]['id']}})['then'](handleEntityNotFound(_0x281e0a,null))['then'](function(_0x392d8b){if(_0x392d8b){return _0x392d8b[_0x94de('0x122')](_0x203c62[_0x94de('0x4c')][_0x94de('0x110')]);}})[_0x94de('0x38')](respondWithStatusCode(_0x281e0a,null))['catch'](handleError(_0x281e0a,null));};exports[_0x94de('0xeb')]=function(_0x1f9a37,_0x25c106){var _0x43b88b=moment()[_0x94de('0x123')]()[_0x94de('0xa8')]();var _0x1319ec=path['join'](config[_0x94de('0xf0')],'server',_0x94de('0x124'),_0x94de('0x125'));var _0x2e719e=path[_0x94de('0xef')](config[_0x94de('0xf0')],_0x94de('0x126'),_0x94de('0x124'),_0x94de('0x127'));var _0x5749f1=path[_0x94de('0xef')](_0x1319ec,_0x43b88b);var _0x137b41=util[_0x94de('0xf2')]('transcript-%d-%s.zip',_0x1f9a37[_0x94de('0xc7')]['id'],_0x43b88b);var _0x47c024=path[_0x94de('0xef')](_0x1319ec,_0x137b41);var _0x2daa96=[];_0x2daa96['push']({'model':db['User'],'as':_0x94de('0x7f'),'attributes':['id','fullname'],'raw':!![]});_0x2daa96[_0x94de('0x11a')]({'model':db[_0x94de('0xf7')],'as':_0x94de('0x77'),'attributes':['id','firstName','lastName'],'raw':!![]});if(_0x1f9a37['query'][_0x94de('0x127')]){_0x2daa96[_0x94de('0x11a')]({'model':db[_0x94de('0xe7')],'as':_0x94de('0xe7'),'raw':!![]});}var _0x35d2fb=[{'model':db['ChatMessage'],'as':_0x94de('0xf6'),'attributes':['id',_0x94de('0x82'),_0x94de('0x87'),_0x94de('0x100'),_0x94de('0x119'),_0x94de('0x8d')],'include':_0x2daa96}];_0x35d2fb['push']({'model':db['ChatWebsite'],'as':'Account','attributes':['id',_0x94de('0x3b')]});_0x35d2fb[_0x94de('0x11a')]({'model':db['User'],'as':_0x94de('0x128'),'attributes':['id','fullname']});return db[_0x94de('0x45')][_0x94de('0x72')]({'where':{'id':_0x1f9a37[_0x94de('0xc7')]['id']},'include':_0x35d2fb})[_0x94de('0x38')](handleEntityNotFound(_0x25c106,null))[_0x94de('0x38')](function(_0x2812a9){if(_0x2812a9){var _0x1bf203=_0x2812a9[_0x94de('0x129')]({'plain':!![]});fs[_0x94de('0x12a')](_0x5749f1);var _0x475605={'format':'A4','border':_0x94de('0x12b'),'header':{'height':'40px','contents':{'first':_0x94de('0x12c')}},'footer':{'height':_0x94de('0x12d'),'contents':{'default':util[_0x94de('0xf2')](_0x94de('0x12e'),util['format'](_0x94de('0x12f'),_0x94de('0x130'),_0x1bf203['id']),moment()['format'](_0x94de('0x131'))[_0x94de('0xa8')]())}}};var _0x690697={'channel':'Chat','account':_0x1bf203[_0x94de('0x132')][_0x94de('0x3b')],'agent':_0x1bf203[_0x94de('0x128')]?_0x1bf203[_0x94de('0x128')][_0x94de('0x3e')]:'N.A.','createdAt':moment(_0x1bf203[_0x94de('0x87')])['format'](_0x94de('0x115'))[_0x94de('0xa8')](),'closedAt':_0x1bf203[_0x94de('0xdf')]?moment(_0x1bf203['closedAt'])[_0x94de('0xf2')](_0x94de('0x115'))['toString']():'','disposition':_0x1bf203[_0x94de('0x133')],'chatInfo':{'browser':_0x1bf203['browserName'],'os':_0x1bf203['osName'],'referer':_0x1bf203[_0x94de('0x134')],'customerIp':_0x1bf203[_0x94de('0x135')],'customerPort':_0x1bf203[_0x94de('0x136')]?_0x1bf203[_0x94de('0x136')]:_0x94de('0x137')},'messages':_(_0x1bf203[_0x94de('0xf6')])['tail']()['filter']({'secret':![]})[_0x94de('0x44')](function(_0x1187ce){if(_0x1187ce[_0x94de('0xe7')]){var _0x4be509=path[_0x94de('0xef')](_0x2e719e,_0x1187ce[_0x94de('0xe7')]['basename']);if(fs[_0x94de('0x138')](_0x4be509)){fs[_0x94de('0x139')](_0x4be509)['pipe'](fs['createWriteStream'](path[_0x94de('0xef')](_0x5749f1,_0x1187ce['Attachment'][_0x94de('0xe4')])));}}return{'date':moment(_0x1187ce[_0x94de('0x87')])[_0x94de('0xf2')](_0x94de('0x115'))['toString'](),'sender':_0x1187ce[_0x94de('0x100')]===_0x94de('0xd6')?_0x1187ce[_0x94de('0x7f')]?_0x1187ce[_0x94de('0x7f')][_0x94de('0x3e')]:_0x94de('0xfa'):_0x1187ce[_0x94de('0x77')]['firstName']+(_0x1187ce[_0x94de('0x77')][_0x94de('0x13a')]?'\x20'+_0x1187ce[_0x94de('0x77')]['lastName']:''),'body':_0x1187ce['Attachment']?_0x1187ce['Attachment'][_0x94de('0xe4')]:_0x1187ce[_0x94de('0x82')],'direction':_0x1187ce[_0x94de('0x100')]==='out'?'A':'C','secret':_0x1187ce[_0x94de('0x119')],'read':_0x1187ce[_0x94de('0x8d')],'attachment':_0x1187ce['Attachment']};})[_0x94de('0x74')]()};return ejs[_0x94de('0x13b')](path['join'](config[_0x94de('0xf0')],_0x94de('0x126'),_0x94de('0x13c'),_0x94de('0x13d')),{'interaction':_0x690697})[_0x94de('0x38')](function(_0xeec556){return new BPromise(function(_0x3d7d55,_0x4a9da7){pdf[_0x94de('0xc9')](_0xeec556,_0x475605)[_0x94de('0x13e')](path['join'](_0x5749f1,_0x94de('0x13f')+_0x1bf203['id']+'-'+_0x43b88b+_0x94de('0x140')),function(_0x1120c3,_0x2da969){if(_0x1120c3)return _0x4a9da7(_0x1120c3);_0x3d7d55(_0x2da969);});});})['then'](function(){return new BPromise(function(_0x261a61,_0x4837b5){zipdir(_0x5749f1,{'saveTo':_0x47c024},function(_0x330d20,_0xfa4db){if(_0x330d20)return _0x4837b5(_0x330d20);return _0x261a61(_0xfa4db);});})[_0x94de('0x38')](function(){return new BPromise(function(_0x46a783,_0x3aa3a7){rimraf(_0x5749f1,function(_0x47bb00){if(_0x47bb00)_0x3aa3a7(_0x47bb00);return _0x46a783();});});})[_0x94de('0x38')](function(){return _0x25c106[_0x94de('0xeb')](_0x47c024,_0x137b41,function(_0xb1526c){if(_0xb1526c){console['log']('err',_0xb1526c);}else{fs['unlinkSync'](_0x47c024);}});});});}else{return _0x25c106[_0x94de('0x2c')](0xc8);}})[_0x94de('0x2b')](handleError(_0x25c106,null));};
\ No newline at end of file
+var _0x06ef=['attachmentDownload','Unauthorized','attachId','download','join','root','server/files/attachments/','close','server/files/chat/upload/','transcript-%s.txt','now','pathTranscript','Messages','ChatWebsite','%s%d','agentAlias','System','customer','Visitor','agentIdentifier','agent_alias','alias','agent_fullname','format','[%s]\x20%s:\x20%s\x0a','secret','appendFileSync','MailAccount','MailServerOut','Smtp','service','host','port','secure','auth','pass','\x22%s\x22\x20<%s>','email','mailTranscript','Mail\x20Transcript','addMessage','ids','getMessages','pick','options','includeAll','findAll','getMyMessages','addTags','omit','spread','emit','chatInteractionTags:save','removeTags','unix','server','files','tmp','attachments','transcript-%d-%s.zip','firstName','lastName','direction','read','Account','Owner','get','mkdirSync','40px','<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>','<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','YYYY-MM-DD','Chat','N.A.','closedAt','YYYY-MM-DD\x20HH:mm:ss','browserName','osName','referer','customerIp','customerPort','tail','createReadStream','pipe','createWriteStream','out','renderFile','views','downloadInteraction.html','.pdf','log','unlinkSync','rimraf','bluebird','mustache','util','sox','to-csv','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','socket.io-emitter','client','http','then','info','ChatInteraction,\x20%s,\x20%s','ChatInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','error','code','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','update','destroy','name','Users','map','fullname','TagIds','Tags','split','forEach','index','fieldName','type','keys','filters','intersection','model','query','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','select','field','color','from','u.id','user_has_chat_interactions','u.id\x20=\x20ui.UserId','chat_interactions','left_join','cm_contacts','o.id\x20=\x20i.UserId','chat_websites','a.id\x20=\x20i.ChatWebsiteId','chat_messages','me.ChatInteractionId\x20=\x20i.id','it.ChatInteractionId\x20=\x20i.id','search','parseSearch','conditions','unreadMessages','value','having','`\x20=\x200','`\x20>\x200','Contact','operator','$substring','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?','find','ContactId','text','start','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','User','UserId','buildExpression','some','ChatWebsiteId','i.ChatWebsiteId\x20IN\x20?','concat','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','\x20IS\x20NULL','\x20=\x20?','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','isNumeric','MATCH\x20(me.body)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','QueryTypes','SELECT','clone','i.id','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','contactName','t.id\x20IN\x20?','resolve','i.ChatWebsiteId\x20IS\x20NOT\x20NULL','user','role','agent','getChatWebsites','isEmpty','i.ChatWebsiteId\x20IS\x20NULL','sequelize','toString','keyBy','ChatInteraction','a.key','Account.key','a.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.firstName','c.email','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','o.fullname','Owner.fullname','o.internal','Owner.internal','ui.ChatInteractionId\x20IN\x20?','groupBy','ChatInteractionId','push','all','rows','show','params','rawAttributes','include','merge','create','body','findOne','vidaooApiKey','vidaooEscalation','https://api-vidaoo.xcally.com/api/v1/sessions','MotionCWB:','follow','join_url','ChatMessage','Sequelize','ValidationError','Unable\x20to\x20create\x20Vidaoo\x20session','updateAttributes','customUpdate','CmContact','abandon','abandonInteraction,\x20%s,\x20%s,\x20%s','closed','disposition','attachmentUpload','file','originalname','basename','filename','mimetype','Attachment'];(function(_0x5db71b,_0x2f04eb){var _0x1f2a53=function(_0x18bcfe){while(--_0x18bcfe){_0x5db71b['push'](_0x5db71b['shift']());}};_0x1f2a53(++_0x2f04eb);}(_0x06ef,0x185));var _0xf06e=function(_0x19d060,_0x48acdc){_0x19d060=_0x19d060-0x0;var _0x51900a=_0x06ef[_0x19d060];return _0x51900a;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xf06e('0x0'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf06e('0x1'));var Mustache=require(_0xf06e('0x2'));var util=require(_0xf06e('0x3'));var path=require('path');var sox=require(_0xf06e('0x4'));var csv=require(_0xf06e('0x5'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xf06e('0x6'));var toCsv=require(_0xf06e('0x5'));var querystring=require(_0xf06e('0x7'));var Papa=require(_0xf06e('0x8'));var Redis=require(_0xf06e('0x9'));var authService=require('../../components/auth/service');var qs=require(_0xf06e('0xa'));var as=require(_0xf06e('0xb'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xf06e('0xc'))(_0xf06e('0xd'));var utils=require(_0xf06e('0xe'));var config=require(_0xf06e('0xf'));var licenseUtil=require(_0xf06e('0x10'));var db=require(_0xf06e('0x11'))['db'];config['redis']=_[_0xf06e('0x12')](config[_0xf06e('0x13')],{'host':'localhost','port':0x18eb});var socket=require(_0xf06e('0x14'))(new Redis(config[_0xf06e('0x13')]));require('./chatInteraction.socket')['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0xf06e('0x15')][_0xf06e('0x16')]({'port':0x232b});var client9004=jayson[_0xf06e('0x15')]['http']({'port':0x232c});function respondWithRpcPromise(_0x3fdacc,_0x375f90,_0x3629f3,_0xab4288){return new BPromise(function(_0x44157a,_0x240326){var _0x448fb6=_0xab4288||client;return _0x448fb6['request'](_0x3fdacc,_0x3629f3)[_0xf06e('0x17')](function(_0x55dabf){logger[_0xf06e('0x18')](_0xf06e('0x19'),_0x375f90,'request\x20sent');logger['debug'](_0xf06e('0x1a'),_0x375f90,_0xf06e('0x1b'),JSON['stringify'](_0x55dabf));if(_0x55dabf['error']){if(_0x55dabf[_0xf06e('0x1c')][_0xf06e('0x1d')]===0x1f4){logger[_0xf06e('0x1c')]('ChatInteraction,\x20%s,\x20%s',_0x375f90,_0x55dabf[_0xf06e('0x1c')][_0xf06e('0x1e')]);return _0x240326(_0x55dabf['error'][_0xf06e('0x1e')]);}logger[_0xf06e('0x1c')](_0xf06e('0x19'),_0x375f90,_0x55dabf['error'][_0xf06e('0x1e')]);return _0x44157a(_0x55dabf[_0xf06e('0x1c')][_0xf06e('0x1e')]);}else{logger[_0xf06e('0x18')](_0xf06e('0x19'),_0x375f90,'request\x20sent');_0x44157a(_0x55dabf[_0xf06e('0x1f')]['message']);}})[_0xf06e('0x20')](function(_0x36b816){logger[_0xf06e('0x1c')](_0xf06e('0x19'),_0x375f90,_0x36b816);_0x240326(_0x36b816);});});}function respondWithStatusCode(_0x1a7f5e,_0x3dc16b){_0x3dc16b=_0x3dc16b||0xcc;return function(_0x5c09e5){if(_0x5c09e5){return _0x1a7f5e[_0xf06e('0x21')](_0x3dc16b);}return _0x1a7f5e[_0xf06e('0x22')](_0x3dc16b)[_0xf06e('0x23')]();};}function respondWithResult(_0x1b1d2a,_0x164fa9){_0x164fa9=_0x164fa9||0xc8;return function(_0x57063f){if(_0x57063f){return _0x1b1d2a[_0xf06e('0x22')](_0x164fa9)[_0xf06e('0x24')](_0x57063f);}};}function respondWithFilteredResult(_0x126aa9,_0x89a74f){return function(_0x373709){if(_0x373709){var _0x25bacb=_0x373709[_0xf06e('0x25')],_0x4b5185=_0x89a74f['offset'],_0x17c427=_0x89a74f[_0xf06e('0x26')]+_0x89a74f[_0xf06e('0x27')],_0x7870d6;if(_0x17c427>=_0x25bacb){_0x17c427=_0x25bacb;_0x7870d6=0xc8;}else{_0x7870d6=0xce;}_0x126aa9[_0xf06e('0x22')](_0x7870d6);return _0x126aa9[_0xf06e('0x28')](_0xf06e('0x29'),_0x4b5185+'-'+_0x17c427+'/'+_0x25bacb)[_0xf06e('0x24')](_0x373709);}return null;};}function patchUpdates(_0x1b25fc){return function(_0x2c19a5){try{jsonpatch[_0xf06e('0x2a')](_0x2c19a5,_0x1b25fc,!![]);}catch(_0x51a105){return BPromise['reject'](_0x51a105);}return _0x2c19a5[_0xf06e('0x2b')]();};}function saveUpdates(_0x4fb3e9,_0x506cd3){return function(_0x274b47){if(_0x274b47){return _0x274b47[_0xf06e('0x2c')](_0x4fb3e9)[_0xf06e('0x17')](function(_0x165e88){return _0x165e88;});}return null;};}function removeEntity(_0x1331ee,_0x792ea2){return function(_0x4c52e8){if(_0x4c52e8){return _0x4c52e8[_0xf06e('0x2d')]()[_0xf06e('0x17')](function(){_0x1331ee[_0xf06e('0x22')](0xcc)['end']();});}};}function handleEntityNotFound(_0x109218,_0x180721){return function(_0x3941ec){if(!_0x3941ec){_0x109218[_0xf06e('0x21')](0x194);}return _0x3941ec;};}function handleError(_0x1477ae,_0x380a8a){_0x380a8a=_0x380a8a||0x1f4;return function(_0x12387b){logger['error'](_0x12387b['stack']);if(_0x12387b[_0xf06e('0x2e')]){delete _0x12387b['name'];}_0x1477ae[_0xf06e('0x22')](_0x380a8a)['send'](_0x12387b);};}function getInteractionUsers(_0x381dc4,_0x4fb24c){return new BPromise(function(_0x4bc7c1,_0x33fb24){try{if(_0x4fb24c[_0x381dc4['id']]){_0x381dc4[_0xf06e('0x2f')]=_[_0xf06e('0x30')](_0x4fb24c[_0x381dc4['id']],function(_0x2356f0){return{'id':_0x2356f0['id'],'fullname':_0x2356f0[_0xf06e('0x31')]};});}}catch(_0x523f90){_0x33fb24(_0x523f90);}_0x4bc7c1(_0x381dc4);});}function getInteractionTags(_0x2e06a1,_0xb20e60){return new BPromise(function(_0x3ee48e,_0x16a880){try{if(_0x2e06a1[_0xf06e('0x32')]){_0x2e06a1[_0xf06e('0x33')]=[];_0x2e06a1[_0xf06e('0x32')][_0xf06e('0x34')](',')[_0xf06e('0x35')](function(_0x346eef){_0x2e06a1[_0xf06e('0x33')]['push'](_0xb20e60[_0x346eef]);});}delete _0x2e06a1[_0xf06e('0x32')];}catch(_0x38ce94){_0x16a880(_0x38ce94);}_0x3ee48e(_0x2e06a1);});}function updateChatInteraction(_0x2dfbb4,_0x3acf46,_0x4100a3){return new BPromise(function(_0x1c819e,_0x1901de){return getInteractionUsers(_0x2dfbb4,_0x4100a3)['then'](function(_0x27c5f8){return getInteractionTags(_0x27c5f8,_0x3acf46);})[_0xf06e('0x17')](function(_0x5ddceb){_0x1c819e(_0x5ddceb);})['catch'](function(_0x1d6835){_0x1901de(_0x1d6835);});});}exports[_0xf06e('0x36')]=function(_0x3ae06c,_0x7fc745){var _0x3b3f7d={},_0x410772={},_0x48b48e={'count':0x0,'rows':[]};var _0x548a97=_[_0xf06e('0x30')](db['ChatInteraction']['rawAttributes'],function(_0x494974){return{'name':_0x494974[_0xf06e('0x37')],'type':_0x494974[_0xf06e('0x38')]['key']};});_0x410772['model']=_[_0xf06e('0x30')](_0x548a97,_0xf06e('0x2e'));_0x410772['query']=_[_0xf06e('0x39')](_0x3ae06c['query']);_0x410772[_0xf06e('0x3a')]=_[_0xf06e('0x3b')](_0x410772[_0xf06e('0x3c')],_0x410772[_0xf06e('0x3d')]);_0x3b3f7d['attributes']=_[_0xf06e('0x3b')](_0x410772[_0xf06e('0x3c')],qs['fields'](_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x3e')]));_0x3b3f7d[_0xf06e('0x3f')]=_0x3b3f7d[_0xf06e('0x3f')][_0xf06e('0x40')]?_0x3b3f7d[_0xf06e('0x3f')]:_0x410772[_0xf06e('0x3c')];if(!_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x41')](_0xf06e('0x42'))){_0x3b3f7d[_0xf06e('0x27')]=qs['limit'](_0x3ae06c['query'][_0xf06e('0x27')]);_0x3b3f7d['offset']=qs['offset'](_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x26')]);}_0x3b3f7d[_0xf06e('0x43')]=qs[_0xf06e('0x44')](_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x44')]);_0x3b3f7d[_0xf06e('0x45')]=qs[_0xf06e('0x3a')](_['pick'](_0x3ae06c[_0xf06e('0x3d')],_0x410772[_0xf06e('0x3a')]),_0x548a97);var _0x56a843=[];var _0xa74d67=squel[_0xf06e('0x46')]()[_0xf06e('0x47')]('id')['field']('name')[_0xf06e('0x47')](_0xf06e('0x48'))[_0xf06e('0x49')]('tools_tags');var _0x9ec791=squel[_0xf06e('0x46')]()[_0xf06e('0x47')](_0xf06e('0x4a'))['field']('u.fullname')[_0xf06e('0x47')]('ui.ChatInteractionId')['from'](_0xf06e('0x4b'),'ui')['left_join']('users','u',_0xf06e('0x4c'));var _0x1d20da=squel[_0xf06e('0x46')]()[_0xf06e('0x49')](_0xf06e('0x4d'),'i')[_0xf06e('0x4e')](_0xf06e('0x4f'),'c','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL')[_0xf06e('0x4e')]('users','o',_0xf06e('0x50'))['left_join'](_0xf06e('0x51'),'a',_0xf06e('0x52'))[_0xf06e('0x4e')](_0xf06e('0x53'),'me',_0xf06e('0x54'))[_0xf06e('0x4e')]('chat_interaction_has_tags','it',_0xf06e('0x55'))[_0xf06e('0x4e')]('tools_tags','t','t.id\x20=\x20it.TagId');var _0x4b0124=squel['expr']();var _0xd1b06b=[];var _0x3dc22f=squel['expr']();var _0x29fba6;if(_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x56')]){_0x29fba6=as[_0xf06e('0x57')](_0x3ae06c['query'][_0xf06e('0x56')]);var _0x23b03f=_0x29fba6['sqlOperator'];for(var _0x3cf2b7=0x0;_0x3cf2b7<_0x29fba6[_0xf06e('0x58')][_0xf06e('0x40')];_0x3cf2b7++){var _0xa1afb9=_0x29fba6[_0xf06e('0x58')][_0x3cf2b7];var _0xbc0cd1='i';var _0x4efff1=_['find'](_0x548a97,[_0xf06e('0x2e'),_0xa1afb9[_0xf06e('0x47')]]);if(!_0x4efff1){switch(_0xa1afb9['field']){case _0xf06e('0x59'):if(_0xa1afb9[_0xf06e('0x5a')]==0x1){_0x1d20da[_0xf06e('0x5b')]('`'+_0xa1afb9[_0xf06e('0x47')]+_0xf06e('0x5c'));}else{_0x1d20da[_0xf06e('0x5b')]('`'+_0xa1afb9['field']+_0xf06e('0x5d'));}break;case _0xf06e('0x5e'):if(_0xa1afb9[_0xf06e('0x5f')]===_0xf06e('0x60')){if(_0xa1afb9[_0xf06e('0x5a')][_0xf06e('0x34')]('\x20')[_0xf06e('0x40')]>0x1){_0x4b0124[_0x23b03f](_0xf06e('0x61'),qs[_0xf06e('0x62')](_0xa1afb9[_0xf06e('0x5a')]),null);}else{var _0x5bf60a='%'+_0xa1afb9[_0xf06e('0x5a')]+'%';_0x4b0124[_0x23b03f](_0xf06e('0x63'),_0x5bf60a,_0x5bf60a,_0x5bf60a);}}else{_0x4efff1=_[_0xf06e('0x64')](_0x548a97,[_0xf06e('0x2e'),'ContactId']);_0xa1afb9[_0xf06e('0x47')]=_0xf06e('0x65');_0x17397b=as['buildExpression'](_0xbc0cd1,_0x4efff1[_0xf06e('0x38')],_0xa1afb9);_0x4b0124[_0x23b03f](_0x17397b[_0xf06e('0x66')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x67')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x23')]);}break;case _0xf06e('0x68'):var _0x4ad726=_0xa1afb9[_0xf06e('0x5a')][_0xf06e('0x34')](',')[_0xf06e('0x30')](function(_0x529f11){return Number(_0x529f11);});_0x4ad726[_0xf06e('0x35')](function(_0x3c74f8){_0x3dc22f['or'](_0xf06e('0x69'),'%,'+_0x3c74f8+',%');});_0xd1b06b=_['union'](_0xd1b06b,_0x4ad726);break;case _0xf06e('0x6a'):if(_0xa1afb9[_0xf06e('0x5f')]===_0xf06e('0x60')){_0x4b0124[_0x23b03f]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0xa1afb9[_0xf06e('0x5a')]+'%',null);}else{_0x4efff1=_[_0xf06e('0x64')](_0x548a97,[_0xf06e('0x2e'),_0xf06e('0x6b')]);_0xa1afb9[_0xf06e('0x47')]=_0xf06e('0x6b');_0x17397b=as[_0xf06e('0x6c')](_0xbc0cd1,_0x4efff1['type'],_0xa1afb9);_0x4b0124[_0x23b03f](_0x17397b[_0xf06e('0x66')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x67')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x23')]);}break;case'body':_0x17397b=as['buildExpression']('me',null,_0xa1afb9);_0x4b0124[_0x23b03f](_0x17397b[_0xf06e('0x66')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x67')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x23')]);break;}}else{var _0x17397b=as[_0xf06e('0x6c')](_0xbc0cd1,_0x4efff1['type'],_0xa1afb9);_0x4b0124[_0x23b03f](_0x17397b[_0xf06e('0x66')],_0x17397b['value'][_0xf06e('0x67')],_0x17397b[_0xf06e('0x5a')][_0xf06e('0x23')]);}}}else{var _0x46b0af=_(_0x3ae06c[_0xf06e('0x3d')])[_0xf06e('0x39')]()['map'](function(_0x2816de){return _[_0xf06e('0x6d')](_0x548a97,[_0xf06e('0x2e'),_0x2816de])?_0x2816de:undefined;})['compact']()[_0xf06e('0x5a')]();if(!_['isEmpty'](_0x46b0af)){_0x46b0af['forEach'](function(_0x1bc1f3){if(_0x1bc1f3===_0xf06e('0x6e')){_0x1d20da['where'](_0xf06e('0x6f'),[][_0xf06e('0x70')](_0x3ae06c[_0xf06e('0x3d')][_0x1bc1f3]));}else if(_0x1bc1f3===_0xf06e('0x71')){var _0x2704d0=JSON[_0xf06e('0x72')](_0x3ae06c['query'][_0x1bc1f3])[_0xf06e('0x73')];var _0x2f2d13=JSON[_0xf06e('0x72')](_0x3ae06c[_0xf06e('0x3d')][_0x1bc1f3])[_0xf06e('0x74')];_0x1d20da[_0xf06e('0x45')](_0xf06e('0x75'),_0x2704d0,_0x2f2d13);}else{if(_0x3ae06c[_0xf06e('0x3d')][_0x1bc1f3]==='null'){_0x1d20da['where']('i.'+_0x1bc1f3+_0xf06e('0x76'));}else{_0x1d20da[_0xf06e('0x45')]('i.'+_0x1bc1f3+_0xf06e('0x77'),_0x3ae06c[_0xf06e('0x3d')][_0x1bc1f3]);}}});}if(_0x3ae06c[_0xf06e('0x3d')]['read']){if(_0x3ae06c[_0xf06e('0x3d')]['read']==0x1){_0x1d20da['having'](_0xf06e('0x78'));}else{_0x1d20da[_0xf06e('0x5b')](_0xf06e('0x79'));}}if(_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x7a')]){_0xd1b06b=_[_0xf06e('0x7b')](_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x7a')])?_0x3ae06c[_0xf06e('0x3d')][_0xf06e('0x7a')]:new Array(_0x3ae06c[_0xf06e('0x3d')]['tag']);_0xd1b06b['forEach'](function(_0x2a9d30){_0x3dc22f['or'](_0xf06e('0x69'),'%,'+_0x2a9d30+',%');});}if(_0x3ae06c['query'][_0xf06e('0x7c')]){var _0x274a18=_0x3ae06c['query'][_0xf06e('0x7c')][_0xf06e('0x7d')]('\x5c','\x5c\x5c')[_0xf06e('0x7d')](/'/g,'\x27\x27');if(qs[_0xf06e('0x7e')](_0x274a18)){_0x4b0124['or']('i.id\x20LIKE\x20?',_0x274a18+'%');}else{_0x4b0124['or'](_0xf06e('0x7f'),qs[_0xf06e('0x62')](_0x274a18))['or'](_0xf06e('0x80'),_0x274a18+'%');}}}_0x1d20da[_0xf06e('0x45')](_0x4b0124);_0x1d20da['group']('i.id');var _0x71b2f5={'type':db['Sequelize'][_0xf06e('0x81')][_0xf06e('0x82')],'raw':!![]};var _0x4c531f=_0x1d20da[_0xf06e('0x83')]();_0x4c531f[_0xf06e('0x47')](_0xf06e('0x84'));_0x4c531f[_0xf06e('0x47')](_0xf06e('0x85'),_0xf06e('0x59'));if(_0x3b3f7d[_0xf06e('0x43')]){_0x3b3f7d['order']['forEach'](function(_0x2ff8e1){var _0x1b8544=_0x2ff8e1[0x0]===_0xf06e('0x86')?_0x2ff8e1[0x0]:'i.'+_0x2ff8e1[0x0];_0x1d20da[_0xf06e('0x43')](_0x1b8544,_0x2ff8e1[0x1]==='DESC'?![]:!![]);});}if(!_['isEmpty'](_0xd1b06b)){_0x1d20da['having'](_0x3dc22f);_0x4c531f[_0xf06e('0x45')](_0xf06e('0x87'),_0xd1b06b);}BPromise[_0xf06e('0x88')]()['then'](function(){if(!_0x29fba6){if(_0x3ae06c['query'][_0xf06e('0x6e')])return;_0x4c531f[_0xf06e('0x45')](_0xf06e('0x89'));_0x1d20da[_0xf06e('0x45')](_0xf06e('0x89'));return;}if(_0x3ae06c[_0xf06e('0x8a')][_0xf06e('0x8b')]!==_0xf06e('0x8c'))return;return _0x3ae06c[_0xf06e('0x8a')][_0xf06e('0x8d')]({'attributes':['id'],'raw':!![]})[_0xf06e('0x17')](function(_0x293a8b){if(_[_0xf06e('0x8e')](_0x293a8b)){_0x4c531f[_0xf06e('0x45')]('i.ChatWebsiteId\x20IS\x20NULL');_0x1d20da['where'](_0xf06e('0x8f'));}else{_0x4c531f[_0xf06e('0x45')](_0xf06e('0x6f'),_[_0xf06e('0x30')](_0x293a8b,'id'));_0x1d20da[_0xf06e('0x45')]('i.ChatWebsiteId\x20IN\x20?',_[_0xf06e('0x30')](_0x293a8b,'id'));}});})[_0xf06e('0x17')](function(){if(_0x3ae06c[_0xf06e('0x8a')]['role']===_0xf06e('0x8c')&&!_0x29fba6&&!_0x3ae06c[_0xf06e('0x3d')]['ChatWebsiteId'])return[];return db[_0xf06e('0x90')]['query'](_0x4c531f[_0xf06e('0x91')](),_0x71b2f5);})[_0xf06e('0x17')](function(_0x5bcb4b){_0x48b48e[_0xf06e('0x25')]=_0x5bcb4b[_0xf06e('0x40')];if(_0x48b48e['count']===0x0)return[];return db[_0xf06e('0x90')][_0xf06e('0x3d')](_0xa74d67[_0xf06e('0x91')](),_0x71b2f5)['then'](function(_0xaac51a){_0x56a843=_[_0xf06e('0x92')](_0xaac51a,'id');_0x71b2f5=_['merge'](_0x71b2f5,{'model':db[_0xf06e('0x93')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x3ae06c[_0xf06e('0x3d')]['fields']){_0x3b3f7d['attributes'][_0xf06e('0x35')](function(_0x400228){_0x1d20da['field']('i.'+_0x400228);});}else{_0x1d20da[_0xf06e('0x47')](_0xf06e('0x85'),_0xf06e('0x59'));_0x1d20da[_0xf06e('0x47')](_0xf06e('0x94'),_0xf06e('0x95'));_0x1d20da[_0xf06e('0x47')](_0xf06e('0x96'),'Account.mandatoryDisposition');_0x1d20da['field'](_0xf06e('0x97'),'contactName');_0x1d20da[_0xf06e('0x47')](_0xf06e('0x98'));_0x1d20da['field']('c.firstName',_0xf06e('0x99'));_0x1d20da[_0xf06e('0x47')]('c.lastName','Contact.lastName');_0x1d20da[_0xf06e('0x47')](_0xf06e('0x9a'),'Contact.email');_0x1d20da[_0xf06e('0x47')](_0xf06e('0x9b'),_0xf06e('0x9c'));_0x1d20da[_0xf06e('0x47')](_0xf06e('0x9d'),_0xf06e('0x9e'));_0x1d20da[_0xf06e('0x47')](_0xf06e('0x9f'),_0xf06e('0xa0'));_0x1d20da[_0xf06e('0x47')](_0xf06e('0xa1'),_0xf06e('0xa2'));_0x1d20da[_0xf06e('0x47')](_0xf06e('0xa3'),_0xf06e('0xa4'));_0x1d20da[_0xf06e('0x47')]('GROUP_CONCAT(DISTINCT\x20t.id)',_0xf06e('0x32'));}if(_0x3b3f7d[_0xf06e('0x27')])_0x1d20da[_0xf06e('0x27')](_0x3b3f7d[_0xf06e('0x27')]);if(_0x3b3f7d[_0xf06e('0x26')])_0x1d20da[_0xf06e('0x26')](_0x3b3f7d['offset']);return db[_0xf06e('0x90')][_0xf06e('0x3d')](_0x1d20da['toString'](),_0x71b2f5);})[_0xf06e('0x17')](function(_0x3dc30f){_0x9ec791[_0xf06e('0x45')](_0xf06e('0xa5'),_[_0xf06e('0x30')](_0x3dc30f,'id'));return db[_0xf06e('0x90')][_0xf06e('0x3d')](_0x9ec791[_0xf06e('0x91')](),_0x71b2f5)[_0xf06e('0x17')](function(_0x5dfc46){var _0xb826de=_[_0xf06e('0xa6')](_0x5dfc46,_0xf06e('0xa7'));var _0x408aef=[];_0x3dc30f[_0xf06e('0x35')](function(_0x368d32){_0x408aef[_0xf06e('0xa8')](updateChatInteraction(_0x368d32,_0x56a843,_0xb826de));});return BPromise[_0xf06e('0xa9')](_0x408aef);});});})['then'](function(_0x17fefd){_0x48b48e[_0xf06e('0xaa')]=_0x17fefd;return _0x48b48e;})[_0xf06e('0x17')](respondWithFilteredResult(_0x7fc745,_0x3b3f7d))['catch'](handleError(_0x7fc745,null));};exports[_0xf06e('0xab')]=function(_0x541377,_0x815f9a){var _0x13435e={'raw':![],'where':{'id':_0x541377[_0xf06e('0xac')]['id']}},_0x551edf={};_0x551edf['model']=_['keys'](db[_0xf06e('0x93')][_0xf06e('0xad')]);_0x551edf[_0xf06e('0x3d')]=_['keys'](_0x541377[_0xf06e('0x3d')]);_0x551edf[_0xf06e('0x3a')]=_[_0xf06e('0x3b')](_0x551edf[_0xf06e('0x3c')],_0x551edf[_0xf06e('0x3d')]);_0x13435e['attributes']=_['intersection'](_0x551edf[_0xf06e('0x3c')],qs[_0xf06e('0x3e')](_0x541377['query'][_0xf06e('0x3e')]));_0x13435e[_0xf06e('0x3f')]=_0x13435e[_0xf06e('0x3f')][_0xf06e('0x40')]?_0x13435e[_0xf06e('0x3f')]:_0x551edf['model'];if(_0x541377[_0xf06e('0x3d')]['includeAll']){_0x13435e[_0xf06e('0xae')]=[{'all':!![]}];}_0x13435e=_[_0xf06e('0xaf')]({},_0x13435e,_0x541377['options']);return db[_0xf06e('0x93')][_0xf06e('0x64')](_0x13435e)[_0xf06e('0x17')](handleEntityNotFound(_0x815f9a,null))['then'](respondWithResult(_0x815f9a,null))[_0xf06e('0x20')](handleError(_0x815f9a,null));};exports[_0xf06e('0xb0')]=function(_0x52aac7,_0x420aa3){return db[_0xf06e('0x93')][_0xf06e('0xb0')](_0x52aac7[_0xf06e('0xb1')],{})['then'](respondWithResult(_0x420aa3,0xc9))[_0xf06e('0x20')](handleError(_0x420aa3,null));};exports['update']=function(_0x4b4d9b,_0x2206bb){if(_0x4b4d9b['body']['id']){delete _0x4b4d9b[_0xf06e('0xb1')]['id'];}return db[_0xf06e('0x93')]['find']({'where':{'id':_0x4b4d9b[_0xf06e('0xac')]['id']}})[_0xf06e('0x17')](handleEntityNotFound(_0x2206bb,null))[_0xf06e('0x17')](saveUpdates(_0x4b4d9b[_0xf06e('0xb1')],null))[_0xf06e('0x17')](respondWithResult(_0x2206bb,null))['catch'](handleError(_0x2206bb,null));};exports[_0xf06e('0x2d')]=function(_0x28eb93,_0x5d8b7d){return db['ChatInteraction'][_0xf06e('0x64')]({'where':{'id':_0x28eb93['params']['id']}})[_0xf06e('0x17')](handleEntityNotFound(_0x5d8b7d,null))[_0xf06e('0x17')](removeEntity(_0x5d8b7d,null))['catch'](handleError(_0x5d8b7d,null));};exports['describe']=function(_0x58228f,_0x13be13){return db[_0xf06e('0x93')]['describe']()['then'](respondWithResult(_0x13be13,null))[_0xf06e('0x20')](handleError(_0x13be13,null));};exports['createVidaooSession']=function(_0x10fbf2,_0x238ff8){var _0x12451d=_0x10fbf2[_0xf06e('0xac')]['id'];var _0x510346;var _0x1c5b35;var _0x5a17f3;return db[_0xf06e('0x93')][_0xf06e('0xb2')]({'where':{'id':_0x12451d}})[_0xf06e('0x17')](function(_0x1dbe2c){_0x510346=_0x1dbe2c;return db['ChatWebsite']['findOne']({'where':{'id':_0x1dbe2c[_0xf06e('0x6e')]},'attributes':['id',_0xf06e('0xb3'),_0xf06e('0xb4')],'raw':!![]});})[_0xf06e('0x17')](function(_0x419063){if(_0x419063&&_0x419063[_0xf06e('0xb3')]&&_0x419063['vidaooEscalation']){_0x1c5b35=_0x419063;var _0x1c0a9c={'rejectUnauthorized':![],'method':'POST','uri':_0xf06e('0xb5'),'headers':{'X-APIKEY':_0x419063[_0xf06e('0xb3')]},'body':{'name':_0xf06e('0xb6')+_0x12451d},'redirect':_0xf06e('0xb7'),'json':!![]};return rp(_0x1c0a9c);}else{throw new db['Sequelize']['ValidationError']('Error\x20in\x20Vidaoo\x20configuration');}})[_0xf06e('0x17')](function(_0x565a55){_0x5a17f3=_0x565a55;if(_0x5a17f3['id']){var _0x1e71ca={'body':_0x5a17f3[_0xf06e('0xb8')],'ChatWebsiteId':_0x1c5b35['id'],'ChatInteractionId':_0x510346['id'],'direction':'out','UserId':_0x10fbf2[_0xf06e('0x8a')]['id']};return db[_0xf06e('0xb9')][_0xf06e('0xb0')](_0x1e71ca,{});}else{throw new db[(_0xf06e('0xba'))][(_0xf06e('0xbb'))](_0xf06e('0xbc'));}})['then'](function(){return _0x510346[_0xf06e('0xbd')]({'vidaooSessionId':_0x5a17f3['id']});})[_0xf06e('0x17')](respondWithResult(_0x238ff8,null))[_0xf06e('0x20')](handleError(_0x238ff8,null));};exports[_0xf06e('0xbe')]=function(_0x964c6b,_0x5e54d2){if(_0x964c6b['body']['id']){delete _0x964c6b['body']['id'];}return db[_0xf06e('0x93')][_0xf06e('0x64')]({'where':{'id':_0x964c6b[_0xf06e('0xac')]['id']},'include':[{'model':db[_0xf06e('0xbf')],'as':_0xf06e('0x5e')}]})[_0xf06e('0x17')](handleEntityNotFound(_0x5e54d2,null))[_0xf06e('0x17')](saveUpdates(_0x964c6b[_0xf06e('0xb1')],null))['then'](respondWithResult(_0x5e54d2,null))[_0xf06e('0x20')](handleError(_0x5e54d2,null));};exports[_0xf06e('0xc0')]=function(_0x3196a2,_0x2cb5b0,_0xeb9f91){if(_0x3196a2['body']['id']){delete _0x3196a2[_0xf06e('0xb1')]['id'];}return db[_0xf06e('0x93')][_0xf06e('0x64')]({'where':{'id':_0x3196a2[_0xf06e('0xac')]['id']}})['then'](function(_0x3861f7){if(!_0x3861f7){logger[_0xf06e('0x1c')](_0xf06e('0xc1'),_0xf06e('0xc0'),0x194,'entity\x20not\x20found');_0x2cb5b0[_0xf06e('0x21')](0x194);}else{if(_0x3861f7[_0xf06e('0x6b')]){throw new db[(_0xf06e('0xba'))]['ValidationError']('Interaction\x20already\x20assigned');}}return _0x3861f7;})['then'](function(_0x2b9b95){if(_0x2b9b95){return _0x2b9b95[_0xf06e('0x2c')]({'closed':_0x3196a2[_0xf06e('0xb1')][_0xf06e('0xc2')],'disposition':_0x3196a2[_0xf06e('0xb1')][_0xf06e('0xc3')]})[_0xf06e('0x17')](function(_0x3045b4){return _0x3045b4;});}})[_0xf06e('0x17')](function(_0xbd434c){return respondWithRpcPromise('AbandonInteraction',_0xf06e('0xc0'),_0x3196a2[_0xf06e('0xb1')],client9004);})[_0xf06e('0x17')](respondWithResult(_0x2cb5b0,null))['catch'](handleError(_0x2cb5b0,null));};exports[_0xf06e('0xc4')]=function(_0x24920b,_0x372125,_0x2a0031){_0x24920b['body'][_0xf06e('0x2e')]=_0x24920b[_0xf06e('0xc5')][_0xf06e('0xc6')];_0x24920b[_0xf06e('0xb1')][_0xf06e('0xc7')]=_0x24920b[_0xf06e('0xc5')][_0xf06e('0xc8')];_0x24920b[_0xf06e('0xb1')]['type']=_0x24920b[_0xf06e('0xc5')][_0xf06e('0xc9')];return db[_0xf06e('0xca')][_0xf06e('0xb0')](_0x24920b[_0xf06e('0xb1')])['then'](respondWithResult(_0x372125,0xc9))[_0xf06e('0x20')](handleError(_0x372125,null));};exports[_0xf06e('0xcb')]=function(_0x34f31d,_0x12f3ec,_0x4c7358){return db[_0xf06e('0x93')][_0xf06e('0xb2')]({'where':{'id':_0x34f31d['params']['id']},'raw':!![]})[_0xf06e('0x17')](handleEntityNotFound(_0x12f3ec,null))['then'](function(_0x67d15d){if(_0x67d15d){if(_0x67d15d[_0xf06e('0xc2')]){return _0x12f3ec[_0xf06e('0x22')](0x193)['json']({'status':0x193,'message':_0xf06e('0xcc')});}return db[_0xf06e('0xca')][_0xf06e('0xb2')]({'where':{'id':_0x34f31d[_0xf06e('0x3d')][_0xf06e('0xcd')]},'raw':!![]})['then'](handleEntityNotFound(_0x12f3ec,null));}})[_0xf06e('0x17')](function(_0x5492cc){if(_0x5492cc){return _0x12f3ec[_0xf06e('0xce')](path[_0xf06e('0xcf')](config[_0xf06e('0xd0')],_0xf06e('0xd1'),_0x5492cc[_0xf06e('0xc7')]));}})[_0xf06e('0x20')](handleError(_0x12f3ec,null));};exports[_0xf06e('0xd2')]=function(_0x1d181d,_0x3dc1fe){var _0x5ef0b7=null;var _0x51f3b6=null;var _0x170b6e=null;var _0x1aa78f=null;if(_0x1d181d[_0xf06e('0xb1')]['id']){delete _0x1d181d[_0xf06e('0xb1')]['id'];}if(_0x1d181d[_0xf06e('0xb1')]['mailTranscript']){_0x1aa78f=path[_0xf06e('0xcf')](config[_0xf06e('0xd0')],_0xf06e('0xd3'),util['format'](_0xf06e('0xd4'),Date[_0xf06e('0xd5')]()));_0x1d181d['body'][_0xf06e('0xd6')]=_0x1aa78f;}return db['ChatInteraction']['find']({'where':{'id':_0x1d181d[_0xf06e('0xac')]['id']},'include':[{'model':db[_0xf06e('0xb9')],'as':_0xf06e('0xd7'),'include':[{'model':db['User'],'as':_0xf06e('0x6a')}]}]})[_0xf06e('0x17')](handleEntityNotFound(_0x3dc1fe,null))[_0xf06e('0x17')](saveUpdates(_0x1d181d['body'],null))[_0xf06e('0x17')](function(_0xff099a){if(_0xff099a){_0x5ef0b7=_0xff099a;return db[_0xf06e('0xd8')]['find']({'where':{'id':_0x5ef0b7[_0xf06e('0x6e')]}});}})[_0xf06e('0x17')](function(_0x572d3e){if(_0x572d3e){_0x170b6e=_0x572d3e;return db[_0xf06e('0xbf')][_0xf06e('0x64')]({'where':{'id':_0x5ef0b7[_0xf06e('0x65')]}});}})[_0xf06e('0x17')](function(_0x3cbbd9){if(_0x3cbbd9){_0x51f3b6=_0x3cbbd9;if(_0x1aa78f){var _0x2b7dcd=null;for(var _0x21abc7=0x1;_0x21abc7<_0x5ef0b7[_0xf06e('0xd7')][_0xf06e('0x40')];++_0x21abc7){_0x2b7dcd=_0x5ef0b7[_0xf06e('0xd7')][_0x21abc7];var _0x4cf832=_0x2b7dcd[_0xf06e('0x6b')]?util['format'](_0xf06e('0xd9'),_0x170b6e[_0xf06e('0xda')],_0x2b7dcd[_0xf06e('0x6b')]):_0xf06e('0xdb');var _0x2ec865=_0x1d181d[_0xf06e('0xb1')][_0xf06e('0xdc')]||util['format'](_0xf06e('0xd9'),_0xf06e('0xdd'),_0x2b7dcd[_0xf06e('0x65')]);switch(_0x170b6e[_0xf06e('0xde')]){case'website_alias':_0x4cf832=_0x2b7dcd['UserId']?util['format']('%s%d',_0x170b6e[_0xf06e('0xda')],_0x2b7dcd[_0xf06e('0x6b')]):_0xf06e('0xdb');break;case _0xf06e('0xdf'):_0x4cf832=_0x2b7dcd[_0xf06e('0x6b')]?_0x2b7dcd[_0xf06e('0x6a')][_0xf06e('0xe0')]||_0x2b7dcd[_0xf06e('0x6a')]['fullname']:_0xf06e('0xdb');break;case _0xf06e('0xe1'):_0x4cf832=_0x2b7dcd[_0xf06e('0x6b')]?_0x2b7dcd['User'][_0xf06e('0x31')]:'System';break;default:_0x4cf832=_0x2b7dcd['UserId']?util[_0xf06e('0xe2')](_0xf06e('0xd9'),_0x170b6e['agentAlias'],_0x2b7dcd[_0xf06e('0x6b')]):_0xf06e('0xdb');}var _0x25485b=util[_0xf06e('0xe2')](_0xf06e('0xe3'),moment(_0x2b7dcd[_0xf06e('0x71')])[_0xf06e('0xe2')]('MM/DD/YYYY\x20HH:mm:ss'),_0x2b7dcd['direction']==='in'?_0x2ec865:_0x4cf832,_0x2b7dcd[_0xf06e('0xb1')]);if(!_0x2b7dcd[_0xf06e('0xe4')]){fs[_0xf06e('0xe5')](_0x1aa78f,_0x25485b);}}return db[_0xf06e('0xe6')][_0xf06e('0xb2')]({'where':{'service':!![]},'include':[{'model':db[_0xf06e('0xe7')],'as':'Smtp','raw':!![]}]});}}})[_0xf06e('0x17')](function(_0x3f8c2b){if(_0x3f8c2b&&_0x3f8c2b[_0xf06e('0xe8')]&&_0x1d181d[_0xf06e('0xb1')]){var _0x52c329={'tls':{'rejectUnauthorized':![]}};if(_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0xe9')]){_0x52c329[_0xf06e('0xe9')]=_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0xe9')];}else{_0x52c329['host']=_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0xea')];_0x52c329[_0xf06e('0xeb')]=_0x3f8c2b['Smtp'][_0xf06e('0xeb')];_0x52c329[_0xf06e('0xec')]=_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0xec')];}if(_0x3f8c2b[_0xf06e('0xe8')]['authentication']){_0x52c329[_0xf06e('0xed')]={'user':_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0x8a')],'pass':_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0xee')]};}return respondWithRpcPromise('SendMail','sendMail',{'account':_0x52c329,'message':{'from':util[_0xf06e('0xe2')](_0xf06e('0xef'),_0x3f8c2b[_0xf06e('0x2e')],_0x3f8c2b[_0xf06e('0xf0')]||_0x3f8c2b[_0xf06e('0xe8')][_0xf06e('0x8a')]),'to':_0x1d181d[_0xf06e('0xb1')][_0xf06e('0xf1')],'subject':_0xf06e('0xf2'),'text':util[_0xf06e('0xe2')]('Hi\x20%s,\x20attached\x20you\x20can\x20find\x20your\x20transcript\x20file.\x20\x0a\x0aRegards.\x20\x0a\x0a',_0x1d181d['body'][_0xf06e('0xf1')]),'attachments':[{'path':_0x1aa78f}]}})[_0xf06e('0x17')](function(){return _0x5ef0b7;})[_0xf06e('0x20')](function(_0x46136c){console[_0xf06e('0x1c')](_0x46136c);});}else{return _0x5ef0b7;}})[_0xf06e('0x17')](respondWithStatusCode(_0x3dc1fe,0xc8))[_0xf06e('0x20')](handleError(_0x3dc1fe,null));};exports['addMessage']=function(_0x563fa4,_0x50a898,_0x1bbd1b){return db[_0xf06e('0xb9')][_0xf06e('0x64')]({'where':{'id':_0x563fa4[_0xf06e('0xac')]['id']}})['then'](handleEntityNotFound(_0x50a898,null))['then'](function(_0x4d2bda){if(_0x4d2bda){return _0x4d2bda[_0xf06e('0xf3')](_0x563fa4['body'][_0xf06e('0xf4')],_['omit'](_0x563fa4[_0xf06e('0xb1')],[_0xf06e('0xf4'),'id'])||{});}})[_0xf06e('0x17')](respondWithResult(_0x50a898,null))[_0xf06e('0x20')](handleError(_0x50a898,null));};exports[_0xf06e('0xf5')]=function(_0x8089bc,_0x2b4514,_0x3e1fe2){var _0x2521cc={'raw':![],'where':{}};var _0x498c6f={};var _0x41eaf2={'count':0x0,'rows':[]};return db[_0xf06e('0x93')][_0xf06e('0xb2')]({'where':{'id':_0x8089bc[_0xf06e('0xac')]['id']}})[_0xf06e('0x17')](handleEntityNotFound(_0x2b4514,null))[_0xf06e('0x17')](function(_0xfd2a38){if(_0xfd2a38){_0x498c6f['model']=_[_0xf06e('0x39')](db[_0xf06e('0xb9')][_0xf06e('0xad')]);_0x498c6f[_0xf06e('0x3d')]=_[_0xf06e('0x39')](_0x8089bc[_0xf06e('0x3d')]);_0x498c6f[_0xf06e('0x3a')]=_[_0xf06e('0x3b')](_0x498c6f[_0xf06e('0x3c')],_0x498c6f[_0xf06e('0x3d')]);_0x2521cc[_0xf06e('0x3f')]=_['intersection'](_0x498c6f['model'],qs[_0xf06e('0x3e')](_0x8089bc[_0xf06e('0x3d')][_0xf06e('0x3e')]));_0x2521cc['attributes']=_0x2521cc[_0xf06e('0x3f')]['length']?_0x2521cc[_0xf06e('0x3f')]:_0x498c6f[_0xf06e('0x3c')];if(!_0x8089bc['query']['hasOwnProperty'](_0xf06e('0x42'))){_0x2521cc[_0xf06e('0x27')]=qs['limit'](_0x8089bc[_0xf06e('0x3d')][_0xf06e('0x27')]);_0x2521cc[_0xf06e('0x26')]=qs['offset'](_0x8089bc[_0xf06e('0x3d')]['offset']);}_0x2521cc['order']=qs[_0xf06e('0x44')](_0x8089bc['query']['sort']);_0x2521cc['where']=qs[_0xf06e('0x3a')](_[_0xf06e('0xf6')](_0x8089bc['query'],_0x498c6f[_0xf06e('0x3a')]));_0x2521cc[_0xf06e('0x45')][_0xf06e('0xa7')]=_0xfd2a38['id'];if(_0x8089bc[_0xf06e('0x3d')]['filter']){_0x2521cc[_0xf06e('0x45')]=_[_0xf06e('0xaf')](_0x2521cc['where'],{'$or':_[_0xf06e('0x30')](_0x2521cc[_0xf06e('0x3f')],function(_0x1a11d2){var _0x484b88={};_0x484b88[_0x1a11d2]={'$like':'%'+_0x8089bc[_0xf06e('0x3d')][_0xf06e('0x7c')]+'%'};return _0x484b88;})});}if(_0x8089bc['query'][_0xf06e('0x73')]){var _0x2b9444=_0x8089bc[_0xf06e('0x3d')][_0xf06e('0x73')]['split'](',');var _0xbdee8e={};_0xbdee8e[_0x2b9444[0x0]]={'$gte':moment(_0x2b9444[0x1])[_0xf06e('0xe2')]('YYYY-MM-DD\x20HH:mm:ss')};_0x2521cc['where']=_[_0xf06e('0xaf')](_0x2521cc[_0xf06e('0x45')],_0xbdee8e);}_0x2521cc=_[_0xf06e('0xaf')]({},_0x2521cc,_0x8089bc[_0xf06e('0xf7')]);return db[_0xf06e('0xb9')][_0xf06e('0x25')]({'where':_0x2521cc['where']})['then'](function(_0x540902){_0x41eaf2[_0xf06e('0x25')]=_0x540902;if(_0x8089bc[_0xf06e('0x3d')][_0xf06e('0xf8')]){_0x2521cc[_0xf06e('0xae')]=[{'all':!![]}];}return db['ChatMessage'][_0xf06e('0xf9')](_0x2521cc);})[_0xf06e('0x17')](function(_0x5dad13){_0x41eaf2[_0xf06e('0xaa')]=_0x5dad13;return _0x41eaf2;});}})[_0xf06e('0x17')](respondWithFilteredResult(_0x2b4514,_0x2521cc))['catch'](handleError(_0x2b4514,null));};exports[_0xf06e('0xfa')]=function(_0x139e39,_0x23c0a9,_0x1ce144){var _0x4d9f28={'where':{}},_0x3cf1f8={},_0x2435f2={'count':0x0,'rows':[]};return db[_0xf06e('0x93')]['findOne']({'where':{'id':_0x139e39['params']['id']}})['then'](handleEntityNotFound(_0x23c0a9,null))[_0xf06e('0x17')](function(_0x1a50b8){if(_0x1a50b8){_0x3cf1f8[_0xf06e('0x3c')]=_[_0xf06e('0x39')](db[_0xf06e('0xb9')][_0xf06e('0xad')]);_0x3cf1f8[_0xf06e('0x3d')]=_['keys'](_0x139e39['query']);_0x3cf1f8['filters']=_[_0xf06e('0x3b')](_0x3cf1f8['model'],_0x3cf1f8['query']);_0x4d9f28[_0xf06e('0x3f')]=_[_0xf06e('0x3b')](_0x3cf1f8[_0xf06e('0x3c')],qs[_0xf06e('0x3e')](_0x139e39[_0xf06e('0x3d')][_0xf06e('0x3e')]));_0x4d9f28[_0xf06e('0x3f')]=_0x4d9f28['attributes'][_0xf06e('0x40')]?_0x4d9f28['attributes']:_0x3cf1f8['model'];if(!_0x139e39[_0xf06e('0x3d')][_0xf06e('0x41')](_0xf06e('0x42'))){_0x4d9f28['limit']=qs[_0xf06e('0x27')](_0x139e39[_0xf06e('0x3d')][_0xf06e('0x27')]);_0x4d9f28['offset']=qs[_0xf06e('0x26')](_0x139e39[_0xf06e('0x3d')]['offset']);}_0x4d9f28[_0xf06e('0x43')]=qs[_0xf06e('0x44')](_0x139e39[_0xf06e('0x3d')][_0xf06e('0x44')]);_0x4d9f28[_0xf06e('0x45')]=qs[_0xf06e('0x3a')](_['pick'](_0x139e39[_0xf06e('0x3d')],_0x3cf1f8[_0xf06e('0x3a')]));_0x4d9f28[_0xf06e('0x45')]['ChatInteractionId']=_0x1a50b8['id'];if(_0x139e39[_0xf06e('0x3d')]['filter']){_0x4d9f28[_0xf06e('0x45')]=_[_0xf06e('0xaf')](_0x4d9f28[_0xf06e('0x45')],{'$or':_[_0xf06e('0x30')](_0x4d9f28['attributes'],function(_0x438df7){var _0x30bdd5={};_0x30bdd5[_0x438df7]={'$like':'%'+_0x139e39[_0xf06e('0x3d')][_0xf06e('0x7c')]+'%'};return _0x30bdd5;})});}_0x4d9f28[_0xf06e('0x45')][_0xf06e('0xe4')]=![];if(_0x139e39[_0xf06e('0x3d')]['id']){_0x4d9f28['where']['id']={'$gt':_0x139e39[_0xf06e('0x3d')]['id']};}_0x4d9f28=_[_0xf06e('0xaf')]({},_0x4d9f28,_0x139e39[_0xf06e('0xf7')]);return db[_0xf06e('0xb9')]['count']({'where':_0x4d9f28[_0xf06e('0x45')]})[_0xf06e('0x17')](function(_0x389839){_0x2435f2[_0xf06e('0x25')]=_0x389839;_0x4d9f28[_0xf06e('0xae')]=[];if(_0x139e39['query']['includeAgent']){_0x4d9f28[_0xf06e('0xae')]['push']({'model':db[_0xf06e('0x6a')],'as':_0xf06e('0x6a'),'attributes':['id',_0xf06e('0x31'),'alias']});}if(_0x139e39[_0xf06e('0x3d')][_0xf06e('0xf8')]){_0x4d9f28[_0xf06e('0xae')]=[{'all':!![]}];}return db[_0xf06e('0xb9')]['findAll'](_0x4d9f28);})[_0xf06e('0x17')](function(_0x5f20ed){_0x2435f2[_0xf06e('0xaa')]=_0x5f20ed;return _0x2435f2;});}})[_0xf06e('0x17')](respondWithFilteredResult(_0x23c0a9,_0x4d9f28))[_0xf06e('0x20')](handleError(_0x23c0a9,null));};exports[_0xf06e('0xfb')]=function(_0x345c15,_0xb9e469,_0x2bf07f){return db[_0xf06e('0x93')][_0xf06e('0x64')]({'where':{'id':_0x345c15[_0xf06e('0xac')]['id']}})[_0xf06e('0x17')](handleEntityNotFound(_0xb9e469,null))['then'](function(_0x8238f3){if(_0x8238f3){return _0x8238f3['setTags'](_0x345c15[_0xf06e('0xb1')][_0xf06e('0xf4')],_[_0xf06e('0xfc')](_0x345c15[_0xf06e('0xb1')],[_0xf06e('0xf4'),'id'])||{})[_0xf06e('0xfd')](function(){return db[_0xf06e('0x68')][_0xf06e('0xf9')]({'attributes':['id',_0xf06e('0x2e'),_0xf06e('0x48')],'where':{'id':_0x345c15[_0xf06e('0xb1')][_0xf06e('0xf4')]}});})[_0xf06e('0x17')](function(_0x536240){socket[_0xf06e('0xfe')](_0xf06e('0xff'),{'id':Number(_0x345c15[_0xf06e('0xac')]['id']),'tags':_0x536240||[]});return{'id':Number(_0x345c15['params']['id']),'tags':_0x536240||[]};});}})['then'](respondWithResult(_0xb9e469,null))[_0xf06e('0x20')](handleError(_0xb9e469,null));};exports[_0xf06e('0x100')]=function(_0x401cc2,_0x4e8f8d,_0x536807){return db[_0xf06e('0x93')]['find']({'where':{'id':_0x401cc2[_0xf06e('0xac')]['id']}})['then'](handleEntityNotFound(_0x4e8f8d,null))[_0xf06e('0x17')](function(_0x4029bd){if(_0x4029bd){return _0x4029bd['removeTags'](_0x401cc2['query'][_0xf06e('0xf4')]);}})[_0xf06e('0x17')](respondWithStatusCode(_0x4e8f8d,null))[_0xf06e('0x20')](handleError(_0x4e8f8d,null));};exports[_0xf06e('0xce')]=function(_0x55be94,_0x450518){var _0x4b536e=moment()[_0xf06e('0x101')]()[_0xf06e('0x91')]();var _0xf43269=path[_0xf06e('0xcf')](config[_0xf06e('0xd0')],_0xf06e('0x102'),_0xf06e('0x103'),_0xf06e('0x104'));var _0x518938=path[_0xf06e('0xcf')](config[_0xf06e('0xd0')],_0xf06e('0x102'),_0xf06e('0x103'),_0xf06e('0x105'));var _0xf2938a=path[_0xf06e('0xcf')](_0xf43269,_0x4b536e);var _0x535af8=util[_0xf06e('0xe2')](_0xf06e('0x106'),_0x55be94[_0xf06e('0xac')]['id'],_0x4b536e);var _0x5e3456=path[_0xf06e('0xcf')](_0xf43269,_0x535af8);var _0x18577a=[];_0x18577a[_0xf06e('0xa8')]({'model':db['User'],'as':_0xf06e('0x6a'),'attributes':['id',_0xf06e('0x31')],'raw':!![]});_0x18577a[_0xf06e('0xa8')]({'model':db['CmContact'],'as':_0xf06e('0x5e'),'attributes':['id',_0xf06e('0x107'),_0xf06e('0x108')],'raw':!![]});if(_0x55be94[_0xf06e('0x3d')][_0xf06e('0x105')]){_0x18577a[_0xf06e('0xa8')]({'model':db[_0xf06e('0xca')],'as':'Attachment','raw':!![]});}var _0x1c21f7=[{'model':db[_0xf06e('0xb9')],'as':_0xf06e('0xd7'),'attributes':['id','body','createdAt',_0xf06e('0x109'),_0xf06e('0xe4'),_0xf06e('0x10a')],'include':_0x18577a}];_0x1c21f7[_0xf06e('0xa8')]({'model':db[_0xf06e('0xd8')],'as':_0xf06e('0x10b'),'attributes':['id','name']});_0x1c21f7[_0xf06e('0xa8')]({'model':db[_0xf06e('0x6a')],'as':_0xf06e('0x10c'),'attributes':['id',_0xf06e('0x31')]});return db[_0xf06e('0x93')][_0xf06e('0x64')]({'where':{'id':_0x55be94[_0xf06e('0xac')]['id']},'include':_0x1c21f7})[_0xf06e('0x17')](handleEntityNotFound(_0x450518,null))[_0xf06e('0x17')](function(_0x2532b2){if(_0x2532b2){var _0x3ca29e=_0x2532b2[_0xf06e('0x10d')]({'plain':!![]});fs[_0xf06e('0x10e')](_0xf2938a);var _0x14c284={'format':'A4','border':'10px','header':{'height':_0xf06e('0x10f'),'contents':{'first':_0xf06e('0x110')}},'footer':{'height':'30px','contents':{'default':util[_0xf06e('0xe2')](_0xf06e('0x111'),util[_0xf06e('0xe2')](_0xf06e('0x112'),'Chat',_0x3ca29e['id']),moment()['format'](_0xf06e('0x113'))[_0xf06e('0x91')]())}}};var _0x5c0692={'channel':_0xf06e('0x114'),'account':_0x3ca29e[_0xf06e('0x10b')][_0xf06e('0x2e')],'agent':_0x3ca29e[_0xf06e('0x10c')]?_0x3ca29e['Owner']['fullname']:_0xf06e('0x115'),'createdAt':moment(_0x3ca29e[_0xf06e('0x71')])['format']('YYYY-MM-DD\x20HH:mm:ss')[_0xf06e('0x91')](),'closedAt':_0x3ca29e['closed']?moment(_0x3ca29e[_0xf06e('0x116')])[_0xf06e('0xe2')](_0xf06e('0x117'))[_0xf06e('0x91')]():'','disposition':_0x3ca29e[_0xf06e('0xc3')],'chatInfo':{'browser':_0x3ca29e[_0xf06e('0x118')],'os':_0x3ca29e[_0xf06e('0x119')],'referer':_0x3ca29e[_0xf06e('0x11a')],'customerIp':_0x3ca29e[_0xf06e('0x11b')],'customerPort':_0x3ca29e[_0xf06e('0x11c')]?_0x3ca29e[_0xf06e('0x11c')]:_0xf06e('0x115')},'messages':_(_0x3ca29e[_0xf06e('0xd7')])[_0xf06e('0x11d')]()[_0xf06e('0x7c')]({'secret':![]})[_0xf06e('0x30')](function(_0x1ad898){if(_0x1ad898['Attachment']){var _0x4ef9df=path[_0xf06e('0xcf')](_0x518938,_0x1ad898[_0xf06e('0xca')]['basename']);if(fs['existsSync'](_0x4ef9df)){fs[_0xf06e('0x11e')](_0x4ef9df)[_0xf06e('0x11f')](fs[_0xf06e('0x120')](path[_0xf06e('0xcf')](_0xf2938a,_0x1ad898['Attachment'][_0xf06e('0xc7')])));}}return{'date':moment(_0x1ad898[_0xf06e('0x71')])[_0xf06e('0xe2')](_0xf06e('0x117'))[_0xf06e('0x91')](),'sender':_0x1ad898[_0xf06e('0x109')]===_0xf06e('0x121')?_0x1ad898['User']?_0x1ad898[_0xf06e('0x6a')][_0xf06e('0x31')]:_0xf06e('0xdb'):_0x1ad898[_0xf06e('0x5e')][_0xf06e('0x107')]+(_0x1ad898[_0xf06e('0x5e')]['lastName']?'\x20'+_0x1ad898[_0xf06e('0x5e')]['lastName']:''),'body':_0x1ad898[_0xf06e('0xca')]?_0x1ad898[_0xf06e('0xca')][_0xf06e('0xc7')]:_0x1ad898[_0xf06e('0xb1')],'direction':_0x1ad898[_0xf06e('0x109')]==='out'?'A':'C','secret':_0x1ad898[_0xf06e('0xe4')],'read':_0x1ad898[_0xf06e('0x10a')],'attachment':_0x1ad898[_0xf06e('0xca')]};})[_0xf06e('0x5a')]()};return ejs[_0xf06e('0x122')](path[_0xf06e('0xcf')](config[_0xf06e('0xd0')],'server',_0xf06e('0x123'),_0xf06e('0x124')),{'interaction':_0x5c0692})['then'](function(_0x196e94){return new BPromise(function(_0xd20f9d,_0x4af4d7){pdf['create'](_0x196e94,_0x14c284)['toFile'](path[_0xf06e('0xcf')](_0xf2938a,'transcript-'+_0x3ca29e['id']+'-'+_0x4b536e+_0xf06e('0x125')),function(_0x49c3a2,_0x1aa1aa){if(_0x49c3a2)return _0x4af4d7(_0x49c3a2);_0xd20f9d(_0x1aa1aa);});});})['then'](function(){return new BPromise(function(_0x36e597,_0xf5c609){zipdir(_0xf2938a,{'saveTo':_0x5e3456},function(_0x11496d,_0x5a8123){if(_0x11496d)return _0xf5c609(_0x11496d);return _0x36e597(_0x5a8123);});})[_0xf06e('0x17')](function(){return new BPromise(function(_0x3182cc,_0x576bb5){rimraf(_0xf2938a,function(_0x4d7e57){if(_0x4d7e57)_0x576bb5(_0x4d7e57);return _0x3182cc();});});})[_0xf06e('0x17')](function(){return _0x450518[_0xf06e('0xce')](_0x5e3456,_0x535af8,function(_0x32d641){if(_0x32d641){console[_0xf06e('0x126')]('err',_0x32d641);}else{fs[_0xf06e('0x127')](_0x5e3456);}});});});}else{return _0x450518[_0xf06e('0x21')](0xc8);}})[_0xf06e('0x20')](handleError(_0x450518,null));};
\ No newline at end of file