Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 18055be..7e7f3db 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x67f7=['split','format','YYYY-MM-DD\x20HH:mm:ss','options','FaxMessage','findAll','addTags','spread','color','emit','faxInteractionTags:save','removeTags','unix','join','root','server','files','tmp','transcript-%d-%s.zip','Attachment','Messages','get','mkdirSync','basename','existsSync','createReadStream','pipe','createWriteStream','download','log','err','unlinkSync','rimraf','zip-dir','request-promise','moment','util','path','to-csv','ejs','fs-extra','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','./faxInteraction.socket','register','end','status','json','limit','undefined','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','sendStatus','error','stack','Users','map','fullname','Tags','forEach','push','TagIds','index','FaxInteraction','rawAttributes','fieldName','type','key','model','name','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','sort','where','select','field','from','tools_tags','u.id','u.fullname','ui.FaxInteractionId','user_has_fax_interactions','left_join','users','u.id\x20=\x20ui.UserId','fax_interactions','cm_contacts','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','fax_accounts','a.id\x20=\x20i.FaxAccountId','fax_messages','fax_interaction_has_tags','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','find','unreadMessages','having','`\x20=\x200','`\x20>\x200','Contact','$substring','value','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?','ContactId','buildExpression','text','start','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','User','operator','UserId','body','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','createdAt','parse','$gte','null','\x20IS\x20NULL','\x20=\x20?','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','isArray','filter','replace','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','QueryTypes','SELECT','clone','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','order','contactName','DESC','i.FaxAccountId\x20IS\x20NOT\x20NULL','user','role','agent','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','keyBy','merge','a.key','a.mandatoryDisposition','Account.mandatoryDisposition','CASE\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','c.firstName','Contact.firstName','c.lastName','Contact.lastName','c.email','c.phone','Contact.phone','Contact.mobile','c.fax','o.fullname','Owner.fullname','o.internal','GROUP_CONCAT(DISTINCT\x20t.id)','sequelize','toString','ui.FaxInteractionId\x20IN\x20?','FaxInteractionId','all','rows','params','includeAll','include','catch','create','describe','addMessage','ids','omit','getMessages','findOne'];(function(_0x52fc63,_0x5a2f5e){var _0x5183aa=function(_0x1c3051){while(--_0x1c3051){_0x52fc63['push'](_0x52fc63['shift']());}};_0x5183aa(++_0x5a2f5e);}(_0x67f7,0x100));var _0x767f=function(_0x3d11fe,_0x1162aa){_0x3d11fe=_0x3d11fe-0x0;var _0x166248=_0x67f7[_0x3d11fe];return _0x166248;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x767f('0x0'));var zipdir=require(_0x767f('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x767f('0x2'));var moment=require(_0x767f('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x767f('0x4'));var path=require(_0x767f('0x5'));var sox=require('sox');var csv=require(_0x767f('0x6'));var ejs=require(_0x767f('0x7'));var fs=require('fs');var fs_extra=require(_0x767f('0x8'));var _=require(_0x767f('0x9'));var squel=require('squel');var crypto=require(_0x767f('0xa'));var jsforce=require(_0x767f('0xb'));var deskjs=require(_0x767f('0xc'));var toCsv=require(_0x767f('0x6'));var querystring=require(_0x767f('0xd'));var Papa=require('papaparse');var Redis=require(_0x767f('0xe'));var authService=require(_0x767f('0xf'));var qs=require(_0x767f('0x10'));var as=require(_0x767f('0x11'));var hardwareService=require(_0x767f('0x12'));var logger=require(_0x767f('0x13'))(_0x767f('0x14'));var utils=require(_0x767f('0x15'));var config=require(_0x767f('0x16'));var licenseUtil=require(_0x767f('0x17'));var db=require(_0x767f('0x18'))['db'];config[_0x767f('0x19')]=_[_0x767f('0x1a')](config[_0x767f('0x19')],{'host':_0x767f('0x1b'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x767f('0x19')]));require(_0x767f('0x1c'))[_0x767f('0x1d')](socket);function respondWithStatusCode(_0x273d8e,_0x2f9081){_0x2f9081=_0x2f9081||0xcc;return function(_0x21a848){if(_0x21a848){return _0x273d8e['sendStatus'](_0x2f9081);}return _0x273d8e['status'](_0x2f9081)[_0x767f('0x1e')]();};}function respondWithResult(_0x160fe2,_0x59ce87){_0x59ce87=_0x59ce87||0xc8;return function(_0xfa30a7){if(_0xfa30a7){return _0x160fe2[_0x767f('0x1f')](_0x59ce87)[_0x767f('0x20')](_0xfa30a7);}};}function respondWithFilteredResult(_0x59e08b,_0x8a462c){return function(_0x17ef2d){if(_0x17ef2d){var _0x2d0356=typeof _0x8a462c['offset']==='undefined'&&typeof _0x8a462c[_0x767f('0x21')]===_0x767f('0x22');var _0x2039e2=_0x17ef2d[_0x767f('0x23')];var _0x4e54e0=_0x2d0356?0x0:_0x8a462c[_0x767f('0x24')];var _0xe2820e=_0x2d0356?_0x17ef2d[_0x767f('0x23')]:_0x8a462c[_0x767f('0x24')]+_0x8a462c[_0x767f('0x21')];var _0x3c5c55;if(_0xe2820e>=_0x2039e2){_0xe2820e=_0x2039e2;_0x3c5c55=0xc8;}else{_0x3c5c55=0xce;}_0x59e08b[_0x767f('0x1f')](_0x3c5c55);return _0x59e08b[_0x767f('0x25')](_0x767f('0x26'),_0x4e54e0+'-'+_0xe2820e+'/'+_0x2039e2)['json'](_0x17ef2d);}return null;};}function patchUpdates(_0x2f9d71){return function(_0x1d1775){try{jsonpatch[_0x767f('0x27')](_0x1d1775,_0x2f9d71,!![]);}catch(_0x50a8ce){return BPromise[_0x767f('0x28')](_0x50a8ce);}return _0x1d1775[_0x767f('0x29')]();};}function saveUpdates(_0x5bc10e,_0x27d484){return function(_0x530106){if(_0x530106){return _0x530106[_0x767f('0x2a')](_0x5bc10e)[_0x767f('0x2b')](function(_0x502da3){return _0x502da3;});}return null;};}function removeEntity(_0x489700,_0x1c39fe){return function(_0x4dfbdb){if(_0x4dfbdb){return _0x4dfbdb[_0x767f('0x2c')]()[_0x767f('0x2b')](function(){_0x489700['status'](0xcc)[_0x767f('0x1e')]();});}};}function handleEntityNotFound(_0x22b673,_0x41dd17){return function(_0x13ae11){if(!_0x13ae11){_0x22b673[_0x767f('0x2d')](0x194);}return _0x13ae11;};}function handleError(_0xa7aef3,_0x285c3b){_0x285c3b=_0x285c3b||0x1f4;return function(_0x2b834c){logger[_0x767f('0x2e')](_0x2b834c[_0x767f('0x2f')]);if(_0x2b834c['name']){delete _0x2b834c['name'];}_0xa7aef3['status'](_0x285c3b)['send'](_0x2b834c);};}function getInteractionUsers(_0x46c662,_0x3bac6a){return new BPromise(function(_0x3a6b00,_0x23ae05){try{if(_0x3bac6a[_0x46c662['id']]){_0x46c662[_0x767f('0x30')]=_[_0x767f('0x31')](_0x3bac6a[_0x46c662['id']],function(_0x37b629){return{'id':_0x37b629['id'],'fullname':_0x37b629[_0x767f('0x32')]};});}}catch(_0xa53b6f){_0x23ae05(_0xa53b6f);}_0x3a6b00(_0x46c662);});}function getInteractionTags(_0x1931d1,_0x6a0710){return new BPromise(function(_0x28b774,_0x42773a){try{if(_0x1931d1['TagIds']){_0x1931d1[_0x767f('0x33')]=[];_0x1931d1['TagIds']['split'](',')[_0x767f('0x34')](function(_0x4cbc46){_0x1931d1[_0x767f('0x33')][_0x767f('0x35')](_0x6a0710[_0x4cbc46]);});}delete _0x1931d1[_0x767f('0x36')];}catch(_0x1366f4){_0x42773a(_0x1366f4);}_0x28b774(_0x1931d1);});}function updateFaxInteraction(_0x2f769a,_0x59e4f2,_0x4345a5){return new BPromise(function(_0x12075d,_0x4d4746){return getInteractionUsers(_0x2f769a,_0x4345a5)[_0x767f('0x2b')](function(_0x1c8093){return getInteractionTags(_0x1c8093,_0x59e4f2);})['then'](function(_0x402529){_0x12075d(_0x402529);})['catch'](function(_0x3873be){_0x4d4746(_0x3873be);});});}exports[_0x767f('0x37')]=function(_0x50a5c9,_0x3ed2d0){var _0x499540={},_0x16bd87={},_0x581213={'count':0x0,'rows':[]};var _0x50c65b=_['map'](db[_0x767f('0x38')][_0x767f('0x39')],function(_0x1023fb){return{'name':_0x1023fb[_0x767f('0x3a')],'type':_0x1023fb[_0x767f('0x3b')][_0x767f('0x3c')]};});_0x16bd87[_0x767f('0x3d')]=_[_0x767f('0x31')](_0x50c65b,_0x767f('0x3e'));_0x16bd87[_0x767f('0x3f')]=_[_0x767f('0x40')](_0x50a5c9['query']);_0x16bd87[_0x767f('0x41')]=_[_0x767f('0x42')](_0x16bd87[_0x767f('0x3d')],_0x16bd87[_0x767f('0x3f')]);_0x499540[_0x767f('0x43')]=_[_0x767f('0x42')](_0x16bd87[_0x767f('0x3d')],qs[_0x767f('0x44')](_0x50a5c9[_0x767f('0x3f')]['fields']));_0x499540[_0x767f('0x43')]=_0x499540[_0x767f('0x43')][_0x767f('0x45')]?_0x499540['attributes']:_0x16bd87['model'];if(!_0x50a5c9['query'][_0x767f('0x46')](_0x767f('0x47'))){_0x499540['limit']=qs[_0x767f('0x21')](_0x50a5c9[_0x767f('0x3f')][_0x767f('0x21')]);_0x499540[_0x767f('0x24')]=qs[_0x767f('0x24')](_0x50a5c9[_0x767f('0x3f')]['offset']);}_0x499540['order']=qs[_0x767f('0x48')](_0x50a5c9[_0x767f('0x3f')][_0x767f('0x48')]);_0x499540[_0x767f('0x49')]=qs[_0x767f('0x41')](_['pick'](_0x50a5c9[_0x767f('0x3f')],_0x16bd87['filters']),_0x50c65b);var _0x23d304=[];var _0x3fb090=squel[_0x767f('0x4a')]()[_0x767f('0x4b')]('id')['field']('name')[_0x767f('0x4b')]('color')[_0x767f('0x4c')](_0x767f('0x4d'));var _0x2dc51a=squel[_0x767f('0x4a')]()['field'](_0x767f('0x4e'))[_0x767f('0x4b')](_0x767f('0x4f'))[_0x767f('0x4b')](_0x767f('0x50'))[_0x767f('0x4c')](_0x767f('0x51'),'ui')[_0x767f('0x52')](_0x767f('0x53'),'u',_0x767f('0x54'));var _0x407173=squel[_0x767f('0x4a')]()['from'](_0x767f('0x55'),'i')['left_join'](_0x767f('0x56'),'c',_0x767f('0x57'))['left_join'](_0x767f('0x53'),'o',_0x767f('0x58'))[_0x767f('0x52')](_0x767f('0x59'),'a',_0x767f('0x5a'))[_0x767f('0x52')](_0x767f('0x5b'),'me','me.FaxInteractionId\x20=\x20i.id')['left_join'](_0x767f('0x5c'),'it','it.FaxInteractionId\x20=\x20i.id')['left_join'](_0x767f('0x4d'),'t',_0x767f('0x5d'));var _0x27a4a8=squel[_0x767f('0x5e')]();var _0x4156a9=[];var _0x437d19=squel[_0x767f('0x5e')]();var _0xb935d6;if(_0x50a5c9[_0x767f('0x3f')][_0x767f('0x5f')]){_0xb935d6=as[_0x767f('0x60')](_0x50a5c9[_0x767f('0x3f')][_0x767f('0x5f')]);var _0x275e1b=_0xb935d6[_0x767f('0x61')];for(var _0x435f3e=0x0;_0x435f3e<_0xb935d6[_0x767f('0x62')][_0x767f('0x45')];_0x435f3e++){var _0x2f6c14=_0xb935d6[_0x767f('0x62')][_0x435f3e];var _0x364a80='i';var _0x462680=_[_0x767f('0x63')](_0x50c65b,[_0x767f('0x3e'),_0x2f6c14[_0x767f('0x4b')]]);if(!_0x462680){switch(_0x2f6c14[_0x767f('0x4b')]){case _0x767f('0x64'):if(_0x2f6c14['value']==0x1){_0x407173[_0x767f('0x65')]('`'+_0x2f6c14[_0x767f('0x4b')]+_0x767f('0x66'));}else{_0x407173[_0x767f('0x65')]('`'+_0x2f6c14[_0x767f('0x4b')]+_0x767f('0x67'));}break;case _0x767f('0x68'):if(_0x2f6c14['operator']===_0x767f('0x69')){if(_0x2f6c14[_0x767f('0x6a')]['split']('\x20')[_0x767f('0x45')]>0x1){_0x27a4a8[_0x275e1b](_0x767f('0x6b'),qs[_0x767f('0x6c')](_0x2f6c14['value']),null);}else{var _0x3293bc='%'+_0x2f6c14['value']+'%';_0x27a4a8[_0x275e1b](_0x767f('0x6d'),_0x3293bc,_0x3293bc,_0x3293bc);}}else{_0x462680=_['find'](_0x50c65b,['name',_0x767f('0x6e')]);_0x2f6c14[_0x767f('0x4b')]=_0x767f('0x6e');_0x29df10=as[_0x767f('0x6f')](_0x364a80,_0x462680['type'],_0x2f6c14);_0x27a4a8[_0x275e1b](_0x29df10[_0x767f('0x70')],_0x29df10[_0x767f('0x6a')][_0x767f('0x71')],_0x29df10[_0x767f('0x6a')]['end']);}break;case _0x767f('0x72'):var _0x52574b=_0x2f6c14['value']['split'](',')[_0x767f('0x31')](function(_0x262460){return Number(_0x262460);});_0x52574b[_0x767f('0x34')](function(_0x42e58d){_0x437d19['or'](_0x767f('0x73'),'%,'+_0x42e58d+',%');});_0x4156a9=_['union'](_0x4156a9,_0x52574b);break;case _0x767f('0x74'):if(_0x2f6c14[_0x767f('0x75')]===_0x767f('0x69')){_0x27a4a8[_0x275e1b]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x2f6c14[_0x767f('0x6a')]+'%',null);}else{_0x462680=_[_0x767f('0x63')](_0x50c65b,[_0x767f('0x3e'),_0x767f('0x76')]);_0x2f6c14['field']='UserId';_0x29df10=as['buildExpression'](_0x364a80,_0x462680['type'],_0x2f6c14);_0x27a4a8[_0x275e1b](_0x29df10[_0x767f('0x70')],_0x29df10[_0x767f('0x6a')][_0x767f('0x71')],_0x29df10['value'][_0x767f('0x1e')]);}break;case _0x767f('0x77'):_0x29df10=as[_0x767f('0x6f')]('me',null,_0x2f6c14);_0x27a4a8[_0x275e1b](_0x29df10['text'],_0x29df10[_0x767f('0x6a')]['start'],_0x29df10[_0x767f('0x6a')][_0x767f('0x1e')]);break;}}else{var _0x29df10=as[_0x767f('0x6f')](_0x364a80,_0x462680[_0x767f('0x3b')],_0x2f6c14);_0x27a4a8[_0x275e1b](_0x29df10['text'],_0x29df10[_0x767f('0x6a')][_0x767f('0x71')],_0x29df10['value']['end']);}}}else{var _0x24b7a4=_(_0x50a5c9[_0x767f('0x3f')])[_0x767f('0x40')]()[_0x767f('0x31')](function(_0x3f0d3e){return _['some'](_0x50c65b,[_0x767f('0x3e'),_0x3f0d3e])?_0x3f0d3e:undefined;})['compact']()['value']();if(!_[_0x767f('0x78')](_0x24b7a4)){_0x24b7a4[_0x767f('0x34')](function(_0x4f6068){if(_0x4f6068===_0x767f('0x79')){_0x407173['where'](_0x767f('0x7a'),[]['concat'](_0x50a5c9[_0x767f('0x3f')][_0x4f6068]));}else if(_0x4f6068===_0x767f('0x7b')){var _0x4f4d21=JSON[_0x767f('0x7c')](_0x50a5c9[_0x767f('0x3f')][_0x4f6068])[_0x767f('0x7d')];var _0x2fe97d=JSON[_0x767f('0x7c')](_0x50a5c9[_0x767f('0x3f')][_0x4f6068])['$lte'];_0x407173[_0x767f('0x49')]('i.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x4f4d21,_0x2fe97d);}else{if(_0x50a5c9[_0x767f('0x3f')][_0x4f6068]===_0x767f('0x7e')){_0x407173[_0x767f('0x49')]('i.'+_0x4f6068+_0x767f('0x7f'));}else{_0x407173[_0x767f('0x49')]('i.'+_0x4f6068+_0x767f('0x80'),_0x50a5c9[_0x767f('0x3f')][_0x4f6068]);}}});}if(_0x50a5c9[_0x767f('0x3f')][_0x767f('0x81')]){if(_0x50a5c9[_0x767f('0x3f')][_0x767f('0x81')]==0x1){_0x407173['having'](_0x767f('0x82'));}else{_0x407173[_0x767f('0x65')](_0x767f('0x83'));}}if(_0x50a5c9['query'][_0x767f('0x84')]){_0x4156a9=_[_0x767f('0x85')](_0x50a5c9[_0x767f('0x3f')][_0x767f('0x84')])?_0x50a5c9['query'][_0x767f('0x84')]:new Array(_0x50a5c9[_0x767f('0x3f')][_0x767f('0x84')]);_0x4156a9[_0x767f('0x34')](function(_0x45c514){_0x437d19['or'](_0x767f('0x73'),'%,'+_0x45c514+',%');});}if(_0x50a5c9[_0x767f('0x3f')][_0x767f('0x86')]){var _0x6fa235=_0x50a5c9[_0x767f('0x3f')][_0x767f('0x86')][_0x767f('0x87')]('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');if(qs[_0x767f('0x88')](_0x6fa235)){_0x27a4a8['or'](_0x767f('0x89'),_0x6fa235+'%')['or'](_0x767f('0x8a'),_0x6fa235+'%');}_0x27a4a8['or'](_0x767f('0x8b'),_0x6fa235+'%');}}_0x407173[_0x767f('0x49')](_0x27a4a8);_0x407173[_0x767f('0x8c')](_0x767f('0x8d'));var _0x205f43={'type':db[_0x767f('0x8e')][_0x767f('0x8f')][_0x767f('0x90')],'raw':!![]};var _0x5eb4dd=_0x407173[_0x767f('0x91')]();_0x5eb4dd[_0x767f('0x4b')]('i.id');_0x5eb4dd['field'](_0x767f('0x92'),_0x767f('0x64'));if(_0x499540[_0x767f('0x93')]){_0x499540['order'][_0x767f('0x34')](function(_0x2def79){var _0x3c90f4=_0x2def79[0x0]===_0x767f('0x94')?_0x2def79[0x0]:'i.'+_0x2def79[0x0];_0x407173[_0x767f('0x93')](_0x3c90f4,_0x2def79[0x1]===_0x767f('0x95')?![]:!![]);});}if(!_[_0x767f('0x78')](_0x4156a9)){_0x407173[_0x767f('0x65')](_0x437d19);_0x5eb4dd['where']('t.id\x20IN\x20?',_0x4156a9);}BPromise['resolve']()[_0x767f('0x2b')](function(){if(!_0xb935d6){if(_0x50a5c9[_0x767f('0x3f')][_0x767f('0x79')])return;_0x5eb4dd[_0x767f('0x49')](_0x767f('0x96'));_0x407173[_0x767f('0x49')](_0x767f('0x96'));return;}if(_0x50a5c9[_0x767f('0x97')][_0x767f('0x98')]!==_0x767f('0x99'))return;return _0x50a5c9[_0x767f('0x97')][_0x767f('0x9a')]({'attributes':['id'],'raw':!![]})[_0x767f('0x2b')](function(_0x1e94ec){if(_[_0x767f('0x78')](_0x1e94ec)){_0x5eb4dd[_0x767f('0x49')](_0x767f('0x9b'));_0x407173[_0x767f('0x49')]('i.FaxAccountId\x20IS\x20NULL');}else{_0x5eb4dd['where'](_0x767f('0x7a'),_[_0x767f('0x31')](_0x1e94ec,'id'));_0x407173['where'](_0x767f('0x7a'),_[_0x767f('0x31')](_0x1e94ec,'id'));}});})[_0x767f('0x2b')](function(){if(_0x50a5c9[_0x767f('0x97')][_0x767f('0x98')]===_0x767f('0x99')&&!_0xb935d6&&!_0x50a5c9[_0x767f('0x3f')]['FaxAccountId'])return[];return db['sequelize'][_0x767f('0x3f')](_0x5eb4dd['toString'](),_0x205f43);})[_0x767f('0x2b')](function(_0x299256){_0x581213['count']=_0x299256[_0x767f('0x45')];if(_0x581213[_0x767f('0x23')]===0x0)return[];return db['sequelize'][_0x767f('0x3f')](_0x3fb090['toString'](),_0x205f43)[_0x767f('0x2b')](function(_0x4a9626){_0x23d304=_[_0x767f('0x9c')](_0x4a9626,'id');_0x205f43=_[_0x767f('0x9d')](_0x205f43,{'model':db['FaxInteraction'],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x50a5c9['query'][_0x767f('0x44')]){_0x499540[_0x767f('0x43')]['forEach'](function(_0x3cc446){_0x407173[_0x767f('0x4b')]('i.'+_0x3cc446);});}else{_0x407173[_0x767f('0x4b')]('SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)',_0x767f('0x64'));_0x407173[_0x767f('0x4b')](_0x767f('0x9e'),'Account.key');_0x407173['field'](_0x767f('0x9f'),_0x767f('0xa0'));_0x407173['field'](_0x767f('0xa1'),'contactName');_0x407173['field']('i.*');_0x407173[_0x767f('0x4b')](_0x767f('0xa2'),_0x767f('0xa3'));_0x407173['field'](_0x767f('0xa4'),_0x767f('0xa5'));_0x407173[_0x767f('0x4b')](_0x767f('0xa6'),'Contact.email');_0x407173['field'](_0x767f('0xa7'),_0x767f('0xa8'));_0x407173[_0x767f('0x4b')]('c.mobile',_0x767f('0xa9'));_0x407173[_0x767f('0x4b')](_0x767f('0xaa'),'Contact.fax');_0x407173[_0x767f('0x4b')](_0x767f('0xab'),_0x767f('0xac'));_0x407173[_0x767f('0x4b')](_0x767f('0xad'),'Owner.internal');_0x407173[_0x767f('0x4b')](_0x767f('0xae'),_0x767f('0x36'));}if(_0x499540['limit'])_0x407173[_0x767f('0x21')](_0x499540[_0x767f('0x21')]);if(_0x499540[_0x767f('0x24')])_0x407173['offset'](_0x499540[_0x767f('0x24')]);return db[_0x767f('0xaf')][_0x767f('0x3f')](_0x407173[_0x767f('0xb0')](),_0x205f43);})[_0x767f('0x2b')](function(_0x5ac35c){if(_0x5ac35c[_0x767f('0x45')]>0x0)_0x2dc51a['where'](_0x767f('0xb1'),_['map'](_0x5ac35c,'id'));return db[_0x767f('0xaf')][_0x767f('0x3f')](_0x2dc51a['toString'](),_0x205f43)[_0x767f('0x2b')](function(_0x113499){var _0x538cb7=_['groupBy'](_0x113499,_0x767f('0xb2'));var _0xb806e7=[];_0x5ac35c['forEach'](function(_0x2ade07){_0xb806e7[_0x767f('0x35')](updateFaxInteraction(_0x2ade07,_0x23d304,_0x538cb7));});return BPromise[_0x767f('0xb3')](_0xb806e7);});});})[_0x767f('0x2b')](function(_0x4fb1e4){_0x581213[_0x767f('0xb4')]=_0x4fb1e4;return _0x581213;})[_0x767f('0x2b')](respondWithFilteredResult(_0x3ed2d0,_0x499540))['catch'](handleError(_0x3ed2d0,null));};exports['show']=function(_0x47c2cd,_0x5af283){var _0x57ddbc={'raw':![],'where':{'id':_0x47c2cd[_0x767f('0xb5')]['id']}},_0x49baba={};_0x49baba['model']=_[_0x767f('0x40')](db[_0x767f('0x38')][_0x767f('0x39')]);_0x49baba['query']=_['keys'](_0x47c2cd['query']);_0x49baba[_0x767f('0x41')]=_['intersection'](_0x49baba[_0x767f('0x3d')],_0x49baba[_0x767f('0x3f')]);_0x57ddbc[_0x767f('0x43')]=_[_0x767f('0x42')](_0x49baba[_0x767f('0x3d')],qs[_0x767f('0x44')](_0x47c2cd[_0x767f('0x3f')][_0x767f('0x44')]));_0x57ddbc[_0x767f('0x43')]=_0x57ddbc[_0x767f('0x43')][_0x767f('0x45')]?_0x57ddbc['attributes']:_0x49baba['model'];if(_0x47c2cd[_0x767f('0x3f')][_0x767f('0xb6')]){_0x57ddbc[_0x767f('0xb7')]=[{'all':!![]}];}_0x57ddbc=_[_0x767f('0x9d')]({},_0x57ddbc,_0x47c2cd['options']);return db['FaxInteraction'][_0x767f('0x63')](_0x57ddbc)[_0x767f('0x2b')](handleEntityNotFound(_0x5af283,null))[_0x767f('0x2b')](respondWithResult(_0x5af283,null))[_0x767f('0xb8')](handleError(_0x5af283,null));};exports[_0x767f('0xb9')]=function(_0x2f3fcb,_0x347f3c){return db[_0x767f('0x38')]['create'](_0x2f3fcb[_0x767f('0x77')],{})['then'](respondWithResult(_0x347f3c,0xc9))[_0x767f('0xb8')](handleError(_0x347f3c,null));};exports[_0x767f('0x2a')]=function(_0x22cfc5,_0x8c73){if(_0x22cfc5[_0x767f('0x77')]['id']){delete _0x22cfc5['body']['id'];}return db['FaxInteraction']['find']({'where':{'id':_0x22cfc5[_0x767f('0xb5')]['id']}})[_0x767f('0x2b')](handleEntityNotFound(_0x8c73,null))[_0x767f('0x2b')](saveUpdates(_0x22cfc5[_0x767f('0x77')],null))['then'](respondWithResult(_0x8c73,null))[_0x767f('0xb8')](handleError(_0x8c73,null));};exports[_0x767f('0x2c')]=function(_0x167778,_0x33094e){return db[_0x767f('0x38')]['find']({'where':{'id':_0x167778[_0x767f('0xb5')]['id']}})[_0x767f('0x2b')](handleEntityNotFound(_0x33094e,null))[_0x767f('0x2b')](removeEntity(_0x33094e,null))[_0x767f('0xb8')](handleError(_0x33094e,null));};exports['describe']=function(_0x4ad95b,_0x18f6da){return db[_0x767f('0x38')][_0x767f('0xba')]()[_0x767f('0x2b')](respondWithResult(_0x18f6da,null))[_0x767f('0xb8')](handleError(_0x18f6da,null));};exports[_0x767f('0xbb')]=function(_0x3fe170,_0x3b646b,_0x377b14){return db['FaxMessage'][_0x767f('0x63')]({'where':{'id':_0x3fe170[_0x767f('0xb5')]['id']}})[_0x767f('0x2b')](handleEntityNotFound(_0x3b646b,null))['then'](function(_0x5bac55){if(_0x5bac55){return _0x5bac55[_0x767f('0xbb')](_0x3fe170[_0x767f('0x77')][_0x767f('0xbc')],_[_0x767f('0xbd')](_0x3fe170[_0x767f('0x77')],['ids','id'])||{});}})[_0x767f('0x2b')](respondWithResult(_0x3b646b,null))[_0x767f('0xb8')](handleError(_0x3b646b,null));};exports[_0x767f('0xbe')]=function(_0xeb42e,_0x14f39a,_0x240bcf){var _0x411719={'raw':![],'where':{}};var _0x2980c7={};var _0x5dabce={'count':0x0,'rows':[]};return db[_0x767f('0x38')][_0x767f('0xbf')]({'where':{'id':_0xeb42e[_0x767f('0xb5')]['id']}})[_0x767f('0x2b')](handleEntityNotFound(_0x14f39a,null))[_0x767f('0x2b')](function(_0x16ec61){if(_0x16ec61){_0x2980c7[_0x767f('0x3d')]=_[_0x767f('0x40')](db['FaxMessage'][_0x767f('0x39')]);_0x2980c7[_0x767f('0x3f')]=_[_0x767f('0x40')](_0xeb42e[_0x767f('0x3f')]);_0x2980c7['filters']=_[_0x767f('0x42')](_0x2980c7[_0x767f('0x3d')],_0x2980c7[_0x767f('0x3f')]);_0x411719['attributes']=_['intersection'](_0x2980c7[_0x767f('0x3d')],qs[_0x767f('0x44')](_0xeb42e[_0x767f('0x3f')][_0x767f('0x44')]));_0x411719['attributes']=_0x411719['attributes'][_0x767f('0x45')]?_0x411719['attributes']:_0x2980c7[_0x767f('0x3d')];if(!_0xeb42e['query']['hasOwnProperty'](_0x767f('0x47'))){_0x411719['limit']=qs[_0x767f('0x21')](_0xeb42e[_0x767f('0x3f')]['limit']);_0x411719[_0x767f('0x24')]=qs[_0x767f('0x24')](_0xeb42e[_0x767f('0x3f')]['offset']);}_0x411719[_0x767f('0x93')]=qs['sort'](_0xeb42e[_0x767f('0x3f')]['sort']);_0x411719['where']=qs[_0x767f('0x41')](_['pick'](_0xeb42e[_0x767f('0x3f')],_0x2980c7['filters']));_0x411719[_0x767f('0x49')][_0x767f('0xb2')]=_0x16ec61['id'];if(_0xeb42e['query'][_0x767f('0x86')]){_0x411719[_0x767f('0x49')]=_[_0x767f('0x9d')](_0x411719[_0x767f('0x49')],{'$or':_[_0x767f('0x31')](_0x411719[_0x767f('0x43')],function(_0x2efd08){var _0x4f493c={};_0x4f493c[_0x2efd08]={'$like':'%'+_0xeb42e[_0x767f('0x3f')][_0x767f('0x86')]+'%'};return _0x4f493c;})});}if(_0xeb42e[_0x767f('0x3f')]['$gte']){var _0x363dd9=_0xeb42e['query'][_0x767f('0x7d')][_0x767f('0xc0')](',');var _0xcb409b={};_0xcb409b[_0x363dd9[0x0]]={'$gte':moment(_0x363dd9[0x1])[_0x767f('0xc1')](_0x767f('0xc2'))};_0x411719['where']=_['merge'](_0x411719['where'],_0xcb409b);}_0x411719=_['merge']({},_0x411719,_0xeb42e[_0x767f('0xc3')]);return db[_0x767f('0xc4')][_0x767f('0x23')]({'where':_0x411719[_0x767f('0x49')]})[_0x767f('0x2b')](function(_0x2931b6){_0x5dabce[_0x767f('0x23')]=_0x2931b6;if(_0xeb42e[_0x767f('0x3f')][_0x767f('0xb6')]){_0x411719[_0x767f('0xb7')]=[{'all':!![]}];}return db[_0x767f('0xc4')][_0x767f('0xc5')](_0x411719);})[_0x767f('0x2b')](function(_0x80d15c){_0x5dabce['rows']=_0x80d15c;return _0x5dabce;});}})[_0x767f('0x2b')](respondWithFilteredResult(_0x14f39a,_0x411719))[_0x767f('0xb8')](handleError(_0x14f39a,null));};exports[_0x767f('0xc6')]=function(_0x3dd4f9,_0x42ce66,_0x32fc42){return db[_0x767f('0x38')][_0x767f('0x63')]({'where':{'id':_0x3dd4f9['params']['id']}})[_0x767f('0x2b')](handleEntityNotFound(_0x42ce66,null))['then'](function(_0x288d7f){if(_0x288d7f){return _0x288d7f['setTags'](_0x3dd4f9[_0x767f('0x77')][_0x767f('0xbc')],_[_0x767f('0xbd')](_0x3dd4f9[_0x767f('0x77')],[_0x767f('0xbc'),'id'])||{})[_0x767f('0xc7')](function(){return db[_0x767f('0x72')][_0x767f('0xc5')]({'attributes':['id',_0x767f('0x3e'),_0x767f('0xc8')],'where':{'id':_0x3dd4f9[_0x767f('0x77')]['ids']}});})[_0x767f('0x2b')](function(_0x28bdd0){socket[_0x767f('0xc9')](_0x767f('0xca'),{'id':Number(_0x3dd4f9[_0x767f('0xb5')]['id']),'tags':_0x28bdd0||[]});return{'id':Number(_0x3dd4f9['params']['id']),'tags':_0x28bdd0||[]};});}})[_0x767f('0x2b')](respondWithResult(_0x42ce66,null))[_0x767f('0xb8')](handleError(_0x42ce66,null));};exports[_0x767f('0xcb')]=function(_0x46e203,_0x536256,_0x2bc19d){return db[_0x767f('0x38')][_0x767f('0x63')]({'where':{'id':_0x46e203[_0x767f('0xb5')]['id']}})['then'](handleEntityNotFound(_0x536256,null))['then'](function(_0xb50bee){if(_0xb50bee){return _0xb50bee[_0x767f('0xcb')](_0x46e203[_0x767f('0x3f')][_0x767f('0xbc')]);}})['then'](respondWithStatusCode(_0x536256,null))[_0x767f('0xb8')](handleError(_0x536256,null));};exports['download']=function(_0x38f050,_0x303aaf){var _0x1fc6f7=moment()[_0x767f('0xcc')]()[_0x767f('0xb0')]();var _0x11b965=path[_0x767f('0xcd')](config[_0x767f('0xce')],_0x767f('0xcf'),_0x767f('0xd0'),_0x767f('0xd1'));var _0x41144d=path['join'](config[_0x767f('0xce')],_0x767f('0xcf'),_0x767f('0xd0'),'attachments');var _0x4989a2=path[_0x767f('0xcd')](_0x11b965,_0x1fc6f7);var _0x38fee7=util[_0x767f('0xc1')](_0x767f('0xd2'),_0x38f050['params']['id'],_0x1fc6f7);var _0x2b8c71=path['join'](_0x11b965,_0x38fee7);var _0x4c05b3=[];_0x4c05b3[_0x767f('0x35')]({'model':db[_0x767f('0xd3')],'as':'Attachment','raw':!![]});var _0x3cfa4f=[{'model':db[_0x767f('0xc4')],'as':'Messages','attributes':['id',_0x767f('0x77'),'createdAt'],'include':_0x4c05b3}];return db['FaxInteraction'][_0x767f('0x63')]({'where':{'id':_0x38f050['params']['id']},'include':_0x3cfa4f})['then'](handleEntityNotFound(_0x303aaf,null))['then'](function(_0x513d94){if(_0x513d94&&_0x513d94[_0x767f('0xd4')]){var _0x46b34e=_0x513d94[_0x767f('0xd5')]({'plain':!![]});fs[_0x767f('0xd6')](_0x4989a2);for(var _0x4aeaf2=0x0;_0x4aeaf2<_0x46b34e[_0x767f('0xd4')][_0x767f('0x45')];_0x4aeaf2++){var _0x3d0a0a=_0x46b34e[_0x767f('0xd4')][_0x4aeaf2][_0x767f('0xd3')];if(_0x3d0a0a){var _0x1ea3e1=path[_0x767f('0xcd')](_0x41144d,_0x3d0a0a[_0x767f('0xd7')]);if(fs[_0x767f('0xd8')](_0x1ea3e1)){fs[_0x767f('0xd9')](_0x1ea3e1)[_0x767f('0xda')](fs[_0x767f('0xdb')](path[_0x767f('0xcd')](_0x4989a2,_0x3d0a0a[_0x767f('0xd7')])));}}}return BPromise['resolve']()[_0x767f('0x2b')](function(){return new BPromise(function(_0x337ebe,_0x2c0b80){zipdir(_0x4989a2,{'saveTo':_0x2b8c71},function(_0x861250,_0x58beb5){if(_0x861250)return _0x2c0b80(_0x861250);return _0x337ebe(_0x58beb5);});})['then'](function(){return new BPromise(function(_0x4e33cc,_0x2d8e35){rimraf(_0x4989a2,function(_0x3dca21){if(_0x3dca21)_0x2d8e35(_0x3dca21);return _0x4e33cc();});});})[_0x767f('0x2b')](function(){return _0x303aaf[_0x767f('0xdc')](_0x2b8c71,_0x38fee7,function(_0x3c7613){if(_0x3c7613){console[_0x767f('0xdd')](_0x767f('0xde'),_0x3c7613);}else{fs[_0x767f('0xdf')](_0x2b8c71);}});});});}else{return _0x303aaf['sendStatus'](0xc8);}})[_0x767f('0xb8')](handleError(_0x303aaf,null));};
\ No newline at end of file
+var _0x81cf=['undefined','limit','set','Content-Range','update','then','destroy','stack','name','send','index','FaxInteraction','rawAttributes','fieldName','type','key','fax','query','user','show','model','keys','filters','intersection','attributes','fields','length','includeAll','include','merge','options','catch','create','body','find','params','describe','addMessage','FaxMessage','ids','findOne','hasOwnProperty','nolimit','order','sort','pick','where','map','$gte','split','count','findAll','rows','addTags','setTags','omit','spread','Tag','color','faxInteractionTags:save','download','unix','join','root','server','files','tmp','attachments','format','transcript-%d-%s.zip','push','Attachment','createdAt','get','mkdirSync','Messages','basename','existsSync','createReadStream','createWriteStream','resolve','log','err','unlinkSync','rimraf','moment','util','path','lodash','ioredis','../../components/interaction/service','../../components/parsers/qs','../../config/logger','../../config/environment','defaults','localhost','socket.io-emitter','./faxInteraction.socket','sendStatus','end','status','json','offset'];(function(_0x41a3af,_0x35694d){var _0x2075ec=function(_0x36dffb){while(--_0x36dffb){_0x41a3af['push'](_0x41a3af['shift']());}};_0x2075ec(++_0x35694d);}(_0x81cf,0x1f0));var _0xf81c=function(_0x423edc,_0x1ec185){_0x423edc=_0x423edc-0x0;var _0x3d6101=_0x81cf[_0x423edc];return _0x3d6101;};'use strict';var rimraf=require(_0xf81c('0x0'));var zipdir=require('zip-dir');var moment=require(_0xf81c('0x1'));var BPromise=require('bluebird');var util=require(_0xf81c('0x2'));var path=require(_0xf81c('0x3'));var fs=require('fs');var _=require(_0xf81c('0x4'));var Redis=require(_0xf81c('0x5'));var interaction=require(_0xf81c('0x6'));var qs=require(_0xf81c('0x7'));var logger=require(_0xf81c('0x8'))('api');var config=require(_0xf81c('0x9'));var db=require('../../mysqldb')['db'];config['redis']=_[_0xf81c('0xa')](config['redis'],{'host':_0xf81c('0xb'),'port':0x18eb});var socket=require(_0xf81c('0xc'))(new Redis(config['redis']));require(_0xf81c('0xd'))['register'](socket);function respondWithStatusCode(_0x21a2b6,_0x5ae3db){_0x5ae3db=_0x5ae3db||0xcc;return function(_0x1fafb6){if(_0x1fafb6){return _0x21a2b6[_0xf81c('0xe')](_0x5ae3db);}return _0x21a2b6['status'](_0x5ae3db)[_0xf81c('0xf')]();};}function respondWithResult(_0x2adebb,_0x59ee9b){_0x59ee9b=_0x59ee9b||0xc8;return function(_0x40230b){if(_0x40230b){return _0x2adebb[_0xf81c('0x10')](_0x59ee9b)[_0xf81c('0x11')](_0x40230b);}};}function respondWithFilteredResult(_0x3470f0,_0x32e454){return function(_0x4756dd){if(_0x4756dd){var _0x594d4d=typeof _0x32e454[_0xf81c('0x12')]===_0xf81c('0x13')&&typeof _0x32e454[_0xf81c('0x14')]===_0xf81c('0x13');var _0x22ce73=_0x4756dd['count'];var _0x5528d5=_0x594d4d?0x0:_0x32e454[_0xf81c('0x12')];var _0x72f842=_0x594d4d?_0x4756dd['count']:_0x32e454[_0xf81c('0x12')]+_0x32e454[_0xf81c('0x14')];var _0x2ca4e2;if(_0x72f842>=_0x22ce73){_0x72f842=_0x22ce73;_0x2ca4e2=0xc8;}else{_0x2ca4e2=0xce;}_0x3470f0[_0xf81c('0x10')](_0x2ca4e2);return _0x3470f0[_0xf81c('0x15')](_0xf81c('0x16'),_0x5528d5+'-'+_0x72f842+'/'+_0x22ce73)[_0xf81c('0x11')](_0x4756dd);}return null;};}function saveUpdates(_0x2b339c){return function(_0x1fe6ad){if(_0x1fe6ad){return _0x1fe6ad[_0xf81c('0x17')](_0x2b339c)[_0xf81c('0x18')](function(_0x34f2a5){return _0x34f2a5;});}return null;};}function removeEntity(_0x2ce548){return function(_0x4dffa0){if(_0x4dffa0){return _0x4dffa0[_0xf81c('0x19')]()['then'](function(){_0x2ce548[_0xf81c('0x10')](0xcc)[_0xf81c('0xf')]();});}};}function handleEntityNotFound(_0x18df54){return function(_0x5aee2b){if(!_0x5aee2b){_0x18df54[_0xf81c('0xe')](0x194);}return _0x5aee2b;};}function handleError(_0x12eb16,_0x2f3b2f){_0x2f3b2f=_0x2f3b2f||0x1f4;return function(_0x4904ab){logger['error'](_0x4904ab[_0xf81c('0x1a')]);if(_0x4904ab[_0xf81c('0x1b')]){delete _0x4904ab[_0xf81c('0x1b')];}_0x12eb16[_0xf81c('0x10')](_0x2f3b2f)[_0xf81c('0x1c')](_0x4904ab);};}exports[_0xf81c('0x1d')]=function(_0x115265,_0x16dacd){var _0x270aaa={};var _0x207251=_['map'](db[_0xf81c('0x1e')][_0xf81c('0x1f')],function(_0x2438f4){return{'name':_0x2438f4[_0xf81c('0x20')],'type':_0x2438f4[_0xf81c('0x21')][_0xf81c('0x22')]};});_0x270aaa=qs['getOptions'](_0x207251,_0x115265);return interaction['findAll'](_0xf81c('0x23'),_0x115265[_0xf81c('0x24')],_0x115265[_0xf81c('0x25')],_0x270aaa,_0x207251)[_0xf81c('0x18')](respondWithFilteredResult(_0x16dacd,_0x270aaa))['catch'](handleError(_0x16dacd,null));};exports[_0xf81c('0x26')]=function(_0x5e0996,_0x118190){var _0x391501={'raw':![],'where':{'id':_0x5e0996['params']['id']}},_0x382a3b={};_0x382a3b[_0xf81c('0x27')]=_[_0xf81c('0x28')](db['FaxInteraction'][_0xf81c('0x1f')]);_0x382a3b['query']=_[_0xf81c('0x28')](_0x5e0996[_0xf81c('0x24')]);_0x382a3b[_0xf81c('0x29')]=_[_0xf81c('0x2a')](_0x382a3b[_0xf81c('0x27')],_0x382a3b['query']);_0x391501[_0xf81c('0x2b')]=_['intersection'](_0x382a3b[_0xf81c('0x27')],qs[_0xf81c('0x2c')](_0x5e0996[_0xf81c('0x24')][_0xf81c('0x2c')]));_0x391501[_0xf81c('0x2b')]=_0x391501[_0xf81c('0x2b')][_0xf81c('0x2d')]?_0x391501[_0xf81c('0x2b')]:_0x382a3b[_0xf81c('0x27')];if(_0x5e0996[_0xf81c('0x24')][_0xf81c('0x2e')]){_0x391501[_0xf81c('0x2f')]=[{'all':!![]}];}_0x391501=_[_0xf81c('0x30')]({},_0x391501,_0x5e0996[_0xf81c('0x31')]);return db[_0xf81c('0x1e')]['find'](_0x391501)[_0xf81c('0x18')](handleEntityNotFound(_0x118190,null))[_0xf81c('0x18')](respondWithResult(_0x118190,null))[_0xf81c('0x32')](handleError(_0x118190,null));};exports[_0xf81c('0x33')]=function(_0x40b77c,_0x37ced1){return db[_0xf81c('0x1e')][_0xf81c('0x33')](_0x40b77c[_0xf81c('0x34')],{})[_0xf81c('0x18')](respondWithResult(_0x37ced1,0xc9))[_0xf81c('0x32')](handleError(_0x37ced1,null));};exports['update']=function(_0x1663af,_0x19b56f){if(_0x1663af['body']['id']){delete _0x1663af[_0xf81c('0x34')]['id'];}return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x1663af[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x19b56f,null))[_0xf81c('0x18')](saveUpdates(_0x1663af[_0xf81c('0x34')],null))[_0xf81c('0x18')](respondWithResult(_0x19b56f,null))[_0xf81c('0x32')](handleError(_0x19b56f,null));};exports['destroy']=function(_0x2afdf2,_0x58eebe){return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x2afdf2[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x58eebe,null))[_0xf81c('0x18')](removeEntity(_0x58eebe,null))[_0xf81c('0x32')](handleError(_0x58eebe,null));};exports[_0xf81c('0x37')]=function(_0x14b1a5,_0x5eb873){return db[_0xf81c('0x1e')][_0xf81c('0x37')]()[_0xf81c('0x18')](respondWithResult(_0x5eb873,null))[_0xf81c('0x32')](handleError(_0x5eb873,null));};exports[_0xf81c('0x38')]=function(_0x5c7111,_0x4e6953){return db[_0xf81c('0x39')]['find']({'where':{'id':_0x5c7111[_0xf81c('0x36')]['id']}})['then'](handleEntityNotFound(_0x4e6953,null))[_0xf81c('0x18')](function(_0x54fff7){if(_0x54fff7){return _0x54fff7[_0xf81c('0x38')](_0x5c7111[_0xf81c('0x34')][_0xf81c('0x3a')],_['omit'](_0x5c7111[_0xf81c('0x34')],['ids','id'])||{});}})[_0xf81c('0x18')](respondWithResult(_0x4e6953,null))[_0xf81c('0x32')](handleError(_0x4e6953,null));};exports['getMessages']=function(_0x395ea3,_0xb7a94c){var _0x12c6c7={'raw':![],'where':{}};var _0x4e58b5={};var _0xb8b846={'count':0x0,'rows':[]};return db[_0xf81c('0x1e')][_0xf81c('0x3b')]({'where':{'id':_0x395ea3['params']['id']}})['then'](handleEntityNotFound(_0xb7a94c,null))['then'](function(_0x3cb87e){if(_0x3cb87e){_0x4e58b5[_0xf81c('0x27')]=_[_0xf81c('0x28')](db[_0xf81c('0x39')][_0xf81c('0x1f')]);_0x4e58b5['query']=_[_0xf81c('0x28')](_0x395ea3[_0xf81c('0x24')]);_0x4e58b5[_0xf81c('0x29')]=_[_0xf81c('0x2a')](_0x4e58b5[_0xf81c('0x27')],_0x4e58b5[_0xf81c('0x24')]);_0x12c6c7[_0xf81c('0x2b')]=_[_0xf81c('0x2a')](_0x4e58b5[_0xf81c('0x27')],qs['fields'](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x2c')]));_0x12c6c7[_0xf81c('0x2b')]=_0x12c6c7[_0xf81c('0x2b')][_0xf81c('0x2d')]?_0x12c6c7[_0xf81c('0x2b')]:_0x4e58b5[_0xf81c('0x27')];if(!_0x395ea3[_0xf81c('0x24')][_0xf81c('0x3c')](_0xf81c('0x3d'))){_0x12c6c7[_0xf81c('0x14')]=qs[_0xf81c('0x14')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x14')]);_0x12c6c7[_0xf81c('0x12')]=qs[_0xf81c('0x12')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x12')]);}_0x12c6c7[_0xf81c('0x3e')]=qs[_0xf81c('0x3f')](_0x395ea3[_0xf81c('0x24')][_0xf81c('0x3f')]);_0x12c6c7['where']=qs[_0xf81c('0x29')](_[_0xf81c('0x40')](_0x395ea3[_0xf81c('0x24')],_0x4e58b5[_0xf81c('0x29')]));_0x12c6c7['where']['FaxInteractionId']=_0x3cb87e['id'];if(_0x395ea3['query']['filter']){_0x12c6c7[_0xf81c('0x41')]=_[_0xf81c('0x30')](_0x12c6c7[_0xf81c('0x41')],{'$or':_[_0xf81c('0x42')](_0x12c6c7[_0xf81c('0x2b')],function(_0x45d1dd){var _0x3fac6e={};_0x3fac6e[_0x45d1dd]={'$like':'%'+_0x395ea3[_0xf81c('0x24')]['filter']+'%'};return _0x3fac6e;})});}if(_0x395ea3[_0xf81c('0x24')]['$gte']){var _0x283b00=_0x395ea3[_0xf81c('0x24')][_0xf81c('0x43')][_0xf81c('0x44')](',');var _0x54f0b9={};_0x54f0b9[_0x283b00[0x0]]={'$gte':moment(_0x283b00[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')};_0x12c6c7[_0xf81c('0x41')]=_[_0xf81c('0x30')](_0x12c6c7['where'],_0x54f0b9);}_0x12c6c7=_[_0xf81c('0x30')]({},_0x12c6c7,_0x395ea3['options']);return db[_0xf81c('0x39')][_0xf81c('0x45')]({'where':_0x12c6c7[_0xf81c('0x41')]})['then'](function(_0x8814af){_0xb8b846['count']=_0x8814af;if(_0x395ea3[_0xf81c('0x24')]['includeAll']){_0x12c6c7[_0xf81c('0x2f')]=[{'all':!![]}];}return db[_0xf81c('0x39')][_0xf81c('0x46')](_0x12c6c7);})[_0xf81c('0x18')](function(_0x1bcf6a){_0xb8b846[_0xf81c('0x47')]=_0x1bcf6a;return _0xb8b846;});}})[_0xf81c('0x18')](respondWithFilteredResult(_0xb7a94c,_0x12c6c7))[_0xf81c('0x32')](handleError(_0xb7a94c,null));};exports[_0xf81c('0x48')]=function(_0x3b7a9f,_0x44dadd){return db[_0xf81c('0x1e')][_0xf81c('0x35')]({'where':{'id':_0x3b7a9f[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x44dadd,null))[_0xf81c('0x18')](function(_0x277598){if(_0x277598){return _0x277598[_0xf81c('0x49')](_0x3b7a9f[_0xf81c('0x34')][_0xf81c('0x3a')],_[_0xf81c('0x4a')](_0x3b7a9f[_0xf81c('0x34')],[_0xf81c('0x3a'),'id'])||{})[_0xf81c('0x4b')](function(){return db[_0xf81c('0x4c')]['findAll']({'attributes':['id',_0xf81c('0x1b'),_0xf81c('0x4d')],'where':{'id':_0x3b7a9f['body'][_0xf81c('0x3a')]}});})[_0xf81c('0x18')](function(_0x27abee){socket['emit'](_0xf81c('0x4e'),{'id':Number(_0x3b7a9f[_0xf81c('0x36')]['id']),'tags':_0x27abee||[]});return{'id':Number(_0x3b7a9f[_0xf81c('0x36')]['id']),'tags':_0x27abee||[]};});}})[_0xf81c('0x18')](respondWithResult(_0x44dadd,null))['catch'](handleError(_0x44dadd,null));};exports['removeTags']=function(_0x28d028,_0x211524){return db[_0xf81c('0x1e')][_0xf81c('0x35')]({'where':{'id':_0x28d028[_0xf81c('0x36')]['id']}})[_0xf81c('0x18')](handleEntityNotFound(_0x211524,null))[_0xf81c('0x18')](function(_0x2a39a6){if(_0x2a39a6){return _0x2a39a6['removeTags'](_0x28d028['query'][_0xf81c('0x3a')]);}})[_0xf81c('0x18')](respondWithStatusCode(_0x211524,null))[_0xf81c('0x32')](handleError(_0x211524,null));};exports[_0xf81c('0x4f')]=function(_0x1a2150,_0xf8b5db){var _0x565dd1=moment()[_0xf81c('0x50')]()['toString']();var _0x8272ed=path[_0xf81c('0x51')](config[_0xf81c('0x52')],_0xf81c('0x53'),_0xf81c('0x54'),_0xf81c('0x55'));var _0x20daca=path[_0xf81c('0x51')](config['root'],_0xf81c('0x53'),_0xf81c('0x54'),_0xf81c('0x56'));var _0x132ae8=path[_0xf81c('0x51')](_0x8272ed,_0x565dd1);var _0x52ecd0=util[_0xf81c('0x57')](_0xf81c('0x58'),_0x1a2150[_0xf81c('0x36')]['id'],_0x565dd1);var _0x29701e=path['join'](_0x8272ed,_0x52ecd0);var _0x4d5854=[];_0x4d5854[_0xf81c('0x59')]({'model':db[_0xf81c('0x5a')],'as':_0xf81c('0x5a'),'raw':!![]});var _0x222300=[{'model':db[_0xf81c('0x39')],'as':'Messages','attributes':['id',_0xf81c('0x34'),_0xf81c('0x5b')],'include':_0x4d5854}];return db['FaxInteraction'][_0xf81c('0x35')]({'where':{'id':_0x1a2150[_0xf81c('0x36')]['id']},'include':_0x222300})[_0xf81c('0x18')](handleEntityNotFound(_0xf8b5db,null))[_0xf81c('0x18')](function(_0x2df6fb){if(_0x2df6fb&&_0x2df6fb['Messages']){var _0x114765=_0x2df6fb[_0xf81c('0x5c')]({'plain':!![]});fs[_0xf81c('0x5d')](_0x132ae8);for(var _0x675e9a=0x0;_0x675e9a<_0x114765[_0xf81c('0x5e')][_0xf81c('0x2d')];_0x675e9a++){var _0x44b7ae=_0x114765['Messages'][_0x675e9a][_0xf81c('0x5a')];if(_0x44b7ae){var _0x5a6af8=path[_0xf81c('0x51')](_0x20daca,_0x44b7ae[_0xf81c('0x5f')]);if(fs[_0xf81c('0x60')](_0x5a6af8)){fs[_0xf81c('0x61')](_0x5a6af8)['pipe'](fs[_0xf81c('0x62')](path[_0xf81c('0x51')](_0x132ae8,_0x44b7ae[_0xf81c('0x5f')])));}}}return BPromise[_0xf81c('0x63')]()['then'](function(){return new BPromise(function(_0x575de5,_0x2d6e4d){zipdir(_0x132ae8,{'saveTo':_0x29701e},function(_0x190e23,_0x3146c7){if(_0x190e23)return _0x2d6e4d(_0x190e23);return _0x575de5(_0x3146c7);});})['then'](function(){return new BPromise(function(_0x414a75,_0x3dccdc){rimraf(_0x132ae8,function(_0xbf6e96){if(_0xbf6e96)_0x3dccdc(_0xbf6e96);return _0x414a75();});});})[_0xf81c('0x18')](function(){return _0xf8b5db[_0xf81c('0x4f')](_0x29701e,_0x52ecd0,function(_0x29159b){if(_0x29159b){console[_0xf81c('0x64')](_0xf81c('0x65'),_0x29159b);}else{fs[_0xf81c('0x66')](_0x29701e);}});});});}else{return _0xf8b5db[_0xf81c('0xe')](0xc8);}})[_0xf81c('0x32')](handleError(_0xf8b5db,null));};
\ No newline at end of file