Built motion from commit f67b3b02.|2.6.31
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 40f63c6..a7f905f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xea8e=['merge','type','VIRTUAL','includeAll','include','findAll','rows','show','params','options','find','body','describe','accept','sms','fax','acceptMessage','reject','UserId','get','FaxInteraction','interaction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','sequelize','QueryTypes','SELECT','contact','agent','fullname','email','interface','channel','motionChannel','event','EventManager','rejectmessage','create','findOne','isNil','AttachmentId','SendFax','FaxAccountId','basename','root','server','files','attachments','Attachment','util','path','lodash','../../components/interaction/service','../../components/parsers/qs','../../mysqldb','redis','defaults','socket.io-emitter','./faxMessage.socket','jayson/promise','client','http','request','then','info','FaxMessage,\x20%s,\x20%s','debug','FaxMessage,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','catch','status','json','undefined','count','offset','set','Content-Range','update','destroy','sendStatus','stack','name','send','index','map','FaxMessage','rawAttributes','key','model','query','keys','filters','intersection','attributes','fields','length','limit','order','sort','pick','filter','where'];(function(_0x4ce566,_0x2fccb7){var _0x887cc9=function(_0x40903d){while(--_0x40903d){_0x4ce566['push'](_0x4ce566['shift']());}};_0x887cc9(++_0x2fccb7);}(_0xea8e,0x178));var _0xeea8=function(_0x482af4,_0x841ba7){_0x482af4=_0x482af4-0x0;var _0x266fbb=_0xea8e[_0x482af4];return _0x266fbb;};'use strict';var util=require(_0xeea8('0x0'));var path=require(_0xeea8('0x1'));var _=require(_0xeea8('0x2'));var Redis=require('ioredis');var interactionService=require(_0xeea8('0x3'));var qs=require(_0xeea8('0x4'));var logger=require('../../config/logger')('api');var config=require('../../config/environment');var db=require(_0xeea8('0x5'))['db'];config[_0xeea8('0x6')]=_[_0xeea8('0x7')](config[_0xeea8('0x6')],{'host':'localhost','port':0x18eb});var socket=require(_0xeea8('0x8'))(new Redis(config[_0xeea8('0x6')]));require(_0xeea8('0x9'))['register'](socket);var jayson=require(_0xeea8('0xa'));var client=jayson[_0xeea8('0xb')][_0xeea8('0xc')]({'port':0x232c});var client9002=jayson[_0xeea8('0xb')]['http']({'port':0x232a});var interaction_log=require('../../config/logger')('fax-interactions');function respondWithRpcPromise(_0x6ba539,_0x1e48c0,_0x2eb71d,_0x36f427){return new Promise(function(_0x1bdd39,_0x259ad1){var _0x246caa=_0x36f427||client;return _0x246caa[_0xeea8('0xd')](_0x6ba539,_0x2eb71d)[_0xeea8('0xe')](function(_0x45bf24){logger[_0xeea8('0xf')](_0xeea8('0x10'),_0x1e48c0,'request\x20sent');logger[_0xeea8('0x11')](_0xeea8('0x12'),_0x1e48c0,_0xeea8('0x13'),JSON[_0xeea8('0x14')](_0x45bf24));if(_0x45bf24[_0xeea8('0x15')]){if(_0x45bf24['error']['code']===0x1f4){logger['error'](_0xeea8('0x10'),_0x1e48c0,_0x45bf24['error'][_0xeea8('0x16')]);return _0x259ad1(_0x45bf24[_0xeea8('0x15')][_0xeea8('0x16')]);}logger['error'](_0xeea8('0x10'),_0x1e48c0,_0x45bf24[_0xeea8('0x15')][_0xeea8('0x16')]);return _0x1bdd39(_0x45bf24[_0xeea8('0x15')][_0xeea8('0x16')]);}else{logger['info'](_0xeea8('0x10'),_0x1e48c0,_0xeea8('0x13'));_0x1bdd39(_0x45bf24['result'][_0xeea8('0x16')]);}})[_0xeea8('0x17')](function(_0x1b398a){logger[_0xeea8('0x15')](_0xeea8('0x10'),_0x1e48c0,_0x1b398a);_0x259ad1(_0x1b398a);});});}function respondWithResult(_0x521409,_0x31431a){_0x31431a=_0x31431a||0xc8;return function(_0xd1a77a){if(_0xd1a77a){return _0x521409[_0xeea8('0x18')](_0x31431a)[_0xeea8('0x19')](_0xd1a77a);}};}function respondWithFilteredResult(_0x227b94,_0x4ec874){return function(_0x3d2c17){if(_0x3d2c17){var _0x1a99c0=typeof _0x4ec874['offset']===_0xeea8('0x1a')&&typeof _0x4ec874['limit']==='undefined';var _0x1b2f9d=_0x3d2c17[_0xeea8('0x1b')];var _0x2399c6=_0x1a99c0?0x0:_0x4ec874[_0xeea8('0x1c')];var _0x553a01=_0x1a99c0?_0x3d2c17[_0xeea8('0x1b')]:_0x4ec874[_0xeea8('0x1c')]+_0x4ec874['limit'];var _0x1e0d77;if(_0x553a01>=_0x1b2f9d){_0x553a01=_0x1b2f9d;_0x1e0d77=0xc8;}else{_0x1e0d77=0xce;}_0x227b94['status'](_0x1e0d77);return _0x227b94[_0xeea8('0x1d')](_0xeea8('0x1e'),_0x2399c6+'-'+_0x553a01+'/'+_0x1b2f9d)[_0xeea8('0x19')](_0x3d2c17);}return null;};}function saveUpdates(_0x4a0fab){return function(_0x2e61b7){if(_0x2e61b7){return _0x2e61b7[_0xeea8('0x1f')](_0x4a0fab)['then'](function(_0x14f45b){return _0x14f45b;});}return null;};}function removeEntity(_0x28ada0){return function(_0x54b81d){if(_0x54b81d){return _0x54b81d[_0xeea8('0x20')]()[_0xeea8('0xe')](function(){_0x28ada0[_0xeea8('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x32cb37){return function(_0x13189a){if(!_0x13189a){_0x32cb37[_0xeea8('0x21')](0x194);}return _0x13189a;};}function handleError(_0x5e26aa,_0x38cfd6){_0x38cfd6=_0x38cfd6||0x1f4;return function(_0x5f4dbf){logger['error'](_0x5f4dbf[_0xeea8('0x22')]);if(_0x5f4dbf['name']){delete _0x5f4dbf[_0xeea8('0x23')];}_0x5e26aa['status'](_0x38cfd6)[_0xeea8('0x24')](_0x5f4dbf);};}exports[_0xeea8('0x25')]=function(_0x44f62c,_0x1b4aed){var _0x3460f0={},_0x23b9ce={},_0x31e19a={'count':0x0,'rows':[]};var _0x25dbdc=_[_0xeea8('0x26')](db[_0xeea8('0x27')][_0xeea8('0x28')],function(_0x3686a1){return{'name':_0x3686a1['fieldName'],'type':_0x3686a1['type'][_0xeea8('0x29')]};});_0x23b9ce[_0xeea8('0x2a')]=_[_0xeea8('0x26')](_0x25dbdc,_0xeea8('0x23'));_0x23b9ce[_0xeea8('0x2b')]=_[_0xeea8('0x2c')](_0x44f62c[_0xeea8('0x2b')]);_0x23b9ce[_0xeea8('0x2d')]=_[_0xeea8('0x2e')](_0x23b9ce[_0xeea8('0x2a')],_0x23b9ce[_0xeea8('0x2b')]);_0x3460f0[_0xeea8('0x2f')]=_['intersection'](_0x23b9ce[_0xeea8('0x2a')],qs[_0xeea8('0x30')](_0x44f62c[_0xeea8('0x2b')]['fields']));_0x3460f0[_0xeea8('0x2f')]=_0x3460f0[_0xeea8('0x2f')][_0xeea8('0x31')]?_0x3460f0[_0xeea8('0x2f')]:_0x23b9ce[_0xeea8('0x2a')];if(!_0x44f62c[_0xeea8('0x2b')]['hasOwnProperty']('nolimit')){_0x3460f0['limit']=qs[_0xeea8('0x32')](_0x44f62c[_0xeea8('0x2b')]['limit']);_0x3460f0['offset']=qs[_0xeea8('0x1c')](_0x44f62c[_0xeea8('0x2b')][_0xeea8('0x1c')]);}_0x3460f0[_0xeea8('0x33')]=qs[_0xeea8('0x34')](_0x44f62c['query'][_0xeea8('0x34')]);_0x3460f0['where']=qs[_0xeea8('0x2d')](_[_0xeea8('0x35')](_0x44f62c[_0xeea8('0x2b')],_0x23b9ce['filters']),_0x25dbdc);if(_0x44f62c[_0xeea8('0x2b')][_0xeea8('0x36')]){_0x3460f0[_0xeea8('0x37')]=_[_0xeea8('0x38')](_0x3460f0['where'],{'$or':_['map'](_0x25dbdc,function(_0x4387b4){if(_0x4387b4[_0xeea8('0x39')]!==_0xeea8('0x3a')){var _0x1fc42b={};_0x1fc42b[_0x4387b4[_0xeea8('0x23')]]={'$like':'%'+_0x44f62c[_0xeea8('0x2b')]['filter']+'%'};return _0x1fc42b;}})});}_0x3460f0=_[_0xeea8('0x38')]({},_0x3460f0,_0x44f62c['options']);var _0x17bc49={'where':_0x3460f0['where']};return db[_0xeea8('0x27')][_0xeea8('0x1b')](_0x17bc49)[_0xeea8('0xe')](function(_0x418f86){_0x31e19a[_0xeea8('0x1b')]=_0x418f86;if(_0x44f62c[_0xeea8('0x2b')][_0xeea8('0x3b')]){_0x3460f0[_0xeea8('0x3c')]=[{'all':!![]}];}return db[_0xeea8('0x27')][_0xeea8('0x3d')](_0x3460f0);})[_0xeea8('0xe')](function(_0x2802d3){_0x31e19a[_0xeea8('0x3e')]=_0x2802d3;return _0x31e19a;})[_0xeea8('0xe')](respondWithFilteredResult(_0x1b4aed,_0x3460f0))[_0xeea8('0x17')](handleError(_0x1b4aed,null));};exports[_0xeea8('0x3f')]=function(_0x379fc8,_0x967be4){var _0x19a0f9={'raw':!![],'where':{'id':_0x379fc8[_0xeea8('0x40')]['id']}},_0x506930={};_0x506930[_0xeea8('0x2a')]=_[_0xeea8('0x2c')](db['FaxMessage'][_0xeea8('0x28')]);_0x506930[_0xeea8('0x2b')]=_['keys'](_0x379fc8[_0xeea8('0x2b')]);_0x506930[_0xeea8('0x2d')]=_[_0xeea8('0x2e')](_0x506930[_0xeea8('0x2a')],_0x506930[_0xeea8('0x2b')]);_0x19a0f9[_0xeea8('0x2f')]=_[_0xeea8('0x2e')](_0x506930[_0xeea8('0x2a')],qs[_0xeea8('0x30')](_0x379fc8[_0xeea8('0x2b')]['fields']));_0x19a0f9[_0xeea8('0x2f')]=_0x19a0f9[_0xeea8('0x2f')]['length']?_0x19a0f9[_0xeea8('0x2f')]:_0x506930[_0xeea8('0x2a')];if(_0x379fc8[_0xeea8('0x2b')]['includeAll']){_0x19a0f9[_0xeea8('0x3c')]=[{'all':!![]}];}_0x19a0f9=_[_0xeea8('0x38')]({},_0x19a0f9,_0x379fc8[_0xeea8('0x41')]);return db['FaxMessage'][_0xeea8('0x42')](_0x19a0f9)['then'](handleEntityNotFound(_0x967be4,null))['then'](respondWithResult(_0x967be4,null))['catch'](handleError(_0x967be4,null));};exports[_0xeea8('0x1f')]=function(_0x296c45,_0xa74720){if(_0x296c45[_0xeea8('0x43')]['id']){delete _0x296c45[_0xeea8('0x43')]['id'];}return db['FaxMessage'][_0xeea8('0x42')]({'where':{'id':_0x296c45[_0xeea8('0x40')]['id']}})['then'](handleEntityNotFound(_0xa74720,null))[_0xeea8('0xe')](saveUpdates(_0x296c45[_0xeea8('0x43')],null))[_0xeea8('0xe')](respondWithResult(_0xa74720,null))['catch'](handleError(_0xa74720,null));};exports[_0xeea8('0x20')]=function(_0x290d89,_0x1dda1e){return db[_0xeea8('0x27')][_0xeea8('0x42')]({'where':{'id':_0x290d89[_0xeea8('0x40')]['id']}})['then'](handleEntityNotFound(_0x1dda1e,null))[_0xeea8('0xe')](removeEntity(_0x1dda1e,null))[_0xeea8('0x17')](handleError(_0x1dda1e,null));};exports[_0xeea8('0x44')]=function(_0x2d3da8,_0x409a12){return db[_0xeea8('0x27')][_0xeea8('0x44')]()[_0xeea8('0xe')](respondWithResult(_0x409a12,null))['catch'](handleError(_0x409a12,null));};exports[_0xeea8('0x45')]=function(_0x680ad,_0x56d011){var _0x4fae6c=_0xeea8('0x46');return interactionService['acceptMessage'](_0x680ad,_0x4fae6c)['then'](respondWithResult(_0x56d011,null))['catch'](handleError(_0x56d011,null));};exports['accept']=function(_0x20ed3f,_0x45dfbd){var _0x2c711f=_0xeea8('0x47');return interactionService[_0xeea8('0x48')](_0x20ed3f,_0x2c711f)[_0xeea8('0xe')](respondWithResult(_0x45dfbd,null))['catch'](handleError(_0x45dfbd,null));};exports[_0xeea8('0x49')]=function(_0x4a2050,_0x3df1d0){var _0x3a1c6d={'agent':{},'channel':_0xeea8('0x47')};if(_0x4a2050['body']['id']){delete _0x4a2050[_0xeea8('0x43')]['id'];}_0x4a2050[_0xeea8('0x43')][_0xeea8('0x4a')]=_0x4a2050[_0xeea8('0x43')]['UserId']||_0x4a2050['user']['id'];_0x3a1c6d['agent']['id']=_0x4a2050[_0xeea8('0x43')][_0xeea8('0x4a')];return db['FaxMessage'][_0xeea8('0x42')]({'where':{'id':_0x4a2050[_0xeea8('0x40')]['id'],'UserId':null}})[_0xeea8('0xe')](handleEntityNotFound(_0x3df1d0,null))[_0xeea8('0xe')](function(_0x7637ec){if(_0x7637ec){_0x3a1c6d[_0xeea8('0x16')]=_0x7637ec[_0xeea8('0x4b')]({'plain':!![]});return db[_0xeea8('0x4c')][_0xeea8('0x42')]({'where':{'id':_0x7637ec['FaxInteractionId']}});}return null;})[_0xeea8('0xe')](handleEntityNotFound(_0x3df1d0,null))[_0xeea8('0xe')](function(_0x31ae32){if(_0x31ae32){_0x3a1c6d[_0xeea8('0x4d')]=_0x31ae32[_0xeea8('0x4b')]({'plain':!![]});interaction_log['info'](_0xeea8('0x4e'),_0x4a2050[_0xeea8('0x4f')]['id'],_0x4a2050[_0xeea8('0x4f')]['name'],_0x4a2050[_0xeea8('0x4f')]['role'],_0x3a1c6d[_0xeea8('0x4d')]['id'],_0x4a2050[_0xeea8('0x43')]?JSON[_0xeea8('0x14')](_0x4a2050['body']):'null');return respondWithRpcPromise('RejectMessage',_0xeea8('0x50'),_0x3a1c6d);}return null;})[_0xeea8('0xe')](function(_0x305707){var _0xdb6ae8=_0xeea8('0x51')+_0x305707[_0xeea8('0x16')][_0xeea8('0x52')];return db[_0xeea8('0x53')][_0xeea8('0x2b')](_0xdb6ae8,{'type':db['Sequelize'][_0xeea8('0x54')][_0xeea8('0x55')],'raw':!![]})[_0xeea8('0xe')](function(_0xf73107){return _0xf73107;});})[_0xeea8('0xe')](function(_0x888fb7){if(_0x888fb7){_0x3a1c6d['message'][_0xeea8('0x56')]=_0x888fb7[0x0];if(!_0x4a2050[_0xeea8('0x43')][_0xeea8('0x4a')])return;return db['User'][_0xeea8('0x42')]({'where':{'id':_0x4a2050[_0xeea8('0x43')][_0xeea8('0x4a')],'role':_0xeea8('0x57')},'attributes':['id',_0xeea8('0x23'),_0xeea8('0x58'),_0xeea8('0x59'),'internal'],'raw':!![]});}return null;})[_0xeea8('0xe')](function(_0x494d2e){if(!_0x494d2e)return null;_0x3a1c6d['message'][_0xeea8('0x57')]=_0x494d2e;return _0x3a1c6d;})['then'](function(_0x932e8c){if(_0x932e8c){_0x932e8c['message'][_0xeea8('0x5a')]=util['format']('SIP/%s',_0x4a2050[_0xeea8('0x4f')][_0xeea8('0x23')]);_0x932e8c[_0xeea8('0x16')][_0xeea8('0x5b')]=_0x3a1c6d[_0xeea8('0x5b')];_0x932e8c[_0xeea8('0x16')][_0xeea8('0x5c')]=_0x3a1c6d[_0xeea8('0x5b')];_0x932e8c[_0xeea8('0x16')][_0xeea8('0x5d')]=_0xeea8('0x49');respondWithRpcPromise(_0xeea8('0x5e'),'EventManager',{'event':_0xeea8('0x5f'),'message':_0x932e8c[_0xeea8('0x16')]},client9002);return _0x3a1c6d;}return null;})[_0xeea8('0xe')](respondWithResult(_0x3df1d0,null))['catch'](handleError(_0x3df1d0,null));};exports[_0xeea8('0x60')]=function(_0x433998,_0xdfe5a7){var _0x45b63c;return db[_0xeea8('0x27')][_0xeea8('0x60')](_0x433998[_0xeea8('0x43')],{})['then'](function(_0xcdbfc){_0x45b63c=_0xcdbfc;return db['CmContact'][_0xeea8('0x61')]({'where':{'id':_0x45b63c['ContactId']}});})[_0xeea8('0xe')](function(_0xcb00e2){if(_[_0xeea8('0x62')](_0xcb00e2)){return;}else{_0x45b63c[_0xeea8('0x47')]=_0xcb00e2[_0xeea8('0x47')];return db['Attachment'][_0xeea8('0x61')]({'where':{'id':_0x45b63c[_0xeea8('0x63')]}});}})[_0xeea8('0xe')](function(_0x36e0b){return respondWithRpcPromise('SendFax',_0xeea8('0x64'),{'FaxAccountId':_[_0xeea8('0x62')](_0x433998[_0xeea8('0x43')])?undefined:_0x433998['body'][_0xeea8('0x65')],'path':_[_0xeea8('0x62')](_0x36e0b)?undefined:util['format']('/var/opt/motion2/server/files/attachments/%s',_0x36e0b[_0xeea8('0x66')]),'fax':_[_0xeea8('0x62')](_0x45b63c[_0xeea8('0x47')])?undefined:_0x45b63c[_0xeea8('0x47')],'AttachmentId':_0x45b63c[_0xeea8('0x63')]},client9002);})[_0xeea8('0xe')](respondWithResult(_0xdfe5a7,0xc9))[_0xeea8('0x17')](handleError(_0xdfe5a7,null));};exports['download']=function(_0xc1ab65,_0x377b83){var _0x3fbafd=path['join'](config[_0xeea8('0x67')],_0xeea8('0x68'),_0xeea8('0x69'),_0xeea8('0x6a'));return db[_0xeea8('0x27')]['find']({'where':{'id':_0xc1ab65[_0xeea8('0x40')]['id']},'include':[{'model':db[_0xeea8('0x6b')],'as':_0xeea8('0x6b')}]})[_0xeea8('0xe')](handleEntityNotFound(_0x377b83,null))[_0xeea8('0xe')](function(_0x10dc87){if(_0x10dc87){return _0x377b83['download'](path['join'](_0x3fbafd,_0x10dc87[_0xeea8('0x6b')][_0xeea8('0x66')]));}})[_0xeea8('0x17')](handleError(_0x377b83,null));};
\ No newline at end of file
+var _0x74f3=['SIP/%s','channel','motionChannel','event','EventManager','rejectmessage','create','findOne','isNil','Attachment','AttachmentId','SendFax','FaxAccountId','basename','files','attachments','download','join','path','lodash','ioredis','../../components/parsers/qs','../../config/logger','api','../../config/environment','../../mysqldb','redis','defaults','socket.io-emitter','register','jayson/promise','client','http','fax-interactions','then','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','stringify','error','message','result','catch','json','undefined','limit','offset','status','set','update','destroy','end','sendStatus','stack','name','map','FaxMessage','rawAttributes','fieldName','key','query','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','type','VIRTUAL','options','findAll','rows','show','params','includeAll','include','find','body','describe','accept','sms','fax','acceptMessage','UserId','user','agent','get','FaxInteraction','FaxInteractionId','interaction','info','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','null','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','ContactId','Sequelize','QueryTypes','SELECT','contact','User','fullname','email','interface','format'];(function(_0x5c5243,_0xa871bd){var _0x19a0e5=function(_0x278613){while(--_0x278613){_0x5c5243['push'](_0x5c5243['shift']());}};_0x19a0e5(++_0xa871bd);}(_0x74f3,0x83));var _0x374f=function(_0x22fd30,_0x3d7bcc){_0x22fd30=_0x22fd30-0x0;var _0x7305ff=_0x74f3[_0x22fd30];return _0x7305ff;};'use strict';var util=require('util');var path=require(_0x374f('0x0'));var _=require(_0x374f('0x1'));var Redis=require(_0x374f('0x2'));var interactionService=require('../../components/interaction/service');var qs=require(_0x374f('0x3'));var logger=require(_0x374f('0x4'))(_0x374f('0x5'));var config=require(_0x374f('0x6'));var db=require(_0x374f('0x7'))['db'];config[_0x374f('0x8')]=_[_0x374f('0x9')](config[_0x374f('0x8')],{'host':'localhost','port':0x18eb});var socket=require(_0x374f('0xa'))(new Redis(config[_0x374f('0x8')]));require('./faxMessage.socket')[_0x374f('0xb')](socket);var jayson=require(_0x374f('0xc'));var client=jayson[_0x374f('0xd')][_0x374f('0xe')]({'port':0x232c});var client9002=jayson['client'][_0x374f('0xe')]({'port':0x232a});var interaction_log=require(_0x374f('0x4'))(_0x374f('0xf'));function respondWithRpcPromise(_0x2f9589,_0x163f58,_0x19ffd9,_0x23c80c){return new Promise(function(_0x3283ef,_0x13da16){var _0x3425f8=_0x23c80c||client;return _0x3425f8['request'](_0x2f9589,_0x19ffd9)[_0x374f('0x10')](function(_0x85432e){logger['info'](_0x374f('0x11'),_0x163f58,_0x374f('0x12'));logger[_0x374f('0x13')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x163f58,_0x374f('0x12'),JSON[_0x374f('0x14')](_0x85432e));if(_0x85432e['error']){if(_0x85432e['error']['code']===0x1f4){logger[_0x374f('0x15')](_0x374f('0x11'),_0x163f58,_0x85432e[_0x374f('0x15')][_0x374f('0x16')]);return _0x13da16(_0x85432e[_0x374f('0x15')]['message']);}logger[_0x374f('0x15')]('FaxMessage,\x20%s,\x20%s',_0x163f58,_0x85432e[_0x374f('0x15')][_0x374f('0x16')]);return _0x3283ef(_0x85432e[_0x374f('0x15')][_0x374f('0x16')]);}else{logger['info'](_0x374f('0x11'),_0x163f58,_0x374f('0x12'));_0x3283ef(_0x85432e[_0x374f('0x17')]['message']);}})[_0x374f('0x18')](function(_0x5b6284){logger['error'](_0x374f('0x11'),_0x163f58,_0x5b6284);_0x13da16(_0x5b6284);});});}function respondWithResult(_0x110167,_0x193a08){_0x193a08=_0x193a08||0xc8;return function(_0x539386){if(_0x539386){return _0x110167['status'](_0x193a08)[_0x374f('0x19')](_0x539386);}};}function respondWithFilteredResult(_0x444511,_0x586a6e){return function(_0x4bcea7){if(_0x4bcea7){var _0x18ee8d=typeof _0x586a6e['offset']===_0x374f('0x1a')&&typeof _0x586a6e[_0x374f('0x1b')]===_0x374f('0x1a');var _0x375ad5=_0x4bcea7['count'];var _0x43ce64=_0x18ee8d?0x0:_0x586a6e[_0x374f('0x1c')];var _0x4b2a1f=_0x18ee8d?_0x4bcea7['count']:_0x586a6e[_0x374f('0x1c')]+_0x586a6e['limit'];var _0x12b239;if(_0x4b2a1f>=_0x375ad5){_0x4b2a1f=_0x375ad5;_0x12b239=0xc8;}else{_0x12b239=0xce;}_0x444511[_0x374f('0x1d')](_0x12b239);return _0x444511[_0x374f('0x1e')]('Content-Range',_0x43ce64+'-'+_0x4b2a1f+'/'+_0x375ad5)[_0x374f('0x19')](_0x4bcea7);}return null;};}function saveUpdates(_0x33880e){return function(_0x260df6){if(_0x260df6){return _0x260df6[_0x374f('0x1f')](_0x33880e)['then'](function(_0x173557){return _0x173557;});}return null;};}function removeEntity(_0x1c4b34){return function(_0x1b214c){if(_0x1b214c){return _0x1b214c[_0x374f('0x20')]()['then'](function(){_0x1c4b34[_0x374f('0x1d')](0xcc)[_0x374f('0x21')]();});}};}function handleEntityNotFound(_0x3c8ceb){return function(_0x3aff5a){if(!_0x3aff5a){_0x3c8ceb[_0x374f('0x22')](0x194);}return _0x3aff5a;};}function handleError(_0x1999cf,_0x49a27a){_0x49a27a=_0x49a27a||0x1f4;return function(_0x18e427){logger[_0x374f('0x15')](_0x18e427[_0x374f('0x23')]);if(_0x18e427[_0x374f('0x24')]){delete _0x18e427[_0x374f('0x24')];}_0x1999cf[_0x374f('0x1d')](_0x49a27a)['send'](_0x18e427);};}exports['index']=function(_0x511504,_0x24fb5c){var _0x541e17={},_0x4e72d4={},_0x273852={'count':0x0,'rows':[]};var _0x229400=_[_0x374f('0x25')](db[_0x374f('0x26')][_0x374f('0x27')],function(_0x6c4ec0){return{'name':_0x6c4ec0[_0x374f('0x28')],'type':_0x6c4ec0['type'][_0x374f('0x29')]};});_0x4e72d4['model']=_[_0x374f('0x25')](_0x229400,_0x374f('0x24'));_0x4e72d4[_0x374f('0x2a')]=_['keys'](_0x511504['query']);_0x4e72d4[_0x374f('0x2b')]=_[_0x374f('0x2c')](_0x4e72d4[_0x374f('0x2d')],_0x4e72d4[_0x374f('0x2a')]);_0x541e17['attributes']=_[_0x374f('0x2c')](_0x4e72d4[_0x374f('0x2d')],qs[_0x374f('0x2e')](_0x511504[_0x374f('0x2a')][_0x374f('0x2e')]));_0x541e17[_0x374f('0x2f')]=_0x541e17[_0x374f('0x2f')][_0x374f('0x30')]?_0x541e17[_0x374f('0x2f')]:_0x4e72d4[_0x374f('0x2d')];if(!_0x511504[_0x374f('0x2a')][_0x374f('0x31')](_0x374f('0x32'))){_0x541e17[_0x374f('0x1b')]=qs[_0x374f('0x1b')](_0x511504['query'][_0x374f('0x1b')]);_0x541e17['offset']=qs['offset'](_0x511504[_0x374f('0x2a')]['offset']);}_0x541e17[_0x374f('0x33')]=qs[_0x374f('0x34')](_0x511504[_0x374f('0x2a')][_0x374f('0x34')]);_0x541e17['where']=qs[_0x374f('0x2b')](_[_0x374f('0x35')](_0x511504['query'],_0x4e72d4['filters']),_0x229400);if(_0x511504[_0x374f('0x2a')][_0x374f('0x36')]){_0x541e17[_0x374f('0x37')]=_[_0x374f('0x38')](_0x541e17[_0x374f('0x37')],{'$or':_['map'](_0x229400,function(_0x5bb26e){if(_0x5bb26e[_0x374f('0x39')]!==_0x374f('0x3a')){var _0x43d266={};_0x43d266[_0x5bb26e[_0x374f('0x24')]]={'$like':'%'+_0x511504[_0x374f('0x2a')][_0x374f('0x36')]+'%'};return _0x43d266;}})});}_0x541e17=_[_0x374f('0x38')]({},_0x541e17,_0x511504[_0x374f('0x3b')]);var _0x3403a9={'where':_0x541e17[_0x374f('0x37')]};return db[_0x374f('0x26')]['count'](_0x3403a9)[_0x374f('0x10')](function(_0xd0dca0){_0x273852['count']=_0xd0dca0;if(_0x511504[_0x374f('0x2a')]['includeAll']){_0x541e17['include']=[{'all':!![]}];}return db['FaxMessage'][_0x374f('0x3c')](_0x541e17);})[_0x374f('0x10')](function(_0x5577b4){_0x273852[_0x374f('0x3d')]=_0x5577b4;return _0x273852;})[_0x374f('0x10')](respondWithFilteredResult(_0x24fb5c,_0x541e17))[_0x374f('0x18')](handleError(_0x24fb5c,null));};exports[_0x374f('0x3e')]=function(_0x38f566,_0x4d900f){var _0x5ed2c3={'raw':!![],'where':{'id':_0x38f566[_0x374f('0x3f')]['id']}},_0x1f445a={};_0x1f445a[_0x374f('0x2d')]=_['keys'](db['FaxMessage'][_0x374f('0x27')]);_0x1f445a[_0x374f('0x2a')]=_['keys'](_0x38f566[_0x374f('0x2a')]);_0x1f445a[_0x374f('0x2b')]=_[_0x374f('0x2c')](_0x1f445a['model'],_0x1f445a[_0x374f('0x2a')]);_0x5ed2c3[_0x374f('0x2f')]=_[_0x374f('0x2c')](_0x1f445a[_0x374f('0x2d')],qs['fields'](_0x38f566[_0x374f('0x2a')][_0x374f('0x2e')]));_0x5ed2c3[_0x374f('0x2f')]=_0x5ed2c3[_0x374f('0x2f')]['length']?_0x5ed2c3[_0x374f('0x2f')]:_0x1f445a[_0x374f('0x2d')];if(_0x38f566[_0x374f('0x2a')][_0x374f('0x40')]){_0x5ed2c3[_0x374f('0x41')]=[{'all':!![]}];}_0x5ed2c3=_[_0x374f('0x38')]({},_0x5ed2c3,_0x38f566[_0x374f('0x3b')]);return db['FaxMessage'][_0x374f('0x42')](_0x5ed2c3)[_0x374f('0x10')](handleEntityNotFound(_0x4d900f,null))['then'](respondWithResult(_0x4d900f,null))[_0x374f('0x18')](handleError(_0x4d900f,null));};exports[_0x374f('0x1f')]=function(_0x434596,_0x401a2f){if(_0x434596['body']['id']){delete _0x434596[_0x374f('0x43')]['id'];}return db[_0x374f('0x26')][_0x374f('0x42')]({'where':{'id':_0x434596[_0x374f('0x3f')]['id']}})[_0x374f('0x10')](handleEntityNotFound(_0x401a2f,null))[_0x374f('0x10')](saveUpdates(_0x434596['body'],null))[_0x374f('0x10')](respondWithResult(_0x401a2f,null))[_0x374f('0x18')](handleError(_0x401a2f,null));};exports[_0x374f('0x20')]=function(_0x5d2e8b,_0x1e925b){return db[_0x374f('0x26')][_0x374f('0x42')]({'where':{'id':_0x5d2e8b[_0x374f('0x3f')]['id']}})['then'](handleEntityNotFound(_0x1e925b,null))[_0x374f('0x10')](removeEntity(_0x1e925b,null))[_0x374f('0x18')](handleError(_0x1e925b,null));};exports['describe']=function(_0x9bb99b,_0x432b98){return db[_0x374f('0x26')][_0x374f('0x44')]()[_0x374f('0x10')](respondWithResult(_0x432b98,null))['catch'](handleError(_0x432b98,null));};exports[_0x374f('0x45')]=function(_0x2b53f6,_0x13a8ac){var _0x654a29=_0x374f('0x46');return interactionService['acceptMessage'](_0x2b53f6,_0x654a29)[_0x374f('0x10')](respondWithResult(_0x13a8ac,null))[_0x374f('0x18')](handleError(_0x13a8ac,null));};exports[_0x374f('0x45')]=function(_0x4a773a,_0x4c23a1){var _0x339a93=_0x374f('0x47');return interactionService[_0x374f('0x48')](_0x4a773a,_0x339a93)['then'](respondWithResult(_0x4c23a1,null))[_0x374f('0x18')](handleError(_0x4c23a1,null));};exports['reject']=function(_0x116e12,_0x28c1ab){var _0x31728d={'agent':{},'channel':'fax'};if(_0x116e12[_0x374f('0x43')]['id']){delete _0x116e12['body']['id'];}_0x116e12[_0x374f('0x43')][_0x374f('0x49')]=_0x116e12['body'][_0x374f('0x49')]||_0x116e12[_0x374f('0x4a')]['id'];_0x31728d[_0x374f('0x4b')]['id']=_0x116e12['body'][_0x374f('0x49')];return db[_0x374f('0x26')][_0x374f('0x42')]({'where':{'id':_0x116e12['params']['id'],'UserId':null}})[_0x374f('0x10')](handleEntityNotFound(_0x28c1ab,null))['then'](function(_0x4c9b7e){if(_0x4c9b7e){_0x31728d[_0x374f('0x16')]=_0x4c9b7e[_0x374f('0x4c')]({'plain':!![]});return db[_0x374f('0x4d')]['find']({'where':{'id':_0x4c9b7e[_0x374f('0x4e')]}});}return null;})[_0x374f('0x10')](handleEntityNotFound(_0x28c1ab,null))[_0x374f('0x10')](function(_0x31b0c4){if(_0x31b0c4){_0x31728d[_0x374f('0x4f')]=_0x31b0c4['get']({'plain':!![]});interaction_log[_0x374f('0x50')](_0x374f('0x51'),_0x116e12['user']['id'],_0x116e12[_0x374f('0x4a')][_0x374f('0x24')],_0x116e12[_0x374f('0x4a')][_0x374f('0x52')],_0x31728d['interaction']['id'],_0x116e12[_0x374f('0x43')]?JSON[_0x374f('0x14')](_0x116e12[_0x374f('0x43')]):_0x374f('0x53'));return respondWithRpcPromise('RejectMessage','rejectMessage',_0x31728d);}return null;})[_0x374f('0x10')](function(_0x441655){var _0x1860f1=_0x374f('0x54')+_0x441655[_0x374f('0x16')][_0x374f('0x55')];return db['sequelize'][_0x374f('0x2a')](_0x1860f1,{'type':db[_0x374f('0x56')][_0x374f('0x57')][_0x374f('0x58')],'raw':!![]})[_0x374f('0x10')](function(_0x3004f6){return _0x3004f6;});})['then'](function(_0x1bd6c0){if(_0x1bd6c0){_0x31728d[_0x374f('0x16')][_0x374f('0x59')]=_0x1bd6c0[0x0];if(!_0x116e12[_0x374f('0x43')][_0x374f('0x49')])return;return db[_0x374f('0x5a')][_0x374f('0x42')]({'where':{'id':_0x116e12[_0x374f('0x43')][_0x374f('0x49')],'role':_0x374f('0x4b')},'attributes':['id',_0x374f('0x24'),_0x374f('0x5b'),_0x374f('0x5c'),'internal'],'raw':!![]});}return null;})[_0x374f('0x10')](function(_0x331271){if(!_0x331271)return null;_0x31728d[_0x374f('0x16')][_0x374f('0x4b')]=_0x331271;return _0x31728d;})[_0x374f('0x10')](function(_0x5ec27f){if(_0x5ec27f){_0x5ec27f[_0x374f('0x16')][_0x374f('0x5d')]=util[_0x374f('0x5e')](_0x374f('0x5f'),_0x116e12[_0x374f('0x4a')][_0x374f('0x24')]);_0x5ec27f[_0x374f('0x16')][_0x374f('0x60')]=_0x31728d[_0x374f('0x60')];_0x5ec27f['message'][_0x374f('0x61')]=_0x31728d['channel'];_0x5ec27f[_0x374f('0x16')][_0x374f('0x62')]='reject';respondWithRpcPromise('EventManager',_0x374f('0x63'),{'event':_0x374f('0x64'),'message':_0x5ec27f[_0x374f('0x16')]},client9002);return _0x31728d;}return null;})[_0x374f('0x10')](respondWithResult(_0x28c1ab,null))[_0x374f('0x18')](handleError(_0x28c1ab,null));};exports[_0x374f('0x65')]=function(_0x286230,_0x76e45d){var _0x2e582e;return db[_0x374f('0x26')][_0x374f('0x65')](_0x286230['body'],{})[_0x374f('0x10')](function(_0x20d87e){_0x2e582e=_0x20d87e;return db['CmContact'][_0x374f('0x66')]({'where':{'id':_0x2e582e['ContactId']}});})[_0x374f('0x10')](function(_0x4998c6){if(_[_0x374f('0x67')](_0x4998c6)){return;}else{_0x2e582e[_0x374f('0x47')]=_0x4998c6[_0x374f('0x47')];return db[_0x374f('0x68')]['findOne']({'where':{'id':_0x2e582e[_0x374f('0x69')]}});}})['then'](function(_0x2c40a9){return respondWithRpcPromise(_0x374f('0x6a'),'SendFax',{'FaxAccountId':_[_0x374f('0x67')](_0x286230[_0x374f('0x43')])?undefined:_0x286230[_0x374f('0x43')][_0x374f('0x6b')],'path':_[_0x374f('0x67')](_0x2c40a9)?undefined:util[_0x374f('0x5e')]('/var/opt/motion2/server/files/attachments/%s',_0x2c40a9[_0x374f('0x6c')]),'fax':_['isNil'](_0x2e582e[_0x374f('0x47')])?undefined:_0x2e582e[_0x374f('0x47')],'AttachmentId':_0x2e582e['AttachmentId']},client9002);})[_0x374f('0x10')](respondWithResult(_0x76e45d,0xc9))['catch'](handleError(_0x76e45d,null));};exports['download']=function(_0x3bf2d6,_0x336332){var _0x1aa913=path['join'](config['root'],'server',_0x374f('0x6d'),_0x374f('0x6e'));return db['FaxMessage'][_0x374f('0x42')]({'where':{'id':_0x3bf2d6[_0x374f('0x3f')]['id']},'include':[{'model':db['Attachment'],'as':'Attachment'}]})[_0x374f('0x10')](handleEntityNotFound(_0x336332,null))[_0x374f('0x10')](function(_0x1f0dc1){if(_0x1f0dc1){return _0x336332[_0x374f('0x6f')](path[_0x374f('0x70')](_0x1aa913,_0x1f0dc1['Attachment'][_0x374f('0x6c')]));}})['catch'](handleError(_0x336332,null));};
\ No newline at end of file