Built motion from commit (unavailable).|2.4.2
[motion2.git] / server / api / faxInteraction / faxInteraction.controller.js
index 2274091..01b5ff5 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x2ac2=['map','isNil','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','concat','createdAt','parse','$gte','$lte','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','filter','replace','\x27\x27\x27\x27','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','group','i.id','Sequelize','clone','COUNT(*)','read','%s\x20=\x200','toString','`Messages.count`\x20=\x200','%s\x20>\x200','tag','expr','having','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','t.id\x20IN\x20?','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','mail_interaction_has_tags','it.MailInteractionId\x20=\x20i.id','sequelize','FaxInteraction','a.key','Account.key','i.*','c.firstName','Contact.firstName','Contact.lastName','Contact.email','Contact.phone','Contact.mobile','Contact.fax','u.fullname','User.name','GROUP_CONCAT(DISTINCT\x20t.id)','TagIds','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','Users','Tags','split','push','rows','catch','show','include','merge','options','find','create','body','params','addMessage','FaxMessage','ids','getMessages','findOne','YYYY-MM-DD\x20HH:mm:ss','findAll','addTags','setTags','omit','spread','Tag','emit','removeTags','download','files','join','tmp','Attachment','mkdirSync','basename','existsSync','createReadStream','pipe','createWriteStream','eml-format','zip-dir','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxInteraction.socket','register','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','stack','name','send','index','rawAttributes','model','keys','intersection','query','fields','attributes','hasOwnProperty','nolimit','order','sort','where','filters','pick','select','field','from','tools_tags','fax_messages','me.FaxInteractionId\x20=\x20i.id','me.read\x20=\x20false','u.id','ui.FaxInteractionId','user_has_fax_interactions','left_join','fax_interactions','ui.UserId\x20=\x20i.UserId','users','u.id\x20=\x20ui.UserId','c.id\x20=\x20i.ContactId\x20AND\x20c.deletedAt\x20IS\x20NULL','o.id\x20=\x20i.UserId','fax_accounts','a.id\x20=\x20i.FaxAccountId','advancedFilter','forEach','value','startOf','utc','format','isArray','condition','Messages.count','length','and','tableAlias','LIKE','ContactId','c.lastName','c.email','\x20LIKE\x20?','\x20<\x20?','TagId','\x20IN\x20?','\x20=\x20?','\x20>\x20?'];(function(_0x2c7618,_0x26be9c){var _0x5ce3f0=function(_0x1837b3){while(--_0x1837b3){_0x2c7618['push'](_0x2c7618['shift']());}};_0x5ce3f0(++_0x26be9c);}(_0x2ac2,0x125));var _0x22ac=function(_0x4ab830,_0x19070b){_0x4ab830=_0x4ab830-0x0;var _0x3f3b64=_0x2ac2[_0x4ab830];return _0x3f3b64;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x22ac('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x22ac('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x22ac('0x2'));var Mustache=require(_0x22ac('0x3'));var util=require(_0x22ac('0x4'));var path=require('path');var sox=require(_0x22ac('0x5'));var csv=require(_0x22ac('0x6'));var ejs=require(_0x22ac('0x7'));var fs=require('fs');var _=require(_0x22ac('0x8'));var squel=require(_0x22ac('0x9'));var crypto=require(_0x22ac('0xa'));var jsforce=require(_0x22ac('0xb'));var deskjs=require(_0x22ac('0xc'));var toCsv=require('to-csv');var querystring=require(_0x22ac('0xd'));var Papa=require(_0x22ac('0xe'));var Redis=require(_0x22ac('0xf'));var authService=require(_0x22ac('0x10'));var qs=require(_0x22ac('0x11'));var hardwareService=require(_0x22ac('0x12'));var logger=require(_0x22ac('0x13'))('api');var utils=require('../../config/utils');var config=require(_0x22ac('0x14'));var db=require(_0x22ac('0x15'))['db'];config[_0x22ac('0x16')]=_[_0x22ac('0x17')](config[_0x22ac('0x16')],{'host':_0x22ac('0x18'),'port':0x18eb});var socket=require(_0x22ac('0x19'))(new Redis(config['redis']));require(_0x22ac('0x1a'))[_0x22ac('0x1b')](socket);function respondWithStatusCode(_0xdc519d,_0x11fcf5){_0x11fcf5=_0x11fcf5||0xcc;return function(_0x31ea4f){if(_0x31ea4f){return _0xdc519d[_0x22ac('0x1c')](_0x11fcf5);}return _0xdc519d[_0x22ac('0x1d')](_0x11fcf5)[_0x22ac('0x1e')]();};}function respondWithResult(_0x3b9eb5,_0x3d4a41){_0x3d4a41=_0x3d4a41||0xc8;return function(_0x139f3d){if(_0x139f3d){return _0x3b9eb5[_0x22ac('0x1d')](_0x3d4a41)[_0x22ac('0x1f')](_0x139f3d);}};}function respondWithFilteredResult(_0x7b9449,_0x54ae93){return function(_0x3e6318){if(_0x3e6318){var _0xfbdaca=_0x3e6318[_0x22ac('0x20')],_0xff484e=_0x54ae93[_0x22ac('0x21')],_0x39b24b=_0x54ae93['offset']+_0x54ae93[_0x22ac('0x22')],_0x9bad09;if(_0x39b24b>=_0xfbdaca){_0x39b24b=_0xfbdaca;_0x9bad09=0xc8;}else{_0x9bad09=0xce;}_0x7b9449[_0x22ac('0x1d')](_0x9bad09);return _0x7b9449[_0x22ac('0x23')](_0x22ac('0x24'),_0xff484e+'-'+_0x39b24b+'/'+_0xfbdaca)['json'](_0x3e6318);}return null;};}function patchUpdates(_0x4233f1){return function(_0x1ff58b){try{jsonpatch['apply'](_0x1ff58b,_0x4233f1,!![]);}catch(_0x26a36c){return BPromise[_0x22ac('0x25')](_0x26a36c);}return _0x1ff58b[_0x22ac('0x26')]();};}function saveUpdates(_0x3145ed,_0x137644){return function(_0x4a83e1){if(_0x4a83e1){return _0x4a83e1[_0x22ac('0x27')](_0x3145ed)[_0x22ac('0x28')](function(_0x591373){return _0x591373;});}return null;};}function removeEntity(_0x406cf2,_0x42ca84){return function(_0x312e52){if(_0x312e52){return _0x312e52[_0x22ac('0x29')]()[_0x22ac('0x28')](function(){_0x406cf2['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3fe368,_0x27edaf){return function(_0x48bf0f){if(!_0x48bf0f){_0x3fe368['sendStatus'](0x194);}return _0x48bf0f;};}function handleError(_0x5c552c,_0xbff0f0){_0xbff0f0=_0xbff0f0||0x1f4;return function(_0xc3c87a){logger['error'](_0xc3c87a[_0x22ac('0x2a')]);if(_0xc3c87a[_0x22ac('0x2b')]){delete _0xc3c87a[_0x22ac('0x2b')];}_0x5c552c['status'](_0xbff0f0)[_0x22ac('0x2c')](_0xc3c87a);};}exports[_0x22ac('0x2d')]=function(_0x4166fb,_0x3bb23a){var _0x5959c7={},_0x373e2e={},_0x4229e8={'count':0x0,'rows':[]};var _0x4def50=db['FaxInteraction'][_0x22ac('0x2e')];_0x373e2e[_0x22ac('0x2f')]=_['keys'](_0x4def50);_0x373e2e['query']=_[_0x22ac('0x30')](_0x4166fb['query']);_0x373e2e['filters']=_[_0x22ac('0x31')](_0x373e2e['model'],_0x373e2e[_0x22ac('0x32')]);_0x5959c7['attributes']=_[_0x22ac('0x31')](_0x373e2e[_0x22ac('0x2f')],qs[_0x22ac('0x33')](_0x4166fb[_0x22ac('0x32')]['fields']));_0x5959c7[_0x22ac('0x34')]=_0x5959c7['attributes']['length']?_0x5959c7[_0x22ac('0x34')]:_0x373e2e[_0x22ac('0x2f')];if(!_0x4166fb[_0x22ac('0x32')][_0x22ac('0x35')](_0x22ac('0x36'))){_0x5959c7['limit']=qs[_0x22ac('0x22')](_0x4166fb[_0x22ac('0x32')][_0x22ac('0x22')]);_0x5959c7[_0x22ac('0x21')]=qs['offset'](_0x4166fb['query']['offset']);}_0x5959c7[_0x22ac('0x37')]=qs[_0x22ac('0x38')](_0x4166fb[_0x22ac('0x32')][_0x22ac('0x38')]);_0x5959c7[_0x22ac('0x39')]=qs[_0x22ac('0x3a')](_[_0x22ac('0x3b')](_0x4166fb[_0x22ac('0x32')],_0x373e2e['filters']));var _0x4eee10=[];var _0x55dfa6=squel[_0x22ac('0x3c')]()[_0x22ac('0x3d')]('id')['field'](_0x22ac('0x2b'))[_0x22ac('0x3d')]('color')[_0x22ac('0x3e')](_0x22ac('0x3f'));var _0x24e363=squel['select']()['field']('COUNT(*)')[_0x22ac('0x3e')](_0x22ac('0x40'),'me')[_0x22ac('0x39')](_0x22ac('0x41'))['where']('me.direction\x20=\x20\x27in\x27')[_0x22ac('0x39')](_0x22ac('0x42'));var _0x3a6e0f=squel[_0x22ac('0x3c')]()[_0x22ac('0x3d')](_0x22ac('0x43'))[_0x22ac('0x3d')](_0x22ac('0x44'))[_0x22ac('0x3e')](_0x22ac('0x45'),'ui')[_0x22ac('0x46')]('users','u','u.id\x20=\x20ui.UserId');var _0x210c9e=squel['select']()[_0x22ac('0x3e')](_0x22ac('0x47'),'i')['left_join'](_0x22ac('0x45'),'ui',_0x22ac('0x48'))['left_join'](_0x22ac('0x49'),'u',_0x22ac('0x4a'))[_0x22ac('0x46')]('cm_contacts','c',_0x22ac('0x4b'))[_0x22ac('0x46')](_0x22ac('0x49'),'o',_0x22ac('0x4c'))[_0x22ac('0x46')](_0x22ac('0x4d'),'a',_0x22ac('0x4e'))[_0x22ac('0x46')](_0x22ac('0x40'),'me','me.FaxInteractionId\x20=\x20i.id');var _0x4bcefd=squel['expr']();if(_0x4166fb['query']['advancedFilter']){var _0x3623a3=JSON['parse'](_0x4166fb[_0x22ac('0x32')][_0x22ac('0x4f')]);_['keys'](_0x3623a3)[_0x22ac('0x50')](function(_0x42fc6a){var _0x1ea54c=_0x3623a3[_0x42fc6a];if(_0x42fc6a==='createdAt'){var _0x99a971=moment(_0x1ea54c[_0x22ac('0x51')]['dateStart'])[_0x22ac('0x52')]('day')[_0x22ac('0x53')]()[_0x22ac('0x54')]();var _0x38edd3=moment(_0x38edd3)[_0x22ac('0x53')]()['endOf']('day')[_0x22ac('0x54')]();_0x4bcefd['and']('i.createdAt\x20BETWEEN\x20?\x20AND\x20?',_0x99a971,_0x38edd3);}else{if(_[_0x22ac('0x55')](_0x1ea54c[_0x22ac('0x56')])){_0x1ea54c[_0x22ac('0x56')][_0x22ac('0x50')](function(_0x5819c8){switch(_0x1ea54c[_0x22ac('0x56')][_0x22ac('0x51')]){case'IS':if(_0x42fc6a!=='TagId'&&_0x42fc6a!==_0x22ac('0x57')){if(_['isArray'](_0x1ea54c['value'])&&_0x1ea54c[_0x22ac('0x51')][_0x22ac('0x58')]>0x1){_0x4bcefd[_0x22ac('0x59')](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+'\x20IN\x20?',_0x1ea54c[_0x22ac('0x51')]);}else{_0x4bcefd['and'](_0x1ea54c['tableAlias']+'.'+_0x42fc6a+'\x20=\x20?',_0x1ea54c['value'][0x0]);}}break;case'=':_0x4bcefd[_0x22ac('0x59')](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+'\x20=\x20?',_0x1ea54c[_0x22ac('0x51')]);break;case _0x22ac('0x5b'):if(_0x42fc6a===_0x22ac('0x5c')){_0x4bcefd[_0x22ac('0x59')]('c.firstName'+'\x20LIKE\x20?','%'+_0x1ea54c['value']+'%');_0x4bcefd['or'](_0x22ac('0x5d')+'\x20LIKE\x20?','%'+_0x1ea54c[_0x22ac('0x51')]+'%');_0x4bcefd['or'](_0x22ac('0x5e')+_0x22ac('0x5f'),'%'+_0x1ea54c[_0x22ac('0x51')]+'%');}else{_0x4bcefd[_0x22ac('0x59')](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+'\x20LIKE\x20?','%'+_0x1ea54c[_0x22ac('0x51')]+'%');}break;case'>':_0x4bcefd[_0x22ac('0x59')](_0x1ea54c['tableAlias']+'.'+_0x42fc6a+'\x20>\x20?',_0x1ea54c[_0x22ac('0x51')]);break;case'<':_0x4bcefd['and'](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+_0x22ac('0x60'),_0x1ea54c[_0x22ac('0x51')]);break;}});}else{switch(_0x1ea54c[_0x22ac('0x56')][_0x22ac('0x51')]){case'IS':if(_0x42fc6a!==_0x22ac('0x61')&&_0x42fc6a!==_0x22ac('0x57')){if(_[_0x22ac('0x55')](_0x1ea54c[_0x22ac('0x51')])&&_0x1ea54c['value'][_0x22ac('0x58')]>0x1){_0x4bcefd['and'](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+_0x22ac('0x62'),_0x1ea54c['value']);}else{_0x4bcefd[_0x22ac('0x59')](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+_0x22ac('0x63'),_0x1ea54c[_0x22ac('0x51')][0x0]);}}break;case'=':_0x4bcefd['and'](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+'\x20=\x20?',_0x1ea54c[_0x22ac('0x51')]);break;case _0x22ac('0x5b'):if(_0x42fc6a==='ContactId'){_0x4bcefd['and']('c.firstName'+'\x20LIKE\x20?','%'+_0x1ea54c[_0x22ac('0x51')]+'%');_0x4bcefd['or'](_0x22ac('0x5d')+_0x22ac('0x5f'),'%'+_0x1ea54c['value']+'%');_0x4bcefd['or']('c.email'+_0x22ac('0x5f'),'%'+_0x1ea54c[_0x22ac('0x51')]+'%');}else{_0x4bcefd[_0x22ac('0x59')](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+_0x22ac('0x5f'),'%'+_0x1ea54c[_0x22ac('0x51')]+'%');}break;case'>':_0x4bcefd['and'](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+_0x22ac('0x64'),_0x1ea54c[_0x22ac('0x51')]);break;case'<':_0x4bcefd[_0x22ac('0x59')](_0x1ea54c[_0x22ac('0x5a')]+'.'+_0x42fc6a+'\x20<\x20?',_0x1ea54c[_0x22ac('0x51')]);break;}}}});}else{var _0x159e60=_(Object['keys'](_0x4166fb['query']))[_0x22ac('0x65')](function(_0x308611){return _0x4def50[_0x22ac('0x35')](_0x308611)?_0x308611:undefined;})['filter'](function(_0x28c20b){return!_[_0x22ac('0x66')](_0x28c20b);})[_0x22ac('0x51')]();if(!_[_0x22ac('0x67')](_0x159e60)){_0x159e60[_0x22ac('0x50')](function(_0x37a691){if(_0x37a691===_0x22ac('0x68')){_0x210c9e[_0x22ac('0x39')](_0x22ac('0x69'),[][_0x22ac('0x6a')](_0x4166fb[_0x22ac('0x32')][_0x37a691]));}else if(_0x37a691===_0x22ac('0x6b')){var _0x3e1e2a=JSON[_0x22ac('0x6c')](_0x4166fb[_0x22ac('0x32')][_0x37a691])[_0x22ac('0x6d')];var _0x12a237=JSON[_0x22ac('0x6c')](_0x4166fb[_0x22ac('0x32')][_0x37a691])[_0x22ac('0x6e')];_0x210c9e['where'](_0x22ac('0x6f'),_0x3e1e2a,_0x12a237);}else{_0x210c9e[_0x22ac('0x39')]('i.'+_0x37a691+_0x22ac('0x63'),_0x4166fb[_0x22ac('0x32')][_0x37a691]);}});}if(_0x4166fb[_0x22ac('0x32')][_0x22ac('0x70')]){var _0x6cb48e=_0x4166fb[_0x22ac('0x32')][_0x22ac('0x70')][_0x22ac('0x71')]('\x5c','\x5c\x5c')[_0x22ac('0x71')]('\x27\x27',_0x22ac('0x72'));if(qs[_0x22ac('0x73')](_0x6cb48e)){_0x4bcefd['or'](_0x22ac('0x74'),_0x6cb48e+'%')['or'](_0x22ac('0x75'),_0x6cb48e+'%');}_0x4bcefd['or'](_0x22ac('0x76'),_0x6cb48e+'%');}}_0x210c9e[_0x22ac('0x39')](_0x4bcefd);if(_0x5959c7[_0x22ac('0x37')]){_0x5959c7['order'][_0x22ac('0x50')](function(_0x3e7707){_0x210c9e['order']('i.'+_0x3e7707[0x0],_0x3e7707[0x1]==='DESC'?![]:!![]);});}_0x210c9e[_0x22ac('0x77')](_0x22ac('0x78'));var _0x4b1339={'type':db[_0x22ac('0x79')]['QueryTypes']['SELECT'],'raw':!![]};var _0x333a02=_0x210c9e[_0x22ac('0x7a')]()['field'](_0x22ac('0x7b'));if(!_0x4166fb['query'][_0x22ac('0x4f')]){if(_0x4166fb[_0x22ac('0x32')][_0x22ac('0x7c')]){if(_0x4166fb[_0x22ac('0x32')][_0x22ac('0x7c')]==0x1){_0x333a02['where'](util[_0x22ac('0x54')](_0x22ac('0x7d'),_0x24e363[_0x22ac('0x7e')]()));_0x210c9e['having'](_0x22ac('0x7f'));}else{_0x333a02[_0x22ac('0x39')](util[_0x22ac('0x54')](_0x22ac('0x80'),_0x24e363[_0x22ac('0x7e')]()));_0x210c9e['having']('`Messages.count`\x20>\x200');}}if(_0x4166fb[_0x22ac('0x32')][_0x22ac('0x81')]){var _0xe43108=_['isArray'](_0x4166fb['query']['tag'])?_0x4166fb[_0x22ac('0x32')][_0x22ac('0x81')]:new Array(_0x4166fb[_0x22ac('0x32')]['tag']);var _0x50d92a=squel[_0x22ac('0x82')]();_0xe43108['forEach'](function(_0x55faa){_0x50d92a['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x55faa+',%');});_0x210c9e[_0x22ac('0x83')](_0x50d92a);_0x333a02[_0x22ac('0x46')](_0x22ac('0x84'),'it',_0x22ac('0x85'));_0x333a02[_0x22ac('0x46')](_0x22ac('0x3f'),'t',_0x22ac('0x86'));_0x333a02['where'](_0x22ac('0x87'),_0xe43108);}}else{var _0x3623a3=JSON[_0x22ac('0x6c')](_0x4166fb[_0x22ac('0x32')]['advancedFilter']);_[_0x22ac('0x30')](_0x3623a3)['forEach'](function(_0x45a644){var _0x21ad06=_0x3623a3[_0x45a644];if(_0x45a644===_0x22ac('0x61')){var _0x48aa2e=_0x21ad06[_0x22ac('0x51')];var _0x44e9db=squel[_0x22ac('0x82')]();_0x48aa2e[_0x22ac('0x50')](function(_0x311978){_0x44e9db['or'](_0x22ac('0x88'),'%,'+_0x311978+',%');});_0x210c9e[_0x22ac('0x83')](_0x44e9db);_0x333a02[_0x22ac('0x46')](_0x22ac('0x89'),'it',_0x22ac('0x8a'));_0x333a02[_0x22ac('0x46')](_0x22ac('0x3f'),'t',_0x22ac('0x86'));_0x333a02[_0x22ac('0x39')]('t.id\x20IN\x20?',_0x48aa2e);}else if(_0x45a644===_0x22ac('0x57')){if(_0x21ad06[_0x22ac('0x51')]['length']===0x1){if(_0x21ad06['value'][0x0]===0x1){_0x333a02[_0x22ac('0x39')](util[_0x22ac('0x54')](_0x22ac('0x7d'),_0x24e363[_0x22ac('0x7e')]()));_0x210c9e[_0x22ac('0x83')](_0x22ac('0x7f'));}else{_0x333a02[_0x22ac('0x39')](util['format'](_0x22ac('0x80'),_0x24e363[_0x22ac('0x7e')]()));_0x210c9e[_0x22ac('0x83')]('`Messages.count`\x20>\x200');}}}});}db[_0x22ac('0x8b')]['query'](_0x333a02[_0x22ac('0x7e')](),_0x4b1339)[_0x22ac('0x28')](function(_0x3535b2){_0x4229e8[_0x22ac('0x20')]=_0x3535b2[_0x22ac('0x58')];if(_0x4229e8[_0x22ac('0x20')]===0x0)return[];return db['sequelize'][_0x22ac('0x32')](_0x55dfa6[_0x22ac('0x7e')](),_0x4b1339)[_0x22ac('0x28')](function(_0x347eeb){_0x4eee10=_['keyBy'](_0x347eeb,'id');_0x4b1339=_['merge'](_0x4b1339,{'model':db[_0x22ac('0x8c')],'mapToModel':!![],'raw':!![],'nest':!![]});_0x210c9e[_0x22ac('0x3d')](_0x24e363,'Messages.count');_0x210c9e[_0x22ac('0x3d')](_0x22ac('0x8d'),_0x22ac('0x8e'));_0x210c9e[_0x22ac('0x3d')](_0x22ac('0x8f'));_0x210c9e[_0x22ac('0x3d')](_0x22ac('0x90'),_0x22ac('0x91'));_0x210c9e[_0x22ac('0x3d')](_0x22ac('0x5d'),_0x22ac('0x92'));_0x210c9e[_0x22ac('0x3d')](_0x22ac('0x5e'),_0x22ac('0x93'));_0x210c9e['field']('c.phone',_0x22ac('0x94'));_0x210c9e[_0x22ac('0x3d')]('c.mobile',_0x22ac('0x95'));_0x210c9e[_0x22ac('0x3d')]('c.fax',_0x22ac('0x96'));_0x210c9e[_0x22ac('0x3d')](_0x22ac('0x97'),_0x22ac('0x98'));_0x210c9e['field'](_0x22ac('0x99'),_0x22ac('0x9a'));_0x210c9e[_0x22ac('0x46')](_0x22ac('0x84'),'it',_0x22ac('0x85'));_0x210c9e['left_join'](_0x22ac('0x3f'),'t','t.id\x20=\x20it.TagId');_0x210c9e['limit'](_0x5959c7['limit']);_0x210c9e[_0x22ac('0x21')](_0x5959c7[_0x22ac('0x21')]);return db[_0x22ac('0x8b')]['query'](_0x210c9e[_0x22ac('0x7e')](),_0x4b1339);})[_0x22ac('0x28')](function(_0x34c84e){_0x3a6e0f[_0x22ac('0x39')](_0x22ac('0x9b'),_['map'](_0x34c84e,'id'));return db[_0x22ac('0x8b')][_0x22ac('0x32')](_0x3a6e0f[_0x22ac('0x7e')](),_0x4b1339)[_0x22ac('0x28')](function(_0x26504d){var _0x2b6d6b=_[_0x22ac('0x9c')](_0x26504d,_0x22ac('0x9d'));_0x34c84e[_0x22ac('0x50')](function(_0x160880){if(_0x2b6d6b[_0x160880['id']]){_0x160880[_0x22ac('0x9e')]=_['map'](_0x2b6d6b[_0x160880['id']],function(_0x187f42){return{'id':_0x187f42['id']};});}if(_0x160880['TagIds']){_0x160880[_0x22ac('0x9f')]=[];_0x160880[_0x22ac('0x9a')][_0x22ac('0xa0')](',')['forEach'](function(_0x23ba62){_0x160880[_0x22ac('0x9f')][_0x22ac('0xa1')](_0x4eee10[_0x23ba62]);});}delete _0x160880['TagIds'];});return _0x34c84e;});});})[_0x22ac('0x28')](function(_0x26fb70){_0x4229e8[_0x22ac('0xa2')]=_0x26fb70;return _0x4229e8;})['then'](respondWithFilteredResult(_0x3bb23a,_0x5959c7))[_0x22ac('0xa3')](handleError(_0x3bb23a,null));};exports[_0x22ac('0xa4')]=function(_0x243560,_0x2c6d34){var _0xb87b97={'raw':![],'where':{'id':_0x243560['params']['id']}},_0x240979={};_0x240979[_0x22ac('0x2f')]=_[_0x22ac('0x30')](db['FaxInteraction'][_0x22ac('0x2e')]);_0x240979['query']=_[_0x22ac('0x30')](_0x243560[_0x22ac('0x32')]);_0x240979[_0x22ac('0x3a')]=_[_0x22ac('0x31')](_0x240979[_0x22ac('0x2f')],_0x240979[_0x22ac('0x32')]);_0xb87b97[_0x22ac('0x34')]=_[_0x22ac('0x31')](_0x240979[_0x22ac('0x2f')],qs[_0x22ac('0x33')](_0x243560[_0x22ac('0x32')][_0x22ac('0x33')]));_0xb87b97[_0x22ac('0x34')]=_0xb87b97[_0x22ac('0x34')][_0x22ac('0x58')]?_0xb87b97[_0x22ac('0x34')]:_0x240979['model'];if(_0x243560[_0x22ac('0x32')]['includeAll']){_0xb87b97[_0x22ac('0xa5')]=[{'all':!![]}];}_0xb87b97=_[_0x22ac('0xa6')]({},_0xb87b97,_0x243560[_0x22ac('0xa7')]);return db[_0x22ac('0x8c')][_0x22ac('0xa8')](_0xb87b97)[_0x22ac('0x28')](handleEntityNotFound(_0x2c6d34,null))[_0x22ac('0x28')](respondWithResult(_0x2c6d34,null))[_0x22ac('0xa3')](handleError(_0x2c6d34,null));};exports[_0x22ac('0xa9')]=function(_0x4fb7e4,_0x24aed9){return db[_0x22ac('0x8c')][_0x22ac('0xa9')](_0x4fb7e4[_0x22ac('0xaa')],{})[_0x22ac('0x28')](respondWithResult(_0x24aed9,0xc9))[_0x22ac('0xa3')](handleError(_0x24aed9,null));};exports[_0x22ac('0x27')]=function(_0x1ebc42,_0x50c575){if(_0x1ebc42[_0x22ac('0xaa')]['id']){delete _0x1ebc42[_0x22ac('0xaa')]['id'];}return db[_0x22ac('0x8c')][_0x22ac('0xa8')]({'where':{'id':_0x1ebc42[_0x22ac('0xab')]['id']}})['then'](handleEntityNotFound(_0x50c575,null))[_0x22ac('0x28')](saveUpdates(_0x1ebc42[_0x22ac('0xaa')],null))[_0x22ac('0x28')](respondWithResult(_0x50c575,null))['catch'](handleError(_0x50c575,null));};exports['destroy']=function(_0x139b40,_0x25b660){return db['FaxInteraction'][_0x22ac('0xa8')]({'where':{'id':_0x139b40[_0x22ac('0xab')]['id']}})[_0x22ac('0x28')](handleEntityNotFound(_0x25b660,null))[_0x22ac('0x28')](removeEntity(_0x25b660,null))[_0x22ac('0xa3')](handleError(_0x25b660,null));};exports['describe']=function(_0x50fcb9,_0x150e34){return db['FaxInteraction']['describe']()[_0x22ac('0x28')](respondWithResult(_0x150e34,null))[_0x22ac('0xa3')](handleError(_0x150e34,null));};exports[_0x22ac('0xac')]=function(_0x563abb,_0x35bc7d,_0x550935){return db[_0x22ac('0xad')][_0x22ac('0xa8')]({'where':{'id':_0x563abb[_0x22ac('0xab')]['id']}})[_0x22ac('0x28')](handleEntityNotFound(_0x35bc7d,null))[_0x22ac('0x28')](function(_0x482289){if(_0x482289){return _0x482289['addMessage'](_0x563abb[_0x22ac('0xaa')]['ids'],_['omit'](_0x563abb[_0x22ac('0xaa')],[_0x22ac('0xae'),'id'])||{});}})[_0x22ac('0x28')](respondWithResult(_0x35bc7d,null))[_0x22ac('0xa3')](handleError(_0x35bc7d,null));};exports[_0x22ac('0xaf')]=function(_0x189a89,_0x4966d8,_0x4b4ce0){var _0x2b32da={'raw':![],'where':{}};var _0x1a2736={};var _0x2661ed={'count':0x0,'rows':[]};return db[_0x22ac('0x8c')][_0x22ac('0xb0')]({'where':{'id':_0x189a89[_0x22ac('0xab')]['id']}})[_0x22ac('0x28')](handleEntityNotFound(_0x4966d8,null))[_0x22ac('0x28')](function(_0x183e0f){if(_0x183e0f){_0x1a2736['model']=_['keys'](db[_0x22ac('0xad')]['rawAttributes']);_0x1a2736[_0x22ac('0x32')]=_[_0x22ac('0x30')](_0x189a89['query']);_0x1a2736[_0x22ac('0x3a')]=_[_0x22ac('0x31')](_0x1a2736[_0x22ac('0x2f')],_0x1a2736['query']);_0x2b32da[_0x22ac('0x34')]=_['intersection'](_0x1a2736[_0x22ac('0x2f')],qs[_0x22ac('0x33')](_0x189a89[_0x22ac('0x32')][_0x22ac('0x33')]));_0x2b32da[_0x22ac('0x34')]=_0x2b32da[_0x22ac('0x34')][_0x22ac('0x58')]?_0x2b32da[_0x22ac('0x34')]:_0x1a2736[_0x22ac('0x2f')];if(!_0x189a89[_0x22ac('0x32')][_0x22ac('0x35')]('nolimit')){_0x2b32da['limit']=qs[_0x22ac('0x22')](_0x189a89[_0x22ac('0x32')][_0x22ac('0x22')]);_0x2b32da['offset']=qs['offset'](_0x189a89[_0x22ac('0x32')][_0x22ac('0x21')]);}_0x2b32da['order']=qs[_0x22ac('0x38')](_0x189a89[_0x22ac('0x32')][_0x22ac('0x38')]);_0x2b32da['where']=qs[_0x22ac('0x3a')](_['pick'](_0x189a89[_0x22ac('0x32')],_0x1a2736['filters']));_0x2b32da[_0x22ac('0x39')]['FaxInteractionId']=_0x183e0f['id'];if(_0x189a89['query']['filter']){_0x2b32da[_0x22ac('0x39')]=_['merge'](_0x2b32da[_0x22ac('0x39')],{'$or':_[_0x22ac('0x65')](_0x2b32da[_0x22ac('0x34')],function(_0x323a0d){var _0x1041c1={};_0x1041c1[_0x323a0d]={'$like':'%'+_0x189a89[_0x22ac('0x32')][_0x22ac('0x70')]+'%'};return _0x1041c1;})});}if(_0x189a89[_0x22ac('0x32')][_0x22ac('0x6d')]){var _0x3ddc40=_0x189a89[_0x22ac('0x32')][_0x22ac('0x6d')][_0x22ac('0xa0')](',');var _0x4b73d9={};_0x4b73d9[_0x3ddc40[0x0]]={'$gte':moment(_0x3ddc40[0x1])[_0x22ac('0x54')](_0x22ac('0xb1'))};_0x2b32da[_0x22ac('0x39')]=_[_0x22ac('0xa6')](_0x2b32da['where'],_0x4b73d9);}_0x2b32da=_['merge']({},_0x2b32da,_0x189a89[_0x22ac('0xa7')]);return db[_0x22ac('0xad')]['count']({'where':_0x2b32da[_0x22ac('0x39')]})[_0x22ac('0x28')](function(_0x11b8a0){_0x2661ed[_0x22ac('0x20')]=_0x11b8a0;if(_0x189a89[_0x22ac('0x32')]['includeAll']){_0x2b32da[_0x22ac('0xa5')]=[{'all':!![]}];}return db[_0x22ac('0xad')][_0x22ac('0xb2')](_0x2b32da);})['then'](function(_0x2927c4){_0x2661ed[_0x22ac('0xa2')]=_0x2927c4;return _0x2661ed;});}})[_0x22ac('0x28')](respondWithFilteredResult(_0x4966d8,_0x2b32da))[_0x22ac('0xa3')](handleError(_0x4966d8,null));};exports[_0x22ac('0xb3')]=function(_0x3bd597,_0x1b86ce,_0x3dbf2a){return db[_0x22ac('0x8c')][_0x22ac('0xa8')]({'where':{'id':_0x3bd597[_0x22ac('0xab')]['id']}})[_0x22ac('0x28')](handleEntityNotFound(_0x1b86ce,null))['then'](function(_0x416fa0){if(_0x416fa0){return _0x416fa0[_0x22ac('0xb4')](_0x3bd597[_0x22ac('0xaa')][_0x22ac('0xae')],_[_0x22ac('0xb5')](_0x3bd597[_0x22ac('0xaa')],[_0x22ac('0xae'),'id'])||{})[_0x22ac('0xb6')](function(){return db[_0x22ac('0xb7')][_0x22ac('0xb2')]({'attributes':['id',_0x22ac('0x2b'),'color'],'where':{'id':_0x3bd597[_0x22ac('0xaa')][_0x22ac('0xae')]}});})['then'](function(_0xdff344){socket[_0x22ac('0xb8')]('faxInteractionTags:save',{'id':Number(_0x3bd597[_0x22ac('0xab')]['id']),'tags':_0xdff344||[]});return{'id':Number(_0x3bd597[_0x22ac('0xab')]['id']),'tags':_0xdff344||[]};});}})[_0x22ac('0x28')](respondWithResult(_0x1b86ce,null))['catch'](handleError(_0x1b86ce,null));};exports['removeTags']=function(_0x1d1fec,_0x378427,_0x848a89){return db[_0x22ac('0x8c')][_0x22ac('0xa8')]({'where':{'id':_0x1d1fec[_0x22ac('0xab')]['id']}})['then'](handleEntityNotFound(_0x378427,null))[_0x22ac('0x28')](function(_0x3f2f71){if(_0x3f2f71){return _0x3f2f71[_0x22ac('0xb9')](_0x1d1fec['query'][_0x22ac('0xae')]);}})[_0x22ac('0x28')](respondWithStatusCode(_0x378427,null))[_0x22ac('0xa3')](handleError(_0x378427,null));};exports[_0x22ac('0xba')]=function(_0x4d38ef,_0x1b8067){var _0x16b759=moment()['unix']()[_0x22ac('0x7e')]();var _0x406296=path['join'](config['root'],'server',_0x22ac('0xbb'),'attachments');var _0x56d69f=path[_0x22ac('0xbc')](config['root'],'server',_0x22ac('0xbb'),_0x22ac('0xbd'));var _0x133c2f=path[_0x22ac('0xbc')](_0x56d69f,_0x16b759);var _0x54665b=util[_0x22ac('0x54')]('interaction-%s.zip',_0x16b759);var _0x34a4ed=path[_0x22ac('0xbc')](_0x56d69f,_0x54665b);var _0xf0870c=![];return db[_0x22ac('0x8c')][_0x22ac('0xa8')]({'where':{'id':_0x4d38ef[_0x22ac('0xab')]['id']}})[_0x22ac('0x28')](handleEntityNotFound(_0x1b8067,null))[_0x22ac('0x28')](function(_0x15d72a){if(_0x15d72a){return _0x15d72a[_0x22ac('0xaf')]({'attributes':['id',_0x22ac('0xaa'),_0x22ac('0x6b')],'include':[{'model':db[_0x22ac('0xbe')],'as':'Attachment'}]});}return[];})[_0x22ac('0x28')](function(_0x645fe8){_0xf0870c=_0x645fe8[_0x22ac('0x58')];if(_0x645fe8['length']){fs[_0x22ac('0xbf')](_0x133c2f);for(var _0x102be5=0x0;_0x102be5<_0x645fe8['length'];_0x102be5++){var _0xb1a5a1=_0x645fe8[_0x102be5];var _0x2a54f4=_0xb1a5a1[_0x22ac('0xbe')];if(_0x2a54f4){var _0x3005a7=path[_0x22ac('0xbc')](_0x406296,_0x2a54f4[_0x22ac('0xc0')]);if(fs[_0x22ac('0xc1')](_0x3005a7)){fs[_0x22ac('0xc2')](_0x3005a7)[_0x22ac('0xc3')](fs[_0x22ac('0xc4')](path['join'](_0x133c2f,_0x2a54f4[_0x22ac('0xc0')])));}}}}})[_0x22ac('0x28')](function(){if(_0xf0870c){return new BPromise(function(_0x143eaf,_0x14b2a8){zipdir(_0x133c2f,{'saveTo':_0x34a4ed},function(_0x2852df,_0x13dc69){if(_0x2852df)return _0x14b2a8(_0x2852df);return _0x143eaf(_0x13dc69);});});}})[_0x22ac('0x28')](function(){if(_0xf0870c){return new BPromise(function(_0x148de0,_0x296905){rimraf(_0x133c2f,function(_0x3aa60c){if(_0x3aa60c)_0x296905(_0x3aa60c);return _0x148de0();});});}})[_0x22ac('0x28')](function(){if(_0xf0870c){return _0x1b8067[_0x22ac('0xba')](_0x34a4ed,_0x54665b,function(_0x42ad8b){if(_0x42ad8b){console['log']('err',_0x42ad8b);}else{fs['unlinkSync'](_0x34a4ed);}});}else{return _0x1b8067[_0x22ac('0x1c')](0xc8);}})[_0x22ac('0xa3')](handleError(_0x1b8067,null));};
\ No newline at end of file
+var _0x9bde=['include','findAll','addTags','ids','spread','Tag','faxInteractionTags:save','removeTags','download','unix','join','root','server','files','interaction-%s.zip','Attachment','mkdirSync','basename','createReadStream','pipe','createWriteStream','log','err','unlinkSync','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../config/license/hardware','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','localhost','./faxInteraction.socket','register','sendStatus','status','end','json','offset','limit','set','Content-Range','apply','save','then','destroy','error','name','send','unreadMessages','count','Users','map','TagIds','Tags','push','catch','rawAttributes','model','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','select','field','color','from','tools_tags','COUNT(*)','me.FaxInteractionId\x20=\x20i.id','me.direction\x20=\x20\x27in\x27','me.read\x20=\x20false','u.id','ui.FaxInteractionId','user_has_fax_interactions','left_join','users','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','expr','advancedFilter','forEach','createdAt','value','startOf','day','format','utc','endOf','and','i.createdAt\x20BETWEEN\x20?\x20AND\x20?','isArray','condition','TagId','Messages.count','tableAlias','\x20IN\x20?','\x20=\x20?','LIKE','ContactId','c.firstName','\x20LIKE\x20?','c.lastName','c.email','\x20>\x20?','isEmpty','FaxAccountId','i.FaxAccountId\x20IN\x20?','concat','parse','$lte','null','\x20IS\x20NULL','replace','isNumeric','i.id\x20LIKE\x20?','i.fax\x20LIKE\x20?','CONCAT(c.firstName,\x20\x27\x20\x27,\x20c.lastName)\x20LIKE\x20?','DESC','group','i.id','Sequelize','SELECT','clone','read','%s\x20=\x200','toString','having','`Messages.count`\x20=\x200','%s\x20>\x200','`Messages.count`\x20>\x200','tag','fax_interaction_has_tags','it.FaxInteractionId\x20=\x20i.id','t.id\x20=\x20it.TagId','CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','mail_interaction_has_tags','it.MailInteractionId\x20=\x20i.id','sequelize','FaxInteraction','a.key','Account.key','Contact.firstName','Contact.lastName','Contact.email','c.phone','Contact.phone','c.mobile','ui.FaxInteractionId\x20IN\x20?','groupBy','FaxInteractionId','all','rows','params','merge','options','create','body','find','describe','addMessage','FaxMessage','omit','getMessages','findOne','filter','split','YYYY-MM-DD\x20HH:mm:ss','includeAll'];(function(_0x5517c0,_0x358609){var _0x33803b=function(_0x513c18){while(--_0x513c18){_0x5517c0['push'](_0x5517c0['shift']());}};_0x33803b(++_0x358609);}(_0x9bde,0xe1));var _0xe9bd=function(_0x114f73,_0x21d7a6){_0x114f73=_0x114f73-0x0;var _0x49463e=_0x9bde[_0x114f73];return _0x49463e;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xe9bd('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe9bd('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe9bd('0x2'));var moment=require(_0xe9bd('0x3'));var BPromise=require(_0xe9bd('0x4'));var Mustache=require(_0xe9bd('0x5'));var util=require(_0xe9bd('0x6'));var path=require(_0xe9bd('0x7'));var sox=require(_0xe9bd('0x8'));var csv=require('to-csv');var ejs=require(_0xe9bd('0x9'));var fs=require('fs');var _=require(_0xe9bd('0xa'));var squel=require(_0xe9bd('0xb'));var crypto=require(_0xe9bd('0xc'));var jsforce=require(_0xe9bd('0xd'));var deskjs=require(_0xe9bd('0xe'));var toCsv=require(_0xe9bd('0xf'));var querystring=require(_0xe9bd('0x10'));var Papa=require(_0xe9bd('0x11'));var Redis=require(_0xe9bd('0x12'));var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var hardwareService=require(_0xe9bd('0x13'));var logger=require(_0xe9bd('0x14'))(_0xe9bd('0x15'));var utils=require('../../config/utils');var config=require(_0xe9bd('0x16'));var db=require(_0xe9bd('0x17'))['db'];config[_0xe9bd('0x18')]=_[_0xe9bd('0x19')](config['redis'],{'host':_0xe9bd('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xe9bd('0x18')]));require(_0xe9bd('0x1b'))[_0xe9bd('0x1c')](socket);function respondWithStatusCode(_0x51109f,_0x47ba5e){_0x47ba5e=_0x47ba5e||0xcc;return function(_0x46a95e){if(_0x46a95e){return _0x51109f[_0xe9bd('0x1d')](_0x47ba5e);}return _0x51109f[_0xe9bd('0x1e')](_0x47ba5e)[_0xe9bd('0x1f')]();};}function respondWithResult(_0x3360bd,_0x389e7b){_0x389e7b=_0x389e7b||0xc8;return function(_0x45a9f2){if(_0x45a9f2){return _0x3360bd['status'](_0x389e7b)[_0xe9bd('0x20')](_0x45a9f2);}};}function respondWithFilteredResult(_0x464a1b,_0x160281){return function(_0x494b27){if(_0x494b27){var _0x36f03d=_0x494b27['count'],_0x3bae08=_0x160281[_0xe9bd('0x21')],_0x34ba2b=_0x160281['offset']+_0x160281[_0xe9bd('0x22')],_0x330733;if(_0x34ba2b>=_0x36f03d){_0x34ba2b=_0x36f03d;_0x330733=0xc8;}else{_0x330733=0xce;}_0x464a1b['status'](_0x330733);return _0x464a1b[_0xe9bd('0x23')](_0xe9bd('0x24'),_0x3bae08+'-'+_0x34ba2b+'/'+_0x36f03d)[_0xe9bd('0x20')](_0x494b27);}return null;};}function patchUpdates(_0x3dda13){return function(_0x1acb82){try{jsonpatch[_0xe9bd('0x25')](_0x1acb82,_0x3dda13,!![]);}catch(_0x6593ce){return BPromise['reject'](_0x6593ce);}return _0x1acb82[_0xe9bd('0x26')]();};}function saveUpdates(_0x28cd17,_0x4ecaf5){return function(_0x37aec1){if(_0x37aec1){return _0x37aec1['update'](_0x28cd17)[_0xe9bd('0x27')](function(_0x1b9cc9){return _0x1b9cc9;});}return null;};}function removeEntity(_0x36f8c0,_0xf02209){return function(_0x5bc4bf){if(_0x5bc4bf){return _0x5bc4bf[_0xe9bd('0x28')]()[_0xe9bd('0x27')](function(){_0x36f8c0[_0xe9bd('0x1e')](0xcc)[_0xe9bd('0x1f')]();});}};}function handleEntityNotFound(_0x2641be,_0xb52d45){return function(_0x399f3c){if(!_0x399f3c){_0x2641be[_0xe9bd('0x1d')](0x194);}return _0x399f3c;};}function handleError(_0x1ae889,_0x5987af){_0x5987af=_0x5987af||0x1f4;return function(_0x3c211a){logger[_0xe9bd('0x29')](_0x3c211a['stack']);if(_0x3c211a[_0xe9bd('0x2a')]){delete _0x3c211a[_0xe9bd('0x2a')];}_0x1ae889[_0xe9bd('0x1e')](_0x5987af)[_0xe9bd('0x2b')](_0x3c211a);};}function getInteractionUnreadMessages(_0x141b95){return new BPromise(function(_0x183601,_0x519f48){try{if(_0x141b95['closed']){_0x141b95[_0xe9bd('0x2c')]=0x0;_0x183601(_0x141b95);}else{return db['FaxMessage'][_0xe9bd('0x2d')]({'where':{'FaxInteractionId':_0x141b95['id'],'direction':'in','read':![]}})[_0xe9bd('0x27')](function(_0x27f80c){_0x141b95[_0xe9bd('0x2c')]=_0x27f80c;_0x183601(_0x141b95);});}}catch(_0x4057df){_0x519f48(_0x4057df);}});}function getInteractionUsers(_0x509e36,_0x4b7bc2){return new BPromise(function(_0x7f2c5,_0x3b6682){try{if(_0x4b7bc2[_0x509e36['id']]){_0x509e36[_0xe9bd('0x2e')]=_[_0xe9bd('0x2f')](_0x4b7bc2[_0x509e36['id']],function(_0xe2436){return{'id':_0xe2436['id']};});}}catch(_0x1f0f9e){_0x3b6682(_0x1f0f9e);}_0x7f2c5(_0x509e36);});}function getInteractionTags(_0x3c31ee,_0x66213a){return new BPromise(function(_0x45703e,_0x4ec15c){try{if(_0x3c31ee[_0xe9bd('0x30')]){_0x3c31ee[_0xe9bd('0x31')]=[];_0x3c31ee[_0xe9bd('0x30')]['split'](',')['forEach'](function(_0x25eeab){_0x3c31ee[_0xe9bd('0x31')][_0xe9bd('0x32')](_0x66213a[_0x25eeab]);});}delete _0x3c31ee[_0xe9bd('0x30')];}catch(_0x1dda43){_0x4ec15c(_0x1dda43);}_0x45703e(_0x3c31ee);});}function updateFaxInteraction(_0x2950e8,_0x1e50ac,_0x1c6173){return new BPromise(function(_0x1a1a29,_0x32b3e3){return getInteractionUnreadMessages(_0x2950e8)[_0xe9bd('0x27')](function(_0x549dd1){return getInteractionUsers(_0x549dd1,_0x1c6173);})[_0xe9bd('0x27')](function(_0x199477){return getInteractionTags(_0x199477,_0x1e50ac);})[_0xe9bd('0x27')](function(_0x8ff624){_0x1a1a29(_0x8ff624);})[_0xe9bd('0x33')](function(_0x147da5){_0x32b3e3(_0x147da5);});});}exports['index']=function(_0x3f3cf5,_0x32e764){var _0x56b4a5={},_0x404a7d={},_0x264c87={'count':0x0,'rows':[]};var _0x4c7d47=db['FaxInteraction'][_0xe9bd('0x34')];_0x404a7d[_0xe9bd('0x35')]=_['keys'](_0x4c7d47);_0x404a7d[_0xe9bd('0x36')]=_[_0xe9bd('0x37')](_0x3f3cf5[_0xe9bd('0x36')]);_0x404a7d['filters']=_[_0xe9bd('0x38')](_0x404a7d['model'],_0x404a7d[_0xe9bd('0x36')]);_0x56b4a5[_0xe9bd('0x39')]=_[_0xe9bd('0x38')](_0x404a7d[_0xe9bd('0x35')],qs['fields'](_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x3a')]));_0x56b4a5[_0xe9bd('0x39')]=_0x56b4a5[_0xe9bd('0x39')][_0xe9bd('0x3b')]?_0x56b4a5[_0xe9bd('0x39')]:_0x404a7d[_0xe9bd('0x35')];if(!_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x3c')](_0xe9bd('0x3d'))){_0x56b4a5['limit']=qs['limit'](_0x3f3cf5[_0xe9bd('0x36')]['limit']);_0x56b4a5[_0xe9bd('0x21')]=qs[_0xe9bd('0x21')](_0x3f3cf5[_0xe9bd('0x36')]['offset']);}_0x56b4a5[_0xe9bd('0x3e')]=qs[_0xe9bd('0x3f')](_0x3f3cf5[_0xe9bd('0x36')]['sort']);_0x56b4a5[_0xe9bd('0x40')]=qs[_0xe9bd('0x41')](_[_0xe9bd('0x42')](_0x3f3cf5[_0xe9bd('0x36')],_0x404a7d[_0xe9bd('0x41')]));var _0x40f87c=[];var _0x221be7=squel[_0xe9bd('0x43')]()[_0xe9bd('0x44')]('id')[_0xe9bd('0x44')](_0xe9bd('0x2a'))[_0xe9bd('0x44')](_0xe9bd('0x45'))[_0xe9bd('0x46')](_0xe9bd('0x47'));var _0x5b70d3=squel['select']()[_0xe9bd('0x44')](_0xe9bd('0x48'))[_0xe9bd('0x46')]('fax_messages','me')['where'](_0xe9bd('0x49'))[_0xe9bd('0x40')](_0xe9bd('0x4a'))[_0xe9bd('0x40')](_0xe9bd('0x4b'));var _0x3d4b58=squel[_0xe9bd('0x43')]()['field'](_0xe9bd('0x4c'))['field'](_0xe9bd('0x4d'))[_0xe9bd('0x46')](_0xe9bd('0x4e'),'ui')[_0xe9bd('0x4f')](_0xe9bd('0x50'),'u','u.id\x20=\x20ui.UserId');var _0x3317d6=squel[_0xe9bd('0x43')]()[_0xe9bd('0x46')]('fax_interactions','i')[_0xe9bd('0x4f')](_0xe9bd('0x51'),'c',_0xe9bd('0x52'))['left_join'](_0xe9bd('0x50'),'o',_0xe9bd('0x53'))[_0xe9bd('0x4f')](_0xe9bd('0x54'),'a',_0xe9bd('0x55'))['left_join'](_0xe9bd('0x56'),'me','me.FaxInteractionId\x20=\x20i.id');var _0x835697=squel[_0xe9bd('0x57')]();if(_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x58')]){var _0x589776=JSON['parse'](_0x3f3cf5[_0xe9bd('0x36')]['advancedFilter']);_[_0xe9bd('0x37')](_0x589776)[_0xe9bd('0x59')](function(_0x5e08ae){var _0x59d5cb=_0x589776[_0x5e08ae];if(_0x5e08ae===_0xe9bd('0x5a')){var _0x524da7=moment(_0x59d5cb[_0xe9bd('0x5b')]['dateStart'])[_0xe9bd('0x5c')](_0xe9bd('0x5d'))['utc']()[_0xe9bd('0x5e')]();var _0x4d6021=moment(_0x4d6021)[_0xe9bd('0x5f')]()[_0xe9bd('0x60')](_0xe9bd('0x5d'))['format']();_0x835697[_0xe9bd('0x61')](_0xe9bd('0x62'),_0x524da7,_0x4d6021);}else{if(_[_0xe9bd('0x63')](_0x59d5cb[_0xe9bd('0x64')])){_0x59d5cb['condition']['forEach'](function(_0x441f89){switch(_0x59d5cb['condition'][_0xe9bd('0x5b')]){case'IS':if(_0x5e08ae!==_0xe9bd('0x65')&&_0x5e08ae!==_0xe9bd('0x66')){if(_[_0xe9bd('0x63')](_0x59d5cb[_0xe9bd('0x5b')])&&_0x59d5cb[_0xe9bd('0x5b')][_0xe9bd('0x3b')]>0x1){_0x835697[_0xe9bd('0x61')](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+_0xe9bd('0x68'),_0x59d5cb[_0xe9bd('0x5b')]);}else{_0x835697[_0xe9bd('0x61')](_0x59d5cb['tableAlias']+'.'+_0x5e08ae+'\x20=\x20?',_0x59d5cb['value'][0x0]);}}break;case'=':_0x835697[_0xe9bd('0x61')](_0x59d5cb['tableAlias']+'.'+_0x5e08ae+_0xe9bd('0x69'),_0x59d5cb[_0xe9bd('0x5b')]);break;case _0xe9bd('0x6a'):if(_0x5e08ae===_0xe9bd('0x6b')){_0x835697[_0xe9bd('0x61')](_0xe9bd('0x6c')+_0xe9bd('0x6d'),'%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');_0x835697['or'](_0xe9bd('0x6e')+'\x20LIKE\x20?','%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');_0x835697['or'](_0xe9bd('0x6f')+_0xe9bd('0x6d'),'%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');}else{_0x835697['and'](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+_0xe9bd('0x6d'),'%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');}break;case'>':_0x835697['and'](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+_0xe9bd('0x70'),_0x59d5cb[_0xe9bd('0x5b')]);break;case'<':_0x835697[_0xe9bd('0x61')](_0x59d5cb['tableAlias']+'.'+_0x5e08ae+'\x20<\x20?',_0x59d5cb[_0xe9bd('0x5b')]);break;}});}else{switch(_0x59d5cb[_0xe9bd('0x64')][_0xe9bd('0x5b')]){case'IS':if(_0x5e08ae!==_0xe9bd('0x65')&&_0x5e08ae!=='Messages.count'){if(_['isArray'](_0x59d5cb[_0xe9bd('0x5b')])&&_0x59d5cb[_0xe9bd('0x5b')][_0xe9bd('0x3b')]>0x1){_0x835697[_0xe9bd('0x61')](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+_0xe9bd('0x68'),_0x59d5cb['value']);}else{_0x835697[_0xe9bd('0x61')](_0x59d5cb['tableAlias']+'.'+_0x5e08ae+_0xe9bd('0x69'),_0x59d5cb[_0xe9bd('0x5b')][0x0]);}}break;case'=':_0x835697[_0xe9bd('0x61')](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+'\x20=\x20?',_0x59d5cb[_0xe9bd('0x5b')]);break;case _0xe9bd('0x6a'):if(_0x5e08ae===_0xe9bd('0x6b')){_0x835697['and'](_0xe9bd('0x6c')+_0xe9bd('0x6d'),'%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');_0x835697['or'](_0xe9bd('0x6e')+_0xe9bd('0x6d'),'%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');_0x835697['or'](_0xe9bd('0x6f')+_0xe9bd('0x6d'),'%'+_0x59d5cb[_0xe9bd('0x5b')]+'%');}else{_0x835697[_0xe9bd('0x61')](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+_0xe9bd('0x6d'),'%'+_0x59d5cb['value']+'%');}break;case'>':_0x835697[_0xe9bd('0x61')](_0x59d5cb[_0xe9bd('0x67')]+'.'+_0x5e08ae+'\x20>\x20?',_0x59d5cb[_0xe9bd('0x5b')]);break;case'<':_0x835697[_0xe9bd('0x61')](_0x59d5cb['tableAlias']+'.'+_0x5e08ae+'\x20<\x20?',_0x59d5cb[_0xe9bd('0x5b')]);break;}}}});}else{var _0x4190f0=_(Object['keys'](_0x3f3cf5['query']))['map'](function(_0x246487){return _0x4c7d47['hasOwnProperty'](_0x246487)?_0x246487:undefined;})['filter'](function(_0x4b5bfb){return!_['isNil'](_0x4b5bfb);})[_0xe9bd('0x5b')]();if(!_[_0xe9bd('0x71')](_0x4190f0)){_0x4190f0[_0xe9bd('0x59')](function(_0x4947b0){if(_0x4947b0===_0xe9bd('0x72')){_0x3317d6[_0xe9bd('0x40')](_0xe9bd('0x73'),[][_0xe9bd('0x74')](_0x3f3cf5['query'][_0x4947b0]));}else if(_0x4947b0===_0xe9bd('0x5a')){var _0x10ef2b=JSON[_0xe9bd('0x75')](_0x3f3cf5['query'][_0x4947b0])['$gte'];var _0x3e68fb=JSON[_0xe9bd('0x75')](_0x3f3cf5[_0xe9bd('0x36')][_0x4947b0])[_0xe9bd('0x76')];_0x3317d6[_0xe9bd('0x40')](_0xe9bd('0x62'),_0x10ef2b,_0x3e68fb);}else{if(_0x3f3cf5[_0xe9bd('0x36')][_0x4947b0]===_0xe9bd('0x77')){_0x3317d6['where']('i.'+_0x4947b0+_0xe9bd('0x78'));}else{_0x3317d6[_0xe9bd('0x40')]('i.'+_0x4947b0+_0xe9bd('0x69'),_0x3f3cf5[_0xe9bd('0x36')][_0x4947b0]);}}});}if(_0x3f3cf5[_0xe9bd('0x36')]['filter']){var _0xa13d16=_0x3f3cf5['query']['filter'][_0xe9bd('0x79')]('\x5c','\x5c\x5c')[_0xe9bd('0x79')]('\x27\x27','\x27\x27\x27\x27');if(qs[_0xe9bd('0x7a')](_0xa13d16)){_0x835697['or'](_0xe9bd('0x7b'),_0xa13d16+'%')['or'](_0xe9bd('0x7c'),_0xa13d16+'%');}_0x835697['or'](_0xe9bd('0x7d'),_0xa13d16+'%');}}_0x3317d6['where'](_0x835697);if(_0x56b4a5[_0xe9bd('0x3e')]){_0x56b4a5[_0xe9bd('0x3e')]['forEach'](function(_0x2a014e){_0x3317d6[_0xe9bd('0x3e')]('i.'+_0x2a014e[0x0],_0x2a014e[0x1]===_0xe9bd('0x7e')?![]:!![]);});}_0x3317d6[_0xe9bd('0x7f')](_0xe9bd('0x80'));var _0x1a36aa={'type':db[_0xe9bd('0x81')]['QueryTypes'][_0xe9bd('0x82')],'raw':!![]};var _0x179edf=_0x3317d6[_0xe9bd('0x83')]()[_0xe9bd('0x44')](_0xe9bd('0x48'));if(!_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x58')]){if(_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x84')]){if(_0x3f3cf5['query'][_0xe9bd('0x84')]==0x1){_0x179edf[_0xe9bd('0x40')](util[_0xe9bd('0x5e')](_0xe9bd('0x85'),_0x5b70d3[_0xe9bd('0x86')]()));_0x3317d6[_0xe9bd('0x87')](_0xe9bd('0x88'));}else{_0x179edf['where'](util[_0xe9bd('0x5e')](_0xe9bd('0x89'),_0x5b70d3['toString']()));_0x3317d6[_0xe9bd('0x87')](_0xe9bd('0x8a'));}}if(_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x8b')]){var _0x242110=_[_0xe9bd('0x63')](_0x3f3cf5[_0xe9bd('0x36')]['tag'])?_0x3f3cf5['query'][_0xe9bd('0x8b')]:new Array(_0x3f3cf5[_0xe9bd('0x36')][_0xe9bd('0x8b')]);var _0x1b863f=squel[_0xe9bd('0x57')]();_0x242110[_0xe9bd('0x59')](function(_0x1b46f4){_0x1b863f['or']('CONCAT(\x27,\x27,\x20`TagIds`,\x20\x27,\x27)\x20LIKE\x20?','%,'+_0x1b46f4+',%');});_0x3317d6[_0xe9bd('0x87')](_0x1b863f);_0x179edf[_0xe9bd('0x4f')](_0xe9bd('0x8c'),'it',_0xe9bd('0x8d'));_0x179edf[_0xe9bd('0x4f')](_0xe9bd('0x47'),'t',_0xe9bd('0x8e'));_0x179edf['where']('t.id\x20IN\x20?',_0x242110);}}else{var _0x589776=JSON[_0xe9bd('0x75')](_0x3f3cf5['query']['advancedFilter']);_['keys'](_0x589776)[_0xe9bd('0x59')](function(_0x402ab2){var _0xf170d4=_0x589776[_0x402ab2];if(_0x402ab2===_0xe9bd('0x65')){var _0xd8a604=_0xf170d4[_0xe9bd('0x5b')];var _0x104173=squel[_0xe9bd('0x57')]();_0xd8a604[_0xe9bd('0x59')](function(_0x5ac1d9){_0x104173['or'](_0xe9bd('0x8f'),'%,'+_0x5ac1d9+',%');});_0x3317d6['having'](_0x104173);_0x179edf[_0xe9bd('0x4f')](_0xe9bd('0x90'),'it',_0xe9bd('0x91'));_0x179edf[_0xe9bd('0x4f')](_0xe9bd('0x47'),'t','t.id\x20=\x20it.TagId');_0x179edf['where']('t.id\x20IN\x20?',_0xd8a604);}else if(_0x402ab2===_0xe9bd('0x66')){if(_0xf170d4[_0xe9bd('0x5b')]['length']===0x1){if(_0xf170d4[_0xe9bd('0x5b')][0x0]===0x1){_0x179edf[_0xe9bd('0x40')](util[_0xe9bd('0x5e')](_0xe9bd('0x85'),_0x5b70d3[_0xe9bd('0x86')]()));_0x3317d6['having'](_0xe9bd('0x88'));}else{_0x179edf[_0xe9bd('0x40')](util[_0xe9bd('0x5e')](_0xe9bd('0x89'),_0x5b70d3[_0xe9bd('0x86')]()));_0x3317d6[_0xe9bd('0x87')](_0xe9bd('0x8a'));}}}});}db[_0xe9bd('0x92')][_0xe9bd('0x36')](_0x179edf[_0xe9bd('0x86')](),_0x1a36aa)['then'](function(_0x4d5288){_0x264c87['count']=_0x4d5288['length'];if(_0x264c87[_0xe9bd('0x2d')]===0x0)return[];return db[_0xe9bd('0x92')][_0xe9bd('0x36')](_0x221be7['toString'](),_0x1a36aa)[_0xe9bd('0x27')](function(_0x36df30){_0x40f87c=_['keyBy'](_0x36df30,'id');_0x1a36aa=_['merge'](_0x1a36aa,{'model':db[_0xe9bd('0x93')],'mapToModel':!![],'raw':!![],'nest':!![]});_0x3317d6[_0xe9bd('0x44')](_0xe9bd('0x94'),_0xe9bd('0x95'));_0x3317d6[_0xe9bd('0x44')]('i.*');_0x3317d6['field']('c.firstName',_0xe9bd('0x96'));_0x3317d6[_0xe9bd('0x44')](_0xe9bd('0x6e'),_0xe9bd('0x97'));_0x3317d6[_0xe9bd('0x44')](_0xe9bd('0x6f'),_0xe9bd('0x98'));_0x3317d6[_0xe9bd('0x44')](_0xe9bd('0x99'),_0xe9bd('0x9a'));_0x3317d6['field'](_0xe9bd('0x9b'),'Contact.mobile');_0x3317d6[_0xe9bd('0x44')]('c.fax','Contact.fax');_0x3317d6[_0xe9bd('0x44')]('GROUP_CONCAT(DISTINCT\x20t.id)',_0xe9bd('0x30'));_0x3317d6['left_join'](_0xe9bd('0x8c'),'it',_0xe9bd('0x8d'));_0x3317d6[_0xe9bd('0x4f')](_0xe9bd('0x47'),'t',_0xe9bd('0x8e'));_0x3317d6[_0xe9bd('0x22')](_0x56b4a5['limit']);_0x3317d6[_0xe9bd('0x21')](_0x56b4a5[_0xe9bd('0x21')]);return db['sequelize'][_0xe9bd('0x36')](_0x3317d6[_0xe9bd('0x86')](),_0x1a36aa);})[_0xe9bd('0x27')](function(_0x59897b){_0x3d4b58[_0xe9bd('0x40')](_0xe9bd('0x9c'),_[_0xe9bd('0x2f')](_0x59897b,'id'));return db[_0xe9bd('0x92')][_0xe9bd('0x36')](_0x3d4b58['toString'](),_0x1a36aa)[_0xe9bd('0x27')](function(_0x157b8e){var _0x591c5f=_[_0xe9bd('0x9d')](_0x157b8e,_0xe9bd('0x9e'));var _0x396679=[];_0x59897b[_0xe9bd('0x59')](function(_0x50243f){_0x396679[_0xe9bd('0x32')](updateFaxInteraction(_0x50243f,_0x40f87c,_0x591c5f));});return BPromise[_0xe9bd('0x9f')](_0x396679);});});})[_0xe9bd('0x27')](function(_0x15ad2f){_0x264c87[_0xe9bd('0xa0')]=_0x15ad2f;return _0x264c87;})[_0xe9bd('0x27')](respondWithFilteredResult(_0x32e764,_0x56b4a5))[_0xe9bd('0x33')](handleError(_0x32e764,null));};exports['show']=function(_0x7c3e0a,_0x59719e){var _0x33dcf6={'raw':![],'where':{'id':_0x7c3e0a[_0xe9bd('0xa1')]['id']}},_0x3a2d9f={};_0x3a2d9f['model']=_[_0xe9bd('0x37')](db['FaxInteraction'][_0xe9bd('0x34')]);_0x3a2d9f[_0xe9bd('0x36')]=_[_0xe9bd('0x37')](_0x7c3e0a[_0xe9bd('0x36')]);_0x3a2d9f[_0xe9bd('0x41')]=_[_0xe9bd('0x38')](_0x3a2d9f[_0xe9bd('0x35')],_0x3a2d9f[_0xe9bd('0x36')]);_0x33dcf6[_0xe9bd('0x39')]=_[_0xe9bd('0x38')](_0x3a2d9f[_0xe9bd('0x35')],qs['fields'](_0x7c3e0a[_0xe9bd('0x36')][_0xe9bd('0x3a')]));_0x33dcf6[_0xe9bd('0x39')]=_0x33dcf6['attributes'][_0xe9bd('0x3b')]?_0x33dcf6[_0xe9bd('0x39')]:_0x3a2d9f['model'];if(_0x7c3e0a['query']['includeAll']){_0x33dcf6['include']=[{'all':!![]}];}_0x33dcf6=_[_0xe9bd('0xa2')]({},_0x33dcf6,_0x7c3e0a[_0xe9bd('0xa3')]);return db[_0xe9bd('0x93')]['find'](_0x33dcf6)[_0xe9bd('0x27')](handleEntityNotFound(_0x59719e,null))[_0xe9bd('0x27')](respondWithResult(_0x59719e,null))['catch'](handleError(_0x59719e,null));};exports[_0xe9bd('0xa4')]=function(_0x35894c,_0x3fed2e){return db[_0xe9bd('0x93')][_0xe9bd('0xa4')](_0x35894c['body'],{})[_0xe9bd('0x27')](respondWithResult(_0x3fed2e,0xc9))[_0xe9bd('0x33')](handleError(_0x3fed2e,null));};exports['update']=function(_0x53d685,_0x54ffbd){if(_0x53d685['body']['id']){delete _0x53d685[_0xe9bd('0xa5')]['id'];}return db[_0xe9bd('0x93')][_0xe9bd('0xa6')]({'where':{'id':_0x53d685[_0xe9bd('0xa1')]['id']}})['then'](handleEntityNotFound(_0x54ffbd,null))['then'](saveUpdates(_0x53d685[_0xe9bd('0xa5')],null))[_0xe9bd('0x27')](respondWithResult(_0x54ffbd,null))[_0xe9bd('0x33')](handleError(_0x54ffbd,null));};exports['destroy']=function(_0x220f1f,_0x2582d9){return db['FaxInteraction']['find']({'where':{'id':_0x220f1f[_0xe9bd('0xa1')]['id']}})[_0xe9bd('0x27')](handleEntityNotFound(_0x2582d9,null))[_0xe9bd('0x27')](removeEntity(_0x2582d9,null))[_0xe9bd('0x33')](handleError(_0x2582d9,null));};exports[_0xe9bd('0xa7')]=function(_0x284a58,_0x1ce898){return db[_0xe9bd('0x93')][_0xe9bd('0xa7')]()['then'](respondWithResult(_0x1ce898,null))[_0xe9bd('0x33')](handleError(_0x1ce898,null));};exports[_0xe9bd('0xa8')]=function(_0x14cdd5,_0x1554fd,_0x213a08){return db[_0xe9bd('0xa9')]['find']({'where':{'id':_0x14cdd5[_0xe9bd('0xa1')]['id']}})['then'](handleEntityNotFound(_0x1554fd,null))[_0xe9bd('0x27')](function(_0x5783cc){if(_0x5783cc){return _0x5783cc[_0xe9bd('0xa8')](_0x14cdd5[_0xe9bd('0xa5')]['ids'],_[_0xe9bd('0xaa')](_0x14cdd5[_0xe9bd('0xa5')],['ids','id'])||{});}})[_0xe9bd('0x27')](respondWithResult(_0x1554fd,null))[_0xe9bd('0x33')](handleError(_0x1554fd,null));};exports[_0xe9bd('0xab')]=function(_0x402d07,_0x56133d,_0x209720){var _0xea6699={'raw':![],'where':{}};var _0x57df6e={};var _0x16b9bf={'count':0x0,'rows':[]};return db[_0xe9bd('0x93')][_0xe9bd('0xac')]({'where':{'id':_0x402d07['params']['id']}})[_0xe9bd('0x27')](handleEntityNotFound(_0x56133d,null))[_0xe9bd('0x27')](function(_0x308fd6){if(_0x308fd6){_0x57df6e[_0xe9bd('0x35')]=_[_0xe9bd('0x37')](db[_0xe9bd('0xa9')][_0xe9bd('0x34')]);_0x57df6e['query']=_[_0xe9bd('0x37')](_0x402d07[_0xe9bd('0x36')]);_0x57df6e[_0xe9bd('0x41')]=_['intersection'](_0x57df6e[_0xe9bd('0x35')],_0x57df6e['query']);_0xea6699['attributes']=_['intersection'](_0x57df6e[_0xe9bd('0x35')],qs['fields'](_0x402d07['query'][_0xe9bd('0x3a')]));_0xea6699[_0xe9bd('0x39')]=_0xea6699['attributes'][_0xe9bd('0x3b')]?_0xea6699[_0xe9bd('0x39')]:_0x57df6e['model'];if(!_0x402d07['query'][_0xe9bd('0x3c')]('nolimit')){_0xea6699['limit']=qs[_0xe9bd('0x22')](_0x402d07[_0xe9bd('0x36')][_0xe9bd('0x22')]);_0xea6699[_0xe9bd('0x21')]=qs[_0xe9bd('0x21')](_0x402d07[_0xe9bd('0x36')][_0xe9bd('0x21')]);}_0xea6699['order']=qs[_0xe9bd('0x3f')](_0x402d07['query']['sort']);_0xea6699[_0xe9bd('0x40')]=qs[_0xe9bd('0x41')](_[_0xe9bd('0x42')](_0x402d07[_0xe9bd('0x36')],_0x57df6e[_0xe9bd('0x41')]));_0xea6699['where'][_0xe9bd('0x9e')]=_0x308fd6['id'];if(_0x402d07[_0xe9bd('0x36')][_0xe9bd('0xad')]){_0xea6699[_0xe9bd('0x40')]=_[_0xe9bd('0xa2')](_0xea6699[_0xe9bd('0x40')],{'$or':_['map'](_0xea6699[_0xe9bd('0x39')],function(_0x265dba){var _0x1d496e={};_0x1d496e[_0x265dba]={'$like':'%'+_0x402d07[_0xe9bd('0x36')][_0xe9bd('0xad')]+'%'};return _0x1d496e;})});}if(_0x402d07[_0xe9bd('0x36')]['$gte']){var _0x23655f=_0x402d07[_0xe9bd('0x36')]['$gte'][_0xe9bd('0xae')](',');var _0x4c5304={};_0x4c5304[_0x23655f[0x0]]={'$gte':moment(_0x23655f[0x1])[_0xe9bd('0x5e')](_0xe9bd('0xaf'))};_0xea6699['where']=_[_0xe9bd('0xa2')](_0xea6699[_0xe9bd('0x40')],_0x4c5304);}_0xea6699=_[_0xe9bd('0xa2')]({},_0xea6699,_0x402d07[_0xe9bd('0xa3')]);return db[_0xe9bd('0xa9')][_0xe9bd('0x2d')]({'where':_0xea6699[_0xe9bd('0x40')]})[_0xe9bd('0x27')](function(_0x41506b){_0x16b9bf['count']=_0x41506b;if(_0x402d07[_0xe9bd('0x36')][_0xe9bd('0xb0')]){_0xea6699[_0xe9bd('0xb1')]=[{'all':!![]}];}return db[_0xe9bd('0xa9')][_0xe9bd('0xb2')](_0xea6699);})[_0xe9bd('0x27')](function(_0x3b453c){_0x16b9bf['rows']=_0x3b453c;return _0x16b9bf;});}})[_0xe9bd('0x27')](respondWithFilteredResult(_0x56133d,_0xea6699))['catch'](handleError(_0x56133d,null));};exports[_0xe9bd('0xb3')]=function(_0xbc686e,_0x2db271,_0x1c2d6d){return db[_0xe9bd('0x93')][_0xe9bd('0xa6')]({'where':{'id':_0xbc686e['params']['id']}})[_0xe9bd('0x27')](handleEntityNotFound(_0x2db271,null))[_0xe9bd('0x27')](function(_0x39b54b){if(_0x39b54b){return _0x39b54b['setTags'](_0xbc686e[_0xe9bd('0xa5')][_0xe9bd('0xb4')],_[_0xe9bd('0xaa')](_0xbc686e[_0xe9bd('0xa5')],[_0xe9bd('0xb4'),'id'])||{})[_0xe9bd('0xb5')](function(){return db[_0xe9bd('0xb6')][_0xe9bd('0xb2')]({'attributes':['id',_0xe9bd('0x2a'),_0xe9bd('0x45')],'where':{'id':_0xbc686e['body'][_0xe9bd('0xb4')]}});})[_0xe9bd('0x27')](function(_0x31aae8){socket['emit'](_0xe9bd('0xb7'),{'id':Number(_0xbc686e[_0xe9bd('0xa1')]['id']),'tags':_0x31aae8||[]});return{'id':Number(_0xbc686e[_0xe9bd('0xa1')]['id']),'tags':_0x31aae8||[]};});}})['then'](respondWithResult(_0x2db271,null))['catch'](handleError(_0x2db271,null));};exports[_0xe9bd('0xb8')]=function(_0x183071,_0x432bb2,_0x436da9){return db[_0xe9bd('0x93')][_0xe9bd('0xa6')]({'where':{'id':_0x183071[_0xe9bd('0xa1')]['id']}})['then'](handleEntityNotFound(_0x432bb2,null))[_0xe9bd('0x27')](function(_0x297ccc){if(_0x297ccc){return _0x297ccc['removeTags'](_0x183071[_0xe9bd('0x36')][_0xe9bd('0xb4')]);}})[_0xe9bd('0x27')](respondWithStatusCode(_0x432bb2,null))[_0xe9bd('0x33')](handleError(_0x432bb2,null));};exports[_0xe9bd('0xb9')]=function(_0x142907,_0x428a2e){var _0x253c42=moment()[_0xe9bd('0xba')]()[_0xe9bd('0x86')]();var _0x38ce72=path[_0xe9bd('0xbb')](config[_0xe9bd('0xbc')],_0xe9bd('0xbd'),_0xe9bd('0xbe'),'attachments');var _0x17c8e8=path[_0xe9bd('0xbb')](config[_0xe9bd('0xbc')],_0xe9bd('0xbd'),_0xe9bd('0xbe'),'tmp');var _0x86b85=path[_0xe9bd('0xbb')](_0x17c8e8,_0x253c42);var _0x1eeb25=util[_0xe9bd('0x5e')](_0xe9bd('0xbf'),_0x253c42);var _0x1fa474=path[_0xe9bd('0xbb')](_0x17c8e8,_0x1eeb25);var _0x463d54=![];return db[_0xe9bd('0x93')][_0xe9bd('0xa6')]({'where':{'id':_0x142907[_0xe9bd('0xa1')]['id']}})[_0xe9bd('0x27')](handleEntityNotFound(_0x428a2e,null))[_0xe9bd('0x27')](function(_0x5953ca){if(_0x5953ca){return _0x5953ca[_0xe9bd('0xab')]({'attributes':['id',_0xe9bd('0xa5'),_0xe9bd('0x5a')],'include':[{'model':db[_0xe9bd('0xc0')],'as':_0xe9bd('0xc0')}]});}return[];})[_0xe9bd('0x27')](function(_0x37c697){_0x463d54=_0x37c697[_0xe9bd('0x3b')];if(_0x37c697[_0xe9bd('0x3b')]){fs[_0xe9bd('0xc1')](_0x86b85);for(var _0xad2195=0x0;_0xad2195<_0x37c697[_0xe9bd('0x3b')];_0xad2195++){var _0x5da417=_0x37c697[_0xad2195];var _0x388fc5=_0x5da417[_0xe9bd('0xc0')];if(_0x388fc5){var _0x62dd82=path[_0xe9bd('0xbb')](_0x38ce72,_0x388fc5[_0xe9bd('0xc2')]);if(fs['existsSync'](_0x62dd82)){fs[_0xe9bd('0xc3')](_0x62dd82)[_0xe9bd('0xc4')](fs[_0xe9bd('0xc5')](path['join'](_0x86b85,_0x388fc5[_0xe9bd('0xc2')])));}}}}})[_0xe9bd('0x27')](function(){if(_0x463d54){return new BPromise(function(_0x496640,_0x4efce6){zipdir(_0x86b85,{'saveTo':_0x1fa474},function(_0x4b8f8e,_0x28e51a){if(_0x4b8f8e)return _0x4efce6(_0x4b8f8e);return _0x496640(_0x28e51a);});});}})[_0xe9bd('0x27')](function(){if(_0x463d54){return new BPromise(function(_0x48cd92,_0x432fcb){rimraf(_0x86b85,function(_0x2daa01){if(_0x2daa01)_0x432fcb(_0x2daa01);return _0x48cd92();});});}})[_0xe9bd('0x27')](function(){if(_0x463d54){return _0x428a2e['download'](_0x1fa474,_0x1eeb25,function(_0x15ad87){if(_0x15ad87){console[_0xe9bd('0xc6')](_0xe9bd('0xc7'),_0x15ad87);}else{fs[_0xe9bd('0xc8')](_0x1fa474);}});}else{return _0x428a2e['sendStatus'](0xc8);}})[_0xe9bd('0x33')](handleError(_0x428a2e,null));};
\ No newline at end of file