c2c652a24a2addbdc655f6bf83ee52777d156f8e
[motion-next.git] / server / api / faxAccount / faxAccount.controller.js
1 const a186_0x5808=['t38timeout','Disposition','getMessages','sendStatus','VoiceExtension','filters','like','removeAgents','getApplications','fullname','server/files/attachments','limit','key','bulkCreate','findOne','mandatoryDispositionPause','set','Contact\x20not\x20found','maxrate','transaction','findAll','defaults','system','undefined','options','rows','Content-Range','minrate','SendFax','basename','getAnswers','intersection','api','isNil','lodash','model','../../mysqldb','map','user','name','catch','CheckAfterSend','FaxAccount,\x20%s,\x20%s,\x20%s','root','then','client','DESC','attributes','from-voip-provider','pick','headerinfo','addAgents','describe','description','util','sequelize','updatedAt','FaxAccountId','UserProfileSection','Unable\x20to\x20retrieve\x20the\x20current\x20user','Tag','Owner','get','localstationid','register','findAndCountAll','Answer','end','json','getInteractions','request\x20sent','FaxAccounts','offset','/var/opt/motion2/server/files/attachments/fax-${CALLERID(num)}-${CUT(UNIQUEID,.,1)}-${CUT(UNIQUEID,.,2)}-${STRFTIME(,,%C%y%m%d%H%M%S)}-rx.tif,d','ListId','destroy','request','fieldName','where','push','join','message','findByPk','addAnswer','CDR(type)=inbound-fax','$gte','error','User','emit','sort','ids','order','CannedAnswer','length','format','tag','FAXOPT(','debug','filter','../../components/parsers/qs','SendFaxRpc,\x20%s','update','List','out','gte','color','userFaxAccount:remove','fax','priority','../../config/environment','send','addAccountApplications','status','jayson/promise','FaxMessage','UserProfileResource','TrunkId','app','removeDispositions','internal','stringify','FaxAccount','fields','Contact','CmList','exten','attachments','addInteraction','rawAttributes','Messages','addApplications','FaxAccount,\x20%s,\x20%s','query','userProfileId','body','FaxInteraction','create','Set','omit','removeAnswers','result','CmContact','Pause','keys','Send\x20Fax\x20failed','ContactId','moment','../../config/logger','filename','nolimit','Contacts','autoAssociation','\x22%s\x22\x20<%s>','VIRTUAL','count','Fax\x20Extension','http','FaxApplication','type','code','List\x20not\x20found','getAgents','merge','Wait','info','stack','path','include','includeAll','params','dataValues','faxdetect','from','isArray'];(function(_0x4a16eb,_0x58081a){const _0x2aa613=function(_0x21225d){while(--_0x21225d){_0x4a16eb['push'](_0x4a16eb['shift']());}};_0x2aa613(++_0x58081a);}(a186_0x5808,0x18c));const a186_0x2aa6=function(_0x4a16eb,_0x58081a){_0x4a16eb=_0x4a16eb-0x0;let _0x2aa613=a186_0x5808[_0x4a16eb];return _0x2aa613;};const _0x53e245=a186_0x2aa6;'use strict';const moment=require(_0x53e245('0x62')),util=require(_0x53e245('0x6')),path=require(_0x53e245('0x76')),_=require(_0x53e245('0xa0')),{getSocket}=require('../../rediscache'),socket=getSocket(),qs=require(_0x53e245('0x33')),logger=require(_0x53e245('0x63'))(_0x53e245('0x9e')),config=require(_0x53e245('0x3d')),db=require(_0x53e245('0xa2'))['db'],{Op}=require('sequelize');require('./faxAccount.socket')[_0x53e245('0x10')](socket);const jayson=require(_0x53e245('0x41')),client=jayson[_0x53e245('0xab')]['http']({'port':0x232c}),client9002=jayson[_0x53e245('0xab')][_0x53e245('0x6c')]({'port':0x232a});function respondWithRpcPromise(_0x21225d,_0x1955f8,_0xdd3a3d,_0x3b203c){return new Promise(function(_0x4e200e,_0x596276){const _0xf175b2=a186_0x2aa6,_0x1d9c68=_0x3b203c||client;return _0x1d9c68[_0xf175b2('0x1c')](_0x21225d,_0xdd3a3d)[_0xf175b2('0xaa')](function(_0x469fa7){const _0x49fc19=_0xf175b2;logger[_0x49fc19('0x74')]('FaxAccount,\x20%s,\x20%s',_0x1955f8,_0x49fc19('0x16')),logger[_0x49fc19('0x31')](_0x49fc19('0xa8'),_0x1955f8,_0x49fc19('0x16'),JSON[_0x49fc19('0x48')](_0x469fa7));if(_0x469fa7[_0x49fc19('0x26')]){if(_0x469fa7[_0x49fc19('0x26')][_0x49fc19('0x6f')]===0x1f4)return logger[_0x49fc19('0x26')](_0x49fc19('0x53'),_0x1955f8,_0x469fa7[_0x49fc19('0x26')][_0x49fc19('0x21')]),_0x596276(_0x469fa7['error'][_0x49fc19('0x21')]);return logger[_0x49fc19('0x26')](_0x49fc19('0x53'),_0x1955f8,_0x469fa7[_0x49fc19('0x26')][_0x49fc19('0x21')]),_0x4e200e(_0x469fa7[_0x49fc19('0x26')][_0x49fc19('0x21')]);}else logger['info'](_0x49fc19('0x53'),_0x1955f8,_0x49fc19('0x16')),_0x4e200e(_0x469fa7[_0x49fc19('0x5c')][_0x49fc19('0x21')]);})[_0xf175b2('0xa6')](function(_0x1d66ba){const _0x38fbec=_0xf175b2;logger[_0x38fbec('0x26')](_0x38fbec('0x53'),_0x1955f8,_0x1d66ba),_0x596276(_0x1d66ba);});});}function respondWithStatusCode(_0x4f2fdb,_0x5b1710){return _0x5b1710=_0x5b1710||0xcc,function(_0x36a2ae){const _0x5876d4=a186_0x2aa6;if(_0x36a2ae)return _0x4f2fdb['sendStatus'](_0x5b1710);return _0x4f2fdb[_0x5876d4('0x40')](_0x5b1710)['end']();};}function respondWithResult(_0x149f8e,_0x2022ad){return _0x2022ad=_0x2022ad||0xc8,function(_0x38ee98){const _0x543b5c=a186_0x2aa6;if(_0x38ee98)return _0x149f8e[_0x543b5c('0x40')](_0x2022ad)[_0x543b5c('0x14')](_0x38ee98);};}function respondWithFilteredResult(_0x31247e,_0x30b6df){return function(_0xf66fa4){const _0x5585e5=a186_0x2aa6;if(_0xf66fa4){const _0x2eb214=_0xf66fa4[_0x5585e5('0x6a')],_0x852362=_0x30b6df[_0x5585e5('0x18')];let _0x14505e=_0x30b6df[_0x5585e5('0x18')]+_0x30b6df[_0x5585e5('0x89')],_0x4d8ad8;return _0x14505e>=_0x2eb214?(_0x14505e=_0x2eb214,_0x4d8ad8=0xc8):_0x4d8ad8=0xce,_0x31247e[_0x5585e5('0x40')](_0x4d8ad8),_0x31247e[_0x5585e5('0x8e')](_0x5585e5('0x98'),_0x852362+'-'+_0x14505e+'/'+_0x2eb214)[_0x5585e5('0x14')](_0xf66fa4);}return null;};}function saveUpdates(_0x5ca9c3){return function(_0x7b27a7){const _0x1f4f78=a186_0x2aa6;if(_0x7b27a7)return _0x7b27a7[_0x1f4f78('0x35')](_0x5ca9c3)[_0x1f4f78('0xaa')](function(_0x53b562){return _0x53b562;});return null;};}function removeEntity(_0x5479a3){return function(_0x236fd7){const _0xfd7888=a186_0x2aa6;if(_0x236fd7)return _0x236fd7[_0xfd7888('0x1b')]()[_0xfd7888('0xaa')](function(){const _0x195464=_0xfd7888,_0x26f524=_0x236fd7[_0x195464('0xe')]({'plain':!![]}),_0x56e2c3=_0x195464('0x17');return db['UserProfileResource']['destroy']({'where':{'type':_0x56e2c3,'resourceId':_0x26f524['id']}})['then'](function(){return _0x236fd7;});})[_0xfd7888('0xaa')](function(){const _0x461a6e=_0xfd7888;_0x5479a3['status'](0xcc)[_0x461a6e('0x13')]();});};}function handleEntityNotFound(_0x40b45e){return function(_0x43b9de){const _0x5049af=a186_0x2aa6;return!_0x43b9de&&_0x40b45e[_0x5049af('0x81')](0x194),_0x43b9de;};}function handleError(_0x1e2e61,_0x1bcd7a){return _0x1bcd7a=_0x1bcd7a||0x1f4,function(_0x16ea3f){const _0xdc60be=a186_0x2aa6;logger[_0xdc60be('0x26')](_0x16ea3f[_0xdc60be('0x75')]),_0x16ea3f[_0xdc60be('0xa5')]&&delete _0x16ea3f[_0xdc60be('0xa5')],_0x1e2e61[_0xdc60be('0x40')](_0x1bcd7a)[_0xdc60be('0x3e')](_0x16ea3f);};}exports['index']=function(_0x1526c5,_0x6c65ec){const _0x3a708d=_0x53e245;let _0x5395bf={'include':[{'model':db[_0x3a708d('0x5e')],'as':_0x3a708d('0x8d')}]};const _0x5a1782={},_0x3d203e={'count':0x0,'rows':[]},_0x351dfc=_[_0x3a708d('0xa3')](db[_0x3a708d('0x49')][_0x3a708d('0x50')],function(_0x4aeeaf){const _0x4f63e3=_0x3a708d;return{'name':_0x4aeeaf[_0x4f63e3('0x1d')],'type':_0x4aeeaf[_0x4f63e3('0x6e')][_0x4f63e3('0x8a')]};});_0x5a1782['model']=_[_0x3a708d('0xa3')](_0x351dfc,_0x3a708d('0xa5')),_0x5a1782['query']=_[_0x3a708d('0x5f')](_0x1526c5[_0x3a708d('0x54')]),_0x5a1782[_0x3a708d('0x83')]=_[_0x3a708d('0x9d')](_0x5a1782['model'],_0x5a1782[_0x3a708d('0x54')]),_0x5395bf[_0x3a708d('0xad')]=_[_0x3a708d('0x9d')](_0x5a1782[_0x3a708d('0xa1')],qs[_0x3a708d('0x4a')](_0x1526c5[_0x3a708d('0x54')]['fields'])),_0x5395bf[_0x3a708d('0xad')]=_0x5395bf[_0x3a708d('0xad')][_0x3a708d('0x2d')]?_0x5395bf[_0x3a708d('0xad')]:_0x5a1782[_0x3a708d('0xa1')];typeof _0x1526c5[_0x3a708d('0x54')]['nolimit']===_0x3a708d('0x95')&&(_0x5395bf['limit']=qs['limit'](_0x1526c5[_0x3a708d('0x54')][_0x3a708d('0x89')]),_0x5395bf[_0x3a708d('0x18')]=qs[_0x3a708d('0x18')](_0x1526c5[_0x3a708d('0x54')][_0x3a708d('0x18')]));_0x5395bf[_0x3a708d('0x2b')]=qs[_0x3a708d('0x29')](_0x1526c5['query'][_0x3a708d('0x29')]),_0x5395bf['where']=qs[_0x3a708d('0x83')](_[_0x3a708d('0x1')](_0x1526c5[_0x3a708d('0x54')],_0x5a1782[_0x3a708d('0x83')]),_0x351dfc);_0x1526c5[_0x3a708d('0x54')][_0x3a708d('0x32')]&&(_0x5395bf[_0x3a708d('0x1e')]=_[_0x3a708d('0x72')](_0x5395bf[_0x3a708d('0x1e')],{[Op['or']]:_[_0x3a708d('0xa3')](_0x351dfc,function(_0x34e4e0){const _0x537055=_0x3a708d;if(_0x34e4e0[_0x537055('0x6e')]!==_0x537055('0x69')){const _0x48b44e={};return _0x48b44e[_0x34e4e0[_0x537055('0xa5')]]={[Op[_0x537055('0x84')]]:'%'+_0x1526c5[_0x537055('0x54')][_0x537055('0x32')]+'%'},_0x48b44e;}})}));_0x5395bf=_['merge']({},_0x5395bf,_0x1526c5[_0x3a708d('0x96')]);const _0x199765={'where':_0x5395bf['where']};return db['FaxAccount'][_0x3a708d('0x6a')](_0x199765)[_0x3a708d('0xaa')](function(_0xdf7949){const _0x4f7bfa=_0x3a708d;return _0x3d203e['count']=_0xdf7949,_0x1526c5[_0x4f7bfa('0x54')]['includeAll']&&(_0x5395bf[_0x4f7bfa('0x77')]=[{'all':!![]}]),db['FaxAccount'][_0x4f7bfa('0x92')](_0x5395bf);})[_0x3a708d('0xaa')](function(_0x3cabc0){const _0x523a5b=_0x3a708d;return _0x3d203e[_0x523a5b('0x97')]=_0x3cabc0,_0x3d203e;})['then'](respondWithFilteredResult(_0x6c65ec,_0x5395bf))[_0x3a708d('0xa6')](handleError(_0x6c65ec,null));},exports['show']=function(_0x196ba5,_0x1c6b4a){const _0x354da9=_0x53e245;let _0x46a3e9={'raw':![],'where':{'id':_0x196ba5[_0x354da9('0x79')]['id']},'include':[{'model':db['Pause'],'as':'mandatoryDispositionPause'}]};const _0x10c61a={};return _0x10c61a[_0x354da9('0xa1')]=_[_0x354da9('0x5f')](db[_0x354da9('0x49')][_0x354da9('0x50')]),_0x10c61a[_0x354da9('0x54')]=_[_0x354da9('0x5f')](_0x196ba5[_0x354da9('0x54')]),_0x10c61a['filters']=_[_0x354da9('0x9d')](_0x10c61a['model'],_0x10c61a['query']),_0x46a3e9[_0x354da9('0xad')]=_[_0x354da9('0x9d')](_0x10c61a[_0x354da9('0xa1')],qs[_0x354da9('0x4a')](_0x196ba5[_0x354da9('0x54')][_0x354da9('0x4a')])),_0x46a3e9['attributes']=_0x46a3e9[_0x354da9('0xad')][_0x354da9('0x2d')]?_0x46a3e9[_0x354da9('0xad')]:_0x10c61a[_0x354da9('0xa1')],_0x196ba5[_0x354da9('0x54')][_0x354da9('0x78')]&&(_0x46a3e9[_0x354da9('0x77')]=[{'all':!![]}]),_0x46a3e9=_[_0x354da9('0x72')]({},_0x46a3e9,_0x196ba5['options']),db[_0x354da9('0x49')][_0x354da9('0x8c')](_0x46a3e9)['then'](handleEntityNotFound(_0x1c6b4a,null))['then'](respondWithResult(_0x1c6b4a,null))[_0x354da9('0xa6')](handleError(_0x1c6b4a,null));},exports['create']=function(_0x43fc33,_0x290289){const _0x25ddd2=_0x53e245;return db[_0x25ddd2('0x49')][_0x25ddd2('0x58')](_0x43fc33['body'],{})[_0x25ddd2('0xaa')](function(_0x39d94d){const _0x2084bf=_0x25ddd2,_0x44d2d9=_0x43fc33['user'][_0x2084bf('0xe')]({'plain':!![]});if(!_0x44d2d9)throw new Error(_0x2084bf('0xb'));if(_0x44d2d9['role']===_0x2084bf('0xa4')){const _0x5cc56a=_0x39d94d[_0x2084bf('0xe')]({'plain':!![]}),_0xb9199f='FaxAccounts';return db[_0x2084bf('0xa')][_0x2084bf('0x8c')]({'where':{'name':_0xb9199f,'userProfileId':_0x44d2d9[_0x2084bf('0x55')]},'raw':!![]})[_0x2084bf('0xaa')](function(_0x1221c1){const _0x29f209=_0x2084bf;return _0x1221c1&&_0x1221c1[_0x29f209('0x67')]===0x0?db[_0x29f209('0x43')][_0x29f209('0x58')]({'name':_0x5cc56a['name'],'resourceId':_0x5cc56a['id'],'type':_0x1221c1[_0x29f209('0xa5')],'sectionId':_0x1221c1['id']},{})[_0x29f209('0xaa')](function(){return _0x39d94d;}):_0x39d94d;})[_0x2084bf('0xa6')](function(_0x4f42e0){const _0x2b4ce3=_0x2084bf;logger[_0x2b4ce3('0x26')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x4f42e0);throw _0x4f42e0;});}return _0x39d94d;})[_0x25ddd2('0xaa')](respondWithResult(_0x290289,0xc9))[_0x25ddd2('0xa6')](handleError(_0x290289,null));},exports['update']=function(_0x1899d2,_0x2d8cda){const _0x29fd1d=_0x53e245;return _0x1899d2[_0x29fd1d('0x56')]['id']&&delete _0x1899d2[_0x29fd1d('0x56')]['id'],db[_0x29fd1d('0x49')]['findOne']({'where':{'id':_0x1899d2[_0x29fd1d('0x79')]['id']},'include':[{'model':db[_0x29fd1d('0x5e')],'as':_0x29fd1d('0x8d')}]})[_0x29fd1d('0xaa')](handleEntityNotFound(_0x2d8cda,null))[_0x29fd1d('0xaa')](saveUpdates(_0x1899d2['body'],null))[_0x29fd1d('0xaa')](respondWithResult(_0x2d8cda,null))[_0x29fd1d('0xa6')](handleError(_0x2d8cda,null));},exports['destroy']=function(_0x5602ab,_0x2fa76f){const _0x5e792d=_0x53e245;return db[_0x5e792d('0x49')][_0x5e792d('0x8c')]({'where':{'id':_0x5602ab[_0x5e792d('0x79')]['id']}})['then'](handleEntityNotFound(_0x2fa76f,null))['then'](removeEntity(_0x2fa76f,null))[_0x5e792d('0xa6')](handleError(_0x2fa76f,null));},exports[_0x53e245('0x4')]=function(_0x52c276,_0x5b6cda){const _0x15a143=_0x53e245;return db['FaxAccount'][_0x15a143('0x4')]()[_0x15a143('0xaa')](respondWithResult(_0x5b6cda,null))[_0x15a143('0xa6')](handleError(_0x5b6cda,null));},exports['addDisposition']=function(_0x20e7be,_0x217870){const _0x3fa27a=_0x53e245;return _0x20e7be[_0x3fa27a('0x56')]['id']&&delete _0x20e7be[_0x3fa27a('0x56')]['id'],db[_0x3fa27a('0x49')][_0x3fa27a('0x8c')]({'where':{'id':_0x20e7be[_0x3fa27a('0x79')]['id']}})[_0x3fa27a('0xaa')](handleEntityNotFound(_0x217870,null))['then'](function(_0xeab3f5){const _0x1b1b46=_0x3fa27a;if(_0xeab3f5)return _0x20e7be[_0x1b1b46('0x56')][_0x1b1b46('0x9')]=_0xeab3f5['id'],db[_0x1b1b46('0x7f')][_0x1b1b46('0x58')](_0x20e7be['body']);})[_0x3fa27a('0xaa')](respondWithResult(_0x217870,null))[_0x3fa27a('0xa6')](handleError(_0x217870,null));},exports['getDispositions']=function(_0xd820bd,_0x5071fe){const _0x1d91cb=_0x53e245;let _0x4426b7={'raw':![],'where':{}};const _0x395dea={},_0x460571={'count':0x0,'rows':[]};return db[_0x1d91cb('0x49')][_0x1d91cb('0x8c')]({'where':{'id':_0xd820bd[_0x1d91cb('0x79')]['id']}})[_0x1d91cb('0xaa')](handleEntityNotFound(_0x5071fe,null))[_0x1d91cb('0xaa')](function(_0x59d752){const _0x1d8738=_0x1d91cb;if(_0x59d752)return _0x395dea['model']=_[_0x1d8738('0x5f')](db[_0x1d8738('0x7f')]['rawAttributes']),_0x395dea[_0x1d8738('0x54')]=_[_0x1d8738('0x5f')](_0xd820bd[_0x1d8738('0x54')]),_0x395dea['filters']=_[_0x1d8738('0x9d')](_0x395dea[_0x1d8738('0xa1')],_0x395dea[_0x1d8738('0x54')]),_0x4426b7[_0x1d8738('0xad')]=_[_0x1d8738('0x9d')](_0x395dea[_0x1d8738('0xa1')],qs[_0x1d8738('0x4a')](_0xd820bd[_0x1d8738('0x54')][_0x1d8738('0x4a')])),_0x4426b7[_0x1d8738('0xad')]=_0x4426b7[_0x1d8738('0xad')]['length']?_0x4426b7[_0x1d8738('0xad')]:_0x395dea[_0x1d8738('0xa1')],typeof _0xd820bd[_0x1d8738('0x54')][_0x1d8738('0x65')]===_0x1d8738('0x95')&&(_0x4426b7[_0x1d8738('0x89')]=qs[_0x1d8738('0x89')](_0xd820bd[_0x1d8738('0x54')][_0x1d8738('0x89')]),_0x4426b7['offset']=qs[_0x1d8738('0x18')](_0xd820bd['query'][_0x1d8738('0x18')])),_0x4426b7[_0x1d8738('0x2b')]=qs[_0x1d8738('0x29')](_0xd820bd[_0x1d8738('0x54')][_0x1d8738('0x29')]),_0x4426b7['where']=qs[_0x1d8738('0x83')](_[_0x1d8738('0x1')](_0xd820bd['query'],_0x395dea[_0x1d8738('0x83')])),_0x4426b7[_0x1d8738('0x1e')][_0x1d8738('0x9')]=_0x59d752['id'],_0xd820bd[_0x1d8738('0x54')][_0x1d8738('0x32')]&&(_0x4426b7[_0x1d8738('0x1e')]=_[_0x1d8738('0x72')](_0x4426b7['where'],{[Op['or']]:_[_0x1d8738('0xa3')](_0x4426b7['attributes'],function(_0xb63c36){const _0x1de5c3=_0x1d8738,_0x425e7f={};return _0x425e7f[_0xb63c36]={[Op[_0x1de5c3('0x84')]]:'%'+_0xd820bd[_0x1de5c3('0x54')][_0x1de5c3('0x32')]+'%'},_0x425e7f;})})),_0x4426b7=_[_0x1d8738('0x72')]({},_0x4426b7,_0xd820bd[_0x1d8738('0x96')]),db[_0x1d8738('0x7f')][_0x1d8738('0x6a')]({'where':_0x4426b7[_0x1d8738('0x1e')]})[_0x1d8738('0xaa')](function(_0x1d6c9f){const _0x222a6b=_0x1d8738;return _0x460571[_0x222a6b('0x6a')]=_0x1d6c9f,_0xd820bd[_0x222a6b('0x54')][_0x222a6b('0x78')]&&(_0x4426b7[_0x222a6b('0x77')]=[{'all':!![]}]),db[_0x222a6b('0x7f')][_0x222a6b('0x92')](_0x4426b7);})['then'](function(_0x25d001){const _0x5c2776=_0x1d8738;return _0x460571[_0x5c2776('0x97')]=_0x25d001,_0x460571;});})[_0x1d91cb('0xaa')](respondWithFilteredResult(_0x5071fe,_0x4426b7))[_0x1d91cb('0xa6')](handleError(_0x5071fe,null));},exports[_0x53e245('0x46')]=function(_0x2cc602,_0x1baf25){const _0x569e04=_0x53e245;return db['FaxAccount']['findOne']({'where':{'id':_0x2cc602[_0x569e04('0x79')]['id']}})['then'](handleEntityNotFound(_0x1baf25,null))[_0x569e04('0xaa')](function(_0x1ea188){const _0x2acf1c=_0x569e04;if(_0x1ea188)return _0x1ea188['removeDispositions'](_0x2cc602['query'][_0x2acf1c('0x2a')]);})[_0x569e04('0xaa')](respondWithStatusCode(_0x1baf25,null))['catch'](handleError(_0x1baf25,null));},exports[_0x53e245('0x23')]=function(_0x3e3790,_0x40b0c1){const _0x45b17d=_0x53e245;return _0x3e3790[_0x45b17d('0x56')]['id']&&delete _0x3e3790[_0x45b17d('0x56')]['id'],db[_0x45b17d('0x49')]['findOne']({'where':{'id':_0x3e3790[_0x45b17d('0x79')]['id']}})[_0x45b17d('0xaa')](handleEntityNotFound(_0x40b0c1,null))[_0x45b17d('0xaa')](function(_0x41193d){const _0x23d21a=_0x45b17d;if(_0x41193d)return _0x3e3790[_0x23d21a('0x56')][_0x23d21a('0x9')]=_0x41193d['id'],db[_0x23d21a('0x2c')][_0x23d21a('0x58')](_0x3e3790[_0x23d21a('0x56')]);})['then'](respondWithResult(_0x40b0c1,null))[_0x45b17d('0xa6')](handleError(_0x40b0c1,null));},exports[_0x53e245('0x9c')]=function(_0x3640db,_0x47efa5){const _0x3ff33e=_0x53e245;let _0x58abe6={'raw':![],'where':{}};const _0x1a6807={},_0x2ae248={'count':0x0,'rows':[]};return db[_0x3ff33e('0x49')][_0x3ff33e('0x8c')]({'where':{'id':_0x3640db[_0x3ff33e('0x79')]['id']}})[_0x3ff33e('0xaa')](handleEntityNotFound(_0x47efa5,null))['then'](function(_0x17a014){const _0x99e0bd=_0x3ff33e;if(_0x17a014)return _0x1a6807[_0x99e0bd('0xa1')]=_[_0x99e0bd('0x5f')](db[_0x99e0bd('0x2c')]['rawAttributes']),_0x1a6807[_0x99e0bd('0x54')]=_[_0x99e0bd('0x5f')](_0x3640db[_0x99e0bd('0x54')]),_0x1a6807[_0x99e0bd('0x83')]=_[_0x99e0bd('0x9d')](_0x1a6807[_0x99e0bd('0xa1')],_0x1a6807[_0x99e0bd('0x54')]),_0x58abe6[_0x99e0bd('0xad')]=_[_0x99e0bd('0x9d')](_0x1a6807[_0x99e0bd('0xa1')],qs[_0x99e0bd('0x4a')](_0x3640db['query'][_0x99e0bd('0x4a')])),_0x58abe6[_0x99e0bd('0xad')]=_0x58abe6[_0x99e0bd('0xad')][_0x99e0bd('0x2d')]?_0x58abe6[_0x99e0bd('0xad')]:_0x1a6807[_0x99e0bd('0xa1')],typeof _0x3640db[_0x99e0bd('0x54')][_0x99e0bd('0x65')]===_0x99e0bd('0x95')&&(_0x58abe6[_0x99e0bd('0x89')]=qs['limit'](_0x3640db[_0x99e0bd('0x54')][_0x99e0bd('0x89')]),_0x58abe6[_0x99e0bd('0x18')]=qs[_0x99e0bd('0x18')](_0x3640db[_0x99e0bd('0x54')]['offset'])),_0x58abe6[_0x99e0bd('0x2b')]=qs[_0x99e0bd('0x29')](_0x3640db[_0x99e0bd('0x54')][_0x99e0bd('0x29')]),_0x58abe6[_0x99e0bd('0x1e')]=qs['filters'](_[_0x99e0bd('0x1')](_0x3640db[_0x99e0bd('0x54')],_0x1a6807[_0x99e0bd('0x83')])),_0x58abe6['where'][_0x99e0bd('0x9')]=_0x17a014['id'],_0x3640db[_0x99e0bd('0x54')][_0x99e0bd('0x32')]&&(_0x58abe6[_0x99e0bd('0x1e')]=_[_0x99e0bd('0x72')](_0x58abe6[_0x99e0bd('0x1e')],{[Op['or']]:_[_0x99e0bd('0xa3')](_0x58abe6[_0x99e0bd('0xad')],function(_0x4f8401){const _0x2b044e=_0x99e0bd,_0x2e6da1={};return _0x2e6da1[_0x4f8401]={[Op['like']]:'%'+_0x3640db[_0x2b044e('0x54')][_0x2b044e('0x32')]+'%'},_0x2e6da1;})})),_0x58abe6=_[_0x99e0bd('0x72')]({},_0x58abe6,_0x3640db[_0x99e0bd('0x96')]),db['CannedAnswer'][_0x99e0bd('0x6a')]({'where':_0x58abe6[_0x99e0bd('0x1e')]})[_0x99e0bd('0xaa')](function(_0x4ee638){const _0x501f58=_0x99e0bd;return _0x2ae248[_0x501f58('0x6a')]=_0x4ee638,_0x3640db[_0x501f58('0x54')][_0x501f58('0x78')]&&(_0x58abe6['include']=[{'all':!![]}]),db[_0x501f58('0x2c')][_0x501f58('0x92')](_0x58abe6);})[_0x99e0bd('0xaa')](function(_0x425a26){return _0x2ae248['rows']=_0x425a26,_0x2ae248;});})[_0x3ff33e('0xaa')](respondWithFilteredResult(_0x47efa5,_0x58abe6))[_0x3ff33e('0xa6')](handleError(_0x47efa5,null));},exports[_0x53e245('0x5b')]=function(_0x2d93d4,_0x5d93f1){const _0x438aaa=_0x53e245;return db[_0x438aaa('0x49')][_0x438aaa('0x8c')]({'where':{'id':_0x2d93d4[_0x438aaa('0x79')]['id']}})[_0x438aaa('0xaa')](handleEntityNotFound(_0x5d93f1,null))[_0x438aaa('0xaa')](function(_0x292485){const _0x50185c=_0x438aaa;if(_0x292485)return _0x292485[_0x50185c('0x5b')](_0x2d93d4[_0x50185c('0x54')]['ids']);})[_0x438aaa('0xaa')](respondWithStatusCode(_0x5d93f1,null))[_0x438aaa('0xa6')](handleError(_0x5d93f1,null));},exports[_0x53e245('0x4f')]=function(_0x1504fd,_0x1c3b40){const _0x46774c=_0x53e245;return db['FaxInteraction']['findOne']({'where':{'id':_0x1504fd[_0x46774c('0x79')]['id']}})[_0x46774c('0xaa')](function(_0x41607d){const _0xf3e177=_0x46774c;if(_0x41607d)return _0x41607d[_0xf3e177('0x4f')](_0x1504fd[_0xf3e177('0x56')]['ids'],{'through':_[_0xf3e177('0x5a')](_0x1504fd[_0xf3e177('0x56')],[_0xf3e177('0x2a'),'id'])});})[_0x46774c('0xaa')](respondWithResult(_0x1c3b40,null))['catch'](handleError(_0x1c3b40,null));},exports[_0x53e245('0x15')]=function(_0x2805f9,_0x19ea41){const _0xad3a8c=_0x53e245;let _0x5c505b={'raw':![],'where':{}};const _0x9b8d9e={},_0x7b9db8={'count':0x0,'rows':[]};return db['FaxAccount'][_0xad3a8c('0x8c')]({'where':{'id':_0x2805f9['params']['id']}})[_0xad3a8c('0xaa')](handleEntityNotFound(_0x19ea41,null))[_0xad3a8c('0xaa')](function(_0x23b873){const _0x4d8af1=_0xad3a8c;if(_0x23b873)return _0x9b8d9e[_0x4d8af1('0xa1')]=_[_0x4d8af1('0x5f')](db['FaxInteraction'][_0x4d8af1('0x50')]),_0x9b8d9e[_0x4d8af1('0x54')]=_[_0x4d8af1('0x5f')](_0x2805f9[_0x4d8af1('0x54')]),_0x9b8d9e[_0x4d8af1('0x83')]=_[_0x4d8af1('0x9d')](_0x9b8d9e[_0x4d8af1('0xa1')],_0x9b8d9e['query']),_0x5c505b[_0x4d8af1('0xad')]=_[_0x4d8af1('0x9d')](_0x9b8d9e[_0x4d8af1('0xa1')],qs['fields'](_0x2805f9[_0x4d8af1('0x54')][_0x4d8af1('0x4a')])),_0x5c505b[_0x4d8af1('0xad')]=_0x5c505b[_0x4d8af1('0xad')][_0x4d8af1('0x2d')]?_0x5c505b[_0x4d8af1('0xad')]:_0x9b8d9e[_0x4d8af1('0xa1')],typeof _0x2805f9[_0x4d8af1('0x54')][_0x4d8af1('0x65')]===_0x4d8af1('0x95')&&(_0x5c505b['limit']=qs['limit'](_0x2805f9[_0x4d8af1('0x54')][_0x4d8af1('0x89')]),_0x5c505b[_0x4d8af1('0x18')]=qs[_0x4d8af1('0x18')](_0x2805f9[_0x4d8af1('0x54')]['offset'])),_0x5c505b[_0x4d8af1('0x2b')]=qs[_0x4d8af1('0x29')](_0x2805f9[_0x4d8af1('0x54')][_0x4d8af1('0x29')]),_0x5c505b[_0x4d8af1('0x1e')]=qs[_0x4d8af1('0x83')](_[_0x4d8af1('0x1')](_0x2805f9[_0x4d8af1('0x54')],_0x9b8d9e['filters'])),_0x5c505b[_0x4d8af1('0x1e')][_0x4d8af1('0x9')]=_0x23b873['id'],_0x2805f9[_0x4d8af1('0x54')]['filter']&&(_0x5c505b[_0x4d8af1('0x1e')]=_[_0x4d8af1('0x72')](_0x5c505b[_0x4d8af1('0x1e')],{[Op['or']]:_['map'](_0x5c505b['attributes'],function(_0x3e2aaf){const _0x128a58=_0x4d8af1,_0x562692={};return _0x562692[_0x3e2aaf]={[Op[_0x128a58('0x84')]]:'%'+_0x2805f9[_0x128a58('0x54')][_0x128a58('0x32')]+'%'},_0x562692;})})),_0x5c505b=_[_0x4d8af1('0x72')]({},_0x5c505b,_0x2805f9[_0x4d8af1('0x96')]),db[_0x4d8af1('0x57')][_0x4d8af1('0x6a')]({'where':_0x5c505b['where']})[_0x4d8af1('0xaa')](function(_0xee6c97){const _0x1ef4b5=_0x4d8af1;return _0x7b9db8['count']=_0xee6c97,_0x2805f9[_0x1ef4b5('0x54')][_0x1ef4b5('0x78')]&&(_0x5c505b[_0x1ef4b5('0x77')]=[{'model':db['CmContact'],'as':_0x1ef4b5('0x4b'),'required':![]},{'model':db[_0x1ef4b5('0x27')],'as':_0x1ef4b5('0xd'),'attributes':[_0x1ef4b5('0xa5'),_0x1ef4b5('0x87'),_0x1ef4b5('0x47')],'required':![]},{'model':db[_0x1ef4b5('0xc')],'as':'Tags','attributes':['id',_0x1ef4b5('0xa5'),_0x1ef4b5('0x39')],'where':_0x2805f9[_0x1ef4b5('0x54')][_0x1ef4b5('0x2f')]?{'id':_0x2805f9['query'][_0x1ef4b5('0x2f')]}:undefined,'required':_0x2805f9[_0x1ef4b5('0x54')][_0x1ef4b5('0x2f')]?!![]:![]}]),db[_0x1ef4b5('0x57')][_0x1ef4b5('0x92')](_0x5c505b);})[_0x4d8af1('0xaa')](function(_0x4c1324){const _0x4829e6=_0x4d8af1;return _0x7b9db8[_0x4829e6('0x97')]=_0x4c1324,_0x7b9db8;});})[_0xad3a8c('0xaa')](respondWithFilteredResult(_0x19ea41,_0x5c505b))[_0xad3a8c('0xa6')](handleError(_0x19ea41,null));},exports[_0x53e245('0x52')]=function(_0x57eed2,_0x1f26f5){const _0x220f11=_0x53e245;return db[_0x220f11('0x49')]['findOne']({'where':{'id':_0x57eed2['params']['id']}})[_0x220f11('0xaa')](handleEntityNotFound(_0x1f26f5,null))[_0x220f11('0xaa')](function(_0x571f42){const _0x3f37a2=_0x220f11;if(_0x571f42)return db[_0x3f37a2('0x7')][_0x3f37a2('0x91')](function(_0x495dcd){const _0x56d6fa=_0x3f37a2;return db['FaxApplication'][_0x56d6fa('0x1b')]({'where':{'FaxAccountId':_0x57eed2[_0x56d6fa('0x79')]['id']},'transaction':_0x495dcd})[_0x56d6fa('0xaa')](function(){const _0x167023=_0x56d6fa,_0x2f88a4=_[_0x167023('0xa3')](_0x57eed2['body'],function(_0x1390c2){const _0x10e55f=_0x167023;return _0x1390c2[_0x10e55f('0x9')]=_0x57eed2['params']['id'],_0x1390c2;});return db[_0x167023('0x6d')][_0x167023('0x8b')](_0x2f88a4,{'transaction':_0x495dcd});});})[_0x3f37a2('0xaa')](function(){const _0x53f446=_0x3f37a2;return db[_0x53f446('0x6d')][_0x53f446('0x11')]({'where':{'FaxAccountId':_0x57eed2[_0x53f446('0x79')]['id']},'order':_0x53f446('0x3c')});});})['then'](respondWithResult(_0x1f26f5,null))[_0x220f11('0xa6')](handleError(_0x1f26f5,null));},exports['getApplications']=function(_0xb4fb97,_0x43c47b){const _0x421dbf=_0x53e245;let _0x435ac9={};const _0x1fe01c={};let _0x527ae6,_0x700b90;return db[_0x421dbf('0x49')][_0x421dbf('0x8c')]({'where':{'id':_0xb4fb97[_0x421dbf('0x79')]['id']}})[_0x421dbf('0xaa')](handleEntityNotFound(_0x43c47b,null))[_0x421dbf('0xaa')](function(_0x4db82c){const _0x148a4c=_0x421dbf;if(_0x4db82c)return _0x527ae6=_0x4db82c,_0x1fe01c[_0x148a4c('0xa1')]=_[_0x148a4c('0x5f')](db[_0x148a4c('0x6d')]['rawAttributes']),_0x1fe01c[_0x148a4c('0x54')]=_[_0x148a4c('0x5f')](_0xb4fb97[_0x148a4c('0x54')]),_0x1fe01c[_0x148a4c('0x83')]=_[_0x148a4c('0x9d')](_0x1fe01c[_0x148a4c('0xa1')],_0x1fe01c[_0x148a4c('0x54')]),_0x435ac9[_0x148a4c('0xad')]=_[_0x148a4c('0x9d')](_0x1fe01c[_0x148a4c('0xa1')],qs['fields'](_0xb4fb97[_0x148a4c('0x54')]['fields'])),_0x435ac9[_0x148a4c('0xad')]=_0x435ac9['attributes'][_0x148a4c('0x2d')]?_0x435ac9[_0x148a4c('0xad')]:_0x1fe01c['model'],_0x435ac9['order']=qs[_0x148a4c('0x29')](_0xb4fb97[_0x148a4c('0x54')][_0x148a4c('0x29')]),_0x435ac9[_0x148a4c('0x1e')]=qs[_0x148a4c('0x83')](_[_0x148a4c('0x1')](_0xb4fb97['query'],_0x1fe01c[_0x148a4c('0x83')])),_0xb4fb97[_0x148a4c('0x54')][_0x148a4c('0x32')]&&(_0x435ac9[_0x148a4c('0x1e')]=_['merge'](_0x435ac9[_0x148a4c('0x1e')],{[Op['or']]:_[_0x148a4c('0xa3')](_0x435ac9[_0x148a4c('0xad')],function(_0x21e772){const _0x40ba20=_0x148a4c,_0x58a87e={};return _0x58a87e[_0x21e772]={[Op[_0x40ba20('0x84')]]:'%'+_0xb4fb97['query'][_0x40ba20('0x32')]+'%'},_0x58a87e;})})),_0x435ac9=_['merge']({},_0x435ac9,_0xb4fb97[_0x148a4c('0x96')]),_0x527ae6['getApplications'](_0x435ac9);})[_0x421dbf('0xaa')](function(_0x21a9fe){const _0xc01cbd=_0x421dbf;if(_0x21a9fe)return _0x700b90=_0x21a9fe[_0xc01cbd('0x2d')],typeof _0xb4fb97[_0xc01cbd('0x54')][_0xc01cbd('0x65')]===_0xc01cbd('0x95')&&(_0x435ac9[_0xc01cbd('0x89')]=qs['limit'](_0xb4fb97[_0xc01cbd('0x54')][_0xc01cbd('0x89')]),_0x435ac9[_0xc01cbd('0x18')]=qs[_0xc01cbd('0x18')](_0xb4fb97[_0xc01cbd('0x54')]['offset'])),_0x527ae6[_0xc01cbd('0x86')](_0x435ac9);})[_0x421dbf('0xaa')](function(_0x3dd2e0){if(_0x3dd2e0)return _0x3dd2e0?{'count':_0x700b90,'rows':_0x3dd2e0}:null;})[_0x421dbf('0xaa')](respondWithResult(_0x43c47b,null))[_0x421dbf('0xa6')](handleError(_0x43c47b,null));};function Extension(_0x39b6fa,_0x3a4868,_0x213a37,_0x40cb3b){const _0x5da1d9=_0x53e245;this['context']=_0x5da1d9('0x0'),this[_0x5da1d9('0x4d')]=_0x39b6fa[_0x5da1d9('0xf')],this[_0x5da1d9('0x45')]=_0x40cb3b,this[_0x5da1d9('0x6e')]=_0x5da1d9('0x94'),this[_0x5da1d9('0x5')]=_0x5da1d9('0x6b'),this['FaxAccountId']=_0x39b6fa['id'],this[_0x5da1d9('0x3c')]=_0x3a4868,this['appdata']=_0x213a37;}function createExtensionsReciveFax(_0x2ad53b){const _0x1af03c=_0x53e245;let _0x57a932=0x1;const _0xa8a209=[];_0xa8a209[_0x1af03c('0x1f')](new Extension(_0x2ad53b,_0x57a932,'',_0x1af03c('0x12'))),_0x57a932+=0x1,_0xa8a209['push'](new Extension(_0x2ad53b,_0x57a932,_0x1af03c('0x24'),_0x1af03c('0x59'))),_0x57a932+=0x1;for(const _0x197d30 in _0x2ad53b){typeof _0x2ad53b[_0x197d30]!=='undefined'&&(_0x197d30==='ecm'||_0x197d30===_0x1af03c('0xf')||_0x197d30==='gateway'||_0x197d30===_0x1af03c('0x7b')||_0x197d30===_0x1af03c('0x2')||_0x197d30===_0x1af03c('0x90')||_0x197d30===_0x1af03c('0x99')||_0x197d30==='modem'||_0x197d30===_0x1af03c('0x7e'))&&(_0xa8a209['push'](new Extension(_0x2ad53b,_0x57a932,_0x1af03c('0x30')+_0x197d30+')='+_0x2ad53b[_0x197d30],_0x1af03c('0x59'))),_0x57a932+=0x1);}return _0xa8a209[_0x1af03c('0x1f')](new Extension(_0x2ad53b,_0x57a932,'6',_0x1af03c('0x73'))),_0x57a932+=0x1,_0xa8a209[_0x1af03c('0x1f')](new Extension(_0x2ad53b,_0x57a932,_0x1af03c('0x19'),'ReceiveFax')),_0x57a932=0x0,_0xa8a209;}exports[_0x53e245('0x3f')]=function(_0x3ef389,_0x477090){const _0x1af70d=_0x53e245;let _0x3a71ec;return db[_0x1af70d('0x7')]['transaction'](function(_0x2bf1cd){const _0x148247=_0x1af70d;return db['FaxAccount'][_0x148247('0x58')](_0x3ef389['body'],{'transaction':_0x2bf1cd})[_0x148247('0xaa')](function(_0xd0bb53){const _0x43bd1c=_0x148247;return _0x3a71ec=_0xd0bb53[_0x43bd1c('0xe')]({'plain':!![]}),db['VoiceExtension']['bulkCreate'](createExtensionsReciveFax(_0x3a71ec),{'transaction':_0x2bf1cd});});})['then'](function(){return _0x3a71ec;})[_0x1af70d('0xaa')](respondWithResult(_0x477090,null))[_0x1af70d('0xa6')](handleError(_0x477090,null));},exports['updateAccountApplications']=function(_0x562b18,_0x18aed9){const _0x33210c=_0x53e245;return db[_0x33210c('0x7')][_0x33210c('0x91')](function(_0x18be2e){const _0x1647f5=_0x33210c;return db[_0x1647f5('0x49')]['update'](_0x562b18[_0x1647f5('0x56')],{'where':{'id':_0x562b18[_0x1647f5('0x56')]['id']},'transaction':_0x18be2e})[_0x1647f5('0xaa')](function(){const _0xb792d0=_0x1647f5;return db[_0xb792d0('0x82')][_0xb792d0('0x1b')]({'where':{'FaxAccountId':_0x562b18[_0xb792d0('0x56')]['id']},'transaction':_0x18be2e})[_0xb792d0('0xaa')](function(){const _0x5b7c8b=_0xb792d0;return db[_0x5b7c8b('0x82')]['bulkCreate'](createExtensionsReciveFax(_[_0x5b7c8b('0x5a')](_0x562b18[_0x5b7c8b('0x56')],['tech',_0x5b7c8b('0x8a'),'createdAt',_0x5b7c8b('0x8'),_0x5b7c8b('0x44'),'ListId'])),{'transaction':_0x18be2e});});});})['then'](function(){const _0x2cce31=_0x33210c;return db[_0x2cce31('0x49')][_0x2cce31('0x22')](_0x562b18['body']['id']);})[_0x33210c('0xaa')](respondWithResult(_0x18aed9,null))[_0x33210c('0xa6')](handleError(_0x18aed9,null));},exports[_0x53e245('0x80')]=function(_0x2e25ff,_0x67cbfb){const _0x98041f=_0x53e245;let _0x26c37c={'raw':!![],'where':{}};const _0x4e39ce={},_0x35672e={'count':0x0,'rows':[]};return db[_0x98041f('0x49')][_0x98041f('0x8c')]({'where':{'id':_0x2e25ff['params']['id']}})[_0x98041f('0xaa')](handleEntityNotFound(_0x67cbfb,null))['then'](function(_0x2038af){const _0x3e07d1=_0x98041f;if(_0x2038af){_0x4e39ce[_0x3e07d1('0xa1')]=_[_0x3e07d1('0x5f')](db[_0x3e07d1('0x42')]['rawAttributes']),_0x4e39ce['query']=_[_0x3e07d1('0x5f')](_0x2e25ff[_0x3e07d1('0x54')]),_0x4e39ce['filters']=_[_0x3e07d1('0x9d')](_0x4e39ce[_0x3e07d1('0xa1')],_0x4e39ce[_0x3e07d1('0x54')]),_0x26c37c[_0x3e07d1('0xad')]=_[_0x3e07d1('0x9d')](_0x4e39ce[_0x3e07d1('0xa1')],qs['fields'](_0x2e25ff[_0x3e07d1('0x54')][_0x3e07d1('0x4a')])),_0x26c37c['attributes']=_0x26c37c[_0x3e07d1('0xad')][_0x3e07d1('0x2d')]?_0x26c37c[_0x3e07d1('0xad')]:_0x4e39ce['model'];typeof _0x2e25ff[_0x3e07d1('0x54')]['nolimit']==='undefined'&&(_0x26c37c[_0x3e07d1('0x89')]=qs[_0x3e07d1('0x89')](_0x2e25ff['query'][_0x3e07d1('0x89')]),_0x26c37c[_0x3e07d1('0x18')]=qs[_0x3e07d1('0x18')](_0x2e25ff[_0x3e07d1('0x54')]['offset']));_0x26c37c[_0x3e07d1('0x2b')]=qs[_0x3e07d1('0x29')](_0x2e25ff[_0x3e07d1('0x54')]['sort']),_0x26c37c['where']=qs[_0x3e07d1('0x83')](_[_0x3e07d1('0x1')](_0x2e25ff[_0x3e07d1('0x54')],_0x4e39ce[_0x3e07d1('0x83')])),_0x26c37c[_0x3e07d1('0x1e')][_0x3e07d1('0x9')]=_0x2038af['id'];_0x2e25ff[_0x3e07d1('0x54')]['filter']&&(_0x26c37c[_0x3e07d1('0x1e')]=_[_0x3e07d1('0x72')](_0x26c37c['where'],{[Op['or']]:_[_0x3e07d1('0xa3')](_0x26c37c[_0x3e07d1('0xad')],function(_0xd103bb){const _0x495e40=_0x3e07d1,_0x2476a1={};return _0x2476a1[_0xd103bb]={[Op[_0x495e40('0x84')]]:'%'+_0x2e25ff['query']['filter']+'%'},_0x2476a1;})}));if(_0x2e25ff[_0x3e07d1('0x54')][_0x3e07d1('0x25')]){const _0x37b88e=_0x2e25ff[_0x3e07d1('0x54')]['$gte']['split'](','),_0x526e39={};_0x526e39[_0x37b88e[0x0]]={[Op[_0x3e07d1('0x38')]]:moment(_0x37b88e[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')},_0x26c37c[_0x3e07d1('0x1e')]=_[_0x3e07d1('0x72')](_0x26c37c[_0x3e07d1('0x1e')],_0x526e39);}return _0x26c37c=_[_0x3e07d1('0x72')]({},_0x26c37c,_0x2e25ff['options']),db[_0x3e07d1('0x42')][_0x3e07d1('0x6a')]({'where':_0x26c37c['where']})[_0x3e07d1('0xaa')](function(_0x4860cd){const _0x7e8cfa=_0x3e07d1;return _0x35672e[_0x7e8cfa('0x6a')]=_0x4860cd,_0x2e25ff['query'][_0x7e8cfa('0x78')]&&(_0x26c37c[_0x7e8cfa('0x77')]=[{'all':!![]}]),db[_0x7e8cfa('0x42')][_0x7e8cfa('0x92')](_0x26c37c);})[_0x3e07d1('0xaa')](function(_0x230bc0){return _0x35672e['rows']=_0x230bc0,_0x35672e;});}})['then'](respondWithFilteredResult(_0x67cbfb,_0x26c37c))[_0x98041f('0xa6')](handleError(_0x67cbfb,null));},exports[_0x53e245('0x3e')]=function(_0x23ed3c,_0x327994){const _0x12b9ee=_0x53e245;let _0x3b317f,_0x3f1f3a;return _0x23ed3c[_0x12b9ee('0x56')]['to']&&(_0x3f1f3a=_0x23ed3c[_0x12b9ee('0x56')]['to'][0x0]),db[_0x12b9ee('0x49')][_0x12b9ee('0x8c')]({'where':{'id':_0x23ed3c[_0x12b9ee('0x79')]['id']},'include':[{'model':db[_0x12b9ee('0x4c')],'as':_0x12b9ee('0x36'),'include':[{'model':db[_0x12b9ee('0x5d')],'as':_0x12b9ee('0x66'),'where':{'fax':_0x3f1f3a},'limit':0x1,'order':[[_0x12b9ee('0x8'),_0x12b9ee('0xac')]]}]}]})['then'](handleEntityNotFound(_0x327994,null))[_0x12b9ee('0xaa')](function(_0x5a9bc9){const _0x535d1f=_0x12b9ee;_0x3b317f=_0x5a9bc9;if(_0x23ed3c[_0x535d1f('0x56')]['attachments']&&_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][_0x535d1f('0x2d')])for(let _0x5cd309=0x0;_0x5cd309<_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][_0x535d1f('0x2d')];_0x5cd309+=0x1){_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][_0x5cd309]={'filename':_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][_0x5cd309][_0x535d1f('0xa5')],'id':_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][_0x5cd309]['id'],'path':path[_0x535d1f('0x20')](config[_0x535d1f('0xa9')],_0x535d1f('0x88'),_0x23ed3c['body'][_0x535d1f('0x4e')][_0x5cd309][_0x535d1f('0x9b')])};}return respondWithRpcPromise(_0x535d1f('0xa7'),'CheckAfterSend',{'FaxAccountId':_[_0x535d1f('0x9f')](_0x23ed3c['params']['id'])?undefined:_0x23ed3c[_0x535d1f('0x79')]['id'],'path':_[_0x535d1f('0x9f')](_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][0x0][_0x535d1f('0x76')])?undefined:_0x23ed3c[_0x535d1f('0x56')][_0x535d1f('0x4e')][0x0][_0x535d1f('0x76')],'fax':_[_0x535d1f('0x9f')](_0x23ed3c[_0x535d1f('0x56')]['to'][0x0])?undefined:_0x23ed3c['body']['to'][0x0]},client9002);})[_0x12b9ee('0xaa')](function(){const _0x2a94ca=_0x12b9ee;if(_0x3b317f){_[_0x2a94ca('0x9f')](_0x23ed3c[_0x2a94ca('0x56')][_0x2a94ca('0x7c')])&&(_0x23ed3c[_0x2a94ca('0x56')][_0x2a94ca('0x7c')]=util[_0x2a94ca('0x2e')](_0x2a94ca('0x68'),_0x3b317f['name'],_0x3b317f[_0x2a94ca('0x3b')]));if(_0x3b317f['List'])return _0x3b317f[_0x2a94ca('0x36')][_0x2a94ca('0x66')][_0x2a94ca('0x2d')]?_0x3b317f[_0x2a94ca('0x36')]['Contacts'][0x0]:db[_0x2a94ca('0x5d')]['create'](_[_0x2a94ca('0x93')](_0x23ed3c[_0x2a94ca('0x56')],{'firstName':_0x23ed3c['body']['to'][0x0],'phone':_0x23ed3c[_0x2a94ca('0x56')]['to'][0x0],'fax':_0x23ed3c[_0x2a94ca('0x56')]['to'][0x0],'ListId':_0x3b317f[_0x2a94ca('0x1a')]}));else throw new Error(_0x2a94ca('0x70'));}else throw new Error(_0x2a94ca('0x60'));})[_0x12b9ee('0xaa')](function(_0x114cc5){const _0x42097c=_0x12b9ee;if(_0x114cc5)return db[_0x42097c('0x57')][_0x42097c('0x8c')]({'where':{'ContactId':_0x114cc5['id'],'closed':![],'FaxAccountId':_0x3b317f['id']}})['then'](function(_0x39d469){const _0x3ad69f=_0x42097c;if(_0x39d469)return[_0x39d469,![]];return db[_0x3ad69f('0x57')][_0x3ad69f('0x58')]({'UserId':_0x23ed3c[_0x3ad69f('0xa4')]['id'],'ContactId':_0x114cc5['id'],'FaxAccountId':_0x3b317f['id'],'fax':_0x23ed3c[_0x3ad69f('0x56')]['to'][0x0],'firstMsgDirection':_0x3ad69f('0x37'),'Messages':[_[_0x3ad69f('0x72')](_0x23ed3c['body'],{'read':![],'body':_0x23ed3c['body']['attachments'][0x0]['filename'],'FaxAccountId':_0x3b317f['id'],'UserId':_0x23ed3c[_0x3ad69f('0xa4')]['id'],'ContactId':_0x114cc5['id'],'AttachmentId':_0x23ed3c['body'][_0x3ad69f('0x4e')][0x0]['id']})]},{'include':[{'model':db[_0x3ad69f('0x42')],'as':_0x3ad69f('0x51')}]})[_0x3ad69f('0xaa')](function(_0x5154d3){return[_0x5154d3,!![]];});});else throw new Error(_0x42097c('0x8f'));})[_0x12b9ee('0xaa')](function([_0x4a1224,_0x280550]){const _0xe2af33=_0x12b9ee;if(_0x280550)return _0x4a1224;return db[_0xe2af33('0x42')]['create']({'direction':_0xe2af33('0x37'),'read':![],'body':_0x23ed3c[_0xe2af33('0x56')]['attachments'][0x0][_0xe2af33('0x64')],'FaxAccountId':_0x3b317f['id'],'FaxInteractionId':_0x4a1224['id'],'UserId':_0x23ed3c[_0xe2af33('0xa4')]['id'],'ContactId':_0x4a1224[_0xe2af33('0x61')],'AttachmentId':_0x23ed3c[_0xe2af33('0x56')][_0xe2af33('0x4e')][0x0]['id']})[_0xe2af33('0xaa')](function(_0x273e22){const _0x4791a4=_0xe2af33;return _0x4a1224[_0x4791a4('0x7a')][_0x4791a4('0x51')]=[],_0x4a1224['dataValues'][_0x4791a4('0x51')][_0x4791a4('0x1f')](_0x273e22[_0x4791a4('0x7a')]),_0x4a1224;});})[_0x12b9ee('0xaa')](function(_0x575064){const _0x4a6b81=_0x12b9ee;return respondWithRpcPromise('SendFax',_0x4a6b81('0x9a'),{'FaxAccountId':_['isNil'](_0x23ed3c['params']['id'])?undefined:_0x23ed3c[_0x4a6b81('0x79')]['id'],'path':_[_0x4a6b81('0x9f')](_0x23ed3c[_0x4a6b81('0x56')][_0x4a6b81('0x4e')][0x0]['path'])?undefined:_0x23ed3c[_0x4a6b81('0x56')][_0x4a6b81('0x4e')][0x0][_0x4a6b81('0x76')],'fax':_[_0x4a6b81('0x9f')](_0x23ed3c[_0x4a6b81('0x56')]['to'][0x0])?undefined:_0x23ed3c['body']['to'][0x0],'AttachmentId':_0x23ed3c['body']['attachments'][0x0]['id']},client9002)[_0x4a6b81('0xaa')](function(_0x39ce4f){const _0x3a2b49=_0x4a6b81;logger[_0x3a2b49('0x74')](_0x3a2b49('0x34'),_0x39ce4f);})[_0x4a6b81('0xa6')](function(_0x3e53da){const _0x18ea08=_0x4a6b81;logger[_0x18ea08('0x74')]('SendFaxRpc,\x20%s',_0x3e53da);}),_0x575064;})['then'](respondWithResult(_0x327994,null))[_0x12b9ee('0xa6')](handleError(_0x327994,null));},exports[_0x53e245('0x3')]=function(_0x3ab0cc,_0x2438bd){const _0x35864a=_0x53e245;return db[_0x35864a('0x49')]['findOne']({'where':{'id':_0x3ab0cc['params']['id']}})[_0x35864a('0xaa')](function(_0x709ac3){const _0x425799=_0x35864a;if(_0x709ac3)return _0x709ac3[_0x425799('0x3')](_0x3ab0cc['body'][_0x425799('0x2a')],{'through':_[_0x425799('0x5a')](_0x3ab0cc['body'],[_0x425799('0x2a'),'id'])})[_0x425799('0xaa')](function(_0x170cb0){const _0x1b44b0=_0x425799;for(let _0x25172d=0x0;_0x25172d<_0x3ab0cc[_0x1b44b0('0x56')][_0x1b44b0('0x2a')][_0x1b44b0('0x2d')];_0x25172d+=0x1){socket[_0x1b44b0('0x28')]('userFaxAccount:save',{'UserId':_0x3ab0cc['body'][_0x1b44b0('0x2a')][_0x25172d],'FaxAccountId':_0x3ab0cc[_0x1b44b0('0x79')]['id']});}return _0x170cb0;});})['then'](respondWithResult(_0x2438bd,null))[_0x35864a('0xa6')](handleError(_0x2438bd,null));},exports[_0x53e245('0x85')]=function(_0xc19fcc,_0x110af2){const _0x5f29a2=_0x53e245;return db[_0x5f29a2('0x49')][_0x5f29a2('0x8c')]({'where':{'id':_0xc19fcc[_0x5f29a2('0x79')]['id']}})[_0x5f29a2('0xaa')](handleEntityNotFound(_0x110af2,null))[_0x5f29a2('0xaa')](function(_0x50d8e9){const _0x43557=_0x5f29a2;if(_0x50d8e9)return _0x50d8e9['removeAgents'](_0xc19fcc[_0x43557('0x54')]['ids'])[_0x43557('0xaa')](function(){const _0x3d2656=_0x43557;if(_[_0x3d2656('0x7d')](_0xc19fcc[_0x3d2656('0x54')][_0x3d2656('0x2a')]))for(let _0x1e3bbc=0x0;_0x1e3bbc<_0xc19fcc['query'][_0x3d2656('0x2a')][_0x3d2656('0x2d')];_0x1e3bbc+=0x1){socket[_0x3d2656('0x28')](_0x3d2656('0x3a'),{'UserId':Number(_0xc19fcc[_0x3d2656('0x54')][_0x3d2656('0x2a')][_0x1e3bbc]),'FaxAccountId':Number(_0xc19fcc[_0x3d2656('0x79')]['id'])});}else socket[_0x3d2656('0x28')]('userFaxAccount:remove',{'UserId':Number(_0xc19fcc[_0x3d2656('0x54')][_0x3d2656('0x2a')]),'FaxAccountId':Number(_0xc19fcc[_0x3d2656('0x79')]['id'])});});})[_0x5f29a2('0xaa')](respondWithStatusCode(_0x110af2,null))[_0x5f29a2('0xa6')](handleError(_0x110af2,null));},exports[_0x53e245('0x71')]=function(_0x28671c,_0x162d7a){const _0x478f0a=_0x53e245;let _0x10cdad={};const _0x2a80e0={};let _0x284aeb,_0x14fe2f;return db['FaxAccount'][_0x478f0a('0x8c')]({'where':{'id':_0x28671c['params']['id']}})['then'](handleEntityNotFound(_0x162d7a,null))[_0x478f0a('0xaa')](function(_0xa2dfd9){const _0x2e7a75=_0x478f0a;if(_0xa2dfd9)return _0x284aeb=_0xa2dfd9,_0x2a80e0[_0x2e7a75('0xa1')]=_[_0x2e7a75('0x5f')](db[_0x2e7a75('0x27')][_0x2e7a75('0x50')]),_0x2a80e0[_0x2e7a75('0x54')]=_['keys'](_0x28671c[_0x2e7a75('0x54')]),_0x2a80e0[_0x2e7a75('0x83')]=_['intersection'](_0x2a80e0[_0x2e7a75('0xa1')],_0x2a80e0['query']),_0x10cdad['attributes']=_['intersection'](_0x2a80e0[_0x2e7a75('0xa1')],qs[_0x2e7a75('0x4a')](_0x28671c['query'][_0x2e7a75('0x4a')])),_0x10cdad[_0x2e7a75('0xad')]=_0x10cdad['attributes']['length']?_0x10cdad['attributes']:_0x2a80e0[_0x2e7a75('0xa1')],_0x10cdad[_0x2e7a75('0x2b')]=qs['sort'](_0x28671c['query'][_0x2e7a75('0x29')]),_0x10cdad[_0x2e7a75('0x1e')]=qs['filters'](_['pick'](_0x28671c[_0x2e7a75('0x54')],_0x2a80e0[_0x2e7a75('0x83')])),_0x28671c[_0x2e7a75('0x54')][_0x2e7a75('0x32')]&&(_0x10cdad[_0x2e7a75('0x1e')]=_[_0x2e7a75('0x72')](_0x10cdad[_0x2e7a75('0x1e')],{[Op['or']]:_[_0x2e7a75('0xa3')](_0x10cdad[_0x2e7a75('0xad')],function(_0x5257cb){const _0x2567ff=_0x2e7a75,_0x3243ae={};return _0x3243ae[_0x5257cb]={[Op[_0x2567ff('0x84')]]:'%'+_0x28671c[_0x2567ff('0x54')][_0x2567ff('0x32')]+'%'},_0x3243ae;})})),_0x10cdad=_['merge']({},_0x10cdad,_0x28671c[_0x2e7a75('0x96')]),_0x284aeb[_0x2e7a75('0x71')](_0x10cdad);})[_0x478f0a('0xaa')](function(_0x591ee5){const _0x18ce97=_0x478f0a;if(_0x591ee5)return _0x14fe2f=_0x591ee5[_0x18ce97('0x2d')],typeof _0x28671c['query'][_0x18ce97('0x65')]===_0x18ce97('0x95')&&(_0x10cdad[_0x18ce97('0x89')]=qs['limit'](_0x28671c[_0x18ce97('0x54')][_0x18ce97('0x89')]),_0x10cdad[_0x18ce97('0x18')]=qs[_0x18ce97('0x18')](_0x28671c[_0x18ce97('0x54')]['offset'])),_0x284aeb['getAgents'](_0x10cdad);})[_0x478f0a('0xaa')](function(_0x13e3ae){if(_0x13e3ae)return _0x13e3ae?{'count':_0x14fe2f,'rows':_0x13e3ae}:null;})[_0x478f0a('0xaa')](respondWithResult(_0x162d7a,null))[_0x478f0a('0xa6')](handleError(_0x162d7a,null));};