Built motion from commit (unavailable).|2.5.10
[motion2.git] / server / api / faxMessage / faxMessage.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x9b87=['server','files','attachments','download','join','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxMessage.socket','jayson/promise','client','http','request','then','info','request\x20sent','stringify','error','code','FaxMessage,\x20%s,\x20%s','message','result','catch','status','end','json','offset','limit','set','Content-Range','apply','save','stack','name','send','index','map','FaxMessage','rawAttributes','fieldName','type','model','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','filter','options','count','includeAll','include','rows','show','params','keys','merge','find','body','destroy','describe','fax-interactions','accept','fax','read','readAt','format','UserId','CmContact','Contact','get','FaxInteraction','FaxInteractionId','update','isNil','read1stAt','YYYY-MM-DD\x20HH:mm:ss','[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','user','role','interaction','null','AcceptMessage','interface','SIP/%s','channel','EventManager','acceptmessage','../../config/logger','reject','agent','RejectMessage','rejectMessage','event','rejectmessage','create','findOne','ContactId','Attachment','AttachmentId','SendFax','FaxAccountId','/var/opt/motion2/server/files/attachments/%s','basename','root'];(function(_0x37dcce,_0x1c6427){var _0x5ef1d5=function(_0x595efa){while(--_0x595efa){_0x37dcce['push'](_0x37dcce['shift']());}};_0x5ef1d5(++_0x1c6427);}(_0x9b87,0x8e));var _0x79b8=function(_0x69c7b2,_0x2750a8){_0x69c7b2=_0x69c7b2-0x0;var _0x57e8a7=_0x9b87[_0x69c7b2];return _0x57e8a7;};'use strict';var pdf=require(_0x79b8('0x0'));var emlformat=require(_0x79b8('0x1'));var rimraf=require(_0x79b8('0x2'));var zipdir=require(_0x79b8('0x3'));var jsonpatch=require(_0x79b8('0x4'));var rp=require(_0x79b8('0x5'));var moment=require(_0x79b8('0x6'));var BPromise=require(_0x79b8('0x7'));var Mustache=require(_0x79b8('0x8'));var util=require(_0x79b8('0x9'));var path=require(_0x79b8('0xa'));var sox=require(_0x79b8('0xb'));var csv=require(_0x79b8('0xc'));var ejs=require(_0x79b8('0xd'));var fs=require('fs');var _=require(_0x79b8('0xe'));var squel=require(_0x79b8('0xf'));var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x79b8('0x10'));var Papa=require(_0x79b8('0x11'));var Redis=require(_0x79b8('0x12'));var authService=require('../../components/auth/service');var qs=require(_0x79b8('0x13'));var as=require(_0x79b8('0x14'));var hardwareService=require(_0x79b8('0x15'));var logger=require('../../config/logger')('api');var utils=require(_0x79b8('0x16'));var config=require(_0x79b8('0x17'));var licenseUtil=require(_0x79b8('0x18'));var db=require(_0x79b8('0x19'))['db'];config[_0x79b8('0x1a')]=_[_0x79b8('0x1b')](config[_0x79b8('0x1a')],{'host':_0x79b8('0x1c'),'port':0x18eb});var socket=require(_0x79b8('0x1d'))(new Redis(config[_0x79b8('0x1a')]));require(_0x79b8('0x1e'))['register'](socket);var jayson=require(_0x79b8('0x1f'));var client=jayson['client']['http']({'port':0x232c});var client9002=jayson[_0x79b8('0x20')][_0x79b8('0x21')]({'port':0x232a});function respondWithRpcPromise(_0x57a248,_0x5ddab5,_0x3e3de3,_0x49e40b){return new BPromise(function(_0x5ef869,_0x26f2ec){var _0x24c02f=_0x49e40b||client;return _0x24c02f[_0x79b8('0x22')](_0x57a248,_0x3e3de3)[_0x79b8('0x23')](function(_0x383a34){logger[_0x79b8('0x24')]('FaxMessage,\x20%s,\x20%s',_0x5ddab5,_0x79b8('0x25'));logger['debug']('FaxMessage,\x20%s,\x20%s,\x20%s',_0x5ddab5,_0x79b8('0x25'),JSON[_0x79b8('0x26')](_0x383a34));if(_0x383a34[_0x79b8('0x27')]){if(_0x383a34[_0x79b8('0x27')][_0x79b8('0x28')]===0x1f4){logger[_0x79b8('0x27')](_0x79b8('0x29'),_0x5ddab5,_0x383a34[_0x79b8('0x27')][_0x79b8('0x2a')]);return _0x26f2ec(_0x383a34['error'][_0x79b8('0x2a')]);}logger[_0x79b8('0x27')]('FaxMessage,\x20%s,\x20%s',_0x5ddab5,_0x383a34[_0x79b8('0x27')][_0x79b8('0x2a')]);return _0x5ef869(_0x383a34['error'][_0x79b8('0x2a')]);}else{logger['info']('FaxMessage,\x20%s,\x20%s',_0x5ddab5,_0x79b8('0x25'));_0x5ef869(_0x383a34[_0x79b8('0x2b')][_0x79b8('0x2a')]);}})[_0x79b8('0x2c')](function(_0x9deb6c){logger['error'](_0x79b8('0x29'),_0x5ddab5,_0x9deb6c);_0x26f2ec(_0x9deb6c);});});}function respondWithStatusCode(_0x338a7b,_0x1e84f3){_0x1e84f3=_0x1e84f3||0xcc;return function(_0x3ba5ac){if(_0x3ba5ac){return _0x338a7b['sendStatus'](_0x1e84f3);}return _0x338a7b[_0x79b8('0x2d')](_0x1e84f3)[_0x79b8('0x2e')]();};}function respondWithResult(_0x14a4d6,_0x4aa92c){_0x4aa92c=_0x4aa92c||0xc8;return function(_0x43a09e){if(_0x43a09e){return _0x14a4d6[_0x79b8('0x2d')](_0x4aa92c)[_0x79b8('0x2f')](_0x43a09e);}};}function respondWithFilteredResult(_0x2942e9,_0x3662aa){return function(_0x23483f){if(_0x23483f){var _0x4f51d1=_0x23483f['count'],_0x434ecd=_0x3662aa[_0x79b8('0x30')],_0x5a24fd=_0x3662aa[_0x79b8('0x30')]+_0x3662aa[_0x79b8('0x31')],_0x169597;if(_0x5a24fd>=_0x4f51d1){_0x5a24fd=_0x4f51d1;_0x169597=0xc8;}else{_0x169597=0xce;}_0x2942e9['status'](_0x169597);return _0x2942e9[_0x79b8('0x32')](_0x79b8('0x33'),_0x434ecd+'-'+_0x5a24fd+'/'+_0x4f51d1)[_0x79b8('0x2f')](_0x23483f);}return null;};}function patchUpdates(_0xdc3993){return function(_0x4df203){try{jsonpatch[_0x79b8('0x34')](_0x4df203,_0xdc3993,!![]);}catch(_0x540e49){return BPromise['reject'](_0x540e49);}return _0x4df203[_0x79b8('0x35')]();};}function saveUpdates(_0x38b521,_0x4a038b){return function(_0x3ff557){if(_0x3ff557){return _0x3ff557['update'](_0x38b521)['then'](function(_0x302598){return _0x302598;});}return null;};}function removeEntity(_0x4823f5,_0x1ad785){return function(_0x5a2af7){if(_0x5a2af7){return _0x5a2af7['destroy']()[_0x79b8('0x23')](function(){_0x4823f5[_0x79b8('0x2d')](0xcc)[_0x79b8('0x2e')]();});}};}function handleEntityNotFound(_0x1e5bd9,_0x330535){return function(_0x3d7214){if(!_0x3d7214){_0x1e5bd9['sendStatus'](0x194);}return _0x3d7214;};}function handleError(_0x2ed1a3,_0x28b32b){_0x28b32b=_0x28b32b||0x1f4;return function(_0x3b248e){logger[_0x79b8('0x27')](_0x3b248e[_0x79b8('0x36')]);if(_0x3b248e[_0x79b8('0x37')]){delete _0x3b248e[_0x79b8('0x37')];}_0x2ed1a3[_0x79b8('0x2d')](_0x28b32b)[_0x79b8('0x38')](_0x3b248e);};}exports[_0x79b8('0x39')]=function(_0x16f7c5,_0x511cc0){var _0x443321={},_0x9de99={},_0x1cbfbf={'count':0x0,'rows':[]};var _0x51cde9=_[_0x79b8('0x3a')](db[_0x79b8('0x3b')][_0x79b8('0x3c')],function(_0x1f0dea){return{'name':_0x1f0dea[_0x79b8('0x3d')],'type':_0x1f0dea[_0x79b8('0x3e')]['key']};});_0x9de99[_0x79b8('0x3f')]=_['map'](_0x51cde9,'name');_0x9de99[_0x79b8('0x40')]=_['keys'](_0x16f7c5['query']);_0x9de99[_0x79b8('0x41')]=_[_0x79b8('0x42')](_0x9de99[_0x79b8('0x3f')],_0x9de99[_0x79b8('0x40')]);_0x443321[_0x79b8('0x43')]=_[_0x79b8('0x42')](_0x9de99[_0x79b8('0x3f')],qs[_0x79b8('0x44')](_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x44')]));_0x443321[_0x79b8('0x43')]=_0x443321[_0x79b8('0x43')][_0x79b8('0x45')]?_0x443321['attributes']:_0x9de99[_0x79b8('0x3f')];if(!_0x16f7c5[_0x79b8('0x40')]['hasOwnProperty'](_0x79b8('0x46'))){_0x443321[_0x79b8('0x31')]=qs['limit'](_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x31')]);_0x443321[_0x79b8('0x30')]=qs[_0x79b8('0x30')](_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x30')]);}_0x443321[_0x79b8('0x47')]=qs[_0x79b8('0x48')](_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x48')]);_0x443321[_0x79b8('0x49')]=qs[_0x79b8('0x41')](_['pick'](_0x16f7c5['query'],_0x9de99[_0x79b8('0x41')]),_0x51cde9);if(_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x4a')]){_0x443321[_0x79b8('0x49')]=_['merge'](_0x443321[_0x79b8('0x49')],{'$or':_[_0x79b8('0x3a')](_0x51cde9,function(_0x24f486){if(_0x24f486[_0x79b8('0x3e')]!=='VIRTUAL'){var _0x2bfee6={};_0x2bfee6[_0x24f486[_0x79b8('0x37')]]={'$like':'%'+_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x4a')]+'%'};return _0x2bfee6;}})});}_0x443321=_['merge']({},_0x443321,_0x16f7c5[_0x79b8('0x4b')]);var _0x415648={'where':_0x443321[_0x79b8('0x49')]};return db[_0x79b8('0x3b')][_0x79b8('0x4c')](_0x415648)[_0x79b8('0x23')](function(_0x478ebb){_0x1cbfbf[_0x79b8('0x4c')]=_0x478ebb;if(_0x16f7c5[_0x79b8('0x40')][_0x79b8('0x4d')]){_0x443321[_0x79b8('0x4e')]=[{'all':!![]}];}return db['FaxMessage']['findAll'](_0x443321);})[_0x79b8('0x23')](function(_0x45d813){_0x1cbfbf[_0x79b8('0x4f')]=_0x45d813;return _0x1cbfbf;})[_0x79b8('0x23')](respondWithFilteredResult(_0x511cc0,_0x443321))[_0x79b8('0x2c')](handleError(_0x511cc0,null));};exports[_0x79b8('0x50')]=function(_0x1d4e87,_0x372d36){var _0x4b0525={'raw':!![],'where':{'id':_0x1d4e87[_0x79b8('0x51')]['id']}},_0x51cd68={};_0x51cd68[_0x79b8('0x3f')]=_[_0x79b8('0x52')](db['FaxMessage'][_0x79b8('0x3c')]);_0x51cd68['query']=_['keys'](_0x1d4e87[_0x79b8('0x40')]);_0x51cd68[_0x79b8('0x41')]=_[_0x79b8('0x42')](_0x51cd68[_0x79b8('0x3f')],_0x51cd68['query']);_0x4b0525['attributes']=_[_0x79b8('0x42')](_0x51cd68[_0x79b8('0x3f')],qs[_0x79b8('0x44')](_0x1d4e87[_0x79b8('0x40')][_0x79b8('0x44')]));_0x4b0525[_0x79b8('0x43')]=_0x4b0525[_0x79b8('0x43')][_0x79b8('0x45')]?_0x4b0525[_0x79b8('0x43')]:_0x51cd68[_0x79b8('0x3f')];if(_0x1d4e87[_0x79b8('0x40')][_0x79b8('0x4d')]){_0x4b0525[_0x79b8('0x4e')]=[{'all':!![]}];}_0x4b0525=_[_0x79b8('0x53')]({},_0x4b0525,_0x1d4e87['options']);return db[_0x79b8('0x3b')][_0x79b8('0x54')](_0x4b0525)[_0x79b8('0x23')](handleEntityNotFound(_0x372d36,null))[_0x79b8('0x23')](respondWithResult(_0x372d36,null))['catch'](handleError(_0x372d36,null));};exports['update']=function(_0xe6316c,_0x4217ec){if(_0xe6316c[_0x79b8('0x55')]['id']){delete _0xe6316c[_0x79b8('0x55')]['id'];}return db['FaxMessage'][_0x79b8('0x54')]({'where':{'id':_0xe6316c[_0x79b8('0x51')]['id']}})['then'](handleEntityNotFound(_0x4217ec,null))[_0x79b8('0x23')](saveUpdates(_0xe6316c[_0x79b8('0x55')],null))[_0x79b8('0x23')](respondWithResult(_0x4217ec,null))['catch'](handleError(_0x4217ec,null));};exports[_0x79b8('0x56')]=function(_0x5dd655,_0x361048){return db[_0x79b8('0x3b')][_0x79b8('0x54')]({'where':{'id':_0x5dd655[_0x79b8('0x51')]['id']}})[_0x79b8('0x23')](handleEntityNotFound(_0x361048,null))[_0x79b8('0x23')](removeEntity(_0x361048,null))[_0x79b8('0x2c')](handleError(_0x361048,null));};exports[_0x79b8('0x57')]=function(_0xe0d55d,_0x17e421){return db['FaxMessage'][_0x79b8('0x57')]()['then'](respondWithResult(_0x17e421,null))[_0x79b8('0x2c')](handleError(_0x17e421,null));};var interaction_log=require('../../config/logger')(_0x79b8('0x58'));exports[_0x79b8('0x59')]=function(_0x4146b0,_0x20b2f3,_0x2fcd4e){var _0x5885a3={'channel':_0x79b8('0x5a')};if(_0x4146b0['body']['id']){delete _0x4146b0[_0x79b8('0x55')]['id'];}_0x4146b0[_0x79b8('0x55')][_0x79b8('0x5b')]=!![];_0x4146b0[_0x79b8('0x55')][_0x79b8('0x5c')]=moment()[_0x79b8('0x5d')]('YYYY-MM-DD\x20HH:mm:ss');_0x4146b0[_0x79b8('0x55')][_0x79b8('0x5e')]=_0x4146b0['body'][_0x79b8('0x5e')]||_0x4146b0['user']['id'];return db[_0x79b8('0x3b')][_0x79b8('0x54')]({'where':{'id':_0x4146b0['params']['id'],'UserId':null},'include':[{'model':db[_0x79b8('0x5f')],'as':_0x79b8('0x60')}]})['then'](handleEntityNotFound(_0x20b2f3,null))[_0x79b8('0x23')](saveUpdates(_0x4146b0['body'],null))[_0x79b8('0x23')](function(_0x5d2bfc){if(_0x5d2bfc){_0x5885a3[_0x79b8('0x2a')]=_0x5d2bfc[_0x79b8('0x61')]({'plain':!![]});return db[_0x79b8('0x62')][_0x79b8('0x54')]({'where':{'id':_0x5d2bfc[_0x79b8('0x63')]}});}return null;})[_0x79b8('0x23')](handleEntityNotFound(_0x20b2f3,null))['then'](function(_0x291ef1){if(_0x291ef1){return _0x291ef1[_0x79b8('0x64')]({'UserId':_0x4146b0['body']['UserId'],'read1stAt':_[_0x79b8('0x65')](_0x291ef1[_0x79b8('0x66')])?moment()['format'](_0x79b8('0x67')):undefined});}return null;})[_0x79b8('0x23')](function(_0x2daf0a){if(_0x2daf0a){_0x5885a3['interaction']=_0x2daf0a[_0x79b8('0x61')]({'plain':!![]});interaction_log[_0x79b8('0x24')](_0x79b8('0x68'),_0x4146b0[_0x79b8('0x69')]['id'],_0x4146b0[_0x79b8('0x69')][_0x79b8('0x37')],_0x4146b0['user'][_0x79b8('0x6a')],_0x5885a3[_0x79b8('0x6b')]['id'],_0x4146b0[_0x79b8('0x55')]?JSON['stringify'](_0x4146b0[_0x79b8('0x55')]):_0x79b8('0x6c'));return respondWithRpcPromise(_0x79b8('0x6d'),'acceptMessage',_0x5885a3);}return null;})[_0x79b8('0x23')](function(_0x2e3b8c){if(_0x2e3b8c){if(_0x4146b0['body']['manual']){_0x5885a3[_0x79b8('0x2a')][_0x79b8('0x6e')]=util[_0x79b8('0x5d')](_0x79b8('0x6f'),_0x4146b0[_0x79b8('0x69')][_0x79b8('0x37')]);_0x5885a3[_0x79b8('0x2a')][_0x79b8('0x70')]=_0x5885a3['channel'];_0x5885a3[_0x79b8('0x2a')]['event']='accept';return respondWithRpcPromise(_0x79b8('0x71'),'EventManager',{'event':_0x79b8('0x72'),'message':_0x5885a3[_0x79b8('0x2a')]},client9002)[_0x79b8('0x23')](function(){return _0x5885a3;});}return _0x5885a3;}return null;})['then'](respondWithResult(_0x20b2f3,null))[_0x79b8('0x2c')](handleError(_0x20b2f3,null));};var interaction_log=require(_0x79b8('0x73'))(_0x79b8('0x58'));exports[_0x79b8('0x74')]=function(_0x12fb6b,_0x225122,_0x1707ad){var _0x2c84d0={'agent':{},'channel':_0x79b8('0x5a')};if(_0x12fb6b[_0x79b8('0x55')]['id']){delete _0x12fb6b[_0x79b8('0x55')]['id'];}_0x12fb6b[_0x79b8('0x55')]['UserId']=_0x12fb6b[_0x79b8('0x55')][_0x79b8('0x5e')]||_0x12fb6b[_0x79b8('0x69')]['id'];_0x2c84d0[_0x79b8('0x75')]['id']=_0x12fb6b[_0x79b8('0x55')][_0x79b8('0x5e')];return db[_0x79b8('0x3b')][_0x79b8('0x54')]({'where':{'id':_0x12fb6b[_0x79b8('0x51')]['id'],'UserId':null}})[_0x79b8('0x23')](handleEntityNotFound(_0x225122,null))[_0x79b8('0x23')](function(_0x4d116d){if(_0x4d116d){_0x2c84d0[_0x79b8('0x2a')]=_0x4d116d['get']({'plain':!![]});return db['FaxInteraction'][_0x79b8('0x54')]({'where':{'id':_0x4d116d[_0x79b8('0x63')]}});}return null;})[_0x79b8('0x23')](handleEntityNotFound(_0x225122,null))[_0x79b8('0x23')](function(_0x211c60){if(_0x211c60){_0x2c84d0[_0x79b8('0x6b')]=_0x211c60[_0x79b8('0x61')]({'plain':!![]});interaction_log[_0x79b8('0x24')]('[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x12fb6b['user']['id'],_0x12fb6b['user'][_0x79b8('0x37')],_0x12fb6b[_0x79b8('0x69')][_0x79b8('0x6a')],_0x2c84d0[_0x79b8('0x6b')]['id'],_0x12fb6b[_0x79b8('0x55')]?JSON[_0x79b8('0x26')](_0x12fb6b[_0x79b8('0x55')]):_0x79b8('0x6c'));return respondWithRpcPromise(_0x79b8('0x76'),_0x79b8('0x77'),_0x2c84d0);}return null;})[_0x79b8('0x23')](function(_0x3678b4){if(_0x3678b4){_0x3678b4['message'][_0x79b8('0x6e')]=util[_0x79b8('0x5d')]('SIP/%s',_0x12fb6b[_0x79b8('0x69')][_0x79b8('0x37')]);_0x3678b4[_0x79b8('0x2a')][_0x79b8('0x70')]=_0x2c84d0[_0x79b8('0x70')];_0x3678b4[_0x79b8('0x2a')][_0x79b8('0x78')]=_0x79b8('0x74');respondWithRpcPromise('EventManager','EventManager',{'event':_0x79b8('0x79'),'message':_0x3678b4[_0x79b8('0x2a')]},client9002);return _0x2c84d0;}return null;})[_0x79b8('0x23')](respondWithResult(_0x225122,null))[_0x79b8('0x2c')](handleError(_0x225122,null));};exports[_0x79b8('0x7a')]=function(_0x7101cc,_0x17b450){var _0x376fb8;return db[_0x79b8('0x3b')][_0x79b8('0x7a')](_0x7101cc['body'],{})['then'](function(_0x5e2b80){_0x376fb8=_0x5e2b80;return db['CmContact'][_0x79b8('0x7b')]({'where':{'id':_0x376fb8[_0x79b8('0x7c')]}});})['then'](function(_0x30b485){if(_[_0x79b8('0x65')](_0x30b485)){return;}else{_0x376fb8[_0x79b8('0x5a')]=_0x30b485[_0x79b8('0x5a')];return db[_0x79b8('0x7d')][_0x79b8('0x7b')]({'where':{'id':_0x376fb8[_0x79b8('0x7e')]}});}})[_0x79b8('0x23')](function(_0x2e67b5){return respondWithRpcPromise(_0x79b8('0x7f'),_0x79b8('0x7f'),{'FaxAccountId':_['isNil'](_0x7101cc['body'])?undefined:_0x7101cc[_0x79b8('0x55')][_0x79b8('0x80')],'path':_[_0x79b8('0x65')](_0x2e67b5)?undefined:util[_0x79b8('0x5d')](_0x79b8('0x81'),_0x2e67b5[_0x79b8('0x82')]),'fax':_[_0x79b8('0x65')](_0x376fb8['fax'])?undefined:_0x376fb8[_0x79b8('0x5a')],'AttachmentId':_0x376fb8[_0x79b8('0x7e')]},client9002);})[_0x79b8('0x23')](respondWithResult(_0x17b450,0xc9))[_0x79b8('0x2c')](handleError(_0x17b450,null));};exports['download']=function(_0x377899,_0x339f5b){var _0x31fb40=path['join'](config[_0x79b8('0x83')],_0x79b8('0x84'),_0x79b8('0x85'),_0x79b8('0x86'));return db['FaxMessage']['find']({'where':{'id':_0x377899[_0x79b8('0x51')]['id']},'include':[{'model':db[_0x79b8('0x7d')],'as':_0x79b8('0x7d')}]})[_0x79b8('0x23')](handleEntityNotFound(_0x339f5b,null))[_0x79b8('0x23')](function(_0x11c8cb){if(_0x11c8cb){return _0x339f5b[_0x79b8('0x87')](path[_0x79b8('0x88')](_0x31fb40,_0x11c8cb['Attachment'][_0x79b8('0x82')]));}})['catch'](handleError(_0x339f5b,null));};