Built motion from commit 14588770.|2.5.38
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
index e869d42..93c2418 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa643=['pick','filter','merge','VIRTUAL','includeAll','include','findAll','show','params','options','find','body','describe','fax-interactions','accept','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','agent','CmContact','FaxInteractionId','interaction','get','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','stringify','null','AcceptMessage','acceptMessage','manual','interface','channel','event','EventManager','acceptmessage','fax','FaxInteraction','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','RejectMessage','SIP/%s','rejectmessage','create','findOne','ContactId','isNil','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','download','join','server','files','attachments','Attachment','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','register','jayson/promise','client','http','then','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','error','code','message','info','result','catch','status','end','json','count','offset','limit','Content-Range','apply','reject','save','update','destroy','stack','name','send','index','map','FaxMessage','rawAttributes','type','key','model','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','order','sort','where'];(function(_0xac0b88,_0x5bb800){var _0x441200=function(_0x3e740c){while(--_0x3e740c){_0xac0b88['push'](_0xac0b88['shift']());}};_0x441200(++_0x5bb800);}(_0xa643,0x148));var _0x3a64=function(_0x5b51be,_0x3b90ce){_0x5b51be=_0x5b51be-0x0;var _0x3e5e90=_0xa643[_0x5b51be];return _0x3e5e90;};'use strict';var pdf=require(_0x3a64('0x0'));var emlformat=require(_0x3a64('0x1'));var rimraf=require(_0x3a64('0x2'));var zipdir=require(_0x3a64('0x3'));var jsonpatch=require(_0x3a64('0x4'));var rp=require(_0x3a64('0x5'));var moment=require(_0x3a64('0x6'));var BPromise=require('bluebird');var Mustache=require(_0x3a64('0x7'));var util=require(_0x3a64('0x8'));var path=require(_0x3a64('0x9'));var sox=require(_0x3a64('0xa'));var csv=require(_0x3a64('0xb'));var ejs=require(_0x3a64('0xc'));var fs=require('fs');var _=require(_0x3a64('0xd'));var squel=require(_0x3a64('0xe'));var crypto=require('crypto');var jsforce=require(_0x3a64('0xf'));var deskjs=require(_0x3a64('0x10'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x3a64('0x11'));var Redis=require(_0x3a64('0x12'));var authService=require(_0x3a64('0x13'));var qs=require(_0x3a64('0x14'));var as=require(_0x3a64('0x15'));var hardwareService=require(_0x3a64('0x16'));var logger=require(_0x3a64('0x17'))('api');var utils=require('../../config/utils');var config=require(_0x3a64('0x18'));var licenseUtil=require(_0x3a64('0x19'));var db=require(_0x3a64('0x1a'))['db'];config['redis']=_[_0x3a64('0x1b')](config[_0x3a64('0x1c')],{'host':_0x3a64('0x1d'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x3a64('0x1c')]));require('./faxMessage.socket')[_0x3a64('0x1e')](socket);var jayson=require(_0x3a64('0x1f'));var client=jayson[_0x3a64('0x20')][_0x3a64('0x21')]({'port':0x232c});var client9002=jayson[_0x3a64('0x20')][_0x3a64('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x2d72c4,_0x330b79,_0x344f92,_0x45c6ca){return new BPromise(function(_0xc0aab8,_0x5fe680){var _0x5b59f9=_0x45c6ca||client;return _0x5b59f9['request'](_0x2d72c4,_0x344f92)[_0x3a64('0x22')](function(_0x312ca1){logger['info'](_0x3a64('0x23'),_0x330b79,_0x3a64('0x24'));logger[_0x3a64('0x25')]('FaxMessage,\x20%s,\x20%s,\x20%s',_0x330b79,_0x3a64('0x24'),JSON['stringify'](_0x312ca1));if(_0x312ca1[_0x3a64('0x26')]){if(_0x312ca1['error'][_0x3a64('0x27')]===0x1f4){logger[_0x3a64('0x26')](_0x3a64('0x23'),_0x330b79,_0x312ca1[_0x3a64('0x26')][_0x3a64('0x28')]);return _0x5fe680(_0x312ca1[_0x3a64('0x26')][_0x3a64('0x28')]);}logger[_0x3a64('0x26')](_0x3a64('0x23'),_0x330b79,_0x312ca1[_0x3a64('0x26')][_0x3a64('0x28')]);return _0xc0aab8(_0x312ca1['error'][_0x3a64('0x28')]);}else{logger[_0x3a64('0x29')](_0x3a64('0x23'),_0x330b79,_0x3a64('0x24'));_0xc0aab8(_0x312ca1[_0x3a64('0x2a')]['message']);}})[_0x3a64('0x2b')](function(_0x4794c7){logger[_0x3a64('0x26')](_0x3a64('0x23'),_0x330b79,_0x4794c7);_0x5fe680(_0x4794c7);});});}function respondWithStatusCode(_0x5475c2,_0x4a619f){_0x4a619f=_0x4a619f||0xcc;return function(_0x3865e2){if(_0x3865e2){return _0x5475c2['sendStatus'](_0x4a619f);}return _0x5475c2[_0x3a64('0x2c')](_0x4a619f)[_0x3a64('0x2d')]();};}function respondWithResult(_0x51cae1,_0x5c3aa8){_0x5c3aa8=_0x5c3aa8||0xc8;return function(_0x3a4a18){if(_0x3a4a18){return _0x51cae1[_0x3a64('0x2c')](_0x5c3aa8)[_0x3a64('0x2e')](_0x3a4a18);}};}function respondWithFilteredResult(_0x26e91d,_0x347a11){return function(_0x2dfe06){if(_0x2dfe06){var _0x53f1c=_0x2dfe06[_0x3a64('0x2f')],_0x3ab3c1=_0x347a11[_0x3a64('0x30')],_0x191fe4=_0x347a11['offset']+_0x347a11[_0x3a64('0x31')],_0x46c386;if(_0x191fe4>=_0x53f1c){_0x191fe4=_0x53f1c;_0x46c386=0xc8;}else{_0x46c386=0xce;}_0x26e91d['status'](_0x46c386);return _0x26e91d['set'](_0x3a64('0x32'),_0x3ab3c1+'-'+_0x191fe4+'/'+_0x53f1c)[_0x3a64('0x2e')](_0x2dfe06);}return null;};}function patchUpdates(_0x2f768c){return function(_0x1c6f89){try{jsonpatch[_0x3a64('0x33')](_0x1c6f89,_0x2f768c,!![]);}catch(_0x3f5964){return BPromise[_0x3a64('0x34')](_0x3f5964);}return _0x1c6f89[_0x3a64('0x35')]();};}function saveUpdates(_0x312a81,_0x1ae349){return function(_0x3e450b){if(_0x3e450b){return _0x3e450b[_0x3a64('0x36')](_0x312a81)[_0x3a64('0x22')](function(_0x397348){return _0x397348;});}return null;};}function removeEntity(_0x50a27a,_0x48160b){return function(_0x572426){if(_0x572426){return _0x572426[_0x3a64('0x37')]()['then'](function(){_0x50a27a[_0x3a64('0x2c')](0xcc)[_0x3a64('0x2d')]();});}};}function handleEntityNotFound(_0x2f7fb1,_0x616931){return function(_0x2f0e18){if(!_0x2f0e18){_0x2f7fb1['sendStatus'](0x194);}return _0x2f0e18;};}function handleError(_0x902b94,_0x3ef460){_0x3ef460=_0x3ef460||0x1f4;return function(_0x5641ad){logger[_0x3a64('0x26')](_0x5641ad[_0x3a64('0x38')]);if(_0x5641ad['name']){delete _0x5641ad[_0x3a64('0x39')];}_0x902b94[_0x3a64('0x2c')](_0x3ef460)[_0x3a64('0x3a')](_0x5641ad);};}exports[_0x3a64('0x3b')]=function(_0x1330b1,_0x26c07c){var _0x113795={},_0x3629df={},_0x60e35d={'count':0x0,'rows':[]};var _0x3aae83=_[_0x3a64('0x3c')](db[_0x3a64('0x3d')][_0x3a64('0x3e')],function(_0x55b386){return{'name':_0x55b386['fieldName'],'type':_0x55b386[_0x3a64('0x3f')][_0x3a64('0x40')]};});_0x3629df[_0x3a64('0x41')]=_[_0x3a64('0x3c')](_0x3aae83,_0x3a64('0x39'));_0x3629df['query']=_[_0x3a64('0x42')](_0x1330b1[_0x3a64('0x43')]);_0x3629df[_0x3a64('0x44')]=_['intersection'](_0x3629df[_0x3a64('0x41')],_0x3629df['query']);_0x113795[_0x3a64('0x45')]=_[_0x3a64('0x46')](_0x3629df['model'],qs[_0x3a64('0x47')](_0x1330b1[_0x3a64('0x43')][_0x3a64('0x47')]));_0x113795['attributes']=_0x113795[_0x3a64('0x45')][_0x3a64('0x48')]?_0x113795[_0x3a64('0x45')]:_0x3629df['model'];if(!_0x1330b1[_0x3a64('0x43')][_0x3a64('0x49')]('nolimit')){_0x113795[_0x3a64('0x31')]=qs[_0x3a64('0x31')](_0x1330b1[_0x3a64('0x43')][_0x3a64('0x31')]);_0x113795[_0x3a64('0x30')]=qs['offset'](_0x1330b1[_0x3a64('0x43')][_0x3a64('0x30')]);}_0x113795[_0x3a64('0x4a')]=qs['sort'](_0x1330b1[_0x3a64('0x43')][_0x3a64('0x4b')]);_0x113795[_0x3a64('0x4c')]=qs['filters'](_[_0x3a64('0x4d')](_0x1330b1[_0x3a64('0x43')],_0x3629df['filters']),_0x3aae83);if(_0x1330b1['query'][_0x3a64('0x4e')]){_0x113795[_0x3a64('0x4c')]=_[_0x3a64('0x4f')](_0x113795[_0x3a64('0x4c')],{'$or':_[_0x3a64('0x3c')](_0x3aae83,function(_0x56e247){if(_0x56e247[_0x3a64('0x3f')]!==_0x3a64('0x50')){var _0x5d9fa7={};_0x5d9fa7[_0x56e247[_0x3a64('0x39')]]={'$like':'%'+_0x1330b1[_0x3a64('0x43')][_0x3a64('0x4e')]+'%'};return _0x5d9fa7;}})});}_0x113795=_[_0x3a64('0x4f')]({},_0x113795,_0x1330b1['options']);var _0x89562a={'where':_0x113795['where']};return db['FaxMessage']['count'](_0x89562a)['then'](function(_0x3b8323){_0x60e35d['count']=_0x3b8323;if(_0x1330b1[_0x3a64('0x43')][_0x3a64('0x51')]){_0x113795[_0x3a64('0x52')]=[{'all':!![]}];}return db[_0x3a64('0x3d')][_0x3a64('0x53')](_0x113795);})[_0x3a64('0x22')](function(_0x3879c1){_0x60e35d['rows']=_0x3879c1;return _0x60e35d;})['then'](respondWithFilteredResult(_0x26c07c,_0x113795))[_0x3a64('0x2b')](handleError(_0x26c07c,null));};exports[_0x3a64('0x54')]=function(_0x57605b,_0x6acce8){var _0xe8dd3c={'raw':!![],'where':{'id':_0x57605b[_0x3a64('0x55')]['id']}},_0x247e06={};_0x247e06[_0x3a64('0x41')]=_['keys'](db['FaxMessage'][_0x3a64('0x3e')]);_0x247e06[_0x3a64('0x43')]=_[_0x3a64('0x42')](_0x57605b[_0x3a64('0x43')]);_0x247e06[_0x3a64('0x44')]=_[_0x3a64('0x46')](_0x247e06[_0x3a64('0x41')],_0x247e06['query']);_0xe8dd3c[_0x3a64('0x45')]=_['intersection'](_0x247e06[_0x3a64('0x41')],qs[_0x3a64('0x47')](_0x57605b[_0x3a64('0x43')][_0x3a64('0x47')]));_0xe8dd3c['attributes']=_0xe8dd3c[_0x3a64('0x45')][_0x3a64('0x48')]?_0xe8dd3c[_0x3a64('0x45')]:_0x247e06[_0x3a64('0x41')];if(_0x57605b[_0x3a64('0x43')][_0x3a64('0x51')]){_0xe8dd3c[_0x3a64('0x52')]=[{'all':!![]}];}_0xe8dd3c=_[_0x3a64('0x4f')]({},_0xe8dd3c,_0x57605b[_0x3a64('0x56')]);return db[_0x3a64('0x3d')][_0x3a64('0x57')](_0xe8dd3c)[_0x3a64('0x22')](handleEntityNotFound(_0x6acce8,null))[_0x3a64('0x22')](respondWithResult(_0x6acce8,null))['catch'](handleError(_0x6acce8,null));};exports[_0x3a64('0x36')]=function(_0x4b4dd,_0x3d99bc){if(_0x4b4dd[_0x3a64('0x58')]['id']){delete _0x4b4dd[_0x3a64('0x58')]['id'];}return db[_0x3a64('0x3d')][_0x3a64('0x57')]({'where':{'id':_0x4b4dd[_0x3a64('0x55')]['id']}})[_0x3a64('0x22')](handleEntityNotFound(_0x3d99bc,null))[_0x3a64('0x22')](saveUpdates(_0x4b4dd['body'],null))[_0x3a64('0x22')](respondWithResult(_0x3d99bc,null))['catch'](handleError(_0x3d99bc,null));};exports[_0x3a64('0x37')]=function(_0x15e2b0,_0x15d093){return db[_0x3a64('0x3d')][_0x3a64('0x57')]({'where':{'id':_0x15e2b0[_0x3a64('0x55')]['id']}})[_0x3a64('0x22')](handleEntityNotFound(_0x15d093,null))[_0x3a64('0x22')](removeEntity(_0x15d093,null))['catch'](handleError(_0x15d093,null));};exports[_0x3a64('0x59')]=function(_0x5a197d,_0x3f3144){return db[_0x3a64('0x3d')][_0x3a64('0x59')]()[_0x3a64('0x22')](respondWithResult(_0x3f3144,null))[_0x3a64('0x2b')](handleError(_0x3f3144,null));};var interaction_log=require(_0x3a64('0x17'))(_0x3a64('0x5a'));exports[_0x3a64('0x5b')]=function(_0x132f22,_0x575d4a,_0x1ef5f7){var _0x34913b={'agent':{},'channel':'fax'};if(_0x132f22[_0x3a64('0x58')]['id']){delete _0x132f22[_0x3a64('0x58')]['id'];}_0x132f22[_0x3a64('0x58')]['read']=!![];_0x132f22[_0x3a64('0x58')][_0x3a64('0x5c')]=moment()[_0x3a64('0x5d')](_0x3a64('0x5e'));_0x132f22[_0x3a64('0x58')][_0x3a64('0x5f')]=_0x132f22[_0x3a64('0x58')][_0x3a64('0x5f')]||_0x132f22['user']['id'];_0x34913b[_0x3a64('0x60')]['id']=_0x132f22[_0x3a64('0x58')][_0x3a64('0x5f')];return db[_0x3a64('0x3d')]['find']({'where':{'id':_0x132f22[_0x3a64('0x55')]['id'],'UserId':null},'include':[{'model':db[_0x3a64('0x61')],'as':'Contact'}]})[_0x3a64('0x22')](handleEntityNotFound(_0x575d4a,null))[_0x3a64('0x22')](saveUpdates(_0x132f22[_0x3a64('0x58')],null))[_0x3a64('0x22')](function(_0x1b007c){if(_0x1b007c){_0x34913b[_0x3a64('0x28')]=_0x1b007c['get']({'plain':!![]});return db['FaxInteraction'][_0x3a64('0x57')]({'where':{'id':_0x1b007c[_0x3a64('0x62')]}});}return null;})[_0x3a64('0x22')](handleEntityNotFound(_0x575d4a,null))[_0x3a64('0x22')](function(_0x23d37c){if(_0x23d37c){return _0x23d37c[_0x3a64('0x36')]({'UserId':_0x132f22[_0x3a64('0x58')][_0x3a64('0x5f')],'read1stAt':_['isNil'](_0x23d37c['read1stAt'])?moment()['format']('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0x3a64('0x22')](function(_0x22f962){if(_0x22f962){_0x34913b[_0x3a64('0x63')]=_0x22f962[_0x3a64('0x64')]({'plain':!![]});interaction_log[_0x3a64('0x29')](_0x3a64('0x65'),_0x132f22['user']['id'],_0x132f22[_0x3a64('0x66')][_0x3a64('0x39')],_0x132f22[_0x3a64('0x66')][_0x3a64('0x67')],_0x34913b[_0x3a64('0x63')]['id'],_0x132f22[_0x3a64('0x58')]?JSON[_0x3a64('0x68')](_0x132f22[_0x3a64('0x58')]):_0x3a64('0x69'));return respondWithRpcPromise(_0x3a64('0x6a'),_0x3a64('0x6b'),_0x34913b);}return null;})[_0x3a64('0x22')](function(_0x17cfeb){if(_0x17cfeb){if(_0x132f22[_0x3a64('0x58')][_0x3a64('0x6c')]){_0x34913b[_0x3a64('0x28')][_0x3a64('0x6d')]=util[_0x3a64('0x5d')]('SIP/%s',_0x132f22[_0x3a64('0x66')][_0x3a64('0x39')]);_0x34913b[_0x3a64('0x28')][_0x3a64('0x6e')]=_0x34913b[_0x3a64('0x6e')];_0x34913b[_0x3a64('0x28')][_0x3a64('0x6f')]=_0x3a64('0x5b');return respondWithRpcPromise(_0x3a64('0x70'),_0x3a64('0x70'),{'event':_0x3a64('0x71'),'message':_0x34913b['message']},client9002)[_0x3a64('0x22')](function(){return _0x34913b;});}return _0x34913b;}return null;})[_0x3a64('0x22')](respondWithResult(_0x575d4a,null))['catch'](handleError(_0x575d4a,null));};var interaction_log=require(_0x3a64('0x17'))(_0x3a64('0x5a'));exports[_0x3a64('0x34')]=function(_0x20811a,_0x1e1645,_0x157b20){var _0x2b33ad={'agent':{},'channel':_0x3a64('0x72')};if(_0x20811a[_0x3a64('0x58')]['id']){delete _0x20811a[_0x3a64('0x58')]['id'];}_0x20811a[_0x3a64('0x58')][_0x3a64('0x5f')]=_0x20811a[_0x3a64('0x58')][_0x3a64('0x5f')]||_0x20811a[_0x3a64('0x66')]['id'];_0x2b33ad[_0x3a64('0x60')]['id']=_0x20811a[_0x3a64('0x58')][_0x3a64('0x5f')];return db[_0x3a64('0x3d')][_0x3a64('0x57')]({'where':{'id':_0x20811a[_0x3a64('0x55')]['id'],'UserId':null}})[_0x3a64('0x22')](handleEntityNotFound(_0x1e1645,null))[_0x3a64('0x22')](function(_0xffbd98){if(_0xffbd98){_0x2b33ad[_0x3a64('0x28')]=_0xffbd98[_0x3a64('0x64')]({'plain':!![]});return db[_0x3a64('0x73')][_0x3a64('0x57')]({'where':{'id':_0xffbd98[_0x3a64('0x62')]}});}return null;})[_0x3a64('0x22')](handleEntityNotFound(_0x1e1645,null))[_0x3a64('0x22')](function(_0x115cb6){if(_0x115cb6){_0x2b33ad[_0x3a64('0x63')]=_0x115cb6['get']({'plain':!![]});interaction_log[_0x3a64('0x29')](_0x3a64('0x74'),_0x20811a[_0x3a64('0x66')]['id'],_0x20811a[_0x3a64('0x66')]['name'],_0x20811a[_0x3a64('0x66')]['role'],_0x2b33ad[_0x3a64('0x63')]['id'],_0x20811a[_0x3a64('0x58')]?JSON[_0x3a64('0x68')](_0x20811a[_0x3a64('0x58')]):_0x3a64('0x69'));return respondWithRpcPromise(_0x3a64('0x75'),'rejectMessage',_0x2b33ad);}return null;})[_0x3a64('0x22')](function(_0x4d019c){if(_0x4d019c){_0x4d019c[_0x3a64('0x28')][_0x3a64('0x6d')]=util[_0x3a64('0x5d')](_0x3a64('0x76'),_0x20811a['user'][_0x3a64('0x39')]);_0x4d019c[_0x3a64('0x28')][_0x3a64('0x6e')]=_0x2b33ad['channel'];_0x4d019c[_0x3a64('0x28')]['event']='reject';respondWithRpcPromise('EventManager','EventManager',{'event':_0x3a64('0x77'),'message':_0x4d019c[_0x3a64('0x28')]},client9002);return _0x2b33ad;}return null;})[_0x3a64('0x22')](respondWithResult(_0x1e1645,null))[_0x3a64('0x2b')](handleError(_0x1e1645,null));};exports[_0x3a64('0x78')]=function(_0x4fd01d,_0x57612f){var _0xbe4dfc;return db[_0x3a64('0x3d')][_0x3a64('0x78')](_0x4fd01d[_0x3a64('0x58')],{})[_0x3a64('0x22')](function(_0x29f2fc){_0xbe4dfc=_0x29f2fc;return db['CmContact'][_0x3a64('0x79')]({'where':{'id':_0xbe4dfc[_0x3a64('0x7a')]}});})[_0x3a64('0x22')](function(_0x2c9103){if(_[_0x3a64('0x7b')](_0x2c9103)){return;}else{_0xbe4dfc[_0x3a64('0x72')]=_0x2c9103['fax'];return db['Attachment'][_0x3a64('0x79')]({'where':{'id':_0xbe4dfc[_0x3a64('0x7c')]}});}})[_0x3a64('0x22')](function(_0x1ab51b){return respondWithRpcPromise('SendFax',_0x3a64('0x7d'),{'FaxAccountId':_['isNil'](_0x4fd01d[_0x3a64('0x58')])?undefined:_0x4fd01d['body'][_0x3a64('0x7e')],'path':_[_0x3a64('0x7b')](_0x1ab51b)?undefined:util[_0x3a64('0x5d')](_0x3a64('0x7f'),_0x1ab51b[_0x3a64('0x80')]),'fax':_[_0x3a64('0x7b')](_0xbe4dfc[_0x3a64('0x72')])?undefined:_0xbe4dfc['fax'],'AttachmentId':_0xbe4dfc[_0x3a64('0x7c')]},client9002);})[_0x3a64('0x22')](respondWithResult(_0x57612f,0xc9))['catch'](handleError(_0x57612f,null));};exports[_0x3a64('0x81')]=function(_0x10b78a,_0x123091){var _0x156f44=path[_0x3a64('0x82')](config['root'],_0x3a64('0x83'),_0x3a64('0x84'),_0x3a64('0x85'));return db[_0x3a64('0x3d')]['find']({'where':{'id':_0x10b78a[_0x3a64('0x55')]['id']},'include':[{'model':db[_0x3a64('0x86')],'as':_0x3a64('0x86')}]})['then'](handleEntityNotFound(_0x123091,null))[_0x3a64('0x22')](function(_0x292a28){if(_0x292a28){return _0x123091[_0x3a64('0x81')](path['join'](_0x156f44,_0x292a28[_0x3a64('0x86')][_0x3a64('0x80')]));}})[_0x3a64('0x2b')](handleError(_0x123091,null));};
\ No newline at end of file
+var _0x6a95=['channel','motionChannel','acceptmessage','reject','agent','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','stringify','RejectMessage','rejectMessage','SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20','sequelize','event','EventManager','rejectmessage','findOne','Attachment','AttachmentId','SendFax','/var/opt/motion2/server/files/attachments/%s','basename','download','root','server','files','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxMessage.socket','jayson/promise','http','client','request','info','FaxMessage,\x20%s,\x20%s','request\x20sent','error','message','result','catch','status','end','json','undefined','limit','count','offset','set','Content-Range','save','update','destroy','then','sendStatus','stack','send','index','map','fieldName','type','key','model','name','keys','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','where','VIRTUAL','filter','merge','options','FaxMessage','includeAll','include','rows','params','rawAttributes','filters','find','body','describe','fax-interactions','accept','fax','read','readAt','YYYY-MM-DD\x20HH:mm:ss','UserId','user','get','FaxInteraction','FaxInteractionId','isNil','format','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','role','interaction','null','acceptMessage','ContactId','Sequelize','QueryTypes','SELECT','contact','User','email','internal','manual','interface','SIP/%s'];(function(_0x385c3f,_0x2c7062){var _0x2e17c3=function(_0x3c62d7){while(--_0x3c62d7){_0x385c3f['push'](_0x385c3f['shift']());}};_0x2e17c3(++_0x2c7062);}(_0x6a95,0x1ce));var _0x56a9=function(_0x501510,_0x61caa9){_0x501510=_0x501510-0x0;var _0x1e6ee5=_0x6a95[_0x501510];return _0x1e6ee5;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x56a9('0x0'));var zipdir=require(_0x56a9('0x1'));var jsonpatch=require(_0x56a9('0x2'));var rp=require(_0x56a9('0x3'));var moment=require(_0x56a9('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x56a9('0x5'));var util=require(_0x56a9('0x6'));var path=require(_0x56a9('0x7'));var sox=require(_0x56a9('0x8'));var csv=require(_0x56a9('0x9'));var ejs=require(_0x56a9('0xa'));var fs=require('fs');var fs_extra=require(_0x56a9('0xb'));var _=require(_0x56a9('0xc'));var squel=require(_0x56a9('0xd'));var crypto=require(_0x56a9('0xe'));var jsforce=require(_0x56a9('0xf'));var deskjs=require(_0x56a9('0x10'));var toCsv=require('to-csv');var querystring=require(_0x56a9('0x11'));var Papa=require(_0x56a9('0x12'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x56a9('0x13'));var as=require(_0x56a9('0x14'));var hardwareService=require(_0x56a9('0x15'));var logger=require(_0x56a9('0x16'))(_0x56a9('0x17'));var utils=require(_0x56a9('0x18'));var config=require(_0x56a9('0x19'));var licenseUtil=require(_0x56a9('0x1a'));var db=require(_0x56a9('0x1b'))['db'];config[_0x56a9('0x1c')]=_[_0x56a9('0x1d')](config[_0x56a9('0x1c')],{'host':_0x56a9('0x1e'),'port':0x18eb});var socket=require(_0x56a9('0x1f'))(new Redis(config[_0x56a9('0x1c')]));require(_0x56a9('0x20'))['register'](socket);var jayson=require(_0x56a9('0x21'));var client=jayson['client'][_0x56a9('0x22')]({'port':0x232c});var client9002=jayson[_0x56a9('0x23')][_0x56a9('0x22')]({'port':0x232a});function respondWithRpcPromise(_0x5d7cb1,_0x9ad7d9,_0x7bd4eb,_0x126ac5){return new BPromise(function(_0x3113f0,_0xbba35b){var _0x17550d=_0x126ac5||client;return _0x17550d[_0x56a9('0x24')](_0x5d7cb1,_0x7bd4eb)['then'](function(_0x3ffcec){logger[_0x56a9('0x25')](_0x56a9('0x26'),_0x9ad7d9,_0x56a9('0x27'));logger['debug']('FaxMessage,\x20%s,\x20%s,\x20%s',_0x9ad7d9,_0x56a9('0x27'),JSON['stringify'](_0x3ffcec));if(_0x3ffcec['error']){if(_0x3ffcec[_0x56a9('0x28')]['code']===0x1f4){logger['error']('FaxMessage,\x20%s,\x20%s',_0x9ad7d9,_0x3ffcec[_0x56a9('0x28')][_0x56a9('0x29')]);return _0xbba35b(_0x3ffcec[_0x56a9('0x28')][_0x56a9('0x29')]);}logger[_0x56a9('0x28')](_0x56a9('0x26'),_0x9ad7d9,_0x3ffcec['error']['message']);return _0x3113f0(_0x3ffcec[_0x56a9('0x28')][_0x56a9('0x29')]);}else{logger[_0x56a9('0x25')](_0x56a9('0x26'),_0x9ad7d9,_0x56a9('0x27'));_0x3113f0(_0x3ffcec[_0x56a9('0x2a')][_0x56a9('0x29')]);}})[_0x56a9('0x2b')](function(_0x4df8c9){logger[_0x56a9('0x28')]('FaxMessage,\x20%s,\x20%s',_0x9ad7d9,_0x4df8c9);_0xbba35b(_0x4df8c9);});});}function respondWithStatusCode(_0x2e8da7,_0x54a91b){_0x54a91b=_0x54a91b||0xcc;return function(_0x50c2c3){if(_0x50c2c3){return _0x2e8da7['sendStatus'](_0x54a91b);}return _0x2e8da7[_0x56a9('0x2c')](_0x54a91b)[_0x56a9('0x2d')]();};}function respondWithResult(_0x374de2,_0x3bf702){_0x3bf702=_0x3bf702||0xc8;return function(_0x55b98c){if(_0x55b98c){return _0x374de2['status'](_0x3bf702)[_0x56a9('0x2e')](_0x55b98c);}};}function respondWithFilteredResult(_0x28a95f,_0x2f95e6){return function(_0x2182fb){if(_0x2182fb){var _0x4c73b8=typeof _0x2f95e6['offset']===_0x56a9('0x2f')&&typeof _0x2f95e6[_0x56a9('0x30')]===_0x56a9('0x2f');var _0x11a140=_0x2182fb[_0x56a9('0x31')];var _0x21d37e=_0x4c73b8?0x0:_0x2f95e6[_0x56a9('0x32')];var _0x11fb89=_0x4c73b8?_0x2182fb[_0x56a9('0x31')]:_0x2f95e6[_0x56a9('0x32')]+_0x2f95e6[_0x56a9('0x30')];var _0x583bff;if(_0x11fb89>=_0x11a140){_0x11fb89=_0x11a140;_0x583bff=0xc8;}else{_0x583bff=0xce;}_0x28a95f[_0x56a9('0x2c')](_0x583bff);return _0x28a95f[_0x56a9('0x33')](_0x56a9('0x34'),_0x21d37e+'-'+_0x11fb89+'/'+_0x11a140)[_0x56a9('0x2e')](_0x2182fb);}return null;};}function patchUpdates(_0xdb792f){return function(_0x30a0b3){try{jsonpatch['apply'](_0x30a0b3,_0xdb792f,!![]);}catch(_0x4eb9d5){return BPromise['reject'](_0x4eb9d5);}return _0x30a0b3[_0x56a9('0x35')]();};}function saveUpdates(_0xb9236d,_0x375f97){return function(_0x16e138){if(_0x16e138){return _0x16e138[_0x56a9('0x36')](_0xb9236d)['then'](function(_0x8e7a24){return _0x8e7a24;});}return null;};}function removeEntity(_0x5be5ac,_0x4ff94f){return function(_0x5aa9fd){if(_0x5aa9fd){return _0x5aa9fd[_0x56a9('0x37')]()[_0x56a9('0x38')](function(){_0x5be5ac['status'](0xcc)[_0x56a9('0x2d')]();});}};}function handleEntityNotFound(_0x383798,_0x5ea1b6){return function(_0x218fef){if(!_0x218fef){_0x383798[_0x56a9('0x39')](0x194);}return _0x218fef;};}function handleError(_0x3af101,_0x5a568b){_0x5a568b=_0x5a568b||0x1f4;return function(_0x22ba75){logger['error'](_0x22ba75[_0x56a9('0x3a')]);if(_0x22ba75['name']){delete _0x22ba75['name'];}_0x3af101[_0x56a9('0x2c')](_0x5a568b)[_0x56a9('0x3b')](_0x22ba75);};}exports[_0x56a9('0x3c')]=function(_0xa243d5,_0x3ba3b6){var _0x381b2f={},_0x4bf29a={},_0x2f45db={'count':0x0,'rows':[]};var _0x7af815=_[_0x56a9('0x3d')](db['FaxMessage']['rawAttributes'],function(_0x76f688){return{'name':_0x76f688[_0x56a9('0x3e')],'type':_0x76f688[_0x56a9('0x3f')][_0x56a9('0x40')]};});_0x4bf29a[_0x56a9('0x41')]=_['map'](_0x7af815,_0x56a9('0x42'));_0x4bf29a['query']=_[_0x56a9('0x43')](_0xa243d5[_0x56a9('0x44')]);_0x4bf29a['filters']=_['intersection'](_0x4bf29a[_0x56a9('0x41')],_0x4bf29a[_0x56a9('0x44')]);_0x381b2f['attributes']=_[_0x56a9('0x45')](_0x4bf29a[_0x56a9('0x41')],qs[_0x56a9('0x46')](_0xa243d5[_0x56a9('0x44')][_0x56a9('0x46')]));_0x381b2f['attributes']=_0x381b2f[_0x56a9('0x47')][_0x56a9('0x48')]?_0x381b2f[_0x56a9('0x47')]:_0x4bf29a['model'];if(!_0xa243d5['query'][_0x56a9('0x49')](_0x56a9('0x4a'))){_0x381b2f[_0x56a9('0x30')]=qs[_0x56a9('0x30')](_0xa243d5[_0x56a9('0x44')][_0x56a9('0x30')]);_0x381b2f[_0x56a9('0x32')]=qs[_0x56a9('0x32')](_0xa243d5[_0x56a9('0x44')]['offset']);}_0x381b2f[_0x56a9('0x4b')]=qs[_0x56a9('0x4c')](_0xa243d5[_0x56a9('0x44')][_0x56a9('0x4c')]);_0x381b2f['where']=qs['filters'](_[_0x56a9('0x4d')](_0xa243d5['query'],_0x4bf29a['filters']),_0x7af815);if(_0xa243d5[_0x56a9('0x44')]['filter']){_0x381b2f[_0x56a9('0x4e')]=_['merge'](_0x381b2f[_0x56a9('0x4e')],{'$or':_[_0x56a9('0x3d')](_0x7af815,function(_0x30e6f4){if(_0x30e6f4[_0x56a9('0x3f')]!==_0x56a9('0x4f')){var _0x84e44f={};_0x84e44f[_0x30e6f4['name']]={'$like':'%'+_0xa243d5[_0x56a9('0x44')][_0x56a9('0x50')]+'%'};return _0x84e44f;}})});}_0x381b2f=_[_0x56a9('0x51')]({},_0x381b2f,_0xa243d5[_0x56a9('0x52')]);var _0x282cd1={'where':_0x381b2f[_0x56a9('0x4e')]};return db[_0x56a9('0x53')][_0x56a9('0x31')](_0x282cd1)[_0x56a9('0x38')](function(_0x225df2){_0x2f45db[_0x56a9('0x31')]=_0x225df2;if(_0xa243d5[_0x56a9('0x44')][_0x56a9('0x54')]){_0x381b2f[_0x56a9('0x55')]=[{'all':!![]}];}return db[_0x56a9('0x53')]['findAll'](_0x381b2f);})[_0x56a9('0x38')](function(_0x12887e){_0x2f45db[_0x56a9('0x56')]=_0x12887e;return _0x2f45db;})[_0x56a9('0x38')](respondWithFilteredResult(_0x3ba3b6,_0x381b2f))[_0x56a9('0x2b')](handleError(_0x3ba3b6,null));};exports['show']=function(_0x11348e,_0x308a68){var _0x34708b={'raw':!![],'where':{'id':_0x11348e[_0x56a9('0x57')]['id']}},_0x4fd616={};_0x4fd616[_0x56a9('0x41')]=_['keys'](db[_0x56a9('0x53')][_0x56a9('0x58')]);_0x4fd616[_0x56a9('0x44')]=_[_0x56a9('0x43')](_0x11348e[_0x56a9('0x44')]);_0x4fd616[_0x56a9('0x59')]=_[_0x56a9('0x45')](_0x4fd616[_0x56a9('0x41')],_0x4fd616[_0x56a9('0x44')]);_0x34708b[_0x56a9('0x47')]=_[_0x56a9('0x45')](_0x4fd616[_0x56a9('0x41')],qs[_0x56a9('0x46')](_0x11348e[_0x56a9('0x44')][_0x56a9('0x46')]));_0x34708b['attributes']=_0x34708b[_0x56a9('0x47')][_0x56a9('0x48')]?_0x34708b['attributes']:_0x4fd616[_0x56a9('0x41')];if(_0x11348e[_0x56a9('0x44')][_0x56a9('0x54')]){_0x34708b['include']=[{'all':!![]}];}_0x34708b=_[_0x56a9('0x51')]({},_0x34708b,_0x11348e[_0x56a9('0x52')]);return db[_0x56a9('0x53')][_0x56a9('0x5a')](_0x34708b)[_0x56a9('0x38')](handleEntityNotFound(_0x308a68,null))[_0x56a9('0x38')](respondWithResult(_0x308a68,null))['catch'](handleError(_0x308a68,null));};exports[_0x56a9('0x36')]=function(_0x3df629,_0xd53179){if(_0x3df629[_0x56a9('0x5b')]['id']){delete _0x3df629[_0x56a9('0x5b')]['id'];}return db['FaxMessage'][_0x56a9('0x5a')]({'where':{'id':_0x3df629[_0x56a9('0x57')]['id']}})[_0x56a9('0x38')](handleEntityNotFound(_0xd53179,null))[_0x56a9('0x38')](saveUpdates(_0x3df629[_0x56a9('0x5b')],null))[_0x56a9('0x38')](respondWithResult(_0xd53179,null))[_0x56a9('0x2b')](handleError(_0xd53179,null));};exports[_0x56a9('0x37')]=function(_0x5b6a84,_0x2000f9){return db[_0x56a9('0x53')][_0x56a9('0x5a')]({'where':{'id':_0x5b6a84[_0x56a9('0x57')]['id']}})[_0x56a9('0x38')](handleEntityNotFound(_0x2000f9,null))[_0x56a9('0x38')](removeEntity(_0x2000f9,null))[_0x56a9('0x2b')](handleError(_0x2000f9,null));};exports['describe']=function(_0x8f4aed,_0x34b32a){return db[_0x56a9('0x53')][_0x56a9('0x5c')]()[_0x56a9('0x38')](respondWithResult(_0x34b32a,null))['catch'](handleError(_0x34b32a,null));};var interaction_log=require(_0x56a9('0x16'))(_0x56a9('0x5d'));exports[_0x56a9('0x5e')]=function(_0x53646f,_0x59ec4b,_0x68bd0f){var _0x2ce9d8={'agent':{},'channel':_0x56a9('0x5f')};if(_0x53646f[_0x56a9('0x5b')]['id']){delete _0x53646f[_0x56a9('0x5b')]['id'];}_0x53646f['body'][_0x56a9('0x60')]=!![];_0x53646f['body'][_0x56a9('0x61')]=moment()['format'](_0x56a9('0x62'));_0x53646f[_0x56a9('0x5b')][_0x56a9('0x63')]=_0x53646f[_0x56a9('0x5b')][_0x56a9('0x63')]||_0x53646f[_0x56a9('0x64')]['id'];_0x2ce9d8['agent']['id']=_0x53646f[_0x56a9('0x5b')][_0x56a9('0x63')];return db['FaxMessage'][_0x56a9('0x5a')]({'where':{'id':_0x53646f[_0x56a9('0x57')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x59ec4b,null))[_0x56a9('0x38')](saveUpdates(_0x53646f[_0x56a9('0x5b')],null))['then'](function(_0x15bb02){if(_0x15bb02){_0x2ce9d8['message']=_0x15bb02[_0x56a9('0x65')]({'plain':!![]});return db[_0x56a9('0x66')]['find']({'where':{'id':_0x15bb02[_0x56a9('0x67')]}});}return null;})[_0x56a9('0x38')](handleEntityNotFound(_0x59ec4b,null))[_0x56a9('0x38')](function(_0x3d21ba){if(_0x3d21ba){return _0x3d21ba[_0x56a9('0x36')]({'UserId':_0x53646f[_0x56a9('0x5b')][_0x56a9('0x63')],'read1stAt':_[_0x56a9('0x68')](_0x3d21ba['read1stAt'])?moment()[_0x56a9('0x69')]('YYYY-MM-DD\x20HH:mm:ss'):undefined});}return null;})[_0x56a9('0x38')](function(_0x491f34){if(_0x491f34){_0x2ce9d8['interaction']=_0x491f34['get']({'plain':!![]});interaction_log[_0x56a9('0x25')](_0x56a9('0x6a'),_0x53646f[_0x56a9('0x64')]['id'],_0x53646f[_0x56a9('0x64')][_0x56a9('0x42')],_0x53646f[_0x56a9('0x64')][_0x56a9('0x6b')],_0x2ce9d8[_0x56a9('0x6c')]['id'],_0x53646f[_0x56a9('0x5b')]?JSON['stringify'](_0x53646f[_0x56a9('0x5b')]):_0x56a9('0x6d'));return respondWithRpcPromise('AcceptMessage',_0x56a9('0x6e'),_0x2ce9d8);}return null;})[_0x56a9('0x38')](function(_0x37b36b){var _0x522091='SELECT\x20*\x20FROM\x20cm_contacts\x20WHERE\x20id\x20=\x20'+_0x37b36b['message'][_0x56a9('0x6f')];return db['sequelize'][_0x56a9('0x44')](_0x522091,{'type':db[_0x56a9('0x70')][_0x56a9('0x71')][_0x56a9('0x72')],'raw':!![]})[_0x56a9('0x38')](function(_0x3d9c08){return _0x3d9c08;});})[_0x56a9('0x38')](function(_0x17e10e){if(_0x17e10e){_0x2ce9d8[_0x56a9('0x29')][_0x56a9('0x73')]=_0x17e10e[0x0];if(!_0x53646f[_0x56a9('0x5b')][_0x56a9('0x63')])return;return db[_0x56a9('0x74')][_0x56a9('0x5a')]({'where':{'id':_0x53646f['body'][_0x56a9('0x63')],'role':'agent'},'attributes':['id','name','fullname',_0x56a9('0x75'),_0x56a9('0x76')],'raw':!![]});}return null;})['then'](function(_0x1a9fc9){if(!_0x1a9fc9)return null;_0x2ce9d8[_0x56a9('0x29')]['agent']=_0x1a9fc9;return _0x2ce9d8;})[_0x56a9('0x38')](function(_0xcad2f1){if(_0xcad2f1){if(_0x53646f[_0x56a9('0x5b')][_0x56a9('0x77')]){_0x2ce9d8[_0x56a9('0x29')][_0x56a9('0x78')]=util[_0x56a9('0x69')](_0x56a9('0x79'),_0x53646f[_0x56a9('0x64')][_0x56a9('0x42')]);_0x2ce9d8['message'][_0x56a9('0x7a')]=_0x2ce9d8['channel'];_0x2ce9d8['message'][_0x56a9('0x7b')]=_0x2ce9d8[_0x56a9('0x7a')];_0x2ce9d8['message']['event']=_0x56a9('0x5e');return respondWithRpcPromise('EventManager','EventManager',{'event':_0x56a9('0x7c'),'message':_0x2ce9d8[_0x56a9('0x29')]},client9002)[_0x56a9('0x38')](function(){return _0x2ce9d8;});}return _0x2ce9d8;}return null;})['then'](respondWithResult(_0x59ec4b,null))[_0x56a9('0x2b')](handleError(_0x59ec4b,null));};var interaction_log=require(_0x56a9('0x16'))(_0x56a9('0x5d'));exports[_0x56a9('0x7d')]=function(_0x11776f,_0x507daf,_0x1a8198){var _0x1d07b1={'agent':{},'channel':_0x56a9('0x5f')};if(_0x11776f[_0x56a9('0x5b')]['id']){delete _0x11776f['body']['id'];}_0x11776f[_0x56a9('0x5b')][_0x56a9('0x63')]=_0x11776f[_0x56a9('0x5b')]['UserId']||_0x11776f['user']['id'];_0x1d07b1[_0x56a9('0x7e')]['id']=_0x11776f[_0x56a9('0x5b')][_0x56a9('0x63')];return db[_0x56a9('0x53')][_0x56a9('0x5a')]({'where':{'id':_0x11776f['params']['id'],'UserId':null}})[_0x56a9('0x38')](handleEntityNotFound(_0x507daf,null))[_0x56a9('0x38')](function(_0x23d0fc){if(_0x23d0fc){_0x1d07b1[_0x56a9('0x29')]=_0x23d0fc['get']({'plain':!![]});return db[_0x56a9('0x66')][_0x56a9('0x5a')]({'where':{'id':_0x23d0fc['FaxInteractionId']}});}return null;})[_0x56a9('0x38')](handleEntityNotFound(_0x507daf,null))[_0x56a9('0x38')](function(_0x38901d){if(_0x38901d){_0x1d07b1[_0x56a9('0x6c')]=_0x38901d[_0x56a9('0x65')]({'plain':!![]});interaction_log['info'](_0x56a9('0x7f'),_0x11776f[_0x56a9('0x64')]['id'],_0x11776f[_0x56a9('0x64')][_0x56a9('0x42')],_0x11776f[_0x56a9('0x64')][_0x56a9('0x6b')],_0x1d07b1[_0x56a9('0x6c')]['id'],_0x11776f[_0x56a9('0x5b')]?JSON[_0x56a9('0x80')](_0x11776f[_0x56a9('0x5b')]):_0x56a9('0x6d'));return respondWithRpcPromise(_0x56a9('0x81'),_0x56a9('0x82'),_0x1d07b1);}return null;})['then'](function(_0x2faf0c){var _0x45a682=_0x56a9('0x83')+_0x2faf0c[_0x56a9('0x29')][_0x56a9('0x6f')];return db[_0x56a9('0x84')]['query'](_0x45a682,{'type':db[_0x56a9('0x70')]['QueryTypes']['SELECT'],'raw':!![]})['then'](function(_0x327d3d){return _0x327d3d;});})[_0x56a9('0x38')](function(_0x2b045e){if(_0x2b045e){_0x1d07b1[_0x56a9('0x29')][_0x56a9('0x73')]=_0x2b045e[0x0];if(!_0x11776f['body']['UserId'])return;return db['User']['find']({'where':{'id':_0x11776f[_0x56a9('0x5b')][_0x56a9('0x63')],'role':'agent'},'attributes':['id','name','fullname','email',_0x56a9('0x76')],'raw':!![]});}return null;})[_0x56a9('0x38')](function(_0x302574){if(!_0x302574)return null;_0x1d07b1[_0x56a9('0x29')][_0x56a9('0x7e')]=_0x302574;return _0x1d07b1;})['then'](function(_0x30c470){if(_0x30c470){_0x30c470[_0x56a9('0x29')][_0x56a9('0x78')]=util[_0x56a9('0x69')]('SIP/%s',_0x11776f[_0x56a9('0x64')][_0x56a9('0x42')]);_0x30c470[_0x56a9('0x29')][_0x56a9('0x7a')]=_0x1d07b1['channel'];_0x30c470[_0x56a9('0x29')][_0x56a9('0x7b')]=_0x1d07b1[_0x56a9('0x7a')];_0x30c470['message'][_0x56a9('0x85')]=_0x56a9('0x7d');respondWithRpcPromise('EventManager',_0x56a9('0x86'),{'event':_0x56a9('0x87'),'message':_0x30c470[_0x56a9('0x29')]},client9002);return _0x1d07b1;}return null;})['then'](respondWithResult(_0x507daf,null))[_0x56a9('0x2b')](handleError(_0x507daf,null));};exports['create']=function(_0x3bc0bf,_0x260384){var _0x51ab06;return db[_0x56a9('0x53')]['create'](_0x3bc0bf[_0x56a9('0x5b')],{})[_0x56a9('0x38')](function(_0x149095){_0x51ab06=_0x149095;return db['CmContact'][_0x56a9('0x88')]({'where':{'id':_0x51ab06['ContactId']}});})[_0x56a9('0x38')](function(_0x28aaf9){if(_[_0x56a9('0x68')](_0x28aaf9)){return;}else{_0x51ab06['fax']=_0x28aaf9['fax'];return db[_0x56a9('0x89')][_0x56a9('0x88')]({'where':{'id':_0x51ab06[_0x56a9('0x8a')]}});}})[_0x56a9('0x38')](function(_0x3b21d7){return respondWithRpcPromise(_0x56a9('0x8b'),'SendFax',{'FaxAccountId':_['isNil'](_0x3bc0bf[_0x56a9('0x5b')])?undefined:_0x3bc0bf[_0x56a9('0x5b')]['FaxAccountId'],'path':_[_0x56a9('0x68')](_0x3b21d7)?undefined:util['format'](_0x56a9('0x8c'),_0x3b21d7[_0x56a9('0x8d')]),'fax':_['isNil'](_0x51ab06['fax'])?undefined:_0x51ab06[_0x56a9('0x5f')],'AttachmentId':_0x51ab06[_0x56a9('0x8a')]},client9002);})['then'](respondWithResult(_0x260384,0xc9))['catch'](handleError(_0x260384,null));};exports[_0x56a9('0x8e')]=function(_0xf6f71c,_0x549754){var _0x302081=path['join'](config[_0x56a9('0x8f')],_0x56a9('0x90'),_0x56a9('0x91'),'attachments');return db[_0x56a9('0x53')]['find']({'where':{'id':_0xf6f71c[_0x56a9('0x57')]['id']},'include':[{'model':db['Attachment'],'as':_0x56a9('0x89')}]})['then'](handleEntityNotFound(_0x549754,null))[_0x56a9('0x38')](function(_0x170637){if(_0x170637){return _0x549754[_0x56a9('0x8e')](path['join'](_0x302081,_0x170637[_0x56a9('0x89')][_0x56a9('0x8d')]));}})[_0x56a9('0x2b')](handleError(_0x549754,null));};
\ No newline at end of file