15dec07277a9bf01004c3d509e6dbab21380829e
[motion-next.git] / server / api / faxAccount / faxAccount.controller.js
1 const a222_0x2a15=['attributes','ContactId','findOne','getAgents','like','CmContact','priority','user','Pause','../../rediscache','getInteractions','minrate','fieldName','get','includeAll','User','json','include','exten','ids','stack','SendFaxRpc,\x20%s','catch','update','FaxAccount,\x20%s,\x20%s','merge','mandatoryDispositionPause','FaxInteraction','path','SendFax','Wait','status','sendStatus','attachments','VoiceExtension','omit','type','bulkCreate','Disposition','tech','info','server/files/attachments','register','filters','format','describe','Owner','FaxApplication','internal','FaxAccount','emit','gateway','Contact','gte','transaction','show','dataValues','localstationid','error','rows','model','updatedAt','then','CDR(type)=inbound-fax','Unable\x20to\x20retrieve\x20the\x20current\x20user','util','removeAnswers','moment','pick','set','getAnswers','addInteraction','ecm','../../mysqldb','userFaxAccount:remove','request\x20sent','removeAgents','params','fields','addAgents','Answer','$gte','Contact\x20not\x20found','filter','modem','FaxAccount,\x20%s,\x20%s,\x20%s','code','Contacts','t38timeout','maxrate','lodash','FaxMessage','Tags','CheckAfterSend','rawAttributes','message','Send\x20Fax\x20failed','push','order','stringify','length','UserProfileResource','faxdetect','app','sequelize','List\x20not\x20found','removeDispositions','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','debug','getMessages','from','tag','/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','options','sort','FaxAccounts','http','client','destroy','../../config/logger','FaxAccountId','intersection','undefined','role','createdAt','out','where','context','addApplications','addAccountApplications','map','limit','findAndCountAll','addDisposition','nolimit','Messages','CannedAnswer','UserProfileSection','name','List','fax','keys','getApplications','updateAccountApplications','headerinfo','system','findAll','userFaxAccount:save','count','isArray','key','ReceiveFax','end','body','basename','create','Set','TrunkId','filename','../../components/parsers/qs','jayson/promise','DESC','root','FAXOPT(','query','appdata','isNil','Fax\x20Extension','\x22%s\x22\x20<%s>','offset'];(function(_0x42dbd3,_0x4a2ae7){const _0x2a150c=function(_0x5a4e5d){while(--_0x5a4e5d){_0x42dbd3['push'](_0x42dbd3['shift']());}};_0x2a150c(++_0x4a2ae7);}(a222_0x2a15,0xfb));const a222_0x5a4e=function(_0x42dbd3,_0x4a2ae7){_0x42dbd3=_0x42dbd3-0x136;let _0x2a150c=a222_0x2a15[_0x42dbd3];return _0x2a150c;};const a222_0x1b0590=a222_0x5a4e;'use strict';const moment=require(a222_0x1b0590(0x1d2)),util=require(a222_0x1b0590(0x1d0)),path=require(a222_0x1b0590(0x1ab)),_=require(a222_0x1b0590(0x13f)),{getSocket}=require(a222_0x1b0590(0x198)),socket=getSocket(),qs=require(a222_0x1b0590(0x184)),logger=require(a222_0x1b0590(0x15c))('api'),config=require('../../config/environment'),{db}=require(a222_0x1b0590(0x1d8)),{Op}=require(a222_0x1b0590(0x14d));require('./faxAccount.socket')[a222_0x1b0590(0x1b9)](socket);const jayson=require(a222_0x1b0590(0x185)),client=jayson[a222_0x1b0590(0x15a)]['http']({'port':0x232c}),client9002=jayson[a222_0x1b0590(0x15a)][a222_0x1b0590(0x159)]({'port':0x232a});function respondWithRpcPromise(_0x580008,_0x4dcc39,_0x19c437,_0x4d8127){return new Promise(function(_0x5cb753,_0x4256e0){const _0x1beb69=a222_0x5a4e,_0x8e5e8c=_0x4d8127||client;return _0x8e5e8c['request'](_0x580008,_0x19c437)[_0x1beb69(0x1cd)](function(_0x90afc8){const _0x2f9fe8=_0x1beb69;logger[_0x2f9fe8(0x1b7)](_0x2f9fe8(0x1a7),_0x4dcc39,'request\x20sent'),logger[_0x2f9fe8(0x151)](_0x2f9fe8(0x13a),_0x4dcc39,_0x2f9fe8(0x1da),JSON[_0x2f9fe8(0x148)](_0x90afc8));if(_0x90afc8[_0x2f9fe8(0x1c9)]){if(_0x90afc8[_0x2f9fe8(0x1c9)][_0x2f9fe8(0x13b)]===0x1f4)return logger['error']('FaxAccount,\x20%s,\x20%s',_0x4dcc39,_0x90afc8[_0x2f9fe8(0x1c9)][_0x2f9fe8(0x144)]),_0x4256e0(_0x90afc8[_0x2f9fe8(0x1c9)][_0x2f9fe8(0x144)]);return logger[_0x2f9fe8(0x1c9)](_0x2f9fe8(0x1a7),_0x4dcc39,_0x90afc8[_0x2f9fe8(0x1c9)][_0x2f9fe8(0x144)]),_0x5cb753(_0x90afc8['error'][_0x2f9fe8(0x144)]);}else logger['info'](_0x2f9fe8(0x1a7),_0x4dcc39,_0x2f9fe8(0x1da)),_0x5cb753(_0x90afc8['result'][_0x2f9fe8(0x144)]);})[_0x1beb69(0x1a5)](function(_0x23bf5d){logger['error']('FaxAccount,\x20%s,\x20%s',_0x4dcc39,_0x23bf5d),_0x4256e0(_0x23bf5d);});});}function respondWithStatusCode(_0x4c7c64,_0x26e00f){return _0x26e00f=_0x26e00f||0xcc,function(_0x8c650){const _0x2491d4=a222_0x5a4e;if(_0x8c650)return _0x4c7c64[_0x2491d4(0x1af)](_0x26e00f);return _0x4c7c64[_0x2491d4(0x1ae)](_0x26e00f)[_0x2491d4(0x17d)]();};}function respondWithResult(_0x5997eb,_0x283b66){return _0x283b66=_0x283b66||0xc8,function(_0x2cb2f6){const _0x56181e=a222_0x5a4e;if(_0x2cb2f6)return _0x5997eb['status'](_0x283b66)[_0x56181e(0x19f)](_0x2cb2f6);};}function respondWithFilteredResult(_0x27cb98,_0x2903f3){return function(_0x422f6d){const _0x25ae05=a222_0x5a4e;if(_0x422f6d){const _0x2b0eac=_0x422f6d['count'],_0x54e438=_0x2903f3['offset'];let _0x494e5a=_0x2903f3[_0x25ae05(0x18e)]+_0x2903f3[_0x25ae05(0x168)],_0x73a1ac;return _0x494e5a>=_0x2b0eac?(_0x494e5a=_0x2b0eac,_0x73a1ac=0xc8):_0x73a1ac=0xce,_0x27cb98[_0x25ae05(0x1ae)](_0x73a1ac),_0x27cb98[_0x25ae05(0x1d4)]('Content-Range',_0x54e438+'-'+_0x494e5a+'/'+_0x2b0eac)[_0x25ae05(0x19f)](_0x422f6d);}return null;};}function saveUpdates(_0x46539e){return function(_0x13c87f){const _0x498fcc=a222_0x5a4e;if(_0x13c87f)return _0x13c87f[_0x498fcc(0x1a6)](_0x46539e)['then'](function(_0x5c5564){return _0x5c5564;});return null;};}function removeEntity(_0x4551d8){return function(_0x53b1a0){const _0x1d12f9=a222_0x5a4e;if(_0x53b1a0)return _0x53b1a0[_0x1d12f9(0x15b)]()[_0x1d12f9(0x1cd)](function(){const _0x3ed4a1=_0x1d12f9,_0x22d364=_0x53b1a0[_0x3ed4a1(0x19c)]({'plain':!![]}),_0x4683cc=_0x3ed4a1(0x158);return db['UserProfileResource'][_0x3ed4a1(0x15b)]({'where':{'type':_0x4683cc,'resourceId':_0x22d364['id']}})[_0x3ed4a1(0x1cd)](function(){return _0x53b1a0;});})[_0x1d12f9(0x1cd)](function(){const _0x4f2ff6=_0x1d12f9;_0x4551d8[_0x4f2ff6(0x1ae)](0xcc)[_0x4f2ff6(0x17d)]();});};}function handleEntityNotFound(_0x471247){return function(_0x4e3220){const _0x22adbe=a222_0x5a4e;return!_0x4e3220&&_0x471247[_0x22adbe(0x1af)](0x194),_0x4e3220;};}function handleError(_0x267ff6,_0x1e9d1f){return _0x1e9d1f=_0x1e9d1f||0x1f4,function(_0x581712){const _0x488919=a222_0x5a4e;logger['error'](_0x581712[_0x488919(0x1a3)]),_0x581712[_0x488919(0x16f)]&&delete _0x581712[_0x488919(0x16f)],_0x267ff6[_0x488919(0x1ae)](_0x1e9d1f)['send'](_0x581712);};}exports['index']=function(_0x5ec752,_0x811ed5){const _0x28f111=a222_0x1b0590;let _0x50f1af={'include':[{'model':db[_0x28f111(0x197)],'as':_0x28f111(0x1a9)}]};const _0x23f5fa={},_0x156090={'count':0x0,'rows':[]},_0x571c8c=_[_0x28f111(0x167)](db[_0x28f111(0x1c0)][_0x28f111(0x143)],function(_0x2ee9f7){const _0x3f0f00=_0x28f111;return{'name':_0x2ee9f7[_0x3f0f00(0x19b)],'type':_0x2ee9f7[_0x3f0f00(0x1b3)][_0x3f0f00(0x17b)]};});_0x23f5fa[_0x28f111(0x1cb)]=_[_0x28f111(0x167)](_0x571c8c,'name'),_0x23f5fa[_0x28f111(0x189)]=_['keys'](_0x5ec752[_0x28f111(0x189)]),_0x23f5fa[_0x28f111(0x1ba)]=_[_0x28f111(0x15e)](_0x23f5fa[_0x28f111(0x1cb)],_0x23f5fa[_0x28f111(0x189)]),_0x50f1af[_0x28f111(0x18f)]=_[_0x28f111(0x15e)](_0x23f5fa[_0x28f111(0x1cb)],qs[_0x28f111(0x1dd)](_0x5ec752['query'][_0x28f111(0x1dd)])),_0x50f1af['attributes']=_0x50f1af[_0x28f111(0x18f)]['length']?_0x50f1af[_0x28f111(0x18f)]:_0x23f5fa[_0x28f111(0x1cb)];typeof _0x5ec752[_0x28f111(0x189)]['nolimit']==='undefined'&&(_0x50f1af[_0x28f111(0x168)]=qs[_0x28f111(0x168)](_0x5ec752[_0x28f111(0x189)][_0x28f111(0x168)]),_0x50f1af[_0x28f111(0x18e)]=qs[_0x28f111(0x18e)](_0x5ec752[_0x28f111(0x189)][_0x28f111(0x18e)]));_0x50f1af[_0x28f111(0x147)]=qs['sort'](_0x5ec752['query'][_0x28f111(0x157)]),_0x50f1af['where']=qs['filters'](_[_0x28f111(0x1d3)](_0x5ec752[_0x28f111(0x189)],_0x23f5fa[_0x28f111(0x1ba)]),_0x571c8c);_0x5ec752[_0x28f111(0x189)]['filter']&&(_0x50f1af[_0x28f111(0x163)]=_[_0x28f111(0x1a8)](_0x50f1af[_0x28f111(0x163)],{[Op['or']]:_['map'](_0x571c8c,function(_0x257c06){const _0x93c259=_0x28f111;if(_0x257c06['type']!=='VIRTUAL'){const _0x57f3d2={};return _0x57f3d2[_0x257c06[_0x93c259(0x16f)]]={[Op[_0x93c259(0x193)]]:'%'+_0x5ec752[_0x93c259(0x189)][_0x93c259(0x138)]+'%'},_0x57f3d2;}})}));_0x50f1af=_[_0x28f111(0x1a8)]({},_0x50f1af,_0x5ec752['options']);const _0xc73655={'where':_0x50f1af[_0x28f111(0x163)]};return db[_0x28f111(0x1c0)][_0x28f111(0x179)](_0xc73655)[_0x28f111(0x1cd)](function(_0x1e8545){const _0x7979ae=_0x28f111;return _0x156090['count']=_0x1e8545,_0x5ec752[_0x7979ae(0x189)][_0x7979ae(0x19d)]&&(_0x50f1af['include']=[{'all':!![]}]),db['FaxAccount'][_0x7979ae(0x177)](_0x50f1af);})[_0x28f111(0x1cd)](function(_0x326a5a){const _0x202d14=_0x28f111;return _0x156090[_0x202d14(0x1ca)]=_0x326a5a,_0x156090;})['then'](respondWithFilteredResult(_0x811ed5,_0x50f1af))['catch'](handleError(_0x811ed5,null));},exports[a222_0x1b0590(0x1c6)]=function(_0x112cef,_0x3ecf75){const _0x46cf12=a222_0x1b0590;let _0x2408c1={'raw':![],'where':{'id':_0x112cef[_0x46cf12(0x1dc)]['id']},'include':[{'model':db[_0x46cf12(0x197)],'as':_0x46cf12(0x1a9)}]};const _0x1e1b16={};return _0x1e1b16['model']=_['keys'](db[_0x46cf12(0x1c0)][_0x46cf12(0x143)]),_0x1e1b16[_0x46cf12(0x189)]=_[_0x46cf12(0x172)](_0x112cef['query']),_0x1e1b16['filters']=_[_0x46cf12(0x15e)](_0x1e1b16[_0x46cf12(0x1cb)],_0x1e1b16[_0x46cf12(0x189)]),_0x2408c1['attributes']=_['intersection'](_0x1e1b16[_0x46cf12(0x1cb)],qs['fields'](_0x112cef[_0x46cf12(0x189)][_0x46cf12(0x1dd)])),_0x2408c1[_0x46cf12(0x18f)]=_0x2408c1[_0x46cf12(0x18f)][_0x46cf12(0x149)]?_0x2408c1[_0x46cf12(0x18f)]:_0x1e1b16[_0x46cf12(0x1cb)],_0x112cef[_0x46cf12(0x189)][_0x46cf12(0x19d)]&&(_0x2408c1[_0x46cf12(0x1a0)]=[{'all':!![]}]),_0x2408c1=_[_0x46cf12(0x1a8)]({},_0x2408c1,_0x112cef['options']),db[_0x46cf12(0x1c0)]['findOne'](_0x2408c1)['then'](handleEntityNotFound(_0x3ecf75,null))[_0x46cf12(0x1cd)](respondWithResult(_0x3ecf75,null))[_0x46cf12(0x1a5)](handleError(_0x3ecf75,null));},exports[a222_0x1b0590(0x180)]=function(_0x2d3446,_0x3701a5){const _0x5f3e47=a222_0x1b0590;return db[_0x5f3e47(0x1c0)][_0x5f3e47(0x180)](_0x2d3446[_0x5f3e47(0x17e)],{})['then'](function(_0x37b845){const _0x1b44c6=_0x5f3e47,_0x2a6b2d=_0x2d3446[_0x1b44c6(0x196)][_0x1b44c6(0x19c)]({'plain':!![]});if(!_0x2a6b2d)throw new Error(_0x1b44c6(0x1cf));if(_0x2a6b2d[_0x1b44c6(0x160)]===_0x1b44c6(0x196)){const _0x3d8a22=_0x37b845[_0x1b44c6(0x19c)]({'plain':!![]}),_0x444024=_0x1b44c6(0x158);return db[_0x1b44c6(0x16e)][_0x1b44c6(0x191)]({'where':{'name':_0x444024,'userProfileId':_0x2a6b2d['userProfileId']},'raw':!![]})['then'](function(_0x1fe98f){const _0x1b4b68=_0x1b44c6;return _0x1fe98f&&_0x1fe98f['autoAssociation']===0x0?db[_0x1b4b68(0x14a)]['create']({'name':_0x3d8a22[_0x1b4b68(0x16f)],'resourceId':_0x3d8a22['id'],'type':_0x1fe98f[_0x1b4b68(0x16f)],'sectionId':_0x1fe98f['id']},{})['then'](function(){return _0x37b845;}):_0x37b845;})[_0x1b44c6(0x1a5)](function(_0xb9fd0){const _0x31a240=_0x1b44c6;logger[_0x31a240(0x1c9)](_0x31a240(0x150),_0xb9fd0);throw _0xb9fd0;});}return _0x37b845;})[_0x5f3e47(0x1cd)](respondWithResult(_0x3701a5,0xc9))[_0x5f3e47(0x1a5)](handleError(_0x3701a5,null));},exports[a222_0x1b0590(0x1a6)]=function(_0x3f89a1,_0x178e72){const _0x47685d=a222_0x1b0590;return _0x3f89a1[_0x47685d(0x17e)]['id']&&delete _0x3f89a1[_0x47685d(0x17e)]['id'],db[_0x47685d(0x1c0)][_0x47685d(0x191)]({'where':{'id':_0x3f89a1['params']['id']},'include':[{'model':db[_0x47685d(0x197)],'as':_0x47685d(0x1a9)}]})[_0x47685d(0x1cd)](handleEntityNotFound(_0x178e72,null))[_0x47685d(0x1cd)](saveUpdates(_0x3f89a1[_0x47685d(0x17e)],null))[_0x47685d(0x1cd)](respondWithResult(_0x178e72,null))['catch'](handleError(_0x178e72,null));},exports[a222_0x1b0590(0x15b)]=function(_0x4588f4,_0x106d75){const _0x2ca209=a222_0x1b0590;return db[_0x2ca209(0x1c0)][_0x2ca209(0x191)]({'where':{'id':_0x4588f4[_0x2ca209(0x1dc)]['id']}})[_0x2ca209(0x1cd)](handleEntityNotFound(_0x106d75,null))[_0x2ca209(0x1cd)](removeEntity(_0x106d75,null))[_0x2ca209(0x1a5)](handleError(_0x106d75,null));},exports[a222_0x1b0590(0x1bc)]=function(_0x277925,_0x4c8a28){const _0x1dedf3=a222_0x1b0590;return db['FaxAccount']['describe']()[_0x1dedf3(0x1cd)](respondWithResult(_0x4c8a28,null))[_0x1dedf3(0x1a5)](handleError(_0x4c8a28,null));},exports[a222_0x1b0590(0x16a)]=function(_0x2444d6,_0x5687d5){const _0x317893=a222_0x1b0590;return _0x2444d6[_0x317893(0x17e)]['id']&&delete _0x2444d6['body']['id'],db[_0x317893(0x1c0)][_0x317893(0x191)]({'where':{'id':_0x2444d6[_0x317893(0x1dc)]['id']}})[_0x317893(0x1cd)](handleEntityNotFound(_0x5687d5,null))[_0x317893(0x1cd)](function(_0x228a00){const _0x28abfa=_0x317893;if(_0x228a00)return _0x2444d6[_0x28abfa(0x17e)]['FaxAccountId']=_0x228a00['id'],db[_0x28abfa(0x1b5)][_0x28abfa(0x180)](_0x2444d6[_0x28abfa(0x17e)]);})['then'](respondWithResult(_0x5687d5,null))[_0x317893(0x1a5)](handleError(_0x5687d5,null));},exports['getDispositions']=function(_0x74574d,_0x5cb3a0){const _0x3833b2=a222_0x1b0590;let _0x7e0e1e={'raw':![],'where':{}};const _0x4b3a42={},_0x361b3f={'count':0x0,'rows':[]};return db[_0x3833b2(0x1c0)]['findOne']({'where':{'id':_0x74574d[_0x3833b2(0x1dc)]['id']}})[_0x3833b2(0x1cd)](handleEntityNotFound(_0x5cb3a0,null))[_0x3833b2(0x1cd)](function(_0x672748){const _0x54abb4=_0x3833b2;if(_0x672748)return _0x4b3a42[_0x54abb4(0x1cb)]=_[_0x54abb4(0x172)](db[_0x54abb4(0x1b5)][_0x54abb4(0x143)]),_0x4b3a42[_0x54abb4(0x189)]=_[_0x54abb4(0x172)](_0x74574d['query']),_0x4b3a42[_0x54abb4(0x1ba)]=_['intersection'](_0x4b3a42[_0x54abb4(0x1cb)],_0x4b3a42['query']),_0x7e0e1e[_0x54abb4(0x18f)]=_['intersection'](_0x4b3a42['model'],qs[_0x54abb4(0x1dd)](_0x74574d[_0x54abb4(0x189)][_0x54abb4(0x1dd)])),_0x7e0e1e[_0x54abb4(0x18f)]=_0x7e0e1e['attributes']['length']?_0x7e0e1e['attributes']:_0x4b3a42[_0x54abb4(0x1cb)],typeof _0x74574d['query']['nolimit']===_0x54abb4(0x15f)&&(_0x7e0e1e[_0x54abb4(0x168)]=qs[_0x54abb4(0x168)](_0x74574d['query']['limit']),_0x7e0e1e[_0x54abb4(0x18e)]=qs['offset'](_0x74574d[_0x54abb4(0x189)]['offset'])),_0x7e0e1e[_0x54abb4(0x147)]=qs[_0x54abb4(0x157)](_0x74574d[_0x54abb4(0x189)][_0x54abb4(0x157)]),_0x7e0e1e[_0x54abb4(0x163)]=qs[_0x54abb4(0x1ba)](_['pick'](_0x74574d[_0x54abb4(0x189)],_0x4b3a42[_0x54abb4(0x1ba)])),_0x7e0e1e[_0x54abb4(0x163)][_0x54abb4(0x15d)]=_0x672748['id'],_0x74574d[_0x54abb4(0x189)][_0x54abb4(0x138)]&&(_0x7e0e1e[_0x54abb4(0x163)]=_[_0x54abb4(0x1a8)](_0x7e0e1e[_0x54abb4(0x163)],{[Op['or']]:_[_0x54abb4(0x167)](_0x7e0e1e[_0x54abb4(0x18f)],function(_0x331474){const _0xe09e2e=_0x54abb4,_0x3fd2fc={};return _0x3fd2fc[_0x331474]={[Op[_0xe09e2e(0x193)]]:'%'+_0x74574d[_0xe09e2e(0x189)]['filter']+'%'},_0x3fd2fc;})})),_0x7e0e1e=_[_0x54abb4(0x1a8)]({},_0x7e0e1e,_0x74574d[_0x54abb4(0x156)]),db[_0x54abb4(0x1b5)][_0x54abb4(0x179)]({'where':_0x7e0e1e[_0x54abb4(0x163)]})['then'](function(_0x32ffbf){const _0x5a1dc3=_0x54abb4;return _0x361b3f['count']=_0x32ffbf,_0x74574d[_0x5a1dc3(0x189)][_0x5a1dc3(0x19d)]&&(_0x7e0e1e[_0x5a1dc3(0x1a0)]=[{'all':!![]}]),db[_0x5a1dc3(0x1b5)][_0x5a1dc3(0x177)](_0x7e0e1e);})[_0x54abb4(0x1cd)](function(_0x581e06){return _0x361b3f['rows']=_0x581e06,_0x361b3f;});})[_0x3833b2(0x1cd)](respondWithFilteredResult(_0x5cb3a0,_0x7e0e1e))[_0x3833b2(0x1a5)](handleError(_0x5cb3a0,null));},exports[a222_0x1b0590(0x14f)]=function(_0x3342da,_0x1915c5){const _0x52b67b=a222_0x1b0590;return db[_0x52b67b(0x1c0)][_0x52b67b(0x191)]({'where':{'id':_0x3342da['params']['id']}})[_0x52b67b(0x1cd)](handleEntityNotFound(_0x1915c5,null))['then'](function(_0x100369){const _0x5b4a84=_0x52b67b;if(_0x100369)return _0x100369[_0x5b4a84(0x14f)](_0x3342da['query'][_0x5b4a84(0x1a2)]);})['then'](respondWithStatusCode(_0x1915c5,null))[_0x52b67b(0x1a5)](handleError(_0x1915c5,null));},exports['addAnswer']=function(_0xfac5a9,_0x58993e){const _0x5e7ccc=a222_0x1b0590;return _0xfac5a9['body']['id']&&delete _0xfac5a9[_0x5e7ccc(0x17e)]['id'],db[_0x5e7ccc(0x1c0)][_0x5e7ccc(0x191)]({'where':{'id':_0xfac5a9['params']['id']}})['then'](handleEntityNotFound(_0x58993e,null))[_0x5e7ccc(0x1cd)](function(_0x325a88){const _0x3488e4=_0x5e7ccc;if(_0x325a88)return _0xfac5a9[_0x3488e4(0x17e)][_0x3488e4(0x15d)]=_0x325a88['id'],db[_0x3488e4(0x16d)][_0x3488e4(0x180)](_0xfac5a9[_0x3488e4(0x17e)]);})[_0x5e7ccc(0x1cd)](respondWithResult(_0x58993e,null))['catch'](handleError(_0x58993e,null));},exports[a222_0x1b0590(0x1d5)]=function(_0x1bef7d,_0x23d718){const _0x4d73b2=a222_0x1b0590;let _0x38efb8={'raw':![],'where':{}};const _0x200ac8={},_0xeb0cb9={'count':0x0,'rows':[]};return db['FaxAccount']['findOne']({'where':{'id':_0x1bef7d['params']['id']}})[_0x4d73b2(0x1cd)](handleEntityNotFound(_0x23d718,null))[_0x4d73b2(0x1cd)](function(_0x4184a4){const _0x3d9601=_0x4d73b2;if(_0x4184a4)return _0x200ac8['model']=_[_0x3d9601(0x172)](db[_0x3d9601(0x16d)][_0x3d9601(0x143)]),_0x200ac8[_0x3d9601(0x189)]=_[_0x3d9601(0x172)](_0x1bef7d[_0x3d9601(0x189)]),_0x200ac8[_0x3d9601(0x1ba)]=_[_0x3d9601(0x15e)](_0x200ac8[_0x3d9601(0x1cb)],_0x200ac8['query']),_0x38efb8['attributes']=_[_0x3d9601(0x15e)](_0x200ac8[_0x3d9601(0x1cb)],qs[_0x3d9601(0x1dd)](_0x1bef7d[_0x3d9601(0x189)][_0x3d9601(0x1dd)])),_0x38efb8[_0x3d9601(0x18f)]=_0x38efb8[_0x3d9601(0x18f)]['length']?_0x38efb8[_0x3d9601(0x18f)]:_0x200ac8[_0x3d9601(0x1cb)],typeof _0x1bef7d[_0x3d9601(0x189)]['nolimit']===_0x3d9601(0x15f)&&(_0x38efb8['limit']=qs[_0x3d9601(0x168)](_0x1bef7d[_0x3d9601(0x189)][_0x3d9601(0x168)]),_0x38efb8['offset']=qs[_0x3d9601(0x18e)](_0x1bef7d['query']['offset'])),_0x38efb8[_0x3d9601(0x147)]=qs[_0x3d9601(0x157)](_0x1bef7d[_0x3d9601(0x189)][_0x3d9601(0x157)]),_0x38efb8['where']=qs[_0x3d9601(0x1ba)](_[_0x3d9601(0x1d3)](_0x1bef7d[_0x3d9601(0x189)],_0x200ac8[_0x3d9601(0x1ba)])),_0x38efb8[_0x3d9601(0x163)][_0x3d9601(0x15d)]=_0x4184a4['id'],_0x1bef7d[_0x3d9601(0x189)]['filter']&&(_0x38efb8['where']=_['merge'](_0x38efb8['where'],{[Op['or']]:_[_0x3d9601(0x167)](_0x38efb8[_0x3d9601(0x18f)],function(_0x304977){const _0x26a9b9=_0x3d9601,_0x289690={};return _0x289690[_0x304977]={[Op['like']]:'%'+_0x1bef7d[_0x26a9b9(0x189)][_0x26a9b9(0x138)]+'%'},_0x289690;})})),_0x38efb8=_['merge']({},_0x38efb8,_0x1bef7d['options']),db[_0x3d9601(0x16d)][_0x3d9601(0x179)]({'where':_0x38efb8[_0x3d9601(0x163)]})[_0x3d9601(0x1cd)](function(_0x5e448f){const _0x2a9d04=_0x3d9601;return _0xeb0cb9['count']=_0x5e448f,_0x1bef7d[_0x2a9d04(0x189)][_0x2a9d04(0x19d)]&&(_0x38efb8[_0x2a9d04(0x1a0)]=[{'all':!![]}]),db[_0x2a9d04(0x16d)][_0x2a9d04(0x177)](_0x38efb8);})[_0x3d9601(0x1cd)](function(_0x3416b2){return _0xeb0cb9['rows']=_0x3416b2,_0xeb0cb9;});})['then'](respondWithFilteredResult(_0x23d718,_0x38efb8))['catch'](handleError(_0x23d718,null));},exports[a222_0x1b0590(0x1d1)]=function(_0x3fafc7,_0x4e4821){const _0x5d34af=a222_0x1b0590;return db[_0x5d34af(0x1c0)][_0x5d34af(0x191)]({'where':{'id':_0x3fafc7[_0x5d34af(0x1dc)]['id']}})[_0x5d34af(0x1cd)](handleEntityNotFound(_0x4e4821,null))[_0x5d34af(0x1cd)](function(_0x599e6e){const _0x3777cf=_0x5d34af;if(_0x599e6e)return _0x599e6e['removeAnswers'](_0x3fafc7[_0x3777cf(0x189)][_0x3777cf(0x1a2)]);})[_0x5d34af(0x1cd)](respondWithStatusCode(_0x4e4821,null))[_0x5d34af(0x1a5)](handleError(_0x4e4821,null));},exports['addInteraction']=function(_0x3d8613,_0x2e6981){const _0x491a96=a222_0x1b0590;return db['FaxInteraction']['findOne']({'where':{'id':_0x3d8613['params']['id']}})[_0x491a96(0x1cd)](function(_0x4cab3d){const _0x87c474=_0x491a96;if(_0x4cab3d)return _0x4cab3d[_0x87c474(0x1d6)](_0x3d8613['body'][_0x87c474(0x1a2)],{'through':_[_0x87c474(0x1b2)](_0x3d8613[_0x87c474(0x17e)],[_0x87c474(0x1a2),'id'])});})[_0x491a96(0x1cd)](respondWithResult(_0x2e6981,null))[_0x491a96(0x1a5)](handleError(_0x2e6981,null));},exports[a222_0x1b0590(0x199)]=function(_0x2c049f,_0x4788b6){const _0x4bcff9=a222_0x1b0590;let _0x1ce744={'raw':![],'where':{}};const _0x5b4963={},_0x5f0499={'count':0x0,'rows':[]};return db[_0x4bcff9(0x1c0)]['findOne']({'where':{'id':_0x2c049f[_0x4bcff9(0x1dc)]['id']}})[_0x4bcff9(0x1cd)](handleEntityNotFound(_0x4788b6,null))[_0x4bcff9(0x1cd)](function(_0x5e0a66){const _0x25cb96=_0x4bcff9;if(_0x5e0a66)return _0x5b4963['model']=_[_0x25cb96(0x172)](db[_0x25cb96(0x1aa)][_0x25cb96(0x143)]),_0x5b4963[_0x25cb96(0x189)]=_[_0x25cb96(0x172)](_0x2c049f['query']),_0x5b4963['filters']=_['intersection'](_0x5b4963[_0x25cb96(0x1cb)],_0x5b4963[_0x25cb96(0x189)]),_0x1ce744[_0x25cb96(0x18f)]=_[_0x25cb96(0x15e)](_0x5b4963['model'],qs[_0x25cb96(0x1dd)](_0x2c049f[_0x25cb96(0x189)][_0x25cb96(0x1dd)])),_0x1ce744[_0x25cb96(0x18f)]=_0x1ce744[_0x25cb96(0x18f)][_0x25cb96(0x149)]?_0x1ce744['attributes']:_0x5b4963[_0x25cb96(0x1cb)],typeof _0x2c049f[_0x25cb96(0x189)][_0x25cb96(0x16b)]===_0x25cb96(0x15f)&&(_0x1ce744[_0x25cb96(0x168)]=qs[_0x25cb96(0x168)](_0x2c049f[_0x25cb96(0x189)]['limit']),_0x1ce744[_0x25cb96(0x18e)]=qs[_0x25cb96(0x18e)](_0x2c049f[_0x25cb96(0x189)][_0x25cb96(0x18e)])),_0x1ce744['order']=qs['sort'](_0x2c049f['query'][_0x25cb96(0x157)]),_0x1ce744[_0x25cb96(0x163)]=qs[_0x25cb96(0x1ba)](_[_0x25cb96(0x1d3)](_0x2c049f[_0x25cb96(0x189)],_0x5b4963['filters'])),_0x1ce744[_0x25cb96(0x163)][_0x25cb96(0x15d)]=_0x5e0a66['id'],_0x2c049f[_0x25cb96(0x189)]['filter']&&(_0x1ce744['where']=_['merge'](_0x1ce744[_0x25cb96(0x163)],{[Op['or']]:_[_0x25cb96(0x167)](_0x1ce744[_0x25cb96(0x18f)],function(_0x111d1e){const _0xdbf492=_0x25cb96,_0x14aff8={};return _0x14aff8[_0x111d1e]={[Op[_0xdbf492(0x193)]]:'%'+_0x2c049f[_0xdbf492(0x189)]['filter']+'%'},_0x14aff8;})})),_0x1ce744=_[_0x25cb96(0x1a8)]({},_0x1ce744,_0x2c049f[_0x25cb96(0x156)]),db[_0x25cb96(0x1aa)][_0x25cb96(0x179)]({'where':_0x1ce744[_0x25cb96(0x163)]})['then'](function(_0x493eb6){const _0x4f5d6e=_0x25cb96;return _0x5f0499[_0x4f5d6e(0x179)]=_0x493eb6,_0x2c049f[_0x4f5d6e(0x189)]['includeAll']&&(_0x1ce744['include']=[{'model':db[_0x4f5d6e(0x194)],'as':_0x4f5d6e(0x1c3),'required':![]},{'model':db['User'],'as':_0x4f5d6e(0x1bd),'attributes':[_0x4f5d6e(0x16f),'fullname',_0x4f5d6e(0x1bf)],'required':![]},{'model':db['Tag'],'as':_0x4f5d6e(0x141),'attributes':['id',_0x4f5d6e(0x16f),'color'],'where':_0x2c049f[_0x4f5d6e(0x189)][_0x4f5d6e(0x154)]?{'id':_0x2c049f[_0x4f5d6e(0x189)]['tag']}:undefined,'required':_0x2c049f['query'][_0x4f5d6e(0x154)]?!![]:![]}]),db[_0x4f5d6e(0x1aa)][_0x4f5d6e(0x177)](_0x1ce744);})[_0x25cb96(0x1cd)](function(_0x13bdc5){const _0x1d80c2=_0x25cb96;return _0x5f0499[_0x1d80c2(0x1ca)]=_0x13bdc5,_0x5f0499;});})['then'](respondWithFilteredResult(_0x4788b6,_0x1ce744))[_0x4bcff9(0x1a5)](handleError(_0x4788b6,null));},exports[a222_0x1b0590(0x165)]=function(_0x207a58,_0x22d7e8){const _0x4d1381=a222_0x1b0590;return db[_0x4d1381(0x1c0)][_0x4d1381(0x191)]({'where':{'id':_0x207a58['params']['id']}})[_0x4d1381(0x1cd)](handleEntityNotFound(_0x22d7e8,null))[_0x4d1381(0x1cd)](function(_0x532575){const _0xd4cb94=_0x4d1381;if(_0x532575)return db['sequelize'][_0xd4cb94(0x1c5)](function(_0x3cf896){const _0x2c2d1d=_0xd4cb94;return db[_0x2c2d1d(0x1be)][_0x2c2d1d(0x15b)]({'where':{'FaxAccountId':_0x207a58[_0x2c2d1d(0x1dc)]['id']},'transaction':_0x3cf896})['then'](function(){const _0xc5d340=_0x2c2d1d,_0x313062=_['map'](_0x207a58[_0xc5d340(0x17e)],function(_0x1dac3d){return _0x1dac3d['FaxAccountId']=_0x207a58['params']['id'],_0x1dac3d;});return db[_0xc5d340(0x1be)][_0xc5d340(0x1b4)](_0x313062,{'transaction':_0x3cf896});});})[_0xd4cb94(0x1cd)](function(){const _0x8f3659=_0xd4cb94;return db['FaxApplication'][_0x8f3659(0x169)]({'where':{'FaxAccountId':_0x207a58['params']['id']},'order':_0x8f3659(0x195)});});})['then'](respondWithResult(_0x22d7e8,null))[_0x4d1381(0x1a5)](handleError(_0x22d7e8,null));},exports[a222_0x1b0590(0x173)]=function(_0x34f8c3,_0x2c074a){const _0x11df0b=a222_0x1b0590;let _0x2e4b57={};const _0x4bb2a7={};let _0x5c4a82,_0x1bfc6e;return db['FaxAccount'][_0x11df0b(0x191)]({'where':{'id':_0x34f8c3['params']['id']}})[_0x11df0b(0x1cd)](handleEntityNotFound(_0x2c074a,null))['then'](function(_0x2a3f01){const _0x36088a=_0x11df0b;if(_0x2a3f01)return _0x5c4a82=_0x2a3f01,_0x4bb2a7[_0x36088a(0x1cb)]=_[_0x36088a(0x172)](db[_0x36088a(0x1be)][_0x36088a(0x143)]),_0x4bb2a7[_0x36088a(0x189)]=_[_0x36088a(0x172)](_0x34f8c3[_0x36088a(0x189)]),_0x4bb2a7[_0x36088a(0x1ba)]=_[_0x36088a(0x15e)](_0x4bb2a7[_0x36088a(0x1cb)],_0x4bb2a7['query']),_0x2e4b57['attributes']=_['intersection'](_0x4bb2a7[_0x36088a(0x1cb)],qs[_0x36088a(0x1dd)](_0x34f8c3[_0x36088a(0x189)][_0x36088a(0x1dd)])),_0x2e4b57[_0x36088a(0x18f)]=_0x2e4b57[_0x36088a(0x18f)]['length']?_0x2e4b57['attributes']:_0x4bb2a7[_0x36088a(0x1cb)],_0x2e4b57[_0x36088a(0x147)]=qs[_0x36088a(0x157)](_0x34f8c3[_0x36088a(0x189)][_0x36088a(0x157)]),_0x2e4b57[_0x36088a(0x163)]=qs[_0x36088a(0x1ba)](_[_0x36088a(0x1d3)](_0x34f8c3[_0x36088a(0x189)],_0x4bb2a7[_0x36088a(0x1ba)])),_0x34f8c3['query'][_0x36088a(0x138)]&&(_0x2e4b57[_0x36088a(0x163)]=_[_0x36088a(0x1a8)](_0x2e4b57[_0x36088a(0x163)],{[Op['or']]:_['map'](_0x2e4b57[_0x36088a(0x18f)],function(_0x10bfaa){const _0x290942=_0x36088a,_0x28f44f={};return _0x28f44f[_0x10bfaa]={[Op[_0x290942(0x193)]]:'%'+_0x34f8c3[_0x290942(0x189)]['filter']+'%'},_0x28f44f;})})),_0x2e4b57=_[_0x36088a(0x1a8)]({},_0x2e4b57,_0x34f8c3[_0x36088a(0x156)]),_0x5c4a82[_0x36088a(0x173)](_0x2e4b57);})[_0x11df0b(0x1cd)](function(_0x116498){const _0x1cd11c=_0x11df0b;if(_0x116498)return _0x1bfc6e=_0x116498[_0x1cd11c(0x149)],typeof _0x34f8c3[_0x1cd11c(0x189)][_0x1cd11c(0x16b)]==='undefined'&&(_0x2e4b57[_0x1cd11c(0x168)]=qs[_0x1cd11c(0x168)](_0x34f8c3[_0x1cd11c(0x189)]['limit']),_0x2e4b57['offset']=qs[_0x1cd11c(0x18e)](_0x34f8c3['query'][_0x1cd11c(0x18e)])),_0x5c4a82[_0x1cd11c(0x173)](_0x2e4b57);})[_0x11df0b(0x1cd)](function(_0x29d04b){if(_0x29d04b)return _0x29d04b?{'count':_0x1bfc6e,'rows':_0x29d04b}:null;})[_0x11df0b(0x1cd)](respondWithResult(_0x2c074a,null))['catch'](handleError(_0x2c074a,null));};function Extension(_0x21706f,_0x1bd0af,_0x5aa6c3,_0x319949){const _0x1ed46f=a222_0x1b0590;this[_0x1ed46f(0x164)]='from-voip-provider',this[_0x1ed46f(0x1a1)]=_0x21706f[_0x1ed46f(0x1c8)],this[_0x1ed46f(0x14c)]=_0x319949,this['type']=_0x1ed46f(0x176),this['description']=_0x1ed46f(0x18c),this[_0x1ed46f(0x15d)]=_0x21706f['id'],this[_0x1ed46f(0x195)]=_0x1bd0af,this[_0x1ed46f(0x18a)]=_0x5aa6c3;}function createExtensionsReciveFax(_0xa9abb2){const _0x46bf98=a222_0x1b0590;let _0x4138ba=0x1;const _0xff4d92=[];_0xff4d92['push'](new Extension(_0xa9abb2,_0x4138ba,'',_0x46bf98(0x1df))),_0x4138ba+=0x1,_0xff4d92[_0x46bf98(0x146)](new Extension(_0xa9abb2,_0x4138ba,_0x46bf98(0x1ce),_0x46bf98(0x181))),_0x4138ba+=0x1;for(const _0x300339 in _0xa9abb2){typeof _0xa9abb2[_0x300339]!==_0x46bf98(0x15f)&&(_0x300339===_0x46bf98(0x1d7)||_0x300339===_0x46bf98(0x1c8)||_0x300339===_0x46bf98(0x1c2)||_0x300339===_0x46bf98(0x14b)||_0x300339===_0x46bf98(0x175)||_0x300339===_0x46bf98(0x13e)||_0x300339===_0x46bf98(0x19a)||_0x300339===_0x46bf98(0x139)||_0x300339===_0x46bf98(0x13d))&&(_0xff4d92[_0x46bf98(0x146)](new Extension(_0xa9abb2,_0x4138ba,_0x46bf98(0x188)+_0x300339+')='+_0xa9abb2[_0x300339],_0x46bf98(0x181))),_0x4138ba+=0x1);}return _0xff4d92[_0x46bf98(0x146)](new Extension(_0xa9abb2,_0x4138ba,'6',_0x46bf98(0x1ad))),_0x4138ba+=0x1,_0xff4d92[_0x46bf98(0x146)](new Extension(_0xa9abb2,_0x4138ba,_0x46bf98(0x155),_0x46bf98(0x17c))),_0x4138ba=0x0,_0xff4d92;}exports[a222_0x1b0590(0x166)]=function(_0x214898,_0x311a82){const _0x12cfe4=a222_0x1b0590;let _0x24da9b;return db[_0x12cfe4(0x14d)]['transaction'](function(_0xbe92b7){const _0x4f577d=_0x12cfe4;return db[_0x4f577d(0x1c0)][_0x4f577d(0x180)](_0x214898[_0x4f577d(0x17e)],{'transaction':_0xbe92b7})[_0x4f577d(0x1cd)](function(_0x4a10f4){const _0x3af5af=_0x4f577d;return _0x24da9b=_0x4a10f4[_0x3af5af(0x19c)]({'plain':!![]}),db[_0x3af5af(0x1b1)][_0x3af5af(0x1b4)](createExtensionsReciveFax(_0x24da9b),{'transaction':_0xbe92b7});});})[_0x12cfe4(0x1cd)](function(){return _0x24da9b;})[_0x12cfe4(0x1cd)](respondWithResult(_0x311a82,null))['catch'](handleError(_0x311a82,null));},exports[a222_0x1b0590(0x174)]=function(_0x13b630,_0x11dd3b){const _0xae3828=a222_0x1b0590;return db[_0xae3828(0x14d)][_0xae3828(0x1c5)](function(_0x5a669e){const _0x3d1fff=_0xae3828;return db[_0x3d1fff(0x1c0)][_0x3d1fff(0x1a6)](_0x13b630[_0x3d1fff(0x17e)],{'where':{'id':_0x13b630['body']['id']},'transaction':_0x5a669e})[_0x3d1fff(0x1cd)](function(){const _0x242eac=_0x3d1fff;return db['VoiceExtension'][_0x242eac(0x15b)]({'where':{'FaxAccountId':_0x13b630['body']['id']},'transaction':_0x5a669e})[_0x242eac(0x1cd)](function(){const _0x24816d=_0x242eac;return db['VoiceExtension'][_0x24816d(0x1b4)](createExtensionsReciveFax(_[_0x24816d(0x1b2)](_0x13b630['body'],[_0x24816d(0x1b6),_0x24816d(0x17b),_0x24816d(0x161),_0x24816d(0x1cc),_0x24816d(0x182),'ListId'])),{'transaction':_0x5a669e});});});})[_0xae3828(0x1cd)](function(){const _0x3a4cbd=_0xae3828;return db[_0x3a4cbd(0x1c0)]['findByPk'](_0x13b630[_0x3a4cbd(0x17e)]['id']);})['then'](respondWithResult(_0x11dd3b,null))['catch'](handleError(_0x11dd3b,null));},exports[a222_0x1b0590(0x152)]=function(_0x45cbf4,_0x3fd0b9){const _0x4ea566=a222_0x1b0590;let _0x342020={'raw':!![],'where':{}};const _0x517388={},_0x45af3f={'count':0x0,'rows':[]};return db[_0x4ea566(0x1c0)][_0x4ea566(0x191)]({'where':{'id':_0x45cbf4[_0x4ea566(0x1dc)]['id']}})[_0x4ea566(0x1cd)](handleEntityNotFound(_0x3fd0b9,null))[_0x4ea566(0x1cd)](function(_0x58c919){const _0x84c324=_0x4ea566;if(_0x58c919){_0x517388[_0x84c324(0x1cb)]=_[_0x84c324(0x172)](db[_0x84c324(0x140)]['rawAttributes']),_0x517388[_0x84c324(0x189)]=_[_0x84c324(0x172)](_0x45cbf4[_0x84c324(0x189)]),_0x517388[_0x84c324(0x1ba)]=_['intersection'](_0x517388[_0x84c324(0x1cb)],_0x517388[_0x84c324(0x189)]),_0x342020[_0x84c324(0x18f)]=_[_0x84c324(0x15e)](_0x517388[_0x84c324(0x1cb)],qs[_0x84c324(0x1dd)](_0x45cbf4[_0x84c324(0x189)]['fields'])),_0x342020['attributes']=_0x342020[_0x84c324(0x18f)][_0x84c324(0x149)]?_0x342020[_0x84c324(0x18f)]:_0x517388['model'];typeof _0x45cbf4[_0x84c324(0x189)][_0x84c324(0x16b)]===_0x84c324(0x15f)&&(_0x342020[_0x84c324(0x168)]=qs[_0x84c324(0x168)](_0x45cbf4[_0x84c324(0x189)][_0x84c324(0x168)]),_0x342020['offset']=qs[_0x84c324(0x18e)](_0x45cbf4[_0x84c324(0x189)]['offset']));_0x342020[_0x84c324(0x147)]=qs[_0x84c324(0x157)](_0x45cbf4[_0x84c324(0x189)][_0x84c324(0x157)]),_0x342020[_0x84c324(0x163)]=qs[_0x84c324(0x1ba)](_[_0x84c324(0x1d3)](_0x45cbf4['query'],_0x517388[_0x84c324(0x1ba)])),_0x342020['where']['FaxAccountId']=_0x58c919['id'];_0x45cbf4[_0x84c324(0x189)][_0x84c324(0x138)]&&(_0x342020[_0x84c324(0x163)]=_['merge'](_0x342020[_0x84c324(0x163)],{[Op['or']]:_[_0x84c324(0x167)](_0x342020['attributes'],function(_0x54bd86){const _0x4b4cc9=_0x84c324,_0x293655={};return _0x293655[_0x54bd86]={[Op[_0x4b4cc9(0x193)]]:'%'+_0x45cbf4[_0x4b4cc9(0x189)][_0x4b4cc9(0x138)]+'%'},_0x293655;})}));if(_0x45cbf4['query'][_0x84c324(0x136)]){const _0x2bc955=_0x45cbf4['query'][_0x84c324(0x136)]['split'](','),_0x77382f={};_0x77382f[_0x2bc955[0x0]]={[Op[_0x84c324(0x1c4)]]:moment(_0x2bc955[0x1])[_0x84c324(0x1bb)]('YYYY-MM-DD\x20HH:mm:ss')},_0x342020[_0x84c324(0x163)]=_[_0x84c324(0x1a8)](_0x342020[_0x84c324(0x163)],_0x77382f);}return _0x342020=_[_0x84c324(0x1a8)]({},_0x342020,_0x45cbf4['options']),db[_0x84c324(0x140)][_0x84c324(0x179)]({'where':_0x342020[_0x84c324(0x163)]})[_0x84c324(0x1cd)](function(_0x1a9c30){const _0x2f6059=_0x84c324;return _0x45af3f[_0x2f6059(0x179)]=_0x1a9c30,_0x45cbf4[_0x2f6059(0x189)][_0x2f6059(0x19d)]&&(_0x342020[_0x2f6059(0x1a0)]=[{'all':!![]}]),db[_0x2f6059(0x140)][_0x2f6059(0x177)](_0x342020);})[_0x84c324(0x1cd)](function(_0x410952){return _0x45af3f['rows']=_0x410952,_0x45af3f;});}})[_0x4ea566(0x1cd)](respondWithFilteredResult(_0x3fd0b9,_0x342020))[_0x4ea566(0x1a5)](handleError(_0x3fd0b9,null));},exports['send']=function(_0x4402c7,_0x227d2d){const _0x6e6fad=a222_0x1b0590;let _0x276d07,_0x302bd4;return _0x4402c7['body']['to']&&(_0x302bd4=_0x4402c7[_0x6e6fad(0x17e)]['to'][0x0]),db['FaxAccount'][_0x6e6fad(0x191)]({'where':{'id':_0x4402c7[_0x6e6fad(0x1dc)]['id']},'include':[{'model':db['CmList'],'as':_0x6e6fad(0x170),'include':[{'model':db[_0x6e6fad(0x194)],'as':_0x6e6fad(0x13c),'where':{'fax':_0x302bd4},'limit':0x1,'order':[[_0x6e6fad(0x1cc),_0x6e6fad(0x186)]]}]}]})[_0x6e6fad(0x1cd)](handleEntityNotFound(_0x227d2d,null))[_0x6e6fad(0x1cd)](function(_0x5252a1){const _0x2d60fc=_0x6e6fad;_0x276d07=_0x5252a1;if(_0x4402c7[_0x2d60fc(0x17e)][_0x2d60fc(0x1b0)]&&_0x4402c7[_0x2d60fc(0x17e)][_0x2d60fc(0x1b0)]['length'])for(let _0x33c6c2=0x0;_0x33c6c2<_0x4402c7[_0x2d60fc(0x17e)][_0x2d60fc(0x1b0)][_0x2d60fc(0x149)];_0x33c6c2+=0x1){_0x4402c7[_0x2d60fc(0x17e)][_0x2d60fc(0x1b0)][_0x33c6c2]={'filename':_0x4402c7['body'][_0x2d60fc(0x1b0)][_0x33c6c2][_0x2d60fc(0x16f)],'id':_0x4402c7['body']['attachments'][_0x33c6c2]['id'],'path':path['join'](config[_0x2d60fc(0x187)],_0x2d60fc(0x1b8),_0x4402c7[_0x2d60fc(0x17e)][_0x2d60fc(0x1b0)][_0x33c6c2][_0x2d60fc(0x17f)])};}return respondWithRpcPromise(_0x2d60fc(0x142),_0x2d60fc(0x142),{'FaxAccountId':_['isNil'](_0x4402c7[_0x2d60fc(0x1dc)]['id'])?undefined:_0x4402c7[_0x2d60fc(0x1dc)]['id'],'path':_[_0x2d60fc(0x18b)](_0x4402c7[_0x2d60fc(0x17e)][_0x2d60fc(0x1b0)][0x0][_0x2d60fc(0x1ab)])?undefined:_0x4402c7[_0x2d60fc(0x17e)]['attachments'][0x0][_0x2d60fc(0x1ab)],'fax':_[_0x2d60fc(0x18b)](_0x4402c7[_0x2d60fc(0x17e)]['to'][0x0])?undefined:_0x4402c7[_0x2d60fc(0x17e)]['to'][0x0]},client9002);})[_0x6e6fad(0x1cd)](function(){const _0x52d82d=_0x6e6fad;if(_0x276d07){_['isNil'](_0x4402c7[_0x52d82d(0x17e)][_0x52d82d(0x153)])&&(_0x4402c7['body'][_0x52d82d(0x153)]=util[_0x52d82d(0x1bb)](_0x52d82d(0x18d),_0x276d07[_0x52d82d(0x16f)],_0x276d07[_0x52d82d(0x171)]));if(_0x276d07[_0x52d82d(0x170)])return _0x276d07[_0x52d82d(0x170)][_0x52d82d(0x13c)]['length']?_0x276d07[_0x52d82d(0x170)]['Contacts'][0x0]:db[_0x52d82d(0x194)][_0x52d82d(0x180)](_['defaults'](_0x4402c7[_0x52d82d(0x17e)],{'firstName':_0x4402c7[_0x52d82d(0x17e)]['to'][0x0],'phone':_0x4402c7[_0x52d82d(0x17e)]['to'][0x0],'fax':_0x4402c7[_0x52d82d(0x17e)]['to'][0x0],'ListId':_0x276d07['ListId']}));else throw new Error(_0x52d82d(0x14e));}else throw new Error(_0x52d82d(0x145));})[_0x6e6fad(0x1cd)](function(_0x4e2cf7){const _0x3b0d0b=_0x6e6fad;if(_0x4e2cf7)return db[_0x3b0d0b(0x1aa)]['findOne']({'where':{'ContactId':_0x4e2cf7['id'],'closed':![],'FaxAccountId':_0x276d07['id']}})[_0x3b0d0b(0x1cd)](function(_0x8266a3){const _0x363b9c=_0x3b0d0b;if(_0x8266a3)return[_0x8266a3,![]];return db[_0x363b9c(0x1aa)][_0x363b9c(0x180)]({'UserId':_0x4402c7[_0x363b9c(0x196)]['id'],'ContactId':_0x4e2cf7['id'],'FaxAccountId':_0x276d07['id'],'fax':_0x4402c7[_0x363b9c(0x17e)]['to'][0x0],'firstMsgDirection':'out','Messages':[_['merge'](_0x4402c7[_0x363b9c(0x17e)],{'read':![],'body':_0x4402c7['body'][_0x363b9c(0x1b0)][0x0]['filename'],'FaxAccountId':_0x276d07['id'],'UserId':_0x4402c7['user']['id'],'ContactId':_0x4e2cf7['id'],'AttachmentId':_0x4402c7[_0x363b9c(0x17e)][_0x363b9c(0x1b0)][0x0]['id']})]},{'include':[{'model':db[_0x363b9c(0x140)],'as':'Messages'}]})[_0x363b9c(0x1cd)](function(_0x4b78e0){return[_0x4b78e0,!![]];});});else throw new Error(_0x3b0d0b(0x137));})['then'](function([_0x3d38e4,_0x3150f]){const _0x43a875=_0x6e6fad;if(_0x3150f)return _0x3d38e4;return db['FaxMessage'][_0x43a875(0x180)]({'direction':_0x43a875(0x162),'read':![],'body':_0x4402c7['body'][_0x43a875(0x1b0)][0x0][_0x43a875(0x183)],'FaxAccountId':_0x276d07['id'],'FaxInteractionId':_0x3d38e4['id'],'UserId':_0x4402c7[_0x43a875(0x196)]['id'],'ContactId':_0x3d38e4[_0x43a875(0x190)],'AttachmentId':_0x4402c7['body']['attachments'][0x0]['id']})[_0x43a875(0x1cd)](function(_0x152477){const _0x4dcee0=_0x43a875;return _0x3d38e4['dataValues'][_0x4dcee0(0x16c)]=[],_0x3d38e4[_0x4dcee0(0x1c7)][_0x4dcee0(0x16c)][_0x4dcee0(0x146)](_0x152477[_0x4dcee0(0x1c7)]),_0x3d38e4;});})[_0x6e6fad(0x1cd)](function(_0x38b30e){const _0x5c27bd=_0x6e6fad;return respondWithRpcPromise(_0x5c27bd(0x1ac),_0x5c27bd(0x1ac),{'FaxAccountId':_[_0x5c27bd(0x18b)](_0x4402c7[_0x5c27bd(0x1dc)]['id'])?undefined:_0x4402c7[_0x5c27bd(0x1dc)]['id'],'path':_[_0x5c27bd(0x18b)](_0x4402c7[_0x5c27bd(0x17e)][_0x5c27bd(0x1b0)][0x0][_0x5c27bd(0x1ab)])?undefined:_0x4402c7[_0x5c27bd(0x17e)][_0x5c27bd(0x1b0)][0x0][_0x5c27bd(0x1ab)],'fax':_[_0x5c27bd(0x18b)](_0x4402c7[_0x5c27bd(0x17e)]['to'][0x0])?undefined:_0x4402c7[_0x5c27bd(0x17e)]['to'][0x0],'AttachmentId':_0x4402c7[_0x5c27bd(0x17e)][_0x5c27bd(0x1b0)][0x0]['id']},client9002)[_0x5c27bd(0x1cd)](function(_0x41b552){const _0x462d93=_0x5c27bd;logger['info'](_0x462d93(0x1a4),_0x41b552);})['catch'](function(_0x4dec29){const _0x1dd926=_0x5c27bd;logger['info'](_0x1dd926(0x1a4),_0x4dec29);}),_0x38b30e;})['then'](respondWithResult(_0x227d2d,null))[_0x6e6fad(0x1a5)](handleError(_0x227d2d,null));},exports[a222_0x1b0590(0x1de)]=function(_0x5261fc,_0x2628af){const _0x4e1bb9=a222_0x1b0590;return db[_0x4e1bb9(0x1c0)]['findOne']({'where':{'id':_0x5261fc['params']['id']}})[_0x4e1bb9(0x1cd)](function(_0x289125){const _0x59ba41=_0x4e1bb9;if(_0x289125)return _0x289125['addAgents'](_0x5261fc['body'][_0x59ba41(0x1a2)],{'through':_[_0x59ba41(0x1b2)](_0x5261fc[_0x59ba41(0x17e)],['ids','id'])})['then'](function(_0x37d8b2){const _0x13355a=_0x59ba41;for(let _0x2f7aff=0x0;_0x2f7aff<_0x5261fc['body']['ids'][_0x13355a(0x149)];_0x2f7aff+=0x1){socket[_0x13355a(0x1c1)](_0x13355a(0x178),{'UserId':_0x5261fc[_0x13355a(0x17e)][_0x13355a(0x1a2)][_0x2f7aff],'FaxAccountId':_0x5261fc['params']['id']});}return _0x37d8b2;});})[_0x4e1bb9(0x1cd)](respondWithResult(_0x2628af,null))[_0x4e1bb9(0x1a5)](handleError(_0x2628af,null));},exports['removeAgents']=function(_0x4a98f7,_0x2478a6){const _0xad3fc8=a222_0x1b0590;return db[_0xad3fc8(0x1c0)][_0xad3fc8(0x191)]({'where':{'id':_0x4a98f7[_0xad3fc8(0x1dc)]['id']}})[_0xad3fc8(0x1cd)](handleEntityNotFound(_0x2478a6,null))[_0xad3fc8(0x1cd)](function(_0x557b2e){const _0x2f7f36=_0xad3fc8;if(_0x557b2e)return _0x557b2e[_0x2f7f36(0x1db)](_0x4a98f7[_0x2f7f36(0x189)][_0x2f7f36(0x1a2)])[_0x2f7f36(0x1cd)](function(){const _0x194cb2=_0x2f7f36;if(_[_0x194cb2(0x17a)](_0x4a98f7[_0x194cb2(0x189)][_0x194cb2(0x1a2)]))for(let _0x17b980=0x0;_0x17b980<_0x4a98f7[_0x194cb2(0x189)][_0x194cb2(0x1a2)][_0x194cb2(0x149)];_0x17b980+=0x1){socket[_0x194cb2(0x1c1)](_0x194cb2(0x1d9),{'UserId':Number(_0x4a98f7[_0x194cb2(0x189)][_0x194cb2(0x1a2)][_0x17b980]),'FaxAccountId':Number(_0x4a98f7[_0x194cb2(0x1dc)]['id'])});}else socket[_0x194cb2(0x1c1)](_0x194cb2(0x1d9),{'UserId':Number(_0x4a98f7['query'][_0x194cb2(0x1a2)]),'FaxAccountId':Number(_0x4a98f7['params']['id'])});});})['then'](respondWithStatusCode(_0x2478a6,null))[_0xad3fc8(0x1a5)](handleError(_0x2478a6,null));},exports[a222_0x1b0590(0x192)]=function(_0x10c4a9,_0x420231){const _0x4ea82b=a222_0x1b0590;let _0x689ca5={};const _0x33b388={};let _0x533245,_0x30caf0;return db[_0x4ea82b(0x1c0)][_0x4ea82b(0x191)]({'where':{'id':_0x10c4a9[_0x4ea82b(0x1dc)]['id']}})[_0x4ea82b(0x1cd)](handleEntityNotFound(_0x420231,null))[_0x4ea82b(0x1cd)](function(_0x40e595){const _0x237a11=_0x4ea82b;if(_0x40e595)return _0x533245=_0x40e595,_0x33b388[_0x237a11(0x1cb)]=_['keys'](db[_0x237a11(0x19e)][_0x237a11(0x143)]),_0x33b388['query']=_[_0x237a11(0x172)](_0x10c4a9[_0x237a11(0x189)]),_0x33b388[_0x237a11(0x1ba)]=_['intersection'](_0x33b388[_0x237a11(0x1cb)],_0x33b388[_0x237a11(0x189)]),_0x689ca5[_0x237a11(0x18f)]=_[_0x237a11(0x15e)](_0x33b388[_0x237a11(0x1cb)],qs[_0x237a11(0x1dd)](_0x10c4a9[_0x237a11(0x189)][_0x237a11(0x1dd)])),_0x689ca5[_0x237a11(0x18f)]=_0x689ca5[_0x237a11(0x18f)][_0x237a11(0x149)]?_0x689ca5[_0x237a11(0x18f)]:_0x33b388['model'],_0x689ca5['order']=qs[_0x237a11(0x157)](_0x10c4a9[_0x237a11(0x189)][_0x237a11(0x157)]),_0x689ca5['where']=qs[_0x237a11(0x1ba)](_['pick'](_0x10c4a9[_0x237a11(0x189)],_0x33b388[_0x237a11(0x1ba)])),_0x10c4a9[_0x237a11(0x189)][_0x237a11(0x138)]&&(_0x689ca5[_0x237a11(0x163)]=_[_0x237a11(0x1a8)](_0x689ca5[_0x237a11(0x163)],{[Op['or']]:_[_0x237a11(0x167)](_0x689ca5[_0x237a11(0x18f)],function(_0x44a5ae){const _0x4d835d=_0x237a11,_0x3eb389={};return _0x3eb389[_0x44a5ae]={[Op['like']]:'%'+_0x10c4a9[_0x4d835d(0x189)][_0x4d835d(0x138)]+'%'},_0x3eb389;})})),_0x689ca5=_['merge']({},_0x689ca5,_0x10c4a9[_0x237a11(0x156)]),_0x533245[_0x237a11(0x192)](_0x689ca5);})[_0x4ea82b(0x1cd)](function(_0x3f2ba2){const _0x19166f=_0x4ea82b;if(_0x3f2ba2)return _0x30caf0=_0x3f2ba2[_0x19166f(0x149)],typeof _0x10c4a9['query'][_0x19166f(0x16b)]===_0x19166f(0x15f)&&(_0x689ca5['limit']=qs['limit'](_0x10c4a9[_0x19166f(0x189)][_0x19166f(0x168)]),_0x689ca5[_0x19166f(0x18e)]=qs[_0x19166f(0x18e)](_0x10c4a9[_0x19166f(0x189)]['offset'])),_0x533245[_0x19166f(0x192)](_0x689ca5);})['then'](function(_0x5ab68f){if(_0x5ab68f)return _0x5ab68f?{'count':_0x30caf0,'rows':_0x5ab68f}:null;})['then'](respondWithResult(_0x420231,null))[_0x4ea82b(0x1a5)](handleError(_0x420231,null));};