Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 05c5143..fafcc0a 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x23a4=['query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','limit','order','sort','where','select','field','color','from','u.id','u.fullname','user_has_fax_interactions','users','u.id\x20=\x20ui.UserId','fax_interactions','cm_contacts','left_join','o.id\x20=\x20i.UserId','fax_accounts','a.id\x20=\x20i.FaxAccountId','fax_messages','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','tools_tags','t.id\x20=\x20it.TagId','search','parseSearch','sqlOperator','conditions','length','find','unreadMessages','value','having','`\x20>\x200','operator','$substring','split','MATCH\x20(c.firstName,\x20c.lastName,\x20c.phone,\x20c.mobile,\x20c.fax,\x20c.email)\x20AGAINST\x20(?\x20IN\x20BOOLEAN\x20MODE)','getFullTextValue','ContactId','buildExpression','type','text','Tag','union','User','UserId','start','keys','compact','isEmpty','i.FaxAccountId\x20IN\x20?','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','\x20IS\x20NULL','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','tag','filter','replace','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','QueryTypes','SELECT','clone','i.id','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','contactName','DESC','FaxAccountId','i.FaxAccountId\x20IS\x20NOT\x20NULL','agent','user','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','role','sequelize','toString','keyBy','merge','a.key','Account.key','a.mandatoryDisposition','Account.mandatoryDisposition','CASE\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','i.*','Contact.firstName','c.lastName','Contact.lastName','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','c.fax','Contact.fax','Owner.fullname','o.internal','GROUP_CONCAT(DISTINCT\x20t.id)','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','rows','include','options','create','body','update','params','describe','addMessage','ids','getMessages','findOne','FaxMessage','pick','format','YYYY-MM-DD\x20HH:mm:ss','includeAll','findAll','addTags','spread','emit','faxInteractionTags:save','removeTags','download','unix','join','root','server','files','tmp','attachments','transcript-%d-%s.zip','Attachment','Messages','get','mkdirSync','basename','existsSync','createWriteStream','resolve','log','unlinkSync','html-pdf','rimraf','zip-dir','request-promise','moment','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','sendStatus','status','json','count','offset','set','Content-Range','apply','reject','save','then','destroy','end','error','stack','name','Users','map','fullname','TagIds','Tags','forEach','push','catch','FaxInteraction','rawAttributes','model'];(function(_0x3d61c6,_0x4571e6){var _0x47e0df=function(_0x25adfd){while(--_0x25adfd){_0x3d61c6['push'](_0x3d61c6['shift']());}};_0x47e0df(++_0x4571e6);}(_0x23a4,0x174));var _0x423a=function(_0x1ac271,_0x330d29){_0x1ac271=_0x1ac271-0x0;var _0x281f49=_0x23a4[_0x1ac271];return _0x281f49;};'use strict';var pdf=require(_0x423a('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x423a('0x1'));var zipdir=require(_0x423a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x423a('0x3'));var moment=require(_0x423a('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x423a('0x5'));var util=require(_0x423a('0x6'));var path=require('path');var sox=require(_0x423a('0x7'));var csv=require(_0x423a('0x8'));var ejs=require(_0x423a('0x9'));var fs=require('fs');var _=require(_0x423a('0xa'));var squel=require(_0x423a('0xb'));var crypto=require(_0x423a('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x423a('0xd'));var toCsv=require(_0x423a('0x8'));var querystring=require(_0x423a('0xe'));var Papa=require('papaparse');var Redis=require(_0x423a('0xf'));var authService=require(_0x423a('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0x423a('0x11'));var hardwareService=require(_0x423a('0x12'));var logger=require(_0x423a('0x13'))(_0x423a('0x14'));var utils=require(_0x423a('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x423a('0x16'));var db=require(_0x423a('0x17'))['db'];config[_0x423a('0x18')]=_[_0x423a('0x19')](config[_0x423a('0x18')],{'host':_0x423a('0x1a'),'port':0x18eb});var socket=require(_0x423a('0x1b'))(new Redis(config[_0x423a('0x18')]));require('./faxInteraction.socket')[_0x423a('0x1c')](socket);function respondWithStatusCode(_0x299015,_0x177df6){_0x177df6=_0x177df6||0xcc;return function(_0x2fd266){if(_0x2fd266){return _0x299015[_0x423a('0x1d')](_0x177df6);}return _0x299015['status'](_0x177df6)['end']();};}function respondWithResult(_0x56f3c7,_0x55ef28){_0x55ef28=_0x55ef28||0xc8;return function(_0x53d914){if(_0x53d914){return _0x56f3c7[_0x423a('0x1e')](_0x55ef28)[_0x423a('0x1f')](_0x53d914);}};}function respondWithFilteredResult(_0x334e8b,_0x4feaf){return function(_0x461e0f){if(_0x461e0f){var _0x3da4cf=_0x461e0f[_0x423a('0x20')],_0x332209=_0x4feaf['offset'],_0x3a90a9=_0x4feaf[_0x423a('0x21')]+_0x4feaf['limit'],_0x10696f;if(_0x3a90a9>=_0x3da4cf){_0x3a90a9=_0x3da4cf;_0x10696f=0xc8;}else{_0x10696f=0xce;}_0x334e8b[_0x423a('0x1e')](_0x10696f);return _0x334e8b[_0x423a('0x22')](_0x423a('0x23'),_0x332209+'-'+_0x3a90a9+'/'+_0x3da4cf)['json'](_0x461e0f);}return null;};}function patchUpdates(_0x463b3e){return function(_0x14b9e4){try{jsonpatch[_0x423a('0x24')](_0x14b9e4,_0x463b3e,!![]);}catch(_0x3e4b4e){return BPromise[_0x423a('0x25')](_0x3e4b4e);}return _0x14b9e4[_0x423a('0x26')]();};}function saveUpdates(_0x130761,_0x14e358){return function(_0x297470){if(_0x297470){return _0x297470['update'](_0x130761)[_0x423a('0x27')](function(_0x308e08){return _0x308e08;});}return null;};}function removeEntity(_0x1e6176,_0x10dd07){return function(_0x4e6550){if(_0x4e6550){return _0x4e6550[_0x423a('0x28')]()[_0x423a('0x27')](function(){_0x1e6176[_0x423a('0x1e')](0xcc)[_0x423a('0x29')]();});}};}function handleEntityNotFound(_0xb2fcff,_0x314fb2){return function(_0x5c5281){if(!_0x5c5281){_0xb2fcff[_0x423a('0x1d')](0x194);}return _0x5c5281;};}function handleError(_0x45d3c2,_0x2f9f73){_0x2f9f73=_0x2f9f73||0x1f4;return function(_0x14f210){logger[_0x423a('0x2a')](_0x14f210[_0x423a('0x2b')]);if(_0x14f210[_0x423a('0x2c')]){delete _0x14f210[_0x423a('0x2c')];}_0x45d3c2['status'](_0x2f9f73)['send'](_0x14f210);};}function getInteractionUsers(_0x24e68a,_0x400b17){return new BPromise(function(_0x3908c7,_0x22edfc){try{if(_0x400b17[_0x24e68a['id']]){_0x24e68a[_0x423a('0x2d')]=_[_0x423a('0x2e')](_0x400b17[_0x24e68a['id']],function(_0x472fdc){return{'id':_0x472fdc['id'],'fullname':_0x472fdc[_0x423a('0x2f')]};});}}catch(_0x12e8b9){_0x22edfc(_0x12e8b9);}_0x3908c7(_0x24e68a);});}function getInteractionTags(_0x5572dc,_0x558dd5){return new BPromise(function(_0x208242,_0x38071e){try{if(_0x5572dc[_0x423a('0x30')]){_0x5572dc[_0x423a('0x31')]=[];_0x5572dc[_0x423a('0x30')]['split'](',')[_0x423a('0x32')](function(_0x2be8f7){_0x5572dc['Tags'][_0x423a('0x33')](_0x558dd5[_0x2be8f7]);});}delete _0x5572dc['TagIds'];}catch(_0x522de0){_0x38071e(_0x522de0);}_0x208242(_0x5572dc);});}function updateFaxInteraction(_0x863970,_0x13a54f,_0x4a2998){return new BPromise(function(_0x40266a,_0x390101){return getInteractionUsers(_0x863970,_0x4a2998)[_0x423a('0x27')](function(_0x52743c){return getInteractionTags(_0x52743c,_0x13a54f);})[_0x423a('0x27')](function(_0x3c749b){_0x40266a(_0x3c749b);})[_0x423a('0x34')](function(_0x2b7564){_0x390101(_0x2b7564);});});}exports['index']=function(_0x17a4fa,_0x165737){var _0x2bd28a={},_0x3ea5c5={},_0x22098f={'count':0x0,'rows':[]};var _0x480b58=_['map'](db[_0x423a('0x35')][_0x423a('0x36')],function(_0x39e959){return{'name':_0x39e959['fieldName'],'type':_0x39e959['type']['key']};});_0x3ea5c5[_0x423a('0x37')]=_[_0x423a('0x2e')](_0x480b58,_0x423a('0x2c'));_0x3ea5c5[_0x423a('0x38')]=_['keys'](_0x17a4fa[_0x423a('0x38')]);_0x3ea5c5[_0x423a('0x39')]=_[_0x423a('0x3a')](_0x3ea5c5[_0x423a('0x37')],_0x3ea5c5[_0x423a('0x38')]);_0x2bd28a[_0x423a('0x3b')]=_['intersection'](_0x3ea5c5['model'],qs[_0x423a('0x3c')](_0x17a4fa[_0x423a('0x38')][_0x423a('0x3c')]));_0x2bd28a[_0x423a('0x3b')]=_0x2bd28a[_0x423a('0x3b')]['length']?_0x2bd28a['attributes']:_0x3ea5c5[_0x423a('0x37')];if(!_0x17a4fa[_0x423a('0x38')][_0x423a('0x3d')](_0x423a('0x3e'))){_0x2bd28a[_0x423a('0x3f')]=qs[_0x423a('0x3f')](_0x17a4fa['query'][_0x423a('0x3f')]);_0x2bd28a[_0x423a('0x21')]=qs[_0x423a('0x21')](_0x17a4fa['query']['offset']);}_0x2bd28a[_0x423a('0x40')]=qs[_0x423a('0x41')](_0x17a4fa[_0x423a('0x38')][_0x423a('0x41')]);_0x2bd28a[_0x423a('0x42')]=qs[_0x423a('0x39')](_['pick'](_0x17a4fa['query'],_0x3ea5c5[_0x423a('0x39')]),_0x480b58);var _0x3e090f=[];var _0x4ac276=squel[_0x423a('0x43')]()[_0x423a('0x44')]('id')[_0x423a('0x44')](_0x423a('0x2c'))[_0x423a('0x44')](_0x423a('0x45'))[_0x423a('0x46')]('tools_tags');var _0xb614aa=squel[_0x423a('0x43')]()[_0x423a('0x44')](_0x423a('0x47'))[_0x423a('0x44')](_0x423a('0x48'))[_0x423a('0x44')]('ui.FaxInteractionId')[_0x423a('0x46')](_0x423a('0x49'),'ui')['left_join'](_0x423a('0x4a'),'u',_0x423a('0x4b'));var _0x36e81e=squel[_0x423a('0x43')]()[_0x423a('0x46')](_0x423a('0x4c'),'i')['left_join'](_0x423a('0x4d'),'c','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL')[_0x423a('0x4e')](_0x423a('0x4a'),'o',_0x423a('0x4f'))[_0x423a('0x4e')](_0x423a('0x50'),'a',_0x423a('0x51'))[_0x423a('0x4e')](_0x423a('0x52'),'me','me.FaxInteractionId\x20=\x20i.id')[_0x423a('0x4e')](_0x423a('0x53'),'it',_0x423a('0x54'))[_0x423a('0x4e')](_0x423a('0x55'),'t',_0x423a('0x56'));var _0x2f7b08=squel['expr']();var _0x25195b=[];var _0x5e9e2a=squel['expr']();var _0x87bde0;if(_0x17a4fa[_0x423a('0x38')][_0x423a('0x57')]){_0x87bde0=as[_0x423a('0x58')](_0x17a4fa[_0x423a('0x38')][_0x423a('0x57')]);var _0x1a9669=_0x87bde0[_0x423a('0x59')];for(var _0x2623b6=0x0;_0x2623b6<_0x87bde0[_0x423a('0x5a')][_0x423a('0x5b')];_0x2623b6++){var _0x584adc=_0x87bde0[_0x423a('0x5a')][_0x2623b6];var _0x375879='i';var _0x2fa715=_[_0x423a('0x5c')](_0x480b58,[_0x423a('0x2c'),_0x584adc[_0x423a('0x44')]]);if(!_0x2fa715){switch(_0x584adc['field']){case _0x423a('0x5d'):if(_0x584adc[_0x423a('0x5e')]==0x1){_0x36e81e['having']('`'+_0x584adc[_0x423a('0x44')]+'`\x20=\x200');}else{_0x36e81e[_0x423a('0x5f')]('`'+_0x584adc['field']+_0x423a('0x60'));}break;case'Contact':if(_0x584adc[_0x423a('0x61')]===_0x423a('0x62')){if(_0x584adc[_0x423a('0x5e')][_0x423a('0x63')]('\x20')[_0x423a('0x5b')]>0x1){_0x2f7b08[_0x1a9669](_0x423a('0x64'),qs[_0x423a('0x65')](_0x584adc[_0x423a('0x5e')]),null);}else{var _0x4b1a3f='%'+_0x584adc[_0x423a('0x5e')]+'%';_0x2f7b08[_0x1a9669]('c.firstName\x20LIKE\x20?\x20OR\x20c.lastName\x20LIKE\x20?\x20OR\x20c.email\x20LIKE\x20?',_0x4b1a3f,_0x4b1a3f,_0x4b1a3f);}}else{_0x2fa715=_[_0x423a('0x5c')](_0x480b58,['name',_0x423a('0x66')]);_0x584adc[_0x423a('0x44')]=_0x423a('0x66');_0x1fb90d=as[_0x423a('0x67')](_0x375879,_0x2fa715[_0x423a('0x68')],_0x584adc);_0x2f7b08[_0x1a9669](_0x1fb90d[_0x423a('0x69')],_0x1fb90d[_0x423a('0x5e')]['start'],_0x1fb90d[_0x423a('0x5e')][_0x423a('0x29')]);}break;case _0x423a('0x6a'):var _0xd46e0d=_0x584adc[_0x423a('0x5e')][_0x423a('0x63')](',')[_0x423a('0x2e')](function(_0x20d17f){return Number(_0x20d17f);});_0xd46e0d[_0x423a('0x32')](function(_0x3077a9){_0x5e9e2a['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x3077a9+',%');});_0x25195b=_[_0x423a('0x6b')](_0x25195b,_0xd46e0d);break;case _0x423a('0x6c'):if(_0x584adc[_0x423a('0x61')]===_0x423a('0x62')){_0x2f7b08[_0x1a9669]('CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','%'+_0x584adc[_0x423a('0x5e')]+'%',null);}else{_0x2fa715=_['find'](_0x480b58,[_0x423a('0x2c'),_0x423a('0x6d')]);_0x584adc['field']=_0x423a('0x6d');_0x1fb90d=as['buildExpression'](_0x375879,_0x2fa715['type'],_0x584adc);_0x2f7b08[_0x1a9669](_0x1fb90d['text'],_0x1fb90d['value'][_0x423a('0x6e')],_0x1fb90d[_0x423a('0x5e')]['end']);}break;case'body':_0x1fb90d=as['buildExpression']('me',null,_0x584adc);_0x2f7b08[_0x1a9669](_0x1fb90d[_0x423a('0x69')],_0x1fb90d[_0x423a('0x5e')][_0x423a('0x6e')],_0x1fb90d[_0x423a('0x5e')][_0x423a('0x29')]);break;}}else{var _0x1fb90d=as[_0x423a('0x67')](_0x375879,_0x2fa715[_0x423a('0x68')],_0x584adc);_0x2f7b08[_0x1a9669](_0x1fb90d[_0x423a('0x69')],_0x1fb90d[_0x423a('0x5e')][_0x423a('0x6e')],_0x1fb90d['value']['end']);}}}else{var _0x130fc5=_(_0x17a4fa[_0x423a('0x38')])[_0x423a('0x6f')]()['map'](function(_0x5dbf17){return _['some'](_0x480b58,['name',_0x5dbf17])?_0x5dbf17:undefined;})[_0x423a('0x70')]()['value']();if(!_[_0x423a('0x71')](_0x130fc5)){_0x130fc5[_0x423a('0x32')](function(_0x252839){if(_0x252839==='FaxAccountId'){_0x36e81e[_0x423a('0x42')](_0x423a('0x72'),[]['concat'](_0x17a4fa['query'][_0x252839]));}else if(_0x252839===_0x423a('0x73')){var _0x58c9a8=JSON[_0x423a('0x74')](_0x17a4fa[_0x423a('0x38')][_0x252839])[_0x423a('0x75')];var _0x2764e8=JSON[_0x423a('0x74')](_0x17a4fa['query'][_0x252839])[_0x423a('0x76')];_0x36e81e[_0x423a('0x42')](_0x423a('0x77'),_0x58c9a8,_0x2764e8);}else{if(_0x17a4fa[_0x423a('0x38')][_0x252839]===_0x423a('0x78')){_0x36e81e['where']('i.'+_0x252839+_0x423a('0x79'));}else{_0x36e81e[_0x423a('0x42')]('i.'+_0x252839+'\x20=\x20?',_0x17a4fa[_0x423a('0x38')][_0x252839]);}}});}if(_0x17a4fa[_0x423a('0x38')][_0x423a('0x7a')]){if(_0x17a4fa[_0x423a('0x38')]['read']==0x1){_0x36e81e[_0x423a('0x5f')](_0x423a('0x7b'));}else{_0x36e81e['having'](_0x423a('0x7c'));}}if(_0x17a4fa['query'][_0x423a('0x7d')]){_0x25195b=_['isArray'](_0x17a4fa[_0x423a('0x38')][_0x423a('0x7d')])?_0x17a4fa[_0x423a('0x38')][_0x423a('0x7d')]:new Array(_0x17a4fa[_0x423a('0x38')][_0x423a('0x7d')]);_0x25195b[_0x423a('0x32')](function(_0x58f997){_0x5e9e2a['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x58f997+',%');});}if(_0x17a4fa[_0x423a('0x38')][_0x423a('0x7e')]){var _0x337a41=_0x17a4fa[_0x423a('0x38')][_0x423a('0x7e')]['replace']('\x5c','\x5c\x5c')[_0x423a('0x7f')](/'/g,'\x27\x27');if(qs['isNumeric'](_0x337a41)){_0x2f7b08['or'](_0x423a('0x80'),_0x337a41+'%')['or'](_0x423a('0x81'),_0x337a41+'%');}_0x2f7b08['or'](_0x423a('0x82'),_0x337a41+'%');}}_0x36e81e[_0x423a('0x42')](_0x2f7b08);_0x36e81e[_0x423a('0x83')]('i.id');var _0x32f66e={'type':db['Sequelize'][_0x423a('0x84')][_0x423a('0x85')],'raw':!![]};var _0x22fc25=_0x36e81e[_0x423a('0x86')]();_0x22fc25['field'](_0x423a('0x87'));_0x22fc25['field'](_0x423a('0x88'),_0x423a('0x5d'));if(_0x2bd28a[_0x423a('0x40')]){_0x2bd28a['order'][_0x423a('0x32')](function(_0x26ccea){var _0x340206=_0x26ccea[0x0]===_0x423a('0x89')?_0x26ccea[0x0]:'i.'+_0x26ccea[0x0];_0x36e81e[_0x423a('0x40')](_0x340206,_0x26ccea[0x1]===_0x423a('0x8a')?![]:!![]);});}if(!_['isEmpty'](_0x25195b)){_0x36e81e[_0x423a('0x5f')](_0x5e9e2a);_0x22fc25[_0x423a('0x42')]('t.id\x20IN\x20?',_0x25195b);}BPromise['resolve']()[_0x423a('0x27')](function(){if(!_0x87bde0){if(_0x17a4fa[_0x423a('0x38')][_0x423a('0x8b')])return;_0x22fc25['where']('i.FaxAccountId\x20IS\x20NOT\x20NULL');_0x36e81e[_0x423a('0x42')](_0x423a('0x8c'));return;}if(_0x17a4fa['user']['role']!==_0x423a('0x8d'))return;return _0x17a4fa[_0x423a('0x8e')][_0x423a('0x8f')]({'attributes':['id'],'raw':!![]})[_0x423a('0x27')](function(_0x34e733){if(_['isEmpty'](_0x34e733)){_0x22fc25[_0x423a('0x42')](_0x423a('0x90'));_0x36e81e[_0x423a('0x42')](_0x423a('0x90'));}else{_0x22fc25[_0x423a('0x42')](_0x423a('0x72'),_[_0x423a('0x2e')](_0x34e733,'id'));_0x36e81e[_0x423a('0x42')](_0x423a('0x72'),_[_0x423a('0x2e')](_0x34e733,'id'));}});})['then'](function(){if(_0x17a4fa[_0x423a('0x8e')][_0x423a('0x91')]===_0x423a('0x8d')&&!_0x87bde0&&!_0x17a4fa[_0x423a('0x38')][_0x423a('0x8b')])return[];return db[_0x423a('0x92')][_0x423a('0x38')](_0x22fc25[_0x423a('0x93')](),_0x32f66e);})[_0x423a('0x27')](function(_0x5889b3){_0x22098f['count']=_0x5889b3[_0x423a('0x5b')];if(_0x22098f[_0x423a('0x20')]===0x0)return[];return db[_0x423a('0x92')]['query'](_0x4ac276['toString'](),_0x32f66e)[_0x423a('0x27')](function(_0x4c41bf){_0x3e090f=_[_0x423a('0x94')](_0x4c41bf,'id');_0x32f66e=_[_0x423a('0x95')](_0x32f66e,{'model':db[_0x423a('0x35')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x17a4fa[_0x423a('0x38')]['fields']){_0x2bd28a['attributes'][_0x423a('0x32')](function(_0x2e2bdd){_0x36e81e[_0x423a('0x44')]('i.'+_0x2e2bdd);});}else{_0x36e81e[_0x423a('0x44')](_0x423a('0x88'),_0x423a('0x5d'));_0x36e81e[_0x423a('0x44')](_0x423a('0x96'),_0x423a('0x97'));_0x36e81e[_0x423a('0x44')](_0x423a('0x98'),_0x423a('0x99'));_0x36e81e[_0x423a('0x44')](_0x423a('0x9a'),'contactName');_0x36e81e[_0x423a('0x44')](_0x423a('0x9b'));_0x36e81e[_0x423a('0x44')]('c.firstName',_0x423a('0x9c'));_0x36e81e[_0x423a('0x44')](_0x423a('0x9d'),_0x423a('0x9e'));_0x36e81e[_0x423a('0x44')]('c.email',_0x423a('0x9f'));_0x36e81e[_0x423a('0x44')](_0x423a('0xa0'),_0x423a('0xa1'));_0x36e81e['field'](_0x423a('0xa2'),_0x423a('0xa3'));_0x36e81e['field'](_0x423a('0xa4'),_0x423a('0xa5'));_0x36e81e[_0x423a('0x44')]('o.fullname',_0x423a('0xa6'));_0x36e81e[_0x423a('0x44')](_0x423a('0xa7'),'Owner.internal');_0x36e81e[_0x423a('0x44')](_0x423a('0xa8'),_0x423a('0x30'));}if(_0x2bd28a['limit'])_0x36e81e[_0x423a('0x3f')](_0x2bd28a['limit']);if(_0x2bd28a[_0x423a('0x21')])_0x36e81e[_0x423a('0x21')](_0x2bd28a['offset']);return db[_0x423a('0x92')][_0x423a('0x38')](_0x36e81e[_0x423a('0x93')](),_0x32f66e);})[_0x423a('0x27')](function(_0x2e949d){_0xb614aa[_0x423a('0x42')](_0x423a('0xa9'),_[_0x423a('0x2e')](_0x2e949d,'id'));return db[_0x423a('0x92')]['query'](_0xb614aa[_0x423a('0x93')](),_0x32f66e)['then'](function(_0x181ea8){var _0x420641=_[_0x423a('0xaa')](_0x181ea8,_0x423a('0xab'));var _0x3975fb=[];_0x2e949d[_0x423a('0x32')](function(_0x1f81e8){_0x3975fb[_0x423a('0x33')](updateFaxInteraction(_0x1f81e8,_0x3e090f,_0x420641));});return BPromise['all'](_0x3975fb);});});})['then'](function(_0x487ee4){_0x22098f[_0x423a('0xac')]=_0x487ee4;return _0x22098f;})[_0x423a('0x27')](respondWithFilteredResult(_0x165737,_0x2bd28a))[_0x423a('0x34')](handleError(_0x165737,null));};exports['show']=function(_0x255ff1,_0x5604a6){var _0x1dd7e0={'raw':![],'where':{'id':_0x255ff1['params']['id']}},_0x240cdc={};_0x240cdc['model']=_[_0x423a('0x6f')](db[_0x423a('0x35')][_0x423a('0x36')]);_0x240cdc['query']=_[_0x423a('0x6f')](_0x255ff1['query']);_0x240cdc[_0x423a('0x39')]=_[_0x423a('0x3a')](_0x240cdc[_0x423a('0x37')],_0x240cdc[_0x423a('0x38')]);_0x1dd7e0[_0x423a('0x3b')]=_[_0x423a('0x3a')](_0x240cdc[_0x423a('0x37')],qs[_0x423a('0x3c')](_0x255ff1[_0x423a('0x38')][_0x423a('0x3c')]));_0x1dd7e0[_0x423a('0x3b')]=_0x1dd7e0[_0x423a('0x3b')]['length']?_0x1dd7e0[_0x423a('0x3b')]:_0x240cdc[_0x423a('0x37')];if(_0x255ff1[_0x423a('0x38')]['includeAll']){_0x1dd7e0[_0x423a('0xad')]=[{'all':!![]}];}_0x1dd7e0=_[_0x423a('0x95')]({},_0x1dd7e0,_0x255ff1[_0x423a('0xae')]);return db['FaxInteraction'][_0x423a('0x5c')](_0x1dd7e0)['then'](handleEntityNotFound(_0x5604a6,null))[_0x423a('0x27')](respondWithResult(_0x5604a6,null))[_0x423a('0x34')](handleError(_0x5604a6,null));};exports[_0x423a('0xaf')]=function(_0x196056,_0x1e1b3c){return db[_0x423a('0x35')]['create'](_0x196056[_0x423a('0xb0')],{})[_0x423a('0x27')](respondWithResult(_0x1e1b3c,0xc9))[_0x423a('0x34')](handleError(_0x1e1b3c,null));};exports[_0x423a('0xb1')]=function(_0x39acbb,_0x2ff585){if(_0x39acbb['body']['id']){delete _0x39acbb[_0x423a('0xb0')]['id'];}return db[_0x423a('0x35')][_0x423a('0x5c')]({'where':{'id':_0x39acbb[_0x423a('0xb2')]['id']}})[_0x423a('0x27')](handleEntityNotFound(_0x2ff585,null))['then'](saveUpdates(_0x39acbb[_0x423a('0xb0')],null))[_0x423a('0x27')](respondWithResult(_0x2ff585,null))[_0x423a('0x34')](handleError(_0x2ff585,null));};exports[_0x423a('0x28')]=function(_0x221952,_0x46810f){return db['FaxInteraction'][_0x423a('0x5c')]({'where':{'id':_0x221952['params']['id']}})['then'](handleEntityNotFound(_0x46810f,null))[_0x423a('0x27')](removeEntity(_0x46810f,null))[_0x423a('0x34')](handleError(_0x46810f,null));};exports[_0x423a('0xb3')]=function(_0x405018,_0x2c678d){return db['FaxInteraction'][_0x423a('0xb3')]()['then'](respondWithResult(_0x2c678d,null))[_0x423a('0x34')](handleError(_0x2c678d,null));};exports[_0x423a('0xb4')]=function(_0x390764,_0x100a38,_0x3e24b9){return db['FaxMessage'][_0x423a('0x5c')]({'where':{'id':_0x390764[_0x423a('0xb2')]['id']}})['then'](handleEntityNotFound(_0x100a38,null))[_0x423a('0x27')](function(_0xff3174){if(_0xff3174){return _0xff3174[_0x423a('0xb4')](_0x390764[_0x423a('0xb0')][_0x423a('0xb5')],_['omit'](_0x390764[_0x423a('0xb0')],[_0x423a('0xb5'),'id'])||{});}})[_0x423a('0x27')](respondWithResult(_0x100a38,null))[_0x423a('0x34')](handleError(_0x100a38,null));};exports[_0x423a('0xb6')]=function(_0x1a740d,_0x4d94b2,_0x11f969){var _0x4e8d0b={'raw':![],'where':{}};var _0x381a7c={};var _0x49e6d9={'count':0x0,'rows':[]};return db[_0x423a('0x35')][_0x423a('0xb7')]({'where':{'id':_0x1a740d['params']['id']}})[_0x423a('0x27')](handleEntityNotFound(_0x4d94b2,null))[_0x423a('0x27')](function(_0x5ad01c){if(_0x5ad01c){_0x381a7c['model']=_[_0x423a('0x6f')](db[_0x423a('0xb8')][_0x423a('0x36')]);_0x381a7c['query']=_[_0x423a('0x6f')](_0x1a740d[_0x423a('0x38')]);_0x381a7c[_0x423a('0x39')]=_[_0x423a('0x3a')](_0x381a7c[_0x423a('0x37')],_0x381a7c[_0x423a('0x38')]);_0x4e8d0b['attributes']=_[_0x423a('0x3a')](_0x381a7c['model'],qs[_0x423a('0x3c')](_0x1a740d['query'][_0x423a('0x3c')]));_0x4e8d0b[_0x423a('0x3b')]=_0x4e8d0b[_0x423a('0x3b')][_0x423a('0x5b')]?_0x4e8d0b[_0x423a('0x3b')]:_0x381a7c[_0x423a('0x37')];if(!_0x1a740d['query'][_0x423a('0x3d')]('nolimit')){_0x4e8d0b[_0x423a('0x3f')]=qs['limit'](_0x1a740d[_0x423a('0x38')][_0x423a('0x3f')]);_0x4e8d0b[_0x423a('0x21')]=qs[_0x423a('0x21')](_0x1a740d['query'][_0x423a('0x21')]);}_0x4e8d0b[_0x423a('0x40')]=qs[_0x423a('0x41')](_0x1a740d[_0x423a('0x38')][_0x423a('0x41')]);_0x4e8d0b['where']=qs['filters'](_[_0x423a('0xb9')](_0x1a740d['query'],_0x381a7c[_0x423a('0x39')]));_0x4e8d0b['where']['FaxInteractionId']=_0x5ad01c['id'];if(_0x1a740d[_0x423a('0x38')][_0x423a('0x7e')]){_0x4e8d0b[_0x423a('0x42')]=_[_0x423a('0x95')](_0x4e8d0b[_0x423a('0x42')],{'$or':_['map'](_0x4e8d0b[_0x423a('0x3b')],function(_0x5eed2a){var _0x2865c9={};_0x2865c9[_0x5eed2a]={'$like':'%'+_0x1a740d[_0x423a('0x38')]['filter']+'%'};return _0x2865c9;})});}if(_0x1a740d[_0x423a('0x38')][_0x423a('0x75')]){var _0x5617b7=_0x1a740d['query']['$gte'][_0x423a('0x63')](',');var _0xb76de1={};_0xb76de1[_0x5617b7[0x0]]={'$gte':moment(_0x5617b7[0x1])[_0x423a('0xba')](_0x423a('0xbb'))};_0x4e8d0b[_0x423a('0x42')]=_['merge'](_0x4e8d0b[_0x423a('0x42')],_0xb76de1);}_0x4e8d0b=_[_0x423a('0x95')]({},_0x4e8d0b,_0x1a740d[_0x423a('0xae')]);return db[_0x423a('0xb8')][_0x423a('0x20')]({'where':_0x4e8d0b[_0x423a('0x42')]})[_0x423a('0x27')](function(_0x2e2b2a){_0x49e6d9[_0x423a('0x20')]=_0x2e2b2a;if(_0x1a740d[_0x423a('0x38')][_0x423a('0xbc')]){_0x4e8d0b['include']=[{'all':!![]}];}return db[_0x423a('0xb8')][_0x423a('0xbd')](_0x4e8d0b);})[_0x423a('0x27')](function(_0x2184db){_0x49e6d9['rows']=_0x2184db;return _0x49e6d9;});}})[_0x423a('0x27')](respondWithFilteredResult(_0x4d94b2,_0x4e8d0b))[_0x423a('0x34')](handleError(_0x4d94b2,null));};exports[_0x423a('0xbe')]=function(_0x2b751c,_0x208b5a,_0x37bc1b){return db[_0x423a('0x35')][_0x423a('0x5c')]({'where':{'id':_0x2b751c['params']['id']}})[_0x423a('0x27')](handleEntityNotFound(_0x208b5a,null))['then'](function(_0xc1eb44){if(_0xc1eb44){return _0xc1eb44['setTags'](_0x2b751c['body'][_0x423a('0xb5')],_['omit'](_0x2b751c[_0x423a('0xb0')],[_0x423a('0xb5'),'id'])||{})[_0x423a('0xbf')](function(){return db[_0x423a('0x6a')]['findAll']({'attributes':['id',_0x423a('0x2c'),_0x423a('0x45')],'where':{'id':_0x2b751c[_0x423a('0xb0')][_0x423a('0xb5')]}});})['then'](function(_0x46c695){socket[_0x423a('0xc0')](_0x423a('0xc1'),{'id':Number(_0x2b751c[_0x423a('0xb2')]['id']),'tags':_0x46c695||[]});return{'id':Number(_0x2b751c[_0x423a('0xb2')]['id']),'tags':_0x46c695||[]};});}})[_0x423a('0x27')](respondWithResult(_0x208b5a,null))[_0x423a('0x34')](handleError(_0x208b5a,null));};exports[_0x423a('0xc2')]=function(_0x638cfd,_0x439c28,_0x5ec2d5){return db['FaxInteraction'][_0x423a('0x5c')]({'where':{'id':_0x638cfd[_0x423a('0xb2')]['id']}})['then'](handleEntityNotFound(_0x439c28,null))[_0x423a('0x27')](function(_0x282d3d){if(_0x282d3d){return _0x282d3d[_0x423a('0xc2')](_0x638cfd['query'][_0x423a('0xb5')]);}})[_0x423a('0x27')](respondWithStatusCode(_0x439c28,null))['catch'](handleError(_0x439c28,null));};exports[_0x423a('0xc3')]=function(_0x2b7a80,_0x23a2a3){var _0x534876=moment()[_0x423a('0xc4')]()[_0x423a('0x93')]();var _0x3c437b=path[_0x423a('0xc5')](config[_0x423a('0xc6')],_0x423a('0xc7'),_0x423a('0xc8'),_0x423a('0xc9'));var _0x7a63b9=path[_0x423a('0xc5')](config[_0x423a('0xc6')],_0x423a('0xc7'),_0x423a('0xc8'),_0x423a('0xca'));var _0x520bd4=path['join'](_0x3c437b,_0x534876);var _0x4ab0da=util[_0x423a('0xba')](_0x423a('0xcb'),_0x2b7a80[_0x423a('0xb2')]['id'],_0x534876);var _0x335909=path[_0x423a('0xc5')](_0x3c437b,_0x4ab0da);var _0xc6c2f0=[];_0xc6c2f0[_0x423a('0x33')]({'model':db[_0x423a('0xcc')],'as':_0x423a('0xcc'),'raw':!![]});var _0x13b9cb=[{'model':db[_0x423a('0xb8')],'as':_0x423a('0xcd'),'attributes':['id',_0x423a('0xb0'),_0x423a('0x73')],'include':_0xc6c2f0}];return db['FaxInteraction'][_0x423a('0x5c')]({'where':{'id':_0x2b7a80[_0x423a('0xb2')]['id']},'include':_0x13b9cb})['then'](handleEntityNotFound(_0x23a2a3,null))[_0x423a('0x27')](function(_0x94e0ec){if(_0x94e0ec&&_0x94e0ec['Messages']){var _0x14c6dd=_0x94e0ec[_0x423a('0xce')]({'plain':!![]});fs[_0x423a('0xcf')](_0x520bd4);for(var _0x1c9f7c=0x0;_0x1c9f7c<_0x14c6dd[_0x423a('0xcd')][_0x423a('0x5b')];_0x1c9f7c++){var _0x2077d7=_0x14c6dd['Messages'][_0x1c9f7c]['Attachment'];if(_0x2077d7){var _0x1f2b38=path['join'](_0x7a63b9,_0x2077d7[_0x423a('0xd0')]);if(fs[_0x423a('0xd1')](_0x1f2b38)){fs['createReadStream'](_0x1f2b38)['pipe'](fs[_0x423a('0xd2')](path['join'](_0x520bd4,_0x2077d7['basename'])));}}}return BPromise[_0x423a('0xd3')]()[_0x423a('0x27')](function(){return new BPromise(function(_0x1764cb,_0x5d64f1){zipdir(_0x520bd4,{'saveTo':_0x335909},function(_0x1f81ac,_0x25f9d8){if(_0x1f81ac)return _0x5d64f1(_0x1f81ac);return _0x1764cb(_0x25f9d8);});})['then'](function(){return new BPromise(function(_0x52a4a9,_0x5b05b0){rimraf(_0x520bd4,function(_0x98b605){if(_0x98b605)_0x5b05b0(_0x98b605);return _0x52a4a9();});});})[_0x423a('0x27')](function(){return _0x23a2a3['download'](_0x335909,_0x4ab0da,function(_0xe4236d){if(_0xe4236d){console[_0x423a('0xd4')]('err',_0xe4236d);}else{fs[_0x423a('0xd5')](_0x335909);}});});});}else{return _0x23a2a3[_0x423a('0x1d')](0xc8);}})[_0x423a('0x34')](handleError(_0x23a2a3,null));};
\ No newline at end of file
+var _0xf7cb=['FaxAccountId','i.FaxAccountId\x20IN\x20?','createdAt','parse','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','null','read','`unreadMessages`\x20=\x200','`unreadMessages`\x20>\x200','isArray','tag','filter','replace','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','group','Sequelize','SELECT','clone','i.id','SUM(me.read\x20=\x200\x20AND\x20me.direction\x20=\x20\x27in\x27)','unreadMessages','contactName','DESC','isEmpty','t.id\x20IN\x20?','i.FaxAccountId\x20IS\x20NOT\x20NULL','role','agent','getFaxAccounts','i.FaxAccountId\x20IS\x20NULL','user','sequelize','toString','keyBy','merge','a.key','a.mandatoryDisposition','Account.mandatoryDisposition','CASE\x20WHEN\x20(c.firstName\x20IS\x20NOT\x20NULL\x20AND\x20c.firstName\x20<>\x20\x27\x27)\x20OR\x20(c.lastName\x20IS\x20NOT\x20NULL\x20AND\x20c.lastName\x20<>\x20\x27\x27)\x20THEN\x20CONCAT(IFNULL(c.firstName,\x20\x27\x27),\x20\x27\x20\x27,\x20IFNULL(c.lastName,\x20\x27\x27))\x20ELSE\x20\x27Unknown\x27\x20END','i.*','c.firstName','Contact.firstName','Contact.lastName','c.email','Contact.email','c.phone','Contact.phone','c.mobile','Contact.mobile','Contact.fax','Owner.fullname','o.internal','GROUP_CONCAT(DISTINCT\x20t.id)','groupBy','FaxInteractionId','all','show','params','includeAll','include','options','create','body','describe','FaxMessage','omit','ids','getMessages','$gte','format','YYYY-MM-DD\x20HH:mm:ss','findAll','rows','addTags','setTags','spread','emit','removeTags','download','unix','root','server','files','tmp','join','attachments','transcript-%d-%s.zip','push','Attachment','Messages','get','mkdirSync','basename','existsSync','createReadStream','pipe','createWriteStream','resolve','log','err','unlinkSync','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','localhost','redis','./faxInteraction.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','save','update','then','destroy','stack','name','send','map','TagIds','split','forEach','Tags','catch','index','FaxInteraction','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','where','pick','select','field','color','from','u.id','u.fullname','ui.FaxInteractionId','user_has_fax_interactions','left_join','users','u.id\x20=\x20ui.UserId','fax_interactions','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','fax_accounts','fax_messages','it.FaxInteractionId\x20=\x20i.id','tools_tags','t.id\x20=\x20it.TagId','expr','search','parseSearch','sqlOperator','conditions','length','find','value','having','`\x20=\x200','`\x20>\x200','Contact','$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?','ContactId','type','text','start','Tag','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','union','User','operator','CONCAT_WS(\x27\x20\x27,\x20o.name,\x20o.fullname)\x20LIKE\x20?','UserId','buildExpression','some','compact'];(function(_0x9d22d8,_0x51c5da){var _0x52afce=function(_0x579845){while(--_0x579845){_0x9d22d8['push'](_0x9d22d8['shift']());}};_0x52afce(++_0x51c5da);}(_0xf7cb,0x67));var _0xbf7c=function(_0x29e090,_0x51b256){_0x29e090=_0x29e090-0x0;var _0x39b72a=_0xf7cb[_0x29e090];return _0x39b72a;};'use strict';var pdf=require(_0xbf7c('0x0'));var emlformat=require(_0xbf7c('0x1'));var rimraf=require(_0xbf7c('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbf7c('0x3'));var rp=require(_0xbf7c('0x4'));var moment=require(_0xbf7c('0x5'));var BPromise=require(_0xbf7c('0x6'));var Mustache=require(_0xbf7c('0x7'));var util=require(_0xbf7c('0x8'));var path=require(_0xbf7c('0x9'));var sox=require(_0xbf7c('0xa'));var csv=require(_0xbf7c('0xb'));var ejs=require(_0xbf7c('0xc'));var fs=require('fs');var _=require(_0xbf7c('0xd'));var squel=require(_0xbf7c('0xe'));var crypto=require(_0xbf7c('0xf'));var jsforce=require(_0xbf7c('0x10'));var deskjs=require(_0xbf7c('0x11'));var toCsv=require(_0xbf7c('0xb'));var querystring=require(_0xbf7c('0x12'));var Papa=require(_0xbf7c('0x13'));var Redis=require('ioredis');var authService=require(_0xbf7c('0x14'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0xbf7c('0x15'))(_0xbf7c('0x16'));var utils=require('../../config/utils');var config=require(_0xbf7c('0x17'));var licenseUtil=require(_0xbf7c('0x18'));var db=require(_0xbf7c('0x19'))['db'];config['redis']=_['defaults'](config['redis'],{'host':_0xbf7c('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xbf7c('0x1b')]));require(_0xbf7c('0x1c'))[_0xbf7c('0x1d')](socket);function respondWithStatusCode(_0x326101,_0x37f64a){_0x37f64a=_0x37f64a||0xcc;return function(_0xfea5dc){if(_0xfea5dc){return _0x326101[_0xbf7c('0x1e')](_0x37f64a);}return _0x326101[_0xbf7c('0x1f')](_0x37f64a)[_0xbf7c('0x20')]();};}function respondWithResult(_0x522203,_0x37d5b4){_0x37d5b4=_0x37d5b4||0xc8;return function(_0x3adc54){if(_0x3adc54){return _0x522203[_0xbf7c('0x1f')](_0x37d5b4)[_0xbf7c('0x21')](_0x3adc54);}};}function respondWithFilteredResult(_0x3b04df,_0x4c427c){return function(_0x48724a){if(_0x48724a){var _0xbf96bd=_0x48724a[_0xbf7c('0x22')],_0x21d814=_0x4c427c[_0xbf7c('0x23')],_0x35e8ac=_0x4c427c['offset']+_0x4c427c[_0xbf7c('0x24')],_0x1e7e8c;if(_0x35e8ac>=_0xbf96bd){_0x35e8ac=_0xbf96bd;_0x1e7e8c=0xc8;}else{_0x1e7e8c=0xce;}_0x3b04df[_0xbf7c('0x1f')](_0x1e7e8c);return _0x3b04df[_0xbf7c('0x25')](_0xbf7c('0x26'),_0x21d814+'-'+_0x35e8ac+'/'+_0xbf96bd)[_0xbf7c('0x21')](_0x48724a);}return null;};}function patchUpdates(_0x321962){return function(_0x530034){try{jsonpatch[_0xbf7c('0x27')](_0x530034,_0x321962,!![]);}catch(_0x141ec8){return BPromise['reject'](_0x141ec8);}return _0x530034[_0xbf7c('0x28')]();};}function saveUpdates(_0x143cfa,_0x3907d8){return function(_0x6c6594){if(_0x6c6594){return _0x6c6594[_0xbf7c('0x29')](_0x143cfa)[_0xbf7c('0x2a')](function(_0x52b7f9){return _0x52b7f9;});}return null;};}function removeEntity(_0x5e82a5,_0x24c167){return function(_0x5545fc){if(_0x5545fc){return _0x5545fc[_0xbf7c('0x2b')]()[_0xbf7c('0x2a')](function(){_0x5e82a5[_0xbf7c('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5be560,_0x56fa0a){return function(_0x40c1c0){if(!_0x40c1c0){_0x5be560[_0xbf7c('0x1e')](0x194);}return _0x40c1c0;};}function handleError(_0x48874e,_0x273243){_0x273243=_0x273243||0x1f4;return function(_0x518b48){logger['error'](_0x518b48[_0xbf7c('0x2c')]);if(_0x518b48[_0xbf7c('0x2d')]){delete _0x518b48['name'];}_0x48874e[_0xbf7c('0x1f')](_0x273243)[_0xbf7c('0x2e')](_0x518b48);};}function getInteractionUsers(_0x1178ba,_0x12eaa1){return new BPromise(function(_0x90aa55,_0x5bf2f0){try{if(_0x12eaa1[_0x1178ba['id']]){_0x1178ba['Users']=_[_0xbf7c('0x2f')](_0x12eaa1[_0x1178ba['id']],function(_0x5d0f8a){return{'id':_0x5d0f8a['id'],'fullname':_0x5d0f8a['fullname']};});}}catch(_0x200e1b){_0x5bf2f0(_0x200e1b);}_0x90aa55(_0x1178ba);});}function getInteractionTags(_0x50f3d3,_0x1fb295){return new BPromise(function(_0x1d9e25,_0x24831f){try{if(_0x50f3d3['TagIds']){_0x50f3d3['Tags']=[];_0x50f3d3[_0xbf7c('0x30')][_0xbf7c('0x31')](',')[_0xbf7c('0x32')](function(_0x518677){_0x50f3d3[_0xbf7c('0x33')]['push'](_0x1fb295[_0x518677]);});}delete _0x50f3d3['TagIds'];}catch(_0x91dc85){_0x24831f(_0x91dc85);}_0x1d9e25(_0x50f3d3);});}function updateFaxInteraction(_0x50e398,_0xc38f78,_0x1550a0){return new BPromise(function(_0x535c0e,_0x2ad0f6){return getInteractionUsers(_0x50e398,_0x1550a0)['then'](function(_0x33ed5c){return getInteractionTags(_0x33ed5c,_0xc38f78);})[_0xbf7c('0x2a')](function(_0x476efe){_0x535c0e(_0x476efe);})[_0xbf7c('0x34')](function(_0xfb5be8){_0x2ad0f6(_0xfb5be8);});});}exports[_0xbf7c('0x35')]=function(_0x329829,_0x16e2d7){var _0x5175d6={},_0x48ab7e={},_0x259dce={'count':0x0,'rows':[]};var _0x9f3abe=_[_0xbf7c('0x2f')](db[_0xbf7c('0x36')][_0xbf7c('0x37')],function(_0x155881){return{'name':_0x155881[_0xbf7c('0x38')],'type':_0x155881['type'][_0xbf7c('0x39')]};});_0x48ab7e[_0xbf7c('0x3a')]=_['map'](_0x9f3abe,'name');_0x48ab7e[_0xbf7c('0x3b')]=_[_0xbf7c('0x3c')](_0x329829[_0xbf7c('0x3b')]);_0x48ab7e[_0xbf7c('0x3d')]=_[_0xbf7c('0x3e')](_0x48ab7e[_0xbf7c('0x3a')],_0x48ab7e['query']);_0x5175d6[_0xbf7c('0x3f')]=_[_0xbf7c('0x3e')](_0x48ab7e['model'],qs[_0xbf7c('0x40')](_0x329829[_0xbf7c('0x3b')]['fields']));_0x5175d6[_0xbf7c('0x3f')]=_0x5175d6['attributes']['length']?_0x5175d6[_0xbf7c('0x3f')]:_0x48ab7e[_0xbf7c('0x3a')];if(!_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x41')](_0xbf7c('0x42'))){_0x5175d6['limit']=qs['limit'](_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x24')]);_0x5175d6[_0xbf7c('0x23')]=qs['offset'](_0x329829['query'][_0xbf7c('0x23')]);}_0x5175d6[_0xbf7c('0x43')]=qs['sort'](_0x329829[_0xbf7c('0x3b')]['sort']);_0x5175d6[_0xbf7c('0x44')]=qs['filters'](_[_0xbf7c('0x45')](_0x329829[_0xbf7c('0x3b')],_0x48ab7e[_0xbf7c('0x3d')]),_0x9f3abe);var _0xffdf47=[];var _0x1a1eaf=squel[_0xbf7c('0x46')]()[_0xbf7c('0x47')]('id')[_0xbf7c('0x47')](_0xbf7c('0x2d'))[_0xbf7c('0x47')](_0xbf7c('0x48'))[_0xbf7c('0x49')]('tools_tags');var _0x17f77b=squel[_0xbf7c('0x46')]()['field'](_0xbf7c('0x4a'))[_0xbf7c('0x47')](_0xbf7c('0x4b'))[_0xbf7c('0x47')](_0xbf7c('0x4c'))[_0xbf7c('0x49')](_0xbf7c('0x4d'),'ui')[_0xbf7c('0x4e')](_0xbf7c('0x4f'),'u',_0xbf7c('0x50'));var _0x1bb1a7=squel[_0xbf7c('0x46')]()[_0xbf7c('0x49')](_0xbf7c('0x51'),'i')[_0xbf7c('0x4e')]('cm_contacts','c',_0xbf7c('0x52'))[_0xbf7c('0x4e')](_0xbf7c('0x4f'),'o',_0xbf7c('0x53'))[_0xbf7c('0x4e')](_0xbf7c('0x54'),'a','a.id\x20=\x20i.FaxAccountId')[_0xbf7c('0x4e')](_0xbf7c('0x55'),'me','me.FaxInteractionId\x20=\x20i.id')['left_join']('fax_interaction_has_tags','it',_0xbf7c('0x56'))[_0xbf7c('0x4e')](_0xbf7c('0x57'),'t',_0xbf7c('0x58'));var _0x4d8964=squel['expr']();var _0x2c33a0=[];var _0x54433d=squel[_0xbf7c('0x59')]();var _0x2bade0;if(_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x5a')]){_0x2bade0=as[_0xbf7c('0x5b')](_0x329829[_0xbf7c('0x3b')]['search']);var _0x54a19d=_0x2bade0[_0xbf7c('0x5c')];for(var _0x37b8d4=0x0;_0x37b8d4<_0x2bade0[_0xbf7c('0x5d')][_0xbf7c('0x5e')];_0x37b8d4++){var _0x37c6b7=_0x2bade0[_0xbf7c('0x5d')][_0x37b8d4];var _0x30ffea='i';var _0x44d089=_[_0xbf7c('0x5f')](_0x9f3abe,['name',_0x37c6b7[_0xbf7c('0x47')]]);if(!_0x44d089){switch(_0x37c6b7[_0xbf7c('0x47')]){case'unreadMessages':if(_0x37c6b7[_0xbf7c('0x60')]==0x1){_0x1bb1a7[_0xbf7c('0x61')]('`'+_0x37c6b7[_0xbf7c('0x47')]+_0xbf7c('0x62'));}else{_0x1bb1a7['having']('`'+_0x37c6b7[_0xbf7c('0x47')]+_0xbf7c('0x63'));}break;case _0xbf7c('0x64'):if(_0x37c6b7['operator']===_0xbf7c('0x65')){if(_0x37c6b7[_0xbf7c('0x60')]['split']('\x20')[_0xbf7c('0x5e')]>0x1){_0x4d8964[_0x54a19d](_0xbf7c('0x66'),qs[_0xbf7c('0x67')](_0x37c6b7[_0xbf7c('0x60')]),null);}else{var _0x352642='%'+_0x37c6b7['value']+'%';_0x4d8964[_0x54a19d](_0xbf7c('0x68'),_0x352642,_0x352642,_0x352642);}}else{_0x44d089=_['find'](_0x9f3abe,[_0xbf7c('0x2d'),_0xbf7c('0x69')]);_0x37c6b7[_0xbf7c('0x47')]=_0xbf7c('0x69');_0x401f6b=as['buildExpression'](_0x30ffea,_0x44d089[_0xbf7c('0x6a')],_0x37c6b7);_0x4d8964[_0x54a19d](_0x401f6b[_0xbf7c('0x6b')],_0x401f6b[_0xbf7c('0x60')][_0xbf7c('0x6c')],_0x401f6b[_0xbf7c('0x60')]['end']);}break;case _0xbf7c('0x6d'):var _0x2554ad=_0x37c6b7[_0xbf7c('0x60')]['split'](',')[_0xbf7c('0x2f')](function(_0x5bbd62){return Number(_0x5bbd62);});_0x2554ad[_0xbf7c('0x32')](function(_0x32798a){_0x54433d['or'](_0xbf7c('0x6e'),'%,'+_0x32798a+',%');});_0x2c33a0=_[_0xbf7c('0x6f')](_0x2c33a0,_0x2554ad);break;case _0xbf7c('0x70'):if(_0x37c6b7[_0xbf7c('0x71')]===_0xbf7c('0x65')){_0x4d8964[_0x54a19d](_0xbf7c('0x72'),'%'+_0x37c6b7['value']+'%',null);}else{_0x44d089=_['find'](_0x9f3abe,[_0xbf7c('0x2d'),_0xbf7c('0x73')]);_0x37c6b7['field']=_0xbf7c('0x73');_0x401f6b=as[_0xbf7c('0x74')](_0x30ffea,_0x44d089[_0xbf7c('0x6a')],_0x37c6b7);_0x4d8964[_0x54a19d](_0x401f6b['text'],_0x401f6b[_0xbf7c('0x60')][_0xbf7c('0x6c')],_0x401f6b['value'][_0xbf7c('0x20')]);}break;case'body':_0x401f6b=as[_0xbf7c('0x74')]('me',null,_0x37c6b7);_0x4d8964[_0x54a19d](_0x401f6b['text'],_0x401f6b['value']['start'],_0x401f6b[_0xbf7c('0x60')][_0xbf7c('0x20')]);break;}}else{var _0x401f6b=as[_0xbf7c('0x74')](_0x30ffea,_0x44d089[_0xbf7c('0x6a')],_0x37c6b7);_0x4d8964[_0x54a19d](_0x401f6b['text'],_0x401f6b[_0xbf7c('0x60')][_0xbf7c('0x6c')],_0x401f6b['value']['end']);}}}else{var _0x5435d5=_(_0x329829[_0xbf7c('0x3b')])[_0xbf7c('0x3c')]()['map'](function(_0x386ecc){return _[_0xbf7c('0x75')](_0x9f3abe,[_0xbf7c('0x2d'),_0x386ecc])?_0x386ecc:undefined;})[_0xbf7c('0x76')]()['value']();if(!_['isEmpty'](_0x5435d5)){_0x5435d5[_0xbf7c('0x32')](function(_0x13ee4c){if(_0x13ee4c===_0xbf7c('0x77')){_0x1bb1a7[_0xbf7c('0x44')](_0xbf7c('0x78'),[]['concat'](_0x329829['query'][_0x13ee4c]));}else if(_0x13ee4c===_0xbf7c('0x79')){var _0xa015ef=JSON[_0xbf7c('0x7a')](_0x329829[_0xbf7c('0x3b')][_0x13ee4c])['$gte'];var _0x128c33=JSON['parse'](_0x329829['query'][_0x13ee4c])[_0xbf7c('0x7b')];_0x1bb1a7['where'](_0xbf7c('0x7c'),_0xa015ef,_0x128c33);}else{if(_0x329829[_0xbf7c('0x3b')][_0x13ee4c]===_0xbf7c('0x7d')){_0x1bb1a7[_0xbf7c('0x44')]('i.'+_0x13ee4c+'\x20IS\x20NULL');}else{_0x1bb1a7['where']('i.'+_0x13ee4c+'\x20=\x20?',_0x329829[_0xbf7c('0x3b')][_0x13ee4c]);}}});}if(_0x329829[_0xbf7c('0x3b')]['read']){if(_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x7e')]==0x1){_0x1bb1a7['having'](_0xbf7c('0x7f'));}else{_0x1bb1a7[_0xbf7c('0x61')](_0xbf7c('0x80'));}}if(_0x329829[_0xbf7c('0x3b')]['tag']){_0x2c33a0=_[_0xbf7c('0x81')](_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x82')])?_0x329829[_0xbf7c('0x3b')]['tag']:new Array(_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x82')]);_0x2c33a0[_0xbf7c('0x32')](function(_0x4113e9){_0x54433d['or'](_0xbf7c('0x6e'),'%,'+_0x4113e9+',%');});}if(_0x329829['query'][_0xbf7c('0x83')]){var _0x15f747=_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x83')][_0xbf7c('0x84')]('\x5c','\x5c\x5c')['replace'](/'/g,'\x27\x27');if(qs['isNumeric'](_0x15f747)){_0x4d8964['or'](_0xbf7c('0x85'),_0x15f747+'%')['or'](_0xbf7c('0x86'),_0x15f747+'%');}_0x4d8964['or']('CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?',_0x15f747+'%');}}_0x1bb1a7['where'](_0x4d8964);_0x1bb1a7[_0xbf7c('0x87')]('i.id');var _0x8db3ab={'type':db[_0xbf7c('0x88')]['QueryTypes'][_0xbf7c('0x89')],'raw':!![]};var _0x5b4c45=_0x1bb1a7[_0xbf7c('0x8a')]();_0x5b4c45[_0xbf7c('0x47')](_0xbf7c('0x8b'));_0x5b4c45[_0xbf7c('0x47')](_0xbf7c('0x8c'),_0xbf7c('0x8d'));if(_0x5175d6[_0xbf7c('0x43')]){_0x5175d6['order']['forEach'](function(_0x398dd1){var _0x3d9262=_0x398dd1[0x0]===_0xbf7c('0x8e')?_0x398dd1[0x0]:'i.'+_0x398dd1[0x0];_0x1bb1a7['order'](_0x3d9262,_0x398dd1[0x1]===_0xbf7c('0x8f')?![]:!![]);});}if(!_[_0xbf7c('0x90')](_0x2c33a0)){_0x1bb1a7[_0xbf7c('0x61')](_0x54433d);_0x5b4c45[_0xbf7c('0x44')](_0xbf7c('0x91'),_0x2c33a0);}BPromise['resolve']()[_0xbf7c('0x2a')](function(){if(!_0x2bade0){if(_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x77')])return;_0x5b4c45['where'](_0xbf7c('0x92'));_0x1bb1a7[_0xbf7c('0x44')](_0xbf7c('0x92'));return;}if(_0x329829['user'][_0xbf7c('0x93')]!==_0xbf7c('0x94'))return;return _0x329829['user'][_0xbf7c('0x95')]({'attributes':['id'],'raw':!![]})[_0xbf7c('0x2a')](function(_0x549399){if(_[_0xbf7c('0x90')](_0x549399)){_0x5b4c45[_0xbf7c('0x44')](_0xbf7c('0x96'));_0x1bb1a7[_0xbf7c('0x44')]('i.FaxAccountId\x20IS\x20NULL');}else{_0x5b4c45['where']('i.FaxAccountId\x20IN\x20?',_[_0xbf7c('0x2f')](_0x549399,'id'));_0x1bb1a7[_0xbf7c('0x44')](_0xbf7c('0x78'),_['map'](_0x549399,'id'));}});})[_0xbf7c('0x2a')](function(){if(_0x329829[_0xbf7c('0x97')][_0xbf7c('0x93')]===_0xbf7c('0x94')&&!_0x2bade0&&!_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x77')])return[];return db[_0xbf7c('0x98')][_0xbf7c('0x3b')](_0x5b4c45[_0xbf7c('0x99')](),_0x8db3ab);})[_0xbf7c('0x2a')](function(_0x556130){_0x259dce['count']=_0x556130[_0xbf7c('0x5e')];if(_0x259dce[_0xbf7c('0x22')]===0x0)return[];return db['sequelize'][_0xbf7c('0x3b')](_0x1a1eaf[_0xbf7c('0x99')](),_0x8db3ab)[_0xbf7c('0x2a')](function(_0x2e0cd9){_0xffdf47=_[_0xbf7c('0x9a')](_0x2e0cd9,'id');_0x8db3ab=_[_0xbf7c('0x9b')](_0x8db3ab,{'model':db[_0xbf7c('0x36')],'mapToModel':!![],'raw':!![],'nest':!![]});if(_0x329829[_0xbf7c('0x3b')][_0xbf7c('0x40')]){_0x5175d6[_0xbf7c('0x3f')][_0xbf7c('0x32')](function(_0x3951c9){_0x1bb1a7[_0xbf7c('0x47')]('i.'+_0x3951c9);});}else{_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0x8c'),_0xbf7c('0x8d'));_0x1bb1a7['field'](_0xbf7c('0x9c'),'Account.key');_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0x9d'),_0xbf7c('0x9e'));_0x1bb1a7['field'](_0xbf7c('0x9f'),_0xbf7c('0x8e'));_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0xa0'));_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0xa1'),_0xbf7c('0xa2'));_0x1bb1a7[_0xbf7c('0x47')]('c.lastName',_0xbf7c('0xa3'));_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0xa4'),_0xbf7c('0xa5'));_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0xa6'),_0xbf7c('0xa7'));_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0xa8'),_0xbf7c('0xa9'));_0x1bb1a7[_0xbf7c('0x47')]('c.fax',_0xbf7c('0xaa'));_0x1bb1a7[_0xbf7c('0x47')]('o.fullname',_0xbf7c('0xab'));_0x1bb1a7['field'](_0xbf7c('0xac'),'Owner.internal');_0x1bb1a7[_0xbf7c('0x47')](_0xbf7c('0xad'),'TagIds');}if(_0x5175d6['limit'])_0x1bb1a7[_0xbf7c('0x24')](_0x5175d6[_0xbf7c('0x24')]);if(_0x5175d6[_0xbf7c('0x23')])_0x1bb1a7[_0xbf7c('0x23')](_0x5175d6[_0xbf7c('0x23')]);return db[_0xbf7c('0x98')]['query'](_0x1bb1a7[_0xbf7c('0x99')](),_0x8db3ab);})['then'](function(_0x1e7189){_0x17f77b[_0xbf7c('0x44')]('ui.FaxInteractionId\x20IN\x20?',_[_0xbf7c('0x2f')](_0x1e7189,'id'));return db[_0xbf7c('0x98')][_0xbf7c('0x3b')](_0x17f77b[_0xbf7c('0x99')](),_0x8db3ab)['then'](function(_0x230884){var _0x5c18d0=_[_0xbf7c('0xae')](_0x230884,_0xbf7c('0xaf'));var _0x2e6dc4=[];_0x1e7189['forEach'](function(_0x55e72c){_0x2e6dc4['push'](updateFaxInteraction(_0x55e72c,_0xffdf47,_0x5c18d0));});return BPromise[_0xbf7c('0xb0')](_0x2e6dc4);});});})[_0xbf7c('0x2a')](function(_0x15b68b){_0x259dce['rows']=_0x15b68b;return _0x259dce;})[_0xbf7c('0x2a')](respondWithFilteredResult(_0x16e2d7,_0x5175d6))['catch'](handleError(_0x16e2d7,null));};exports[_0xbf7c('0xb1')]=function(_0x215c55,_0x48a53c){var _0x286628={'raw':![],'where':{'id':_0x215c55[_0xbf7c('0xb2')]['id']}},_0x4209a9={};_0x4209a9[_0xbf7c('0x3a')]=_['keys'](db[_0xbf7c('0x36')]['rawAttributes']);_0x4209a9['query']=_[_0xbf7c('0x3c')](_0x215c55[_0xbf7c('0x3b')]);_0x4209a9[_0xbf7c('0x3d')]=_[_0xbf7c('0x3e')](_0x4209a9[_0xbf7c('0x3a')],_0x4209a9[_0xbf7c('0x3b')]);_0x286628['attributes']=_[_0xbf7c('0x3e')](_0x4209a9['model'],qs[_0xbf7c('0x40')](_0x215c55[_0xbf7c('0x3b')]['fields']));_0x286628[_0xbf7c('0x3f')]=_0x286628[_0xbf7c('0x3f')][_0xbf7c('0x5e')]?_0x286628['attributes']:_0x4209a9[_0xbf7c('0x3a')];if(_0x215c55[_0xbf7c('0x3b')][_0xbf7c('0xb3')]){_0x286628[_0xbf7c('0xb4')]=[{'all':!![]}];}_0x286628=_[_0xbf7c('0x9b')]({},_0x286628,_0x215c55[_0xbf7c('0xb5')]);return db[_0xbf7c('0x36')][_0xbf7c('0x5f')](_0x286628)[_0xbf7c('0x2a')](handleEntityNotFound(_0x48a53c,null))[_0xbf7c('0x2a')](respondWithResult(_0x48a53c,null))[_0xbf7c('0x34')](handleError(_0x48a53c,null));};exports[_0xbf7c('0xb6')]=function(_0x5f0bb2,_0x14dafa){return db[_0xbf7c('0x36')][_0xbf7c('0xb6')](_0x5f0bb2['body'],{})[_0xbf7c('0x2a')](respondWithResult(_0x14dafa,0xc9))[_0xbf7c('0x34')](handleError(_0x14dafa,null));};exports[_0xbf7c('0x29')]=function(_0x433e70,_0x2926a2){if(_0x433e70[_0xbf7c('0xb7')]['id']){delete _0x433e70[_0xbf7c('0xb7')]['id'];}return db['FaxInteraction'][_0xbf7c('0x5f')]({'where':{'id':_0x433e70[_0xbf7c('0xb2')]['id']}})[_0xbf7c('0x2a')](handleEntityNotFound(_0x2926a2,null))[_0xbf7c('0x2a')](saveUpdates(_0x433e70[_0xbf7c('0xb7')],null))[_0xbf7c('0x2a')](respondWithResult(_0x2926a2,null))['catch'](handleError(_0x2926a2,null));};exports[_0xbf7c('0x2b')]=function(_0xc124a7,_0x573500){return db[_0xbf7c('0x36')][_0xbf7c('0x5f')]({'where':{'id':_0xc124a7[_0xbf7c('0xb2')]['id']}})[_0xbf7c('0x2a')](handleEntityNotFound(_0x573500,null))['then'](removeEntity(_0x573500,null))['catch'](handleError(_0x573500,null));};exports[_0xbf7c('0xb8')]=function(_0x1ad7b4,_0x4f4acc){return db[_0xbf7c('0x36')]['describe']()[_0xbf7c('0x2a')](respondWithResult(_0x4f4acc,null))[_0xbf7c('0x34')](handleError(_0x4f4acc,null));};exports['addMessage']=function(_0x313347,_0x109c97,_0xf94478){return db[_0xbf7c('0xb9')][_0xbf7c('0x5f')]({'where':{'id':_0x313347[_0xbf7c('0xb2')]['id']}})[_0xbf7c('0x2a')](handleEntityNotFound(_0x109c97,null))[_0xbf7c('0x2a')](function(_0x5670fc){if(_0x5670fc){return _0x5670fc['addMessage'](_0x313347['body']['ids'],_[_0xbf7c('0xba')](_0x313347['body'],[_0xbf7c('0xbb'),'id'])||{});}})[_0xbf7c('0x2a')](respondWithResult(_0x109c97,null))['catch'](handleError(_0x109c97,null));};exports[_0xbf7c('0xbc')]=function(_0x49facf,_0x1e7a20,_0x476a1c){var _0x1f00b8={'raw':![],'where':{}};var _0x3e7845={};var _0x3f4118={'count':0x0,'rows':[]};return db[_0xbf7c('0x36')]['findOne']({'where':{'id':_0x49facf[_0xbf7c('0xb2')]['id']}})['then'](handleEntityNotFound(_0x1e7a20,null))[_0xbf7c('0x2a')](function(_0x45d94b){if(_0x45d94b){_0x3e7845['model']=_[_0xbf7c('0x3c')](db[_0xbf7c('0xb9')][_0xbf7c('0x37')]);_0x3e7845[_0xbf7c('0x3b')]=_[_0xbf7c('0x3c')](_0x49facf[_0xbf7c('0x3b')]);_0x3e7845[_0xbf7c('0x3d')]=_[_0xbf7c('0x3e')](_0x3e7845[_0xbf7c('0x3a')],_0x3e7845['query']);_0x1f00b8['attributes']=_[_0xbf7c('0x3e')](_0x3e7845[_0xbf7c('0x3a')],qs[_0xbf7c('0x40')](_0x49facf['query'][_0xbf7c('0x40')]));_0x1f00b8['attributes']=_0x1f00b8[_0xbf7c('0x3f')][_0xbf7c('0x5e')]?_0x1f00b8[_0xbf7c('0x3f')]:_0x3e7845[_0xbf7c('0x3a')];if(!_0x49facf[_0xbf7c('0x3b')][_0xbf7c('0x41')](_0xbf7c('0x42'))){_0x1f00b8['limit']=qs[_0xbf7c('0x24')](_0x49facf[_0xbf7c('0x3b')][_0xbf7c('0x24')]);_0x1f00b8[_0xbf7c('0x23')]=qs[_0xbf7c('0x23')](_0x49facf[_0xbf7c('0x3b')][_0xbf7c('0x23')]);}_0x1f00b8[_0xbf7c('0x43')]=qs['sort'](_0x49facf[_0xbf7c('0x3b')]['sort']);_0x1f00b8[_0xbf7c('0x44')]=qs[_0xbf7c('0x3d')](_[_0xbf7c('0x45')](_0x49facf['query'],_0x3e7845[_0xbf7c('0x3d')]));_0x1f00b8[_0xbf7c('0x44')][_0xbf7c('0xaf')]=_0x45d94b['id'];if(_0x49facf[_0xbf7c('0x3b')][_0xbf7c('0x83')]){_0x1f00b8[_0xbf7c('0x44')]=_[_0xbf7c('0x9b')](_0x1f00b8[_0xbf7c('0x44')],{'$or':_[_0xbf7c('0x2f')](_0x1f00b8[_0xbf7c('0x3f')],function(_0x114b9d){var _0x22b5fd={};_0x22b5fd[_0x114b9d]={'$like':'%'+_0x49facf['query'][_0xbf7c('0x83')]+'%'};return _0x22b5fd;})});}if(_0x49facf[_0xbf7c('0x3b')][_0xbf7c('0xbd')]){var _0x4cb1d8=_0x49facf[_0xbf7c('0x3b')][_0xbf7c('0xbd')][_0xbf7c('0x31')](',');var _0x4f222c={};_0x4f222c[_0x4cb1d8[0x0]]={'$gte':moment(_0x4cb1d8[0x1])[_0xbf7c('0xbe')](_0xbf7c('0xbf'))};_0x1f00b8['where']=_[_0xbf7c('0x9b')](_0x1f00b8['where'],_0x4f222c);}_0x1f00b8=_[_0xbf7c('0x9b')]({},_0x1f00b8,_0x49facf[_0xbf7c('0xb5')]);return db[_0xbf7c('0xb9')][_0xbf7c('0x22')]({'where':_0x1f00b8[_0xbf7c('0x44')]})['then'](function(_0x3bc20d){_0x3f4118[_0xbf7c('0x22')]=_0x3bc20d;if(_0x49facf['query']['includeAll']){_0x1f00b8[_0xbf7c('0xb4')]=[{'all':!![]}];}return db[_0xbf7c('0xb9')][_0xbf7c('0xc0')](_0x1f00b8);})[_0xbf7c('0x2a')](function(_0x5cc57f){_0x3f4118[_0xbf7c('0xc1')]=_0x5cc57f;return _0x3f4118;});}})['then'](respondWithFilteredResult(_0x1e7a20,_0x1f00b8))[_0xbf7c('0x34')](handleError(_0x1e7a20,null));};exports[_0xbf7c('0xc2')]=function(_0x407d9e,_0x78c106,_0x443034){return db[_0xbf7c('0x36')]['find']({'where':{'id':_0x407d9e['params']['id']}})[_0xbf7c('0x2a')](handleEntityNotFound(_0x78c106,null))[_0xbf7c('0x2a')](function(_0x4afd57){if(_0x4afd57){return _0x4afd57[_0xbf7c('0xc3')](_0x407d9e[_0xbf7c('0xb7')][_0xbf7c('0xbb')],_[_0xbf7c('0xba')](_0x407d9e[_0xbf7c('0xb7')],[_0xbf7c('0xbb'),'id'])||{})[_0xbf7c('0xc4')](function(){return db[_0xbf7c('0x6d')][_0xbf7c('0xc0')]({'attributes':['id',_0xbf7c('0x2d'),'color'],'where':{'id':_0x407d9e[_0xbf7c('0xb7')][_0xbf7c('0xbb')]}});})[_0xbf7c('0x2a')](function(_0x34d322){socket[_0xbf7c('0xc5')]('faxInteractionTags:save',{'id':Number(_0x407d9e[_0xbf7c('0xb2')]['id']),'tags':_0x34d322||[]});return{'id':Number(_0x407d9e[_0xbf7c('0xb2')]['id']),'tags':_0x34d322||[]};});}})[_0xbf7c('0x2a')](respondWithResult(_0x78c106,null))[_0xbf7c('0x34')](handleError(_0x78c106,null));};exports[_0xbf7c('0xc6')]=function(_0x21e5d0,_0x539bbd,_0x385276){return db[_0xbf7c('0x36')]['find']({'where':{'id':_0x21e5d0[_0xbf7c('0xb2')]['id']}})[_0xbf7c('0x2a')](handleEntityNotFound(_0x539bbd,null))[_0xbf7c('0x2a')](function(_0x21c537){if(_0x21c537){return _0x21c537['removeTags'](_0x21e5d0[_0xbf7c('0x3b')][_0xbf7c('0xbb')]);}})[_0xbf7c('0x2a')](respondWithStatusCode(_0x539bbd,null))[_0xbf7c('0x34')](handleError(_0x539bbd,null));};exports[_0xbf7c('0xc7')]=function(_0x2df596,_0x3edeb5){var _0x4e37c1=moment()[_0xbf7c('0xc8')]()['toString']();var _0x334005=path['join'](config[_0xbf7c('0xc9')],_0xbf7c('0xca'),_0xbf7c('0xcb'),_0xbf7c('0xcc'));var _0x1dc056=path[_0xbf7c('0xcd')](config['root'],'server',_0xbf7c('0xcb'),_0xbf7c('0xce'));var _0x19dfda=path['join'](_0x334005,_0x4e37c1);var _0x11820b=util['format'](_0xbf7c('0xcf'),_0x2df596[_0xbf7c('0xb2')]['id'],_0x4e37c1);var _0x364a2f=path[_0xbf7c('0xcd')](_0x334005,_0x11820b);var _0x3149a=[];_0x3149a[_0xbf7c('0xd0')]({'model':db[_0xbf7c('0xd1')],'as':_0xbf7c('0xd1'),'raw':!![]});var _0x28e73c=[{'model':db[_0xbf7c('0xb9')],'as':_0xbf7c('0xd2'),'attributes':['id',_0xbf7c('0xb7'),'createdAt'],'include':_0x3149a}];return db[_0xbf7c('0x36')][_0xbf7c('0x5f')]({'where':{'id':_0x2df596['params']['id']},'include':_0x28e73c})[_0xbf7c('0x2a')](handleEntityNotFound(_0x3edeb5,null))[_0xbf7c('0x2a')](function(_0x4d1255){if(_0x4d1255&&_0x4d1255[_0xbf7c('0xd2')]){var _0xb3ad90=_0x4d1255[_0xbf7c('0xd3')]({'plain':!![]});fs[_0xbf7c('0xd4')](_0x19dfda);for(var _0x161985=0x0;_0x161985<_0xb3ad90[_0xbf7c('0xd2')]['length'];_0x161985++){var _0x74028f=_0xb3ad90['Messages'][_0x161985][_0xbf7c('0xd1')];if(_0x74028f){var _0x2297d4=path[_0xbf7c('0xcd')](_0x1dc056,_0x74028f[_0xbf7c('0xd5')]);if(fs[_0xbf7c('0xd6')](_0x2297d4)){fs[_0xbf7c('0xd7')](_0x2297d4)[_0xbf7c('0xd8')](fs[_0xbf7c('0xd9')](path[_0xbf7c('0xcd')](_0x19dfda,_0x74028f[_0xbf7c('0xd5')])));}}}return BPromise[_0xbf7c('0xda')]()[_0xbf7c('0x2a')](function(){return new BPromise(function(_0x341734,_0x3acf76){zipdir(_0x19dfda,{'saveTo':_0x364a2f},function(_0xc6c405,_0x106483){if(_0xc6c405)return _0x3acf76(_0xc6c405);return _0x341734(_0x106483);});})[_0xbf7c('0x2a')](function(){return new BPromise(function(_0x53c7fe,_0x54bfe3){rimraf(_0x19dfda,function(_0x278459){if(_0x278459)_0x54bfe3(_0x278459);return _0x53c7fe();});});})[_0xbf7c('0x2a')](function(){return _0x3edeb5[_0xbf7c('0xc7')](_0x364a2f,_0x11820b,function(_0x35e6d4){if(_0x35e6d4){console[_0xbf7c('0xdb')](_0xbf7c('0xdc'),_0x35e6d4);}else{fs[_0xbf7c('0xdd')](_0x364a2f);}});});});}else{return _0x3edeb5['sendStatus'](0xc8);}})[_0xbf7c('0x34')](handleError(_0x3edeb5,null));};
\ No newline at end of file