Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / faxMessage / faxMessage.controller.js
index 919cc87..9e33a98 100644 (file)
@@ -1 +1 @@
-const a205_0x22c0=['AttachmentId','interface','status','basename','FaxMessage,\x20%s,\x20%s,\x20%s','get','ContactId','limit','rejectMessage','fax','index','attributes','key','FaxAccountId','request','channel','download','readAt','read','describe','FaxMessage','catch','../../config/logger','debug','accept','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','rawAttributes','nolimit','request\x20sent','/var/opt/motion2/server/files/attachments/%s','message','where','http','fax-interactions','YYYY-MM-DD\x20HH:mm:ss','count','type','length','update','query','keys','agent','acceptmessage','order','params','role','model','UserId','server','./faxMessage.socket','offset','Contact','sequelize','FaxInteractionId','rows','reject','path','AcceptMessage','../../mysqldb','isNil','include','format','acceptMessage','join','stringify','error','filters','register','then','FaxMessage,\x20%s,\x20%s','interaction','stack','EventManager','fields','client','intersection','map','lodash','filter','merge','findOne','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','VIRTUAL','read1stAt','findAll','body','destroy','CmContact','includeAll','api','create','SIP/%s','Attachment','RejectMessage','name','event','user','null','json','set','util','options','SendFax','manual','end','sort','FaxInteraction','attachments','info','undefined'];(function(_0x2f39af,_0x22c08f){const _0x1d4b8a=function(_0x1f96b7){while(--_0x1f96b7){_0x2f39af['push'](_0x2f39af['shift']());}};_0x1d4b8a(++_0x22c08f);}(a205_0x22c0,0x1b8));const a205_0x1d4b=function(_0x2f39af,_0x22c08f){_0x2f39af=_0x2f39af-0x0;let _0x1d4b8a=a205_0x22c0[_0x2f39af];return _0x1d4b8a;};const _0x2e8036=a205_0x1d4b;'use strict';const moment=require('moment'),util=require(_0x2e8036('0x64')),path=require(_0x2e8036('0x38')),_=require(_0x2e8036('0x4d')),{getSocket}=require('../../rediscache'),socket=getSocket(),qs=require('../../components/parsers/qs'),logger=require(_0x2e8036('0x16'))(_0x2e8036('0x59')),config=require('../../config/environment'),interaction_log=require(_0x2e8036('0x16'))(_0x2e8036('0x21')),db=require(_0x2e8036('0x3a'))['db'],{Op}=require(_0x2e8036('0x34'));require(_0x2e8036('0x31'))[_0x2e8036('0x43')](socket);const jayson=require('jayson/promise'),client=jayson[_0x2e8036('0x4a')][_0x2e8036('0x20')]({'port':0x232c}),client9002=jayson[_0x2e8036('0x4a')][_0x2e8036('0x20')]({'port':0x232a});function respondWithRpcPromise(_0x1f96b7,_0x56ccf6,_0x4ab2e2,_0x442575){return new Promise(function(_0x123d27,_0x175df6){const _0x72d88b=a205_0x1d4b,_0x5e9244=_0x442575||client;return _0x5e9244[_0x72d88b('0xe')](_0x1f96b7,_0x4ab2e2)['then'](function(_0x3d7138){const _0x559e6f=_0x72d88b;logger[_0x559e6f('0x6c')](_0x559e6f('0x45'),_0x56ccf6,'request\x20sent'),logger[_0x559e6f('0x17')](_0x559e6f('0x4'),_0x56ccf6,_0x559e6f('0x1c'),JSON[_0x559e6f('0x40')](_0x3d7138));if(_0x3d7138[_0x559e6f('0x41')]){if(_0x3d7138[_0x559e6f('0x41')]['code']===0x1f4)return logger[_0x559e6f('0x41')]('FaxMessage,\x20%s,\x20%s',_0x56ccf6,_0x3d7138[_0x559e6f('0x41')][_0x559e6f('0x1e')]),_0x175df6(_0x3d7138[_0x559e6f('0x41')][_0x559e6f('0x1e')]);return logger[_0x559e6f('0x41')](_0x559e6f('0x45'),_0x56ccf6,_0x3d7138['error'][_0x559e6f('0x1e')]),_0x123d27(_0x3d7138[_0x559e6f('0x41')][_0x559e6f('0x1e')]);}else logger[_0x559e6f('0x6c')](_0x559e6f('0x45'),_0x56ccf6,_0x559e6f('0x1c')),_0x123d27(_0x3d7138['result']['message']);})[_0x72d88b('0x15')](function(_0x297ce4){const _0x3dbd5=_0x72d88b;logger[_0x3dbd5('0x41')](_0x3dbd5('0x45'),_0x56ccf6,_0x297ce4),_0x175df6(_0x297ce4);});});}function respondWithResult(_0x1de300,_0x56e335){return _0x56e335=_0x56e335||0xc8,function(_0x4b061d){const _0x443e09=a205_0x1d4b;if(_0x4b061d)return _0x1de300[_0x443e09('0x2')](_0x56e335)['json'](_0x4b061d);};}function respondWithFilteredResult(_0x4b9bfa,_0xf449f8){return function(_0x4f5421){const _0x1a235a=a205_0x1d4b;if(_0x4f5421){const _0x4dd433=_0x4f5421['count'],_0x13b5c6=_0xf449f8[_0x1a235a('0x32')];let _0x61c985=_0xf449f8[_0x1a235a('0x32')]+_0xf449f8[_0x1a235a('0x7')],_0xcaedf9;return _0x61c985>=_0x4dd433?(_0x61c985=_0x4dd433,_0xcaedf9=0xc8):_0xcaedf9=0xce,_0x4b9bfa[_0x1a235a('0x2')](_0xcaedf9),_0x4b9bfa[_0x1a235a('0x63')]('Content-Range',_0x13b5c6+'-'+_0x61c985+'/'+_0x4dd433)[_0x1a235a('0x62')](_0x4f5421);}return null;};}function saveUpdates(_0x1cc996){return function(_0x3b79d0){const _0x8e033a=a205_0x1d4b;if(_0x3b79d0)return _0x3b79d0[_0x8e033a('0x26')](_0x1cc996)['then'](function(_0x11945b){return _0x11945b;});return null;};}function removeEntity(_0x3fc40a){return function(_0x328b43){const _0x103c25=a205_0x1d4b;if(_0x328b43)return _0x328b43[_0x103c25('0x56')]()['then'](function(){const _0x121d4a=_0x103c25;_0x3fc40a[_0x121d4a('0x2')](0xcc)[_0x121d4a('0x68')]();});};}function handleEntityNotFound(_0x287387){return function(_0x5400d4){return!_0x5400d4&&_0x287387['sendStatus'](0x194),_0x5400d4;};}function handleError(_0x20d389,_0x539efb){return _0x539efb=_0x539efb||0x1f4,function(_0x134578){const _0x307a56=a205_0x1d4b;logger[_0x307a56('0x41')](_0x134578[_0x307a56('0x47')]),_0x134578[_0x307a56('0x5e')]&&delete _0x134578[_0x307a56('0x5e')],_0x20d389[_0x307a56('0x2')](_0x539efb)['send'](_0x134578);};}exports[_0x2e8036('0xa')]=function(_0x186c5d,_0x197236){const _0x529442=_0x2e8036;let _0x533be6={};const _0x14b927={},_0x19f5de={'count':0x0,'rows':[]},_0x252661=_[_0x529442('0x4c')](db[_0x529442('0x14')][_0x529442('0x1a')],function(_0x5c4d0d){const _0x3b8bb8=_0x529442;return{'name':_0x5c4d0d['fieldName'],'type':_0x5c4d0d[_0x3b8bb8('0x24')][_0x3b8bb8('0xc')]};});_0x14b927['model']=_[_0x529442('0x4c')](_0x252661,_0x529442('0x5e')),_0x14b927['query']=_[_0x529442('0x28')](_0x186c5d[_0x529442('0x27')]),_0x14b927[_0x529442('0x42')]=_['intersection'](_0x14b927[_0x529442('0x2e')],_0x14b927[_0x529442('0x27')]),_0x533be6[_0x529442('0xb')]=_[_0x529442('0x4b')](_0x14b927[_0x529442('0x2e')],qs['fields'](_0x186c5d[_0x529442('0x27')][_0x529442('0x49')])),_0x533be6[_0x529442('0xb')]=_0x533be6[_0x529442('0xb')][_0x529442('0x25')]?_0x533be6[_0x529442('0xb')]:_0x14b927[_0x529442('0x2e')];typeof _0x186c5d[_0x529442('0x27')][_0x529442('0x1b')]===_0x529442('0x6d')&&(_0x533be6[_0x529442('0x7')]=qs[_0x529442('0x7')](_0x186c5d[_0x529442('0x27')][_0x529442('0x7')]),_0x533be6[_0x529442('0x32')]=qs[_0x529442('0x32')](_0x186c5d[_0x529442('0x27')]['offset']));_0x533be6[_0x529442('0x2b')]=qs[_0x529442('0x69')](_0x186c5d[_0x529442('0x27')]['sort']),_0x533be6[_0x529442('0x1f')]=qs[_0x529442('0x42')](_['pick'](_0x186c5d['query'],_0x14b927['filters']),_0x252661);_0x186c5d[_0x529442('0x27')][_0x529442('0x4e')]&&(_0x533be6['where']=_[_0x529442('0x4f')](_0x533be6[_0x529442('0x1f')],{[Op['or']]:_[_0x529442('0x4c')](_0x252661,function(_0x5f06fb){const _0x2cbfbb=_0x529442;if(_0x5f06fb['type']!==_0x2cbfbb('0x52')){const _0x372db6={};return _0x372db6[_0x5f06fb[_0x2cbfbb('0x5e')]]={[Op['like']]:'%'+_0x186c5d[_0x2cbfbb('0x27')][_0x2cbfbb('0x4e')]+'%'},_0x372db6;}})}));_0x533be6=_['merge']({},_0x533be6,_0x186c5d[_0x529442('0x65')]);const _0x2b048c={'where':_0x533be6[_0x529442('0x1f')]};return db[_0x529442('0x14')][_0x529442('0x23')](_0x2b048c)[_0x529442('0x44')](function(_0x286505){const _0x2be4a9=_0x529442;return _0x19f5de[_0x2be4a9('0x23')]=_0x286505,_0x186c5d[_0x2be4a9('0x27')]['includeAll']&&(_0x533be6[_0x2be4a9('0x3c')]=[{'all':!![]}]),db['FaxMessage'][_0x2be4a9('0x54')](_0x533be6);})['then'](function(_0x2919de){const _0x49873d=_0x529442;return _0x19f5de[_0x49873d('0x36')]=_0x2919de,_0x19f5de;})[_0x529442('0x44')](respondWithFilteredResult(_0x197236,_0x533be6))['catch'](handleError(_0x197236,null));},exports['show']=function(_0x33a3b5,_0x974e26){const _0x8e7e29=_0x2e8036;let _0x383bbd={'raw':!![],'where':{'id':_0x33a3b5[_0x8e7e29('0x2c')]['id']}};const _0x5d59d3={};return _0x5d59d3[_0x8e7e29('0x2e')]=_[_0x8e7e29('0x28')](db[_0x8e7e29('0x14')][_0x8e7e29('0x1a')]),_0x5d59d3['query']=_['keys'](_0x33a3b5[_0x8e7e29('0x27')]),_0x5d59d3['filters']=_[_0x8e7e29('0x4b')](_0x5d59d3['model'],_0x5d59d3[_0x8e7e29('0x27')]),_0x383bbd[_0x8e7e29('0xb')]=_[_0x8e7e29('0x4b')](_0x5d59d3[_0x8e7e29('0x2e')],qs[_0x8e7e29('0x49')](_0x33a3b5[_0x8e7e29('0x27')]['fields'])),_0x383bbd[_0x8e7e29('0xb')]=_0x383bbd[_0x8e7e29('0xb')][_0x8e7e29('0x25')]?_0x383bbd[_0x8e7e29('0xb')]:_0x5d59d3[_0x8e7e29('0x2e')],_0x33a3b5[_0x8e7e29('0x27')][_0x8e7e29('0x58')]&&(_0x383bbd[_0x8e7e29('0x3c')]=[{'all':!![]}]),_0x383bbd=_[_0x8e7e29('0x4f')]({},_0x383bbd,_0x33a3b5[_0x8e7e29('0x65')]),db[_0x8e7e29('0x14')][_0x8e7e29('0x50')](_0x383bbd)[_0x8e7e29('0x44')](handleEntityNotFound(_0x974e26,null))[_0x8e7e29('0x44')](respondWithResult(_0x974e26,null))[_0x8e7e29('0x15')](handleError(_0x974e26,null));},exports[_0x2e8036('0x26')]=function(_0x223e0b,_0x1e32d2){const _0x5d0f8b=_0x2e8036;return _0x223e0b[_0x5d0f8b('0x55')]['id']&&delete _0x223e0b[_0x5d0f8b('0x55')]['id'],db[_0x5d0f8b('0x14')][_0x5d0f8b('0x50')]({'where':{'id':_0x223e0b[_0x5d0f8b('0x2c')]['id']}})['then'](handleEntityNotFound(_0x1e32d2,null))['then'](saveUpdates(_0x223e0b[_0x5d0f8b('0x55')],null))['then'](respondWithResult(_0x1e32d2,null))[_0x5d0f8b('0x15')](handleError(_0x1e32d2,null));},exports[_0x2e8036('0x56')]=function(_0x4ae69c,_0x444bb1){const _0x33b9f1=_0x2e8036;return db[_0x33b9f1('0x14')][_0x33b9f1('0x50')]({'where':{'id':_0x4ae69c[_0x33b9f1('0x2c')]['id']}})[_0x33b9f1('0x44')](handleEntityNotFound(_0x444bb1,null))['then'](removeEntity(_0x444bb1,null))[_0x33b9f1('0x15')](handleError(_0x444bb1,null));},exports[_0x2e8036('0x13')]=function(_0x1af4e3,_0x35d1b6){const _0x488dc0=_0x2e8036;return db['FaxMessage'][_0x488dc0('0x13')]()['then'](respondWithResult(_0x35d1b6,null))['catch'](handleError(_0x35d1b6,null));},exports['accept']=function(_0x574148,_0x266fcc){const _0x5bc1ca=_0x2e8036,_0x3b32e0={'channel':'fax'};return _0x574148[_0x5bc1ca('0x55')]['id']&&delete _0x574148[_0x5bc1ca('0x55')]['id'],_0x574148[_0x5bc1ca('0x55')][_0x5bc1ca('0x12')]=!![],_0x574148[_0x5bc1ca('0x55')][_0x5bc1ca('0x11')]=moment()[_0x5bc1ca('0x3d')](_0x5bc1ca('0x22')),_0x574148[_0x5bc1ca('0x55')]['UserId']=_0x574148[_0x5bc1ca('0x55')][_0x5bc1ca('0x2f')]||_0x574148[_0x5bc1ca('0x60')]['id'],db[_0x5bc1ca('0x14')][_0x5bc1ca('0x50')]({'where':{'id':_0x574148[_0x5bc1ca('0x2c')]['id'],'UserId':null},'include':[{'model':db[_0x5bc1ca('0x57')],'as':_0x5bc1ca('0x33')}]})[_0x5bc1ca('0x44')](handleEntityNotFound(_0x266fcc,null))[_0x5bc1ca('0x44')](saveUpdates(_0x574148[_0x5bc1ca('0x55')],null))[_0x5bc1ca('0x44')](function(_0x3f1d2c){const _0x5f3f08=_0x5bc1ca;if(_0x3f1d2c)return _0x3b32e0[_0x5f3f08('0x1e')]=_0x3f1d2c['get']({'plain':!![]}),db[_0x5f3f08('0x6a')][_0x5f3f08('0x50')]({'where':{'id':_0x3f1d2c['FaxInteractionId']}});return null;})[_0x5bc1ca('0x44')](handleEntityNotFound(_0x266fcc,null))[_0x5bc1ca('0x44')](function(_0x44fd99){const _0x541398=_0x5bc1ca;if(_0x44fd99)return _0x44fd99[_0x541398('0x26')]({'UserId':_0x574148['body']['UserId'],'read1stAt':_[_0x541398('0x3b')](_0x44fd99[_0x541398('0x53')])?moment()[_0x541398('0x3d')](_0x541398('0x22')):undefined});return null;})[_0x5bc1ca('0x44')](function(_0x20eda8){const _0x5b2c98=_0x5bc1ca;if(_0x20eda8)return _0x3b32e0[_0x5b2c98('0x46')]=_0x20eda8['get']({'plain':!![]}),interaction_log[_0x5b2c98('0x6c')](_0x5b2c98('0x19'),_0x574148[_0x5b2c98('0x60')]['id'],_0x574148[_0x5b2c98('0x60')][_0x5b2c98('0x5e')],_0x574148[_0x5b2c98('0x60')]['role'],_0x3b32e0[_0x5b2c98('0x46')]['id'],_0x574148[_0x5b2c98('0x55')]?JSON[_0x5b2c98('0x40')](_0x574148[_0x5b2c98('0x55')]):_0x5b2c98('0x61')),respondWithRpcPromise(_0x5b2c98('0x39'),_0x5b2c98('0x3e'),_0x3b32e0);return null;})[_0x5bc1ca('0x44')](function(_0x330b5b){const _0x25f250=_0x5bc1ca;if(_0x330b5b){if(_0x574148[_0x25f250('0x55')][_0x25f250('0x67')])return _0x3b32e0[_0x25f250('0x1e')][_0x25f250('0x1')]=util[_0x25f250('0x3d')](_0x25f250('0x5b'),_0x574148[_0x25f250('0x60')][_0x25f250('0x5e')]),_0x3b32e0[_0x25f250('0x1e')][_0x25f250('0xf')]=_0x3b32e0['channel'],_0x3b32e0[_0x25f250('0x1e')][_0x25f250('0x5f')]=_0x25f250('0x18'),respondWithRpcPromise(_0x25f250('0x48'),_0x25f250('0x48'),{'event':_0x25f250('0x2a'),'message':_0x3b32e0[_0x25f250('0x1e')]},client9002)[_0x25f250('0x44')](function(){return _0x3b32e0;});return _0x3b32e0;}return null;})[_0x5bc1ca('0x44')](respondWithResult(_0x266fcc,null))[_0x5bc1ca('0x15')](handleError(_0x266fcc,null));},exports['reject']=function(_0x88e509,_0x56be88){const _0x3db990=_0x2e8036,_0x1166f5={'agent':{},'channel':'fax'};return _0x88e509[_0x3db990('0x55')]['id']&&delete _0x88e509[_0x3db990('0x55')]['id'],_0x88e509[_0x3db990('0x55')][_0x3db990('0x2f')]=_0x88e509[_0x3db990('0x55')]['UserId']||_0x88e509[_0x3db990('0x60')]['id'],_0x1166f5[_0x3db990('0x29')]['id']=_0x88e509[_0x3db990('0x55')][_0x3db990('0x2f')],db[_0x3db990('0x14')][_0x3db990('0x50')]({'where':{'id':_0x88e509[_0x3db990('0x2c')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x56be88,null))[_0x3db990('0x44')](function(_0x57ca35){const _0x160348=_0x3db990;if(_0x57ca35)return _0x1166f5[_0x160348('0x1e')]=_0x57ca35[_0x160348('0x5')]({'plain':!![]}),db[_0x160348('0x6a')][_0x160348('0x50')]({'where':{'id':_0x57ca35[_0x160348('0x35')]}});return null;})['then'](handleEntityNotFound(_0x56be88,null))['then'](function(_0x4138f0){const _0x4deb41=_0x3db990;if(_0x4138f0)return _0x1166f5[_0x4deb41('0x46')]=_0x4138f0[_0x4deb41('0x5')]({'plain':!![]}),interaction_log[_0x4deb41('0x6c')](_0x4deb41('0x51'),_0x88e509[_0x4deb41('0x60')]['id'],_0x88e509['user'][_0x4deb41('0x5e')],_0x88e509[_0x4deb41('0x60')][_0x4deb41('0x2d')],_0x1166f5['interaction']['id'],_0x88e509[_0x4deb41('0x55')]?JSON[_0x4deb41('0x40')](_0x88e509['body']):_0x4deb41('0x61')),respondWithRpcPromise(_0x4deb41('0x5d'),_0x4deb41('0x8'),_0x1166f5);return null;})[_0x3db990('0x44')](function(_0x52dde9){const _0x7159cc=_0x3db990;if(_0x52dde9)return _0x52dde9['message'][_0x7159cc('0x1')]=util['format'](_0x7159cc('0x5b'),_0x88e509[_0x7159cc('0x60')][_0x7159cc('0x5e')]),_0x52dde9['message'][_0x7159cc('0xf')]=_0x1166f5[_0x7159cc('0xf')],_0x52dde9[_0x7159cc('0x1e')][_0x7159cc('0x5f')]=_0x7159cc('0x37'),respondWithRpcPromise('EventManager','EventManager',{'event':'rejectmessage','message':_0x52dde9[_0x7159cc('0x1e')]},client9002),_0x1166f5;return null;})[_0x3db990('0x44')](respondWithResult(_0x56be88,null))[_0x3db990('0x15')](handleError(_0x56be88,null));},exports['create']=function(_0x62d86d,_0x374177){const _0x8e2804=_0x2e8036;let _0x15c5f8;return db[_0x8e2804('0x14')][_0x8e2804('0x5a')](_0x62d86d[_0x8e2804('0x55')],{})['then'](function(_0x581721){const _0x1fe46b=_0x8e2804;return _0x15c5f8=_0x581721,db[_0x1fe46b('0x57')][_0x1fe46b('0x50')]({'where':{'id':_0x15c5f8[_0x1fe46b('0x6')]}});})['then'](function(_0x19bf21){const _0x33fa07=_0x8e2804;if(_[_0x33fa07('0x3b')](_0x19bf21))return;else return _0x15c5f8[_0x33fa07('0x9')]=_0x19bf21[_0x33fa07('0x9')],db[_0x33fa07('0x5c')][_0x33fa07('0x50')]({'where':{'id':_0x15c5f8[_0x33fa07('0x0')]}});})[_0x8e2804('0x44')](function(_0x45bfca){const _0x553fcd=_0x8e2804;return respondWithRpcPromise('SendFax',_0x553fcd('0x66'),{'FaxAccountId':_[_0x553fcd('0x3b')](_0x62d86d[_0x553fcd('0x55')])?undefined:_0x62d86d[_0x553fcd('0x55')][_0x553fcd('0xd')],'path':_['isNil'](_0x45bfca)?undefined:util['format'](_0x553fcd('0x1d'),_0x45bfca[_0x553fcd('0x3')]),'fax':_['isNil'](_0x15c5f8[_0x553fcd('0x9')])?undefined:_0x15c5f8[_0x553fcd('0x9')],'AttachmentId':_0x15c5f8['AttachmentId']},client9002);})['then'](respondWithResult(_0x374177,0xc9))[_0x8e2804('0x15')](handleError(_0x374177,null));},exports[_0x2e8036('0x10')]=function(_0x29ea47,_0x1a78e1){const _0x2440fc=_0x2e8036,_0x1fb8fe=path['join'](config['root'],_0x2440fc('0x30'),'files',_0x2440fc('0x6b'));return db['FaxMessage'][_0x2440fc('0x50')]({'where':{'id':_0x29ea47[_0x2440fc('0x2c')]['id']},'include':[{'model':db[_0x2440fc('0x5c')],'as':_0x2440fc('0x5c')}]})[_0x2440fc('0x44')](handleEntityNotFound(_0x1a78e1,null))[_0x2440fc('0x44')](function(_0x2bf2de){const _0x18461a=_0x2440fc;if(_0x2bf2de)return _0x1a78e1['download'](path[_0x18461a('0x3f')](_0x1fb8fe,_0x2bf2de['Attachment'][_0x18461a('0x3')]));})[_0x2440fc('0x15')](handleError(_0x1a78e1,null));};
\ No newline at end of file
+const a205_0x5b73=['lodash','merge','manual','YYYY-MM-DD\x20HH:mm:ss','channel','attributes','get','error','isNil','SendFax','end','name','limit','rawAttributes','sort','EventManager','type','model','/var/opt/motion2/server/files/attachments/%s','query','ContactId','files','key','agent','SIP/%s','Content-Range','format','undefined','../../mysqldb','register','count','../../config/logger','FaxMessage,\x20%s,\x20%s','readAt','message','length','Contact','../../config/environment','map','sendStatus','show','acceptMessage','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','read','create','findAll','user','FaxInteraction','AttachmentId','filter','./faxMessage.socket','UserId','VIRTUAL','AcceptMessage','intersection','download','include','http','debug','filters','where','jayson/promise','keys','then','stack','client','sequelize','interaction','index','catch','Attachment','basename','read1stAt','options','request\x20sent','attachments','includeAll','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','rows','RejectMessage','event','body','fax-interactions','offset','json','acceptmessage','CmContact','interface','status','result','describe','null','accept','params','info','fax','fields','role','FaxInteractionId','root','fieldName','findOne','stringify','FaxMessage','update','order','like','pick'];(function(_0x4a4c9f,_0x5b7301){const _0x58e4ce=function(_0x1fde0b){while(--_0x1fde0b){_0x4a4c9f['push'](_0x4a4c9f['shift']());}};_0x58e4ce(++_0x5b7301);}(a205_0x5b73,0x1d4));const a205_0x58e4=function(_0x4a4c9f,_0x5b7301){_0x4a4c9f=_0x4a4c9f-0x0;let _0x58e4ce=a205_0x5b73[_0x4a4c9f];return _0x58e4ce;};const _0x3ef3ea=a205_0x58e4;'use strict';const moment=require('moment'),util=require('util'),path=require('path'),_=require(_0x3ef3ea('0x48')),{getSocket}=require('../../rediscache'),socket=getSocket(),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')('api'),config=require(_0x3ef3ea('0x1')),interaction_log=require(_0x3ef3ea('0x67'))(_0x3ef3ea('0x2e')),db=require(_0x3ef3ea('0x64'))['db'],{Op}=require(_0x3ef3ea('0x1e'));require(_0x3ef3ea('0xe'))[_0x3ef3ea('0x65')](socket);const jayson=require(_0x3ef3ea('0x19')),client=jayson[_0x3ef3ea('0x1d')]['http']({'port':0x232c}),client9002=jayson['client'][_0x3ef3ea('0x15')]({'port':0x232a});function respondWithRpcPromise(_0x1fde0b,_0x3e0691,_0x9d01a6,_0x2ea448){return new Promise(function(_0x2755c7,_0x57e3af){const _0x5f36e9=a205_0x58e4,_0x5ef595=_0x2ea448||client;return _0x5ef595['request'](_0x1fde0b,_0x9d01a6)[_0x5f36e9('0x1b')](function(_0x1ef149){const _0x317534=_0x5f36e9;logger['info'](_0x317534('0x68'),_0x3e0691,_0x317534('0x26')),logger[_0x317534('0x16')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x3e0691,_0x317534('0x26'),JSON['stringify'](_0x1ef149));if(_0x1ef149['error']){if(_0x1ef149[_0x317534('0x4f')]['code']===0x1f4)return logger[_0x317534('0x4f')](_0x317534('0x68'),_0x3e0691,_0x1ef149[_0x317534('0x4f')][_0x317534('0x6a')]),_0x57e3af(_0x1ef149[_0x317534('0x4f')]['message']);return logger[_0x317534('0x4f')](_0x317534('0x68'),_0x3e0691,_0x1ef149['error'][_0x317534('0x6a')]),_0x2755c7(_0x1ef149[_0x317534('0x4f')][_0x317534('0x6a')]);}else logger[_0x317534('0x3a')](_0x317534('0x68'),_0x3e0691,_0x317534('0x26')),_0x2755c7(_0x1ef149[_0x317534('0x35')][_0x317534('0x6a')]);})['catch'](function(_0xa14cb3){const _0x220482=_0x5f36e9;logger[_0x220482('0x4f')](_0x220482('0x68'),_0x3e0691,_0xa14cb3),_0x57e3af(_0xa14cb3);});});}function respondWithResult(_0x5b2393,_0x409786){return _0x409786=_0x409786||0xc8,function(_0x373596){const _0xa01a7=a205_0x58e4;if(_0x373596)return _0x5b2393[_0xa01a7('0x34')](_0x409786)['json'](_0x373596);};}function respondWithFilteredResult(_0xe7c762,_0x50b3b4){return function(_0x3143e3){const _0x14112a=a205_0x58e4;if(_0x3143e3){const _0x222691=_0x3143e3[_0x14112a('0x66')],_0x12bbf8=_0x50b3b4['offset'];let _0x291c7c=_0x50b3b4['offset']+_0x50b3b4[_0x14112a('0x54')],_0x270069;return _0x291c7c>=_0x222691?(_0x291c7c=_0x222691,_0x270069=0xc8):_0x270069=0xce,_0xe7c762[_0x14112a('0x34')](_0x270069),_0xe7c762['set'](_0x14112a('0x61'),_0x12bbf8+'-'+_0x291c7c+'/'+_0x222691)[_0x14112a('0x30')](_0x3143e3);}return null;};}function saveUpdates(_0x3a877b){return function(_0x4aeee7){const _0x4434b9=a205_0x58e4;if(_0x4aeee7)return _0x4aeee7[_0x4434b9('0x44')](_0x3a877b)[_0x4434b9('0x1b')](function(_0x17081b){return _0x17081b;});return null;};}function removeEntity(_0xb07a6e){return function(_0x1c3eff){if(_0x1c3eff)return _0x1c3eff['destroy']()['then'](function(){const _0x46c630=a205_0x58e4;_0xb07a6e[_0x46c630('0x34')](0xcc)[_0x46c630('0x52')]();});};}function handleEntityNotFound(_0x1f3445){return function(_0x23a811){const _0x55c763=a205_0x58e4;return!_0x23a811&&_0x1f3445[_0x55c763('0x3')](0x194),_0x23a811;};}function handleError(_0x193412,_0x58ec0e){return _0x58ec0e=_0x58ec0e||0x1f4,function(_0x36b9d7){const _0x4ca5d9=a205_0x58e4;logger[_0x4ca5d9('0x4f')](_0x36b9d7[_0x4ca5d9('0x1c')]),_0x36b9d7[_0x4ca5d9('0x53')]&&delete _0x36b9d7[_0x4ca5d9('0x53')],_0x193412[_0x4ca5d9('0x34')](_0x58ec0e)['send'](_0x36b9d7);};}exports[_0x3ef3ea('0x20')]=function(_0x2f923c,_0x558e8f){const _0x33fed9=_0x3ef3ea;let _0x2a2158={};const _0x48c81c={},_0x59a5d8={'count':0x0,'rows':[]},_0x105dac=_[_0x33fed9('0x2')](db[_0x33fed9('0x43')]['rawAttributes'],function(_0xab60b3){const _0x44e154=_0x33fed9;return{'name':_0xab60b3[_0x44e154('0x40')],'type':_0xab60b3[_0x44e154('0x58')][_0x44e154('0x5e')]};});_0x48c81c['model']=_[_0x33fed9('0x2')](_0x105dac,_0x33fed9('0x53')),_0x48c81c[_0x33fed9('0x5b')]=_[_0x33fed9('0x1a')](_0x2f923c['query']),_0x48c81c[_0x33fed9('0x17')]=_[_0x33fed9('0x12')](_0x48c81c[_0x33fed9('0x59')],_0x48c81c[_0x33fed9('0x5b')]),_0x2a2158['attributes']=_['intersection'](_0x48c81c[_0x33fed9('0x59')],qs['fields'](_0x2f923c[_0x33fed9('0x5b')][_0x33fed9('0x3c')])),_0x2a2158['attributes']=_0x2a2158[_0x33fed9('0x4d')][_0x33fed9('0x6b')]?_0x2a2158[_0x33fed9('0x4d')]:_0x48c81c[_0x33fed9('0x59')];typeof _0x2f923c[_0x33fed9('0x5b')]['nolimit']===_0x33fed9('0x63')&&(_0x2a2158[_0x33fed9('0x54')]=qs['limit'](_0x2f923c[_0x33fed9('0x5b')][_0x33fed9('0x54')]),_0x2a2158[_0x33fed9('0x2f')]=qs[_0x33fed9('0x2f')](_0x2f923c[_0x33fed9('0x5b')]['offset']));_0x2a2158[_0x33fed9('0x45')]=qs[_0x33fed9('0x56')](_0x2f923c['query'][_0x33fed9('0x56')]),_0x2a2158['where']=qs[_0x33fed9('0x17')](_[_0x33fed9('0x47')](_0x2f923c[_0x33fed9('0x5b')],_0x48c81c[_0x33fed9('0x17')]),_0x105dac);_0x2f923c[_0x33fed9('0x5b')][_0x33fed9('0xd')]&&(_0x2a2158[_0x33fed9('0x18')]=_[_0x33fed9('0x49')](_0x2a2158['where'],{[Op['or']]:_[_0x33fed9('0x2')](_0x105dac,function(_0xc2535f){const _0x27de36=_0x33fed9;if(_0xc2535f['type']!==_0x27de36('0x10')){const _0x114444={};return _0x114444[_0xc2535f[_0x27de36('0x53')]]={[Op[_0x27de36('0x46')]]:'%'+_0x2f923c[_0x27de36('0x5b')][_0x27de36('0xd')]+'%'},_0x114444;}})}));_0x2a2158=_['merge']({},_0x2a2158,_0x2f923c[_0x33fed9('0x25')]);const _0x397ab6={'where':_0x2a2158[_0x33fed9('0x18')]};return db[_0x33fed9('0x43')][_0x33fed9('0x66')](_0x397ab6)['then'](function(_0x2a425a){const _0xa8e49b=_0x33fed9;return _0x59a5d8[_0xa8e49b('0x66')]=_0x2a425a,_0x2f923c['query'][_0xa8e49b('0x28')]&&(_0x2a2158[_0xa8e49b('0x14')]=[{'all':!![]}]),db[_0xa8e49b('0x43')][_0xa8e49b('0x9')](_0x2a2158);})[_0x33fed9('0x1b')](function(_0x35a2f9){const _0x348551=_0x33fed9;return _0x59a5d8[_0x348551('0x2a')]=_0x35a2f9,_0x59a5d8;})['then'](respondWithFilteredResult(_0x558e8f,_0x2a2158))['catch'](handleError(_0x558e8f,null));},exports[_0x3ef3ea('0x4')]=function(_0x3ced36,_0x115388){const _0x38534d=_0x3ef3ea;let _0x2e5a46={'raw':!![],'where':{'id':_0x3ced36[_0x38534d('0x39')]['id']}};const _0xaa769b={};return _0xaa769b[_0x38534d('0x59')]=_[_0x38534d('0x1a')](db[_0x38534d('0x43')][_0x38534d('0x55')]),_0xaa769b[_0x38534d('0x5b')]=_[_0x38534d('0x1a')](_0x3ced36[_0x38534d('0x5b')]),_0xaa769b[_0x38534d('0x17')]=_[_0x38534d('0x12')](_0xaa769b[_0x38534d('0x59')],_0xaa769b['query']),_0x2e5a46[_0x38534d('0x4d')]=_['intersection'](_0xaa769b['model'],qs[_0x38534d('0x3c')](_0x3ced36[_0x38534d('0x5b')]['fields'])),_0x2e5a46[_0x38534d('0x4d')]=_0x2e5a46[_0x38534d('0x4d')][_0x38534d('0x6b')]?_0x2e5a46[_0x38534d('0x4d')]:_0xaa769b[_0x38534d('0x59')],_0x3ced36['query'][_0x38534d('0x28')]&&(_0x2e5a46[_0x38534d('0x14')]=[{'all':!![]}]),_0x2e5a46=_[_0x38534d('0x49')]({},_0x2e5a46,_0x3ced36[_0x38534d('0x25')]),db[_0x38534d('0x43')][_0x38534d('0x41')](_0x2e5a46)[_0x38534d('0x1b')](handleEntityNotFound(_0x115388,null))[_0x38534d('0x1b')](respondWithResult(_0x115388,null))[_0x38534d('0x21')](handleError(_0x115388,null));},exports[_0x3ef3ea('0x44')]=function(_0x11c3aa,_0x245fbf){const _0x3d9611=_0x3ef3ea;return _0x11c3aa['body']['id']&&delete _0x11c3aa[_0x3d9611('0x2d')]['id'],db[_0x3d9611('0x43')][_0x3d9611('0x41')]({'where':{'id':_0x11c3aa[_0x3d9611('0x39')]['id']}})[_0x3d9611('0x1b')](handleEntityNotFound(_0x245fbf,null))[_0x3d9611('0x1b')](saveUpdates(_0x11c3aa[_0x3d9611('0x2d')],null))['then'](respondWithResult(_0x245fbf,null))[_0x3d9611('0x21')](handleError(_0x245fbf,null));},exports['destroy']=function(_0x47dfaa,_0x10e466){const _0x551dc1=_0x3ef3ea;return db[_0x551dc1('0x43')][_0x551dc1('0x41')]({'where':{'id':_0x47dfaa[_0x551dc1('0x39')]['id']}})['then'](handleEntityNotFound(_0x10e466,null))['then'](removeEntity(_0x10e466,null))[_0x551dc1('0x21')](handleError(_0x10e466,null));},exports[_0x3ef3ea('0x36')]=function(_0x2e3f85,_0x43cd6d){const _0x851af9=_0x3ef3ea;return db[_0x851af9('0x43')][_0x851af9('0x36')]()[_0x851af9('0x1b')](respondWithResult(_0x43cd6d,null))[_0x851af9('0x21')](handleError(_0x43cd6d,null));},exports[_0x3ef3ea('0x38')]=function(_0x58ccb3,_0x46e321){const _0x56aed7=_0x3ef3ea,_0x5d538f={'channel':_0x56aed7('0x3b')};return _0x58ccb3[_0x56aed7('0x2d')]['id']&&delete _0x58ccb3[_0x56aed7('0x2d')]['id'],_0x58ccb3[_0x56aed7('0x2d')][_0x56aed7('0x7')]=!![],_0x58ccb3[_0x56aed7('0x2d')][_0x56aed7('0x69')]=moment()[_0x56aed7('0x62')](_0x56aed7('0x4b')),_0x58ccb3[_0x56aed7('0x2d')]['UserId']=_0x58ccb3[_0x56aed7('0x2d')][_0x56aed7('0xf')]||_0x58ccb3['user']['id'],db['FaxMessage'][_0x56aed7('0x41')]({'where':{'id':_0x58ccb3['params']['id'],'UserId':null},'include':[{'model':db[_0x56aed7('0x32')],'as':_0x56aed7('0x0')}]})[_0x56aed7('0x1b')](handleEntityNotFound(_0x46e321,null))[_0x56aed7('0x1b')](saveUpdates(_0x58ccb3[_0x56aed7('0x2d')],null))[_0x56aed7('0x1b')](function(_0x1e36fc){const _0x5e9ad0=_0x56aed7;if(_0x1e36fc)return _0x5d538f[_0x5e9ad0('0x6a')]=_0x1e36fc[_0x5e9ad0('0x4e')]({'plain':!![]}),db[_0x5e9ad0('0xb')]['findOne']({'where':{'id':_0x1e36fc[_0x5e9ad0('0x3e')]}});return null;})[_0x56aed7('0x1b')](handleEntityNotFound(_0x46e321,null))[_0x56aed7('0x1b')](function(_0x38fb8f){const _0x3ff82a=_0x56aed7;if(_0x38fb8f)return _0x38fb8f['update']({'UserId':_0x58ccb3['body'][_0x3ff82a('0xf')],'read1stAt':_[_0x3ff82a('0x50')](_0x38fb8f[_0x3ff82a('0x24')])?moment()[_0x3ff82a('0x62')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});return null;})[_0x56aed7('0x1b')](function(_0x315745){const _0x1b0ee4=_0x56aed7;if(_0x315745)return _0x5d538f[_0x1b0ee4('0x1f')]=_0x315745[_0x1b0ee4('0x4e')]({'plain':!![]}),interaction_log[_0x1b0ee4('0x3a')](_0x1b0ee4('0x6'),_0x58ccb3[_0x1b0ee4('0xa')]['id'],_0x58ccb3['user'][_0x1b0ee4('0x53')],_0x58ccb3['user'][_0x1b0ee4('0x3d')],_0x5d538f['interaction']['id'],_0x58ccb3['body']?JSON[_0x1b0ee4('0x42')](_0x58ccb3[_0x1b0ee4('0x2d')]):'null'),respondWithRpcPromise(_0x1b0ee4('0x11'),_0x1b0ee4('0x5'),_0x5d538f);return null;})[_0x56aed7('0x1b')](function(_0x46a2b7){const _0x17fc3b=_0x56aed7;if(_0x46a2b7){if(_0x58ccb3['body'][_0x17fc3b('0x4a')])return _0x5d538f[_0x17fc3b('0x6a')][_0x17fc3b('0x33')]=util[_0x17fc3b('0x62')]('SIP/%s',_0x58ccb3[_0x17fc3b('0xa')][_0x17fc3b('0x53')]),_0x5d538f['message'][_0x17fc3b('0x4c')]=_0x5d538f['channel'],_0x5d538f[_0x17fc3b('0x6a')][_0x17fc3b('0x2c')]=_0x17fc3b('0x38'),respondWithRpcPromise(_0x17fc3b('0x57'),'EventManager',{'event':_0x17fc3b('0x31'),'message':_0x5d538f['message']},client9002)[_0x17fc3b('0x1b')](function(){return _0x5d538f;});return _0x5d538f;}return null;})['then'](respondWithResult(_0x46e321,null))[_0x56aed7('0x21')](handleError(_0x46e321,null));},exports['reject']=function(_0x1286cd,_0x2f21d4){const _0x4e9b71=_0x3ef3ea,_0x4ce92d={'agent':{},'channel':'fax'};return _0x1286cd['body']['id']&&delete _0x1286cd[_0x4e9b71('0x2d')]['id'],_0x1286cd['body'][_0x4e9b71('0xf')]=_0x1286cd[_0x4e9b71('0x2d')][_0x4e9b71('0xf')]||_0x1286cd[_0x4e9b71('0xa')]['id'],_0x4ce92d[_0x4e9b71('0x5f')]['id']=_0x1286cd[_0x4e9b71('0x2d')][_0x4e9b71('0xf')],db['FaxMessage'][_0x4e9b71('0x41')]({'where':{'id':_0x1286cd[_0x4e9b71('0x39')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x2f21d4,null))[_0x4e9b71('0x1b')](function(_0x3d6ef2){const _0x240959=_0x4e9b71;if(_0x3d6ef2)return _0x4ce92d[_0x240959('0x6a')]=_0x3d6ef2[_0x240959('0x4e')]({'plain':!![]}),db[_0x240959('0xb')]['findOne']({'where':{'id':_0x3d6ef2[_0x240959('0x3e')]}});return null;})[_0x4e9b71('0x1b')](handleEntityNotFound(_0x2f21d4,null))[_0x4e9b71('0x1b')](function(_0x13a83e){const _0x10fd93=_0x4e9b71;if(_0x13a83e)return _0x4ce92d[_0x10fd93('0x1f')]=_0x13a83e[_0x10fd93('0x4e')]({'plain':!![]}),interaction_log[_0x10fd93('0x3a')](_0x10fd93('0x29'),_0x1286cd[_0x10fd93('0xa')]['id'],_0x1286cd['user']['name'],_0x1286cd['user'][_0x10fd93('0x3d')],_0x4ce92d['interaction']['id'],_0x1286cd[_0x10fd93('0x2d')]?JSON[_0x10fd93('0x42')](_0x1286cd[_0x10fd93('0x2d')]):_0x10fd93('0x37')),respondWithRpcPromise(_0x10fd93('0x2b'),'rejectMessage',_0x4ce92d);return null;})['then'](function(_0x4dbe5d){const _0x333502=_0x4e9b71;if(_0x4dbe5d)return _0x4dbe5d[_0x333502('0x6a')][_0x333502('0x33')]=util[_0x333502('0x62')](_0x333502('0x60'),_0x1286cd['user'][_0x333502('0x53')]),_0x4dbe5d['message'][_0x333502('0x4c')]=_0x4ce92d[_0x333502('0x4c')],_0x4dbe5d[_0x333502('0x6a')][_0x333502('0x2c')]='reject',respondWithRpcPromise('EventManager',_0x333502('0x57'),{'event':'rejectmessage','message':_0x4dbe5d[_0x333502('0x6a')]},client9002),_0x4ce92d;return null;})[_0x4e9b71('0x1b')](respondWithResult(_0x2f21d4,null))['catch'](handleError(_0x2f21d4,null));},exports[_0x3ef3ea('0x8')]=function(_0x255211,_0xd978b7){const _0x188178=_0x3ef3ea;let _0x2318c2;return db[_0x188178('0x43')][_0x188178('0x8')](_0x255211[_0x188178('0x2d')],{})['then'](function(_0x26d9b4){const _0x108318=_0x188178;return _0x2318c2=_0x26d9b4,db[_0x108318('0x32')][_0x108318('0x41')]({'where':{'id':_0x2318c2[_0x108318('0x5c')]}});})[_0x188178('0x1b')](function(_0x632050){const _0x276fd6=_0x188178;if(_[_0x276fd6('0x50')](_0x632050))return;else return _0x2318c2[_0x276fd6('0x3b')]=_0x632050[_0x276fd6('0x3b')],db[_0x276fd6('0x22')][_0x276fd6('0x41')]({'where':{'id':_0x2318c2[_0x276fd6('0xc')]}});})[_0x188178('0x1b')](function(_0x1a6a9a){const _0x344f65=_0x188178;return respondWithRpcPromise(_0x344f65('0x51'),_0x344f65('0x51'),{'FaxAccountId':_[_0x344f65('0x50')](_0x255211['body'])?undefined:_0x255211[_0x344f65('0x2d')]['FaxAccountId'],'path':_[_0x344f65('0x50')](_0x1a6a9a)?undefined:util['format'](_0x344f65('0x5a'),_0x1a6a9a['basename']),'fax':_[_0x344f65('0x50')](_0x2318c2[_0x344f65('0x3b')])?undefined:_0x2318c2[_0x344f65('0x3b')],'AttachmentId':_0x2318c2[_0x344f65('0xc')]},client9002);})['then'](respondWithResult(_0xd978b7,0xc9))[_0x188178('0x21')](handleError(_0xd978b7,null));},exports['download']=function(_0x3e5301,_0xca81ad){const _0x50447b=_0x3ef3ea,_0x39c06e=path['join'](config[_0x50447b('0x3f')],'server',_0x50447b('0x5d'),_0x50447b('0x27'));return db[_0x50447b('0x43')]['findOne']({'where':{'id':_0x3e5301['params']['id']},'include':[{'model':db[_0x50447b('0x22')],'as':_0x50447b('0x22')}]})[_0x50447b('0x1b')](handleEntityNotFound(_0xca81ad,null))[_0x50447b('0x1b')](function(_0x547e2d){const _0x5b9f6e=_0x50447b;if(_0x547e2d)return _0xca81ad[_0x5b9f6e('0x13')](path['join'](_0x39c06e,_0x547e2d[_0x5b9f6e('0x22')][_0x5b9f6e('0x23')]));})[_0x50447b('0x21')](handleError(_0xca81ad,null));};
\ No newline at end of file