Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index 1e073aa..66ed0c2 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf9cf=['EventManager','rejectmessage','create','findOne','ContactId','Attachment','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','download','join','root','files','basename','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./faxMessage.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','debug','stringify','code','error','FaxMessage,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','offset','undefined','count','limit','json','reject','update','destroy','stack','name','index','map','FaxMessage','rawAttributes','type','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','rows','show','params','include','find','body','describe','fax-interactions','accept','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','agent','get','FaxInteractionId','isNil','read1stAt','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','interaction','null','AcceptMessage','acceptMessage','sequelize','SELECT','contact','User','fullname','email','internal','manual','SIP/%s','channel','motionChannel','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','Sequelize','QueryTypes','interface'];(function(_0x59aa93,_0x46ff65){var _0x3d2428=function(_0x201c56){while(--_0x201c56){_0x59aa93['push'](_0x59aa93['shift']());}};_0x3d2428(++_0x46ff65);}(_0xf9cf,0x1b9));var _0xff9c=function(_0xf47ff3,_0x2439eb){_0xf47ff3=_0xf47ff3-0x0;var _0x476dde=_0xf9cf[_0xf47ff3];return _0x476dde;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xff9c('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xff9c('0x1'));var rp=require(_0xff9c('0x2'));var moment=require(_0xff9c('0x3'));var BPromise=require(_0xff9c('0x4'));var Mustache=require(_0xff9c('0x5'));var util=require(_0xff9c('0x6'));var path=require('path');var sox=require(_0xff9c('0x7'));var csv=require(_0xff9c('0x8'));var ejs=require(_0xff9c('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xff9c('0xa'));var squel=require(_0xff9c('0xb'));var crypto=require(_0xff9c('0xc'));var jsforce=require(_0xff9c('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xff9c('0xe'));var Papa=require(_0xff9c('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require('../../components/parsers/qs');var as=require(_0xff9c('0x10'));var hardwareService=require(_0xff9c('0x11'));var logger=require(_0xff9c('0x12'))(_0xff9c('0x13'));var utils=require(_0xff9c('0x14'));var config=require(_0xff9c('0x15'));var licenseUtil=require(_0xff9c('0x16'));var db=require(_0xff9c('0x17'))['db'];config[_0xff9c('0x18')]=_['defaults'](config[_0xff9c('0x18')],{'host':_0xff9c('0x19'),'port':0x18eb});var socket=require(_0xff9c('0x1a'))(new Redis(config[_0xff9c('0x18')]));require(_0xff9c('0x1b'))[_0xff9c('0x1c')](socket);var jayson=require(_0xff9c('0x1d'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson[_0xff9c('0x1e')][_0xff9c('0x1f')]({'port':0x232a});function respondWithRpcPromise(_0x2af068,_0x189484,_0x3b0ea3,_0xd19ba4){return new BPromise(function(_0x254a22,_0x2144ab){var _0x4ab37f=_0xd19ba4||client;return _0x4ab37f[_0xff9c('0x20')](_0x2af068,_0x3b0ea3)[_0xff9c('0x21')](function(_0x497425){logger[_0xff9c('0x22')]('FaxMessage,\x20%s,\x20%s',_0x189484,_0xff9c('0x23'));logger[_0xff9c('0x24')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x189484,'request\x20sent',JSON[_0xff9c('0x25')](_0x497425));if(_0x497425['error']){if(_0x497425['error'][_0xff9c('0x26')]===0x1f4){logger[_0xff9c('0x27')](_0xff9c('0x28'),_0x189484,_0x497425[_0xff9c('0x27')]['message']);return _0x2144ab(_0x497425[_0xff9c('0x27')]['message']);}logger[_0xff9c('0x27')]('FaxMessage,\x20%s,\x20%s',_0x189484,_0x497425[_0xff9c('0x27')]['message']);return _0x254a22(_0x497425['error'][_0xff9c('0x29')]);}else{logger[_0xff9c('0x22')]('FaxMessage,\x20%s,\x20%s',_0x189484,'request\x20sent');_0x254a22(_0x497425[_0xff9c('0x2a')][_0xff9c('0x29')]);}})[_0xff9c('0x2b')](function(_0x221495){logger[_0xff9c('0x27')]('FaxMessage,\x20%s,\x20%s',_0x189484,_0x221495);_0x2144ab(_0x221495);});});}function respondWithStatusCode(_0x23bc4a,_0x46c9cc){_0x46c9cc=_0x46c9cc||0xcc;return function(_0x4cf078){if(_0x4cf078){return _0x23bc4a[_0xff9c('0x2c')](_0x46c9cc);}return _0x23bc4a[_0xff9c('0x2d')](_0x46c9cc)[_0xff9c('0x2e')]();};}function respondWithResult(_0x272a8b,_0x2854df){_0x2854df=_0x2854df||0xc8;return function(_0xbfb2d6){if(_0xbfb2d6){return _0x272a8b[_0xff9c('0x2d')](_0x2854df)['json'](_0xbfb2d6);}};}function respondWithFilteredResult(_0x527305,_0x2b4dcb){return function(_0x160922){if(_0x160922){var _0x6ac171=typeof _0x2b4dcb[_0xff9c('0x2f')]===_0xff9c('0x30')&&typeof _0x2b4dcb['limit']==='undefined';var _0x28bf6e=_0x160922['count'];var _0x1b140d=_0x6ac171?0x0:_0x2b4dcb['offset'];var _0x2e10c9=_0x6ac171?_0x160922[_0xff9c('0x31')]:_0x2b4dcb['offset']+_0x2b4dcb[_0xff9c('0x32')];var _0x1d6627;if(_0x2e10c9>=_0x28bf6e){_0x2e10c9=_0x28bf6e;_0x1d6627=0xc8;}else{_0x1d6627=0xce;}_0x527305['status'](_0x1d6627);return _0x527305['set']('Content-Range',_0x1b140d+'-'+_0x2e10c9+'/'+_0x28bf6e)[_0xff9c('0x33')](_0x160922);}return null;};}function patchUpdates(_0x3b05e0){return function(_0x1338b7){try{jsonpatch['apply'](_0x1338b7,_0x3b05e0,!![]);}catch(_0x177e62){return BPromise[_0xff9c('0x34')](_0x177e62);}return _0x1338b7['save']();};}function saveUpdates(_0x35e904,_0x5c1602){return function(_0x4204e3){if(_0x4204e3){return _0x4204e3[_0xff9c('0x35')](_0x35e904)[_0xff9c('0x21')](function(_0x3ec2d2){return _0x3ec2d2;});}return null;};}function removeEntity(_0x161d4e,_0x206f3b){return function(_0x2c451a){if(_0x2c451a){return _0x2c451a[_0xff9c('0x36')]()['then'](function(){_0x161d4e[_0xff9c('0x2d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3099d3,_0x437b67){return function(_0x451b93){if(!_0x451b93){_0x3099d3[_0xff9c('0x2c')](0x194);}return _0x451b93;};}function handleError(_0x41dee9,_0x308080){_0x308080=_0x308080||0x1f4;return function(_0x3a0a5e){logger[_0xff9c('0x27')](_0x3a0a5e[_0xff9c('0x37')]);if(_0x3a0a5e[_0xff9c('0x38')]){delete _0x3a0a5e[_0xff9c('0x38')];}_0x41dee9[_0xff9c('0x2d')](_0x308080)['send'](_0x3a0a5e);};}exports[_0xff9c('0x39')]=function(_0x27714c,_0x32e466){var _0x3613ad={},_0x3a9433={},_0x29ce4f={'count':0x0,'rows':[]};var _0x5f35ee=_[_0xff9c('0x3a')](db[_0xff9c('0x3b')][_0xff9c('0x3c')],function(_0x452b7b){return{'name':_0x452b7b['fieldName'],'type':_0x452b7b[_0xff9c('0x3d')]['key']};});_0x3a9433[_0xff9c('0x3e')]=_[_0xff9c('0x3a')](_0x5f35ee,'name');_0x3a9433[_0xff9c('0x3f')]=_[_0xff9c('0x40')](_0x27714c[_0xff9c('0x3f')]);_0x3a9433[_0xff9c('0x41')]=_['intersection'](_0x3a9433[_0xff9c('0x3e')],_0x3a9433[_0xff9c('0x3f')]);_0x3613ad[_0xff9c('0x42')]=_[_0xff9c('0x43')](_0x3a9433[_0xff9c('0x3e')],qs[_0xff9c('0x44')](_0x27714c[_0xff9c('0x3f')]['fields']));_0x3613ad['attributes']=_0x3613ad['attributes'][_0xff9c('0x45')]?_0x3613ad[_0xff9c('0x42')]:_0x3a9433[_0xff9c('0x3e')];if(!_0x27714c['query'][_0xff9c('0x46')](_0xff9c('0x47'))){_0x3613ad['limit']=qs[_0xff9c('0x32')](_0x27714c['query']['limit']);_0x3613ad[_0xff9c('0x2f')]=qs[_0xff9c('0x2f')](_0x27714c[_0xff9c('0x3f')][_0xff9c('0x2f')]);}_0x3613ad[_0xff9c('0x48')]=qs['sort'](_0x27714c[_0xff9c('0x3f')][_0xff9c('0x49')]);_0x3613ad[_0xff9c('0x4a')]=qs[_0xff9c('0x41')](_[_0xff9c('0x4b')](_0x27714c['query'],_0x3a9433['filters']),_0x5f35ee);if(_0x27714c[_0xff9c('0x3f')][_0xff9c('0x4c')]){_0x3613ad[_0xff9c('0x4a')]=_[_0xff9c('0x4d')](_0x3613ad[_0xff9c('0x4a')],{'$or':_['map'](_0x5f35ee,function(_0x1a5e12){if(_0x1a5e12['type']!==_0xff9c('0x4e')){var _0x51cd63={};_0x51cd63[_0x1a5e12[_0xff9c('0x38')]]={'$like':'%'+_0x27714c[_0xff9c('0x3f')][_0xff9c('0x4c')]+'%'};return _0x51cd63;}})});}_0x3613ad=_['merge']({},_0x3613ad,_0x27714c[_0xff9c('0x4f')]);var _0x551766={'where':_0x3613ad[_0xff9c('0x4a')]};return db[_0xff9c('0x3b')]['count'](_0x551766)[_0xff9c('0x21')](function(_0x493a75){_0x29ce4f[_0xff9c('0x31')]=_0x493a75;if(_0x27714c[_0xff9c('0x3f')][_0xff9c('0x50')]){_0x3613ad['include']=[{'all':!![]}];}return db[_0xff9c('0x3b')]['findAll'](_0x3613ad);})['then'](function(_0x3806da){_0x29ce4f[_0xff9c('0x51')]=_0x3806da;return _0x29ce4f;})[_0xff9c('0x21')](respondWithFilteredResult(_0x32e466,_0x3613ad))[_0xff9c('0x2b')](handleError(_0x32e466,null));};exports[_0xff9c('0x52')]=function(_0x1d8cb9,_0x45fabf){var _0x1901f9={'raw':!![],'where':{'id':_0x1d8cb9[_0xff9c('0x53')]['id']}},_0x53d43c={};_0x53d43c[_0xff9c('0x3e')]=_[_0xff9c('0x40')](db[_0xff9c('0x3b')][_0xff9c('0x3c')]);_0x53d43c['query']=_[_0xff9c('0x40')](_0x1d8cb9[_0xff9c('0x3f')]);_0x53d43c[_0xff9c('0x41')]=_[_0xff9c('0x43')](_0x53d43c[_0xff9c('0x3e')],_0x53d43c[_0xff9c('0x3f')]);_0x1901f9[_0xff9c('0x42')]=_[_0xff9c('0x43')](_0x53d43c[_0xff9c('0x3e')],qs['fields'](_0x1d8cb9[_0xff9c('0x3f')]['fields']));_0x1901f9[_0xff9c('0x42')]=_0x1901f9['attributes'][_0xff9c('0x45')]?_0x1901f9[_0xff9c('0x42')]:_0x53d43c[_0xff9c('0x3e')];if(_0x1d8cb9[_0xff9c('0x3f')][_0xff9c('0x50')]){_0x1901f9[_0xff9c('0x54')]=[{'all':!![]}];}_0x1901f9=_[_0xff9c('0x4d')]({},_0x1901f9,_0x1d8cb9['options']);return db[_0xff9c('0x3b')][_0xff9c('0x55')](_0x1901f9)[_0xff9c('0x21')](handleEntityNotFound(_0x45fabf,null))['then'](respondWithResult(_0x45fabf,null))[_0xff9c('0x2b')](handleError(_0x45fabf,null));};exports[_0xff9c('0x35')]=function(_0x12dd03,_0x1be112){if(_0x12dd03[_0xff9c('0x56')]['id']){delete _0x12dd03['body']['id'];}return db[_0xff9c('0x3b')][_0xff9c('0x55')]({'where':{'id':_0x12dd03[_0xff9c('0x53')]['id']}})[_0xff9c('0x21')](handleEntityNotFound(_0x1be112,null))[_0xff9c('0x21')](saveUpdates(_0x12dd03[_0xff9c('0x56')],null))[_0xff9c('0x21')](respondWithResult(_0x1be112,null))[_0xff9c('0x2b')](handleError(_0x1be112,null));};exports['destroy']=function(_0x2857b5,_0x7c8637){return db['FaxMessage']['find']({'where':{'id':_0x2857b5[_0xff9c('0x53')]['id']}})[_0xff9c('0x21')](handleEntityNotFound(_0x7c8637,null))[_0xff9c('0x21')](removeEntity(_0x7c8637,null))[_0xff9c('0x2b')](handleError(_0x7c8637,null));};exports[_0xff9c('0x57')]=function(_0x6cc6d0,_0x1b3bc0){return db[_0xff9c('0x3b')][_0xff9c('0x57')]()[_0xff9c('0x21')](respondWithResult(_0x1b3bc0,null))[_0xff9c('0x2b')](handleError(_0x1b3bc0,null));};var interaction_log=require(_0xff9c('0x12'))(_0xff9c('0x58'));exports[_0xff9c('0x59')]=function(_0x406c84,_0x58e281,_0x2e9850){var _0x174661={'agent':{},'channel':_0xff9c('0x5a')};if(_0x406c84[_0xff9c('0x56')]['id']){delete _0x406c84[_0xff9c('0x56')]['id'];}_0x406c84[_0xff9c('0x56')][_0xff9c('0x5b')]=!![];_0x406c84[_0xff9c('0x56')][_0xff9c('0x5c')]=moment()[_0xff9c('0x5d')](_0xff9c('0x5e'));_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')]=_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')]||_0x406c84[_0xff9c('0x60')]['id'];_0x174661[_0xff9c('0x61')]['id']=_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')];return db['FaxMessage'][_0xff9c('0x55')]({'where':{'id':_0x406c84[_0xff9c('0x53')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x58e281,null))[_0xff9c('0x21')](saveUpdates(_0x406c84[_0xff9c('0x56')],null))['then'](function(_0x40d45a){if(_0x40d45a){_0x174661['message']=_0x40d45a[_0xff9c('0x62')]({'plain':!![]});return db['FaxInteraction']['find']({'where':{'id':_0x40d45a[_0xff9c('0x63')]}});}return null;})[_0xff9c('0x21')](handleEntityNotFound(_0x58e281,null))['then'](function(_0xe00aa9){if(_0xe00aa9){return _0xe00aa9['update']({'UserId':_0x406c84[_0xff9c('0x56')][_0xff9c('0x5f')],'read1stAt':_[_0xff9c('0x64')](_0xe00aa9[_0xff9c('0x65')])?moment()[_0xff9c('0x5d')](_0xff9c('0x5e')):undefined});}return null;})[_0xff9c('0x21')](function(_0xa2d9b){if(_0xa2d9b){_0x174661['interaction']=_0xa2d9b[_0xff9c('0x62')]({'plain':!![]});interaction_log[_0xff9c('0x22')](_0xff9c('0x66'),_0x406c84[_0xff9c('0x60')]['id'],_0x406c84[_0xff9c('0x60')][_0xff9c('0x38')],_0x406c84[_0xff9c('0x60')][_0xff9c('0x67')],_0x174661[_0xff9c('0x68')]['id'],_0x406c84[_0xff9c('0x56')]?JSON[_0xff9c('0x25')](_0x406c84[_0xff9c('0x56')]):_0xff9c('0x69'));return respondWithRpcPromise(_0xff9c('0x6a'),_0xff9c('0x6b'),_0x174661);}return null;})[_0xff9c('0x21')](function(_0x1d1244){var _0x1afca1='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x1d1244[_0xff9c('0x29')]['ContactId'];return db[_0xff9c('0x6c')][_0xff9c('0x3f')](_0x1afca1,{'type':db['Sequelize']['QueryTypes'][_0xff9c('0x6d')],'raw':!![]})[_0xff9c('0x21')](function(_0x4613e2){return _0x4613e2;});})[_0xff9c('0x21')](function(_0x4baf5b){if(_0x4baf5b){_0x174661['message'][_0xff9c('0x6e')]=_0x4baf5b[0x0];if(!_0x406c84['body'][_0xff9c('0x5f')])return;return db[_0xff9c('0x6f')]['find']({'where':{'id':_0x406c84['body']['UserId'],'role':'agent'},'attributes':['id',_0xff9c('0x38'),_0xff9c('0x70'),_0xff9c('0x71'),_0xff9c('0x72')],'raw':!![]});}return null;})[_0xff9c('0x21')](function(_0x3f498c){if(!_0x3f498c)return null;_0x174661[_0xff9c('0x29')][_0xff9c('0x61')]=_0x3f498c;return _0x174661;})[_0xff9c('0x21')](function(_0x4117ee){if(_0x4117ee){if(_0x406c84[_0xff9c('0x56')][_0xff9c('0x73')]){_0x174661[_0xff9c('0x29')]['interface']=util[_0xff9c('0x5d')](_0xff9c('0x74'),_0x406c84[_0xff9c('0x60')][_0xff9c('0x38')]);_0x174661['message']['channel']=_0x174661[_0xff9c('0x75')];_0x174661[_0xff9c('0x29')][_0xff9c('0x76')]=_0x174661['channel'];_0x174661[_0xff9c('0x29')]['event']=_0xff9c('0x59');return respondWithRpcPromise('EventManager','EventManager',{'event':'acceptmessage','message':_0x174661[_0xff9c('0x29')]},client9002)['then'](function(){return _0x174661;});}return _0x174661;}return null;})[_0xff9c('0x21')](respondWithResult(_0x58e281,null))['catch'](handleError(_0x58e281,null));};var interaction_log=require(_0xff9c('0x12'))(_0xff9c('0x58'));exports[_0xff9c('0x34')]=function(_0x44b68a,_0x327e0e,_0x1dac92){var _0x39cb9a={'agent':{},'channel':_0xff9c('0x5a')};if(_0x44b68a['body']['id']){delete _0x44b68a[_0xff9c('0x56')]['id'];}_0x44b68a['body'][_0xff9c('0x5f')]=_0x44b68a['body'][_0xff9c('0x5f')]||_0x44b68a['user']['id'];_0x39cb9a['agent']['id']=_0x44b68a['body'][_0xff9c('0x5f')];return db[_0xff9c('0x3b')][_0xff9c('0x55')]({'where':{'id':_0x44b68a[_0xff9c('0x53')]['id'],'UserId':null}})[_0xff9c('0x21')](handleEntityNotFound(_0x327e0e,null))[_0xff9c('0x21')](function(_0x427323){if(_0x427323){_0x39cb9a[_0xff9c('0x29')]=_0x427323[_0xff9c('0x62')]({'plain':!![]});return db[_0xff9c('0x77')]['find']({'where':{'id':_0x427323[_0xff9c('0x63')]}});}return null;})[_0xff9c('0x21')](handleEntityNotFound(_0x327e0e,null))[_0xff9c('0x21')](function(_0x3dfe01){if(_0x3dfe01){_0x39cb9a[_0xff9c('0x68')]=_0x3dfe01[_0xff9c('0x62')]({'plain':!![]});interaction_log[_0xff9c('0x22')](_0xff9c('0x78'),_0x44b68a[_0xff9c('0x60')]['id'],_0x44b68a[_0xff9c('0x60')][_0xff9c('0x38')],_0x44b68a[_0xff9c('0x60')][_0xff9c('0x67')],_0x39cb9a['interaction']['id'],_0x44b68a[_0xff9c('0x56')]?JSON[_0xff9c('0x25')](_0x44b68a[_0xff9c('0x56')]):_0xff9c('0x69'));return respondWithRpcPromise(_0xff9c('0x79'),_0xff9c('0x7a'),_0x39cb9a);}return null;})['then'](function(_0x324e57){var _0x2eff3a=_0xff9c('0x7b')+_0x324e57[_0xff9c('0x29')]['ContactId'];return db['sequelize']['query'](_0x2eff3a,{'type':db[_0xff9c('0x7c')][_0xff9c('0x7d')][_0xff9c('0x6d')],'raw':!![]})['then'](function(_0x26d6de){return _0x26d6de;});})[_0xff9c('0x21')](function(_0x4bf0a9){if(_0x4bf0a9){_0x39cb9a[_0xff9c('0x29')][_0xff9c('0x6e')]=_0x4bf0a9[0x0];if(!_0x44b68a['body']['UserId'])return;return db[_0xff9c('0x6f')][_0xff9c('0x55')]({'where':{'id':_0x44b68a[_0xff9c('0x56')][_0xff9c('0x5f')],'role':_0xff9c('0x61')},'attributes':['id','name','fullname','email',_0xff9c('0x72')],'raw':!![]});}return null;})['then'](function(_0x80046d){if(!_0x80046d)return null;_0x39cb9a[_0xff9c('0x29')][_0xff9c('0x61')]=_0x80046d;return _0x39cb9a;})[_0xff9c('0x21')](function(_0x385ef8){if(_0x385ef8){_0x385ef8[_0xff9c('0x29')][_0xff9c('0x7e')]=util[_0xff9c('0x5d')](_0xff9c('0x74'),_0x44b68a[_0xff9c('0x60')][_0xff9c('0x38')]);_0x385ef8['message']['channel']=_0x39cb9a[_0xff9c('0x75')];_0x385ef8['message']['motionChannel']=_0x39cb9a[_0xff9c('0x75')];_0x385ef8['message']['event']=_0xff9c('0x34');respondWithRpcPromise(_0xff9c('0x7f'),_0xff9c('0x7f'),{'event':_0xff9c('0x80'),'message':_0x385ef8['message']},client9002);return _0x39cb9a;}return null;})[_0xff9c('0x21')](respondWithResult(_0x327e0e,null))['catch'](handleError(_0x327e0e,null));};exports[_0xff9c('0x81')]=function(_0x5ea8ca,_0x4345bd){var _0x36fa9a;return db[_0xff9c('0x3b')]['create'](_0x5ea8ca[_0xff9c('0x56')],{})[_0xff9c('0x21')](function(_0x5604fc){_0x36fa9a=_0x5604fc;return db['CmContact'][_0xff9c('0x82')]({'where':{'id':_0x36fa9a[_0xff9c('0x83')]}});})['then'](function(_0x169de9){if(_[_0xff9c('0x64')](_0x169de9)){return;}else{_0x36fa9a['fax']=_0x169de9['fax'];return db[_0xff9c('0x84')][_0xff9c('0x82')]({'where':{'id':_0x36fa9a[_0xff9c('0x85')]}});}})['then'](function(_0x2e447f){return respondWithRpcPromise(_0xff9c('0x86'),_0xff9c('0x86'),{'FaxAccountId':_['isNil'](_0x5ea8ca[_0xff9c('0x56')])?undefined:_0x5ea8ca[_0xff9c('0x56')][_0xff9c('0x87')],'path':_[_0xff9c('0x64')](_0x2e447f)?undefined:util['format'](_0xff9c('0x88'),_0x2e447f['basename']),'fax':_['isNil'](_0x36fa9a[_0xff9c('0x5a')])?undefined:_0x36fa9a[_0xff9c('0x5a')],'AttachmentId':_0x36fa9a[_0xff9c('0x85')]},client9002);})[_0xff9c('0x21')](respondWithResult(_0x4345bd,0xc9))[_0xff9c('0x2b')](handleError(_0x4345bd,null));};exports[_0xff9c('0x89')]=function(_0x343c2d,_0x1c7908){var _0x9ec879=path[_0xff9c('0x8a')](config[_0xff9c('0x8b')],'server',_0xff9c('0x8c'),'attachments');return db['FaxMessage']['find']({'where':{'id':_0x343c2d[_0xff9c('0x53')]['id']},'include':[{'model':db[_0xff9c('0x84')],'as':_0xff9c('0x84')}]})['then'](handleEntityNotFound(_0x1c7908,null))['then'](function(_0xe800fe){if(_0xe800fe){return _0x1c7908['download'](path[_0xff9c('0x8a')](_0x9ec879,_0xe800fe[_0xff9c('0x84')][_0xff9c('0x8d')]));}})[_0xff9c('0x2b')](handleError(_0x1c7908,null));};
\ No newline at end of file
+var _0x7b74=['destroy','stack','name','index','map','FaxMessage','rawAttributes','fieldName','type','key','keys','filters','model','query','attributes','fields','length','limit','order','sort','where','filter','merge','VIRTUAL','includeAll','findAll','rows','show','params','intersection','include','find','update','body','describe','../../config/logger','fax-interactions','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','get','FaxInteraction','FaxInteractionId','isNil','interaction','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','stringify','null','AcceptMessage','ContactId','User','fullname','email','internal','agent','manual','interface','channel','motionChannel','event','accept','EventManager','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','Sequelize','QueryTypes','contact','SIP/%s','rejectmessage','create','CmContact','Attachment','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','fax','join','files','download','eml-format','rimraf','zip-dir','moment','bluebird','mustache','util','path','sox','to-csv','ejs','squel','crypto','desk.js','querystring','../../components/auth/service','../../components/parsers/advancedSearch','api','../../config/utils','../../mysqldb','redis','defaults','socket.io-emitter','./faxMessage.socket','register','jayson/promise','client','http','request','then','info','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','error','code','FaxMessage,\x20%s,\x20%s','message','result','catch','sendStatus','end','status','json','offset','undefined','count','set','Content-Range','apply','reject','save'];(function(_0x40d493,_0x21619d){var _0x28946b=function(_0x4efa65){while(--_0x4efa65){_0x40d493['push'](_0x40d493['shift']());}};_0x28946b(++_0x21619d);}(_0x7b74,0x164));var _0x47b7=function(_0x278238,_0x2e59d8){_0x278238=_0x278238-0x0;var _0x1644a6=_0x7b74[_0x278238];return _0x1644a6;};'use strict';var emlformat=require(_0x47b7('0x0'));var rimraf=require(_0x47b7('0x1'));var zipdir=require(_0x47b7('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x47b7('0x3'));var BPromise=require(_0x47b7('0x4'));var Mustache=require(_0x47b7('0x5'));var util=require(_0x47b7('0x6'));var path=require(_0x47b7('0x7'));var sox=require(_0x47b7('0x8'));var csv=require(_0x47b7('0x9'));var ejs=require(_0x47b7('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x47b7('0xb'));var crypto=require(_0x47b7('0xc'));var jsforce=require('jsforce');var deskjs=require(_0x47b7('0xd'));var toCsv=require(_0x47b7('0x9'));var querystring=require(_0x47b7('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x47b7('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x47b7('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x47b7('0x11'));var utils=require(_0x47b7('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x47b7('0x13'))['db'];config[_0x47b7('0x14')]=_[_0x47b7('0x15')](config['redis'],{'host':'localhost','port':0x18eb});var socket=require(_0x47b7('0x16'))(new Redis(config[_0x47b7('0x14')]));require(_0x47b7('0x17'))[_0x47b7('0x18')](socket);var jayson=require(_0x47b7('0x19'));var client=jayson[_0x47b7('0x1a')][_0x47b7('0x1b')]({'port':0x232c});var client9002=jayson[_0x47b7('0x1a')][_0x47b7('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x13d6ec,_0x264756,_0x1dd4b9,_0x554fbf){return new BPromise(function(_0x557d09,_0x2a9a8b){var _0x4f19c4=_0x554fbf||client;return _0x4f19c4[_0x47b7('0x1c')](_0x13d6ec,_0x1dd4b9)[_0x47b7('0x1d')](function(_0x36b925){logger[_0x47b7('0x1e')]('FaxMessage,\x20%s,\x20%s',_0x264756,_0x47b7('0x1f'));logger[_0x47b7('0x20')](_0x47b7('0x21'),_0x264756,'request\x20sent',JSON['stringify'](_0x36b925));if(_0x36b925[_0x47b7('0x22')]){if(_0x36b925[_0x47b7('0x22')][_0x47b7('0x23')]===0x1f4){logger[_0x47b7('0x22')](_0x47b7('0x24'),_0x264756,_0x36b925[_0x47b7('0x22')][_0x47b7('0x25')]);return _0x2a9a8b(_0x36b925[_0x47b7('0x22')]['message']);}logger[_0x47b7('0x22')]('FaxMessage,\x20%s,\x20%s',_0x264756,_0x36b925['error'][_0x47b7('0x25')]);return _0x557d09(_0x36b925[_0x47b7('0x22')]['message']);}else{logger[_0x47b7('0x1e')](_0x47b7('0x24'),_0x264756,_0x47b7('0x1f'));_0x557d09(_0x36b925[_0x47b7('0x26')][_0x47b7('0x25')]);}})[_0x47b7('0x27')](function(_0x492cf4){logger[_0x47b7('0x22')]('FaxMessage,\x20%s,\x20%s',_0x264756,_0x492cf4);_0x2a9a8b(_0x492cf4);});});}function respondWithStatusCode(_0x7b0ae5,_0x1c715d){_0x1c715d=_0x1c715d||0xcc;return function(_0x27c8fc){if(_0x27c8fc){return _0x7b0ae5[_0x47b7('0x28')](_0x1c715d);}return _0x7b0ae5['status'](_0x1c715d)[_0x47b7('0x29')]();};}function respondWithResult(_0x2abf83,_0x50e62d){_0x50e62d=_0x50e62d||0xc8;return function(_0x36e469){if(_0x36e469){return _0x2abf83[_0x47b7('0x2a')](_0x50e62d)[_0x47b7('0x2b')](_0x36e469);}};}function respondWithFilteredResult(_0xb68a5,_0x2ebe89){return function(_0x3178cb){if(_0x3178cb){var _0x231e52=typeof _0x2ebe89[_0x47b7('0x2c')]===_0x47b7('0x2d')&&typeof _0x2ebe89['limit']===_0x47b7('0x2d');var _0x3d01b6=_0x3178cb[_0x47b7('0x2e')];var _0xa0dac0=_0x231e52?0x0:_0x2ebe89[_0x47b7('0x2c')];var _0x51a907=_0x231e52?_0x3178cb['count']:_0x2ebe89[_0x47b7('0x2c')]+_0x2ebe89['limit'];var _0x52e834;if(_0x51a907>=_0x3d01b6){_0x51a907=_0x3d01b6;_0x52e834=0xc8;}else{_0x52e834=0xce;}_0xb68a5['status'](_0x52e834);return _0xb68a5[_0x47b7('0x2f')](_0x47b7('0x30'),_0xa0dac0+'-'+_0x51a907+'/'+_0x3d01b6)['json'](_0x3178cb);}return null;};}function patchUpdates(_0x21af14){return function(_0x3166b3){try{jsonpatch[_0x47b7('0x31')](_0x3166b3,_0x21af14,!![]);}catch(_0x19a768){return BPromise[_0x47b7('0x32')](_0x19a768);}return _0x3166b3[_0x47b7('0x33')]();};}function saveUpdates(_0x384ada,_0x6b403c){return function(_0x550588){if(_0x550588){return _0x550588['update'](_0x384ada)['then'](function(_0x32e958){return _0x32e958;});}return null;};}function removeEntity(_0x13c4c5,_0x1045cd){return function(_0x34b874){if(_0x34b874){return _0x34b874[_0x47b7('0x34')]()[_0x47b7('0x1d')](function(){_0x13c4c5['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x3ed2fd,_0x1c8a6c){return function(_0x536210){if(!_0x536210){_0x3ed2fd['sendStatus'](0x194);}return _0x536210;};}function handleError(_0x1e09a2,_0x5b46ff){_0x5b46ff=_0x5b46ff||0x1f4;return function(_0x212a6e){logger[_0x47b7('0x22')](_0x212a6e[_0x47b7('0x35')]);if(_0x212a6e[_0x47b7('0x36')]){delete _0x212a6e['name'];}_0x1e09a2[_0x47b7('0x2a')](_0x5b46ff)['send'](_0x212a6e);};}exports[_0x47b7('0x37')]=function(_0x4d1483,_0xe1fcc){var _0x165e0b={},_0x19cdb7={},_0x59fbb9={'count':0x0,'rows':[]};var _0x33a255=_[_0x47b7('0x38')](db[_0x47b7('0x39')][_0x47b7('0x3a')],function(_0xd99787){return{'name':_0xd99787[_0x47b7('0x3b')],'type':_0xd99787[_0x47b7('0x3c')][_0x47b7('0x3d')]};});_0x19cdb7['model']=_[_0x47b7('0x38')](_0x33a255,_0x47b7('0x36'));_0x19cdb7['query']=_[_0x47b7('0x3e')](_0x4d1483['query']);_0x19cdb7[_0x47b7('0x3f')]=_['intersection'](_0x19cdb7[_0x47b7('0x40')],_0x19cdb7[_0x47b7('0x41')]);_0x165e0b[_0x47b7('0x42')]=_['intersection'](_0x19cdb7[_0x47b7('0x40')],qs[_0x47b7('0x43')](_0x4d1483[_0x47b7('0x41')][_0x47b7('0x43')]));_0x165e0b[_0x47b7('0x42')]=_0x165e0b[_0x47b7('0x42')][_0x47b7('0x44')]?_0x165e0b['attributes']:_0x19cdb7['model'];if(!_0x4d1483[_0x47b7('0x41')]['hasOwnProperty']('nolimit')){_0x165e0b['limit']=qs[_0x47b7('0x45')](_0x4d1483[_0x47b7('0x41')][_0x47b7('0x45')]);_0x165e0b['offset']=qs[_0x47b7('0x2c')](_0x4d1483[_0x47b7('0x41')]['offset']);}_0x165e0b[_0x47b7('0x46')]=qs[_0x47b7('0x47')](_0x4d1483[_0x47b7('0x41')][_0x47b7('0x47')]);_0x165e0b[_0x47b7('0x48')]=qs[_0x47b7('0x3f')](_['pick'](_0x4d1483['query'],_0x19cdb7[_0x47b7('0x3f')]),_0x33a255);if(_0x4d1483[_0x47b7('0x41')][_0x47b7('0x49')]){_0x165e0b[_0x47b7('0x48')]=_[_0x47b7('0x4a')](_0x165e0b[_0x47b7('0x48')],{'$or':_[_0x47b7('0x38')](_0x33a255,function(_0x39b42e){if(_0x39b42e[_0x47b7('0x3c')]!==_0x47b7('0x4b')){var _0x3f7fb3={};_0x3f7fb3[_0x39b42e[_0x47b7('0x36')]]={'$like':'%'+_0x4d1483[_0x47b7('0x41')][_0x47b7('0x49')]+'%'};return _0x3f7fb3;}})});}_0x165e0b=_[_0x47b7('0x4a')]({},_0x165e0b,_0x4d1483['options']);var _0x5ded62={'where':_0x165e0b[_0x47b7('0x48')]};return db[_0x47b7('0x39')][_0x47b7('0x2e')](_0x5ded62)[_0x47b7('0x1d')](function(_0x292b32){_0x59fbb9['count']=_0x292b32;if(_0x4d1483[_0x47b7('0x41')][_0x47b7('0x4c')]){_0x165e0b['include']=[{'all':!![]}];}return db['FaxMessage'][_0x47b7('0x4d')](_0x165e0b);})[_0x47b7('0x1d')](function(_0x54951d){_0x59fbb9[_0x47b7('0x4e')]=_0x54951d;return _0x59fbb9;})['then'](respondWithFilteredResult(_0xe1fcc,_0x165e0b))[_0x47b7('0x27')](handleError(_0xe1fcc,null));};exports[_0x47b7('0x4f')]=function(_0x1dacf9,_0x2bc7a3){var _0x2c71de={'raw':!![],'where':{'id':_0x1dacf9[_0x47b7('0x50')]['id']}},_0x2f442b={};_0x2f442b[_0x47b7('0x40')]=_[_0x47b7('0x3e')](db['FaxMessage'][_0x47b7('0x3a')]);_0x2f442b[_0x47b7('0x41')]=_[_0x47b7('0x3e')](_0x1dacf9[_0x47b7('0x41')]);_0x2f442b[_0x47b7('0x3f')]=_[_0x47b7('0x51')](_0x2f442b[_0x47b7('0x40')],_0x2f442b['query']);_0x2c71de[_0x47b7('0x42')]=_['intersection'](_0x2f442b[_0x47b7('0x40')],qs[_0x47b7('0x43')](_0x1dacf9[_0x47b7('0x41')][_0x47b7('0x43')]));_0x2c71de['attributes']=_0x2c71de[_0x47b7('0x42')][_0x47b7('0x44')]?_0x2c71de[_0x47b7('0x42')]:_0x2f442b[_0x47b7('0x40')];if(_0x1dacf9['query'][_0x47b7('0x4c')]){_0x2c71de[_0x47b7('0x52')]=[{'all':!![]}];}_0x2c71de=_[_0x47b7('0x4a')]({},_0x2c71de,_0x1dacf9['options']);return db[_0x47b7('0x39')][_0x47b7('0x53')](_0x2c71de)[_0x47b7('0x1d')](handleEntityNotFound(_0x2bc7a3,null))[_0x47b7('0x1d')](respondWithResult(_0x2bc7a3,null))[_0x47b7('0x27')](handleError(_0x2bc7a3,null));};exports[_0x47b7('0x54')]=function(_0x2a6a45,_0x4a5162){if(_0x2a6a45[_0x47b7('0x55')]['id']){delete _0x2a6a45[_0x47b7('0x55')]['id'];}return db[_0x47b7('0x39')][_0x47b7('0x53')]({'where':{'id':_0x2a6a45[_0x47b7('0x50')]['id']}})[_0x47b7('0x1d')](handleEntityNotFound(_0x4a5162,null))['then'](saveUpdates(_0x2a6a45[_0x47b7('0x55')],null))[_0x47b7('0x1d')](respondWithResult(_0x4a5162,null))[_0x47b7('0x27')](handleError(_0x4a5162,null));};exports[_0x47b7('0x34')]=function(_0x56daaf,_0x1ee5ed){return db[_0x47b7('0x39')]['find']({'where':{'id':_0x56daaf[_0x47b7('0x50')]['id']}})[_0x47b7('0x1d')](handleEntityNotFound(_0x1ee5ed,null))[_0x47b7('0x1d')](removeEntity(_0x1ee5ed,null))[_0x47b7('0x27')](handleError(_0x1ee5ed,null));};exports[_0x47b7('0x56')]=function(_0x1498dc,_0x2d49b4){return db[_0x47b7('0x39')][_0x47b7('0x56')]()[_0x47b7('0x1d')](respondWithResult(_0x2d49b4,null))[_0x47b7('0x27')](handleError(_0x2d49b4,null));};var interaction_log=require(_0x47b7('0x57'))(_0x47b7('0x58'));exports['accept']=function(_0xc51ef5,_0x16f75a,_0x4354fc){var _0x1a2eff={'agent':{},'channel':'fax'};if(_0xc51ef5[_0x47b7('0x55')]['id']){delete _0xc51ef5['body']['id'];}_0xc51ef5['body']['read']=!![];_0xc51ef5[_0x47b7('0x55')][_0x47b7('0x59')]=moment()[_0x47b7('0x5a')](_0x47b7('0x5b'));_0xc51ef5[_0x47b7('0x55')][_0x47b7('0x5c')]=_0xc51ef5['body'][_0x47b7('0x5c')]||_0xc51ef5[_0x47b7('0x5d')]['id'];_0x1a2eff['agent']['id']=_0xc51ef5[_0x47b7('0x55')][_0x47b7('0x5c')];return db[_0x47b7('0x39')][_0x47b7('0x53')]({'where':{'id':_0xc51ef5[_0x47b7('0x50')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x16f75a,null))['then'](saveUpdates(_0xc51ef5[_0x47b7('0x55')],null))[_0x47b7('0x1d')](function(_0x479a69){if(_0x479a69){_0x1a2eff[_0x47b7('0x25')]=_0x479a69[_0x47b7('0x5e')]({'plain':!![]});return db[_0x47b7('0x5f')][_0x47b7('0x53')]({'where':{'id':_0x479a69[_0x47b7('0x60')]}});}return null;})[_0x47b7('0x1d')](handleEntityNotFound(_0x16f75a,null))['then'](function(_0x34005f){if(_0x34005f){return _0x34005f['update']({'UserId':_0xc51ef5['body'][_0x47b7('0x5c')],'read1stAt':_[_0x47b7('0x61')](_0x34005f['read1stAt'])?moment()[_0x47b7('0x5a')](_0x47b7('0x5b')):undefined});}return null;})[_0x47b7('0x1d')](function(_0x10f6c2){if(_0x10f6c2){_0x1a2eff[_0x47b7('0x62')]=_0x10f6c2['get']({'plain':!![]});interaction_log[_0x47b7('0x1e')](_0x47b7('0x63'),_0xc51ef5[_0x47b7('0x5d')]['id'],_0xc51ef5[_0x47b7('0x5d')][_0x47b7('0x36')],_0xc51ef5[_0x47b7('0x5d')][_0x47b7('0x64')],_0x1a2eff['interaction']['id'],_0xc51ef5[_0x47b7('0x55')]?JSON[_0x47b7('0x65')](_0xc51ef5['body']):_0x47b7('0x66'));return respondWithRpcPromise(_0x47b7('0x67'),'acceptMessage',_0x1a2eff);}return null;})[_0x47b7('0x1d')](function(_0x25aaea){var _0x521884='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x25aaea[_0x47b7('0x25')][_0x47b7('0x68')];return db['sequelize'][_0x47b7('0x41')](_0x521884,{'type':db['Sequelize']['QueryTypes']['SELECT'],'raw':!![]})[_0x47b7('0x1d')](function(_0x4d8ffc){return _0x4d8ffc;});})[_0x47b7('0x1d')](function(_0x323fdb){if(_0x323fdb){_0x1a2eff[_0x47b7('0x25')]['contact']=_0x323fdb[0x0];if(!_0xc51ef5[_0x47b7('0x55')][_0x47b7('0x5c')])return;return db[_0x47b7('0x69')][_0x47b7('0x53')]({'where':{'id':_0xc51ef5['body']['UserId'],'role':'agent'},'attributes':['id',_0x47b7('0x36'),_0x47b7('0x6a'),_0x47b7('0x6b'),_0x47b7('0x6c')],'raw':!![]});}return null;})[_0x47b7('0x1d')](function(_0x4a412b){if(!_0x4a412b)return null;_0x1a2eff[_0x47b7('0x25')][_0x47b7('0x6d')]=_0x4a412b;return _0x1a2eff;})['then'](function(_0x592e24){if(_0x592e24){if(_0xc51ef5['body'][_0x47b7('0x6e')]){_0x1a2eff[_0x47b7('0x25')][_0x47b7('0x6f')]=util[_0x47b7('0x5a')]('SIP/%s',_0xc51ef5[_0x47b7('0x5d')]['name']);_0x1a2eff[_0x47b7('0x25')][_0x47b7('0x70')]=_0x1a2eff[_0x47b7('0x70')];_0x1a2eff[_0x47b7('0x25')][_0x47b7('0x71')]=_0x1a2eff[_0x47b7('0x70')];_0x1a2eff[_0x47b7('0x25')][_0x47b7('0x72')]=_0x47b7('0x73');return respondWithRpcPromise(_0x47b7('0x74'),_0x47b7('0x74'),{'event':'acceptmessage','message':_0x1a2eff[_0x47b7('0x25')]},client9002)['then'](function(){return _0x1a2eff;});}return _0x1a2eff;}return null;})[_0x47b7('0x1d')](respondWithResult(_0x16f75a,null))[_0x47b7('0x27')](handleError(_0x16f75a,null));};var interaction_log=require(_0x47b7('0x57'))('fax-interactions');exports[_0x47b7('0x32')]=function(_0x5884f9,_0x3b65d4,_0x15ddcf){var _0x42196a={'agent':{},'channel':'fax'};if(_0x5884f9['body']['id']){delete _0x5884f9[_0x47b7('0x55')]['id'];}_0x5884f9[_0x47b7('0x55')][_0x47b7('0x5c')]=_0x5884f9['body']['UserId']||_0x5884f9[_0x47b7('0x5d')]['id'];_0x42196a[_0x47b7('0x6d')]['id']=_0x5884f9[_0x47b7('0x55')][_0x47b7('0x5c')];return db[_0x47b7('0x39')]['find']({'where':{'id':_0x5884f9['params']['id'],'UserId':null}})[_0x47b7('0x1d')](handleEntityNotFound(_0x3b65d4,null))[_0x47b7('0x1d')](function(_0x13ea0c){if(_0x13ea0c){_0x42196a[_0x47b7('0x25')]=_0x13ea0c[_0x47b7('0x5e')]({'plain':!![]});return db['FaxInteraction'][_0x47b7('0x53')]({'where':{'id':_0x13ea0c[_0x47b7('0x60')]}});}return null;})[_0x47b7('0x1d')](handleEntityNotFound(_0x3b65d4,null))[_0x47b7('0x1d')](function(_0x457e12){if(_0x457e12){_0x42196a[_0x47b7('0x62')]=_0x457e12[_0x47b7('0x5e')]({'plain':!![]});interaction_log[_0x47b7('0x1e')](_0x47b7('0x75'),_0x5884f9[_0x47b7('0x5d')]['id'],_0x5884f9[_0x47b7('0x5d')]['name'],_0x5884f9['user'][_0x47b7('0x64')],_0x42196a[_0x47b7('0x62')]['id'],_0x5884f9[_0x47b7('0x55')]?JSON[_0x47b7('0x65')](_0x5884f9[_0x47b7('0x55')]):'null');return respondWithRpcPromise(_0x47b7('0x76'),'rejectMessage',_0x42196a);}return null;})[_0x47b7('0x1d')](function(_0x2b7f67){var _0x313028='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x2b7f67[_0x47b7('0x25')][_0x47b7('0x68')];return db['sequelize'][_0x47b7('0x41')](_0x313028,{'type':db[_0x47b7('0x77')][_0x47b7('0x78')]['SELECT'],'raw':!![]})['then'](function(_0x13b21d){return _0x13b21d;});})[_0x47b7('0x1d')](function(_0x4d703f){if(_0x4d703f){_0x42196a[_0x47b7('0x25')][_0x47b7('0x79')]=_0x4d703f[0x0];if(!_0x5884f9[_0x47b7('0x55')][_0x47b7('0x5c')])return;return db[_0x47b7('0x69')][_0x47b7('0x53')]({'where':{'id':_0x5884f9[_0x47b7('0x55')]['UserId'],'role':_0x47b7('0x6d')},'attributes':['id',_0x47b7('0x36'),_0x47b7('0x6a'),_0x47b7('0x6b'),_0x47b7('0x6c')],'raw':!![]});}return null;})[_0x47b7('0x1d')](function(_0x3f4be0){if(!_0x3f4be0)return null;_0x42196a[_0x47b7('0x25')][_0x47b7('0x6d')]=_0x3f4be0;return _0x42196a;})[_0x47b7('0x1d')](function(_0x35720d){if(_0x35720d){_0x35720d[_0x47b7('0x25')][_0x47b7('0x6f')]=util[_0x47b7('0x5a')](_0x47b7('0x7a'),_0x5884f9[_0x47b7('0x5d')][_0x47b7('0x36')]);_0x35720d[_0x47b7('0x25')][_0x47b7('0x70')]=_0x42196a['channel'];_0x35720d[_0x47b7('0x25')]['motionChannel']=_0x42196a[_0x47b7('0x70')];_0x35720d['message'][_0x47b7('0x72')]=_0x47b7('0x32');respondWithRpcPromise('EventManager',_0x47b7('0x74'),{'event':_0x47b7('0x7b'),'message':_0x35720d[_0x47b7('0x25')]},client9002);return _0x42196a;}return null;})[_0x47b7('0x1d')](respondWithResult(_0x3b65d4,null))[_0x47b7('0x27')](handleError(_0x3b65d4,null));};exports[_0x47b7('0x7c')]=function(_0x49235c,_0x4ba199){var _0x1b244c;return db[_0x47b7('0x39')][_0x47b7('0x7c')](_0x49235c[_0x47b7('0x55')],{})[_0x47b7('0x1d')](function(_0x414aae){_0x1b244c=_0x414aae;return db[_0x47b7('0x7d')]['findOne']({'where':{'id':_0x1b244c['ContactId']}});})[_0x47b7('0x1d')](function(_0x3b4037){if(_['isNil'](_0x3b4037)){return;}else{_0x1b244c['fax']=_0x3b4037['fax'];return db[_0x47b7('0x7e')]['findOne']({'where':{'id':_0x1b244c[_0x47b7('0x7f')]}});}})[_0x47b7('0x1d')](function(_0x1c8ff1){return respondWithRpcPromise(_0x47b7('0x80'),_0x47b7('0x80'),{'FaxAccountId':_[_0x47b7('0x61')](_0x49235c['body'])?undefined:_0x49235c['body'][_0x47b7('0x81')],'path':_[_0x47b7('0x61')](_0x1c8ff1)?undefined:util[_0x47b7('0x5a')](_0x47b7('0x82'),_0x1c8ff1[_0x47b7('0x83')]),'fax':_[_0x47b7('0x61')](_0x1b244c[_0x47b7('0x84')])?undefined:_0x1b244c['fax'],'AttachmentId':_0x1b244c[_0x47b7('0x7f')]},client9002);})[_0x47b7('0x1d')](respondWithResult(_0x4ba199,0xc9))['catch'](handleError(_0x4ba199,null));};exports['download']=function(_0x1e9ded,_0x45d341){var _0x5d8ee8=path[_0x47b7('0x85')](config['root'],'server',_0x47b7('0x86'),'attachments');return db[_0x47b7('0x39')]['find']({'where':{'id':_0x1e9ded['params']['id']},'include':[{'model':db['Attachment'],'as':_0x47b7('0x7e')}]})[_0x47b7('0x1d')](handleEntityNotFound(_0x45d341,null))[_0x47b7('0x1d')](function(_0x53fda0){if(_0x53fda0){return _0x45d341[_0x47b7('0x87')](path[_0x47b7('0x85')](_0x5d8ee8,_0x53fda0[_0x47b7('0x7e')][_0x47b7('0x83')]));}})[_0x47b7('0x27')](handleError(_0x45d341,null));};
\ No newline at end of file