5559b93c9541a7a21d724ceb7bd0ef5848827ee0
[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 _0xffb6=['basename','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','ejs','lodash','squel','crypto','jsforce','desk.js','to-csv','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./faxMessage.socket','register','jayson/promise','client','http','then','info','FaxMessage,\x20%s,\x20%s','request\x20sent','debug','FaxMessage,\x20%s,\x20%s,\x20%s','stringify','error','code','message','status','end','json','count','offset','Content-Range','apply','reject','destroy','sendStatus','send','map','FaxMessage','rawAttributes','fieldName','type','key','model','name','query','filters','attributes','intersection','fields','hasOwnProperty','nolimit','limit','order','where','pick','filter','VIRTUAL','options','include','findAll','rows','catch','keys','length','merge','find','update','body','params','fax-interactions','accept','fax','read','readAt','format','YYYY-MM-DD\x20HH:mm:ss','UserId','user','CmContact','Contact','get','isNil','interaction','role','AcceptMessage','acceptMessage','interface','SIP/%s','channel','event','EventManager','FaxInteractionId','[FAXMESSAGE:REJECT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','null','RejectMessage','rejectMessage','rejectmessage','create','findOne','ContactId','Attachment','AttachmentId','SendFax','download','join','server','files'];(function(_0x5933fb,_0x9115ad){var _0x44d988=function(_0x295228){while(--_0x295228){_0x5933fb['push'](_0x5933fb['shift']());}};_0x44d988(++_0x9115ad);}(_0xffb6,0x81));var _0x6ffb=function(_0x21686f,_0x313628){_0x21686f=_0x21686f-0x0;var _0x4e9450=_0xffb6[_0x21686f];return _0x4e9450;};'use strict';var pdf=require(_0x6ffb('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x6ffb('0x1'));var zipdir=require(_0x6ffb('0x2'));var jsonpatch=require(_0x6ffb('0x3'));var rp=require('request-promise');var moment=require(_0x6ffb('0x4'));var BPromise=require(_0x6ffb('0x5'));var Mustache=require(_0x6ffb('0x6'));var util=require(_0x6ffb('0x7'));var path=require(_0x6ffb('0x8'));var sox=require(_0x6ffb('0x9'));var csv=require('to-csv');var ejs=require(_0x6ffb('0xa'));var fs=require('fs');var _=require(_0x6ffb('0xb'));var squel=require(_0x6ffb('0xc'));var crypto=require(_0x6ffb('0xd'));var jsforce=require(_0x6ffb('0xe'));var deskjs=require(_0x6ffb('0xf'));var toCsv=require(_0x6ffb('0x10'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x6ffb('0x11'));var qs=require(_0x6ffb('0x12'));var as=require(_0x6ffb('0x13'));var hardwareService=require(_0x6ffb('0x14'));var logger=require(_0x6ffb('0x15'))(_0x6ffb('0x16'));var utils=require('../../config/utils');var config=require(_0x6ffb('0x17'));var licenseUtil=require(_0x6ffb('0x18'));var db=require(_0x6ffb('0x19'))['db'];config[_0x6ffb('0x1a')]=_[_0x6ffb('0x1b')](config['redis'],{'host':_0x6ffb('0x1c'),'port':0x18eb});var socket=require(_0x6ffb('0x1d'))(new Redis(config[_0x6ffb('0x1a')]));require(_0x6ffb('0x1e'))[_0x6ffb('0x1f')](socket);var jayson=require(_0x6ffb('0x20'));var client=jayson[_0x6ffb('0x21')][_0x6ffb('0x22')]({'port':0x232c});var client9002=jayson[_0x6ffb('0x21')]['http']({'port':0x232a});function respondWithRpcPromise(_0x567da6,_0xbd665,_0x47eed8,_0x12232f){return new BPromise(function(_0x33c78a,_0x5addaa){var _0x3b505e=_0x12232f||client;return _0x3b505e['request'](_0x567da6,_0x47eed8)[_0x6ffb('0x23')](function(_0x61f2dc){logger[_0x6ffb('0x24')](_0x6ffb('0x25'),_0xbd665,_0x6ffb('0x26'));logger[_0x6ffb('0x27')](_0x6ffb('0x28'),_0xbd665,_0x6ffb('0x26'),JSON[_0x6ffb('0x29')](_0x61f2dc));if(_0x61f2dc[_0x6ffb('0x2a')]){if(_0x61f2dc[_0x6ffb('0x2a')][_0x6ffb('0x2b')]===0x1f4){logger[_0x6ffb('0x2a')](_0x6ffb('0x25'),_0xbd665,_0x61f2dc['error'][_0x6ffb('0x2c')]);return _0x5addaa(_0x61f2dc[_0x6ffb('0x2a')][_0x6ffb('0x2c')]);}logger[_0x6ffb('0x2a')](_0x6ffb('0x25'),_0xbd665,_0x61f2dc[_0x6ffb('0x2a')][_0x6ffb('0x2c')]);return _0x33c78a(_0x61f2dc['error'][_0x6ffb('0x2c')]);}else{logger[_0x6ffb('0x24')](_0x6ffb('0x25'),_0xbd665,_0x6ffb('0x26'));_0x33c78a(_0x61f2dc['result'][_0x6ffb('0x2c')]);}})['catch'](function(_0x22ebf1){logger[_0x6ffb('0x2a')]('FaxMessage,\x20%s,\x20%s',_0xbd665,_0x22ebf1);_0x5addaa(_0x22ebf1);});});}function respondWithStatusCode(_0x7f915a,_0x4b4b9d){_0x4b4b9d=_0x4b4b9d||0xcc;return function(_0x48919c){if(_0x48919c){return _0x7f915a['sendStatus'](_0x4b4b9d);}return _0x7f915a[_0x6ffb('0x2d')](_0x4b4b9d)[_0x6ffb('0x2e')]();};}function respondWithResult(_0x4793f6,_0x49ac19){_0x49ac19=_0x49ac19||0xc8;return function(_0x281705){if(_0x281705){return _0x4793f6['status'](_0x49ac19)[_0x6ffb('0x2f')](_0x281705);}};}function respondWithFilteredResult(_0x25244a,_0x117be0){return function(_0x1e207d){if(_0x1e207d){var _0x29ad25=_0x1e207d[_0x6ffb('0x30')],_0x5b608a=_0x117be0[_0x6ffb('0x31')],_0x2aa677=_0x117be0[_0x6ffb('0x31')]+_0x117be0['limit'],_0x40c458;if(_0x2aa677>=_0x29ad25){_0x2aa677=_0x29ad25;_0x40c458=0xc8;}else{_0x40c458=0xce;}_0x25244a['status'](_0x40c458);return _0x25244a['set'](_0x6ffb('0x32'),_0x5b608a+'-'+_0x2aa677+'/'+_0x29ad25)[_0x6ffb('0x2f')](_0x1e207d);}return null;};}function patchUpdates(_0x2c733e){return function(_0x2ca702){try{jsonpatch[_0x6ffb('0x33')](_0x2ca702,_0x2c733e,!![]);}catch(_0xf2bb55){return BPromise[_0x6ffb('0x34')](_0xf2bb55);}return _0x2ca702['save']();};}function saveUpdates(_0x200cb3,_0x1c2c03){return function(_0x2694ba){if(_0x2694ba){return _0x2694ba['update'](_0x200cb3)[_0x6ffb('0x23')](function(_0x5727a6){return _0x5727a6;});}return null;};}function removeEntity(_0x102f35,_0x59ced5){return function(_0x36df4e){if(_0x36df4e){return _0x36df4e[_0x6ffb('0x35')]()[_0x6ffb('0x23')](function(){_0x102f35[_0x6ffb('0x2d')](0xcc)[_0x6ffb('0x2e')]();});}};}function handleEntityNotFound(_0x157765,_0x721b02){return function(_0x3fdf10){if(!_0x3fdf10){_0x157765[_0x6ffb('0x36')](0x194);}return _0x3fdf10;};}function handleError(_0x118f2a,_0x2bf5dc){_0x2bf5dc=_0x2bf5dc||0x1f4;return function(_0x44f03e){logger[_0x6ffb('0x2a')](_0x44f03e['stack']);if(_0x44f03e['name']){delete _0x44f03e['name'];}_0x118f2a[_0x6ffb('0x2d')](_0x2bf5dc)[_0x6ffb('0x37')](_0x44f03e);};}exports['index']=function(_0x124896,_0x15b9df){var _0x41313d={},_0x397f4b={},_0x32ce5f={'count':0x0,'rows':[]};var _0x515449=_[_0x6ffb('0x38')](db[_0x6ffb('0x39')][_0x6ffb('0x3a')],function(_0x47ff7b){return{'name':_0x47ff7b[_0x6ffb('0x3b')],'type':_0x47ff7b[_0x6ffb('0x3c')][_0x6ffb('0x3d')]};});_0x397f4b[_0x6ffb('0x3e')]=_['map'](_0x515449,_0x6ffb('0x3f'));_0x397f4b[_0x6ffb('0x40')]=_['keys'](_0x124896[_0x6ffb('0x40')]);_0x397f4b[_0x6ffb('0x41')]=_['intersection'](_0x397f4b[_0x6ffb('0x3e')],_0x397f4b[_0x6ffb('0x40')]);_0x41313d[_0x6ffb('0x42')]=_[_0x6ffb('0x43')](_0x397f4b[_0x6ffb('0x3e')],qs[_0x6ffb('0x44')](_0x124896['query'][_0x6ffb('0x44')]));_0x41313d[_0x6ffb('0x42')]=_0x41313d['attributes']['length']?_0x41313d[_0x6ffb('0x42')]:_0x397f4b[_0x6ffb('0x3e')];if(!_0x124896['query'][_0x6ffb('0x45')](_0x6ffb('0x46'))){_0x41313d[_0x6ffb('0x47')]=qs[_0x6ffb('0x47')](_0x124896[_0x6ffb('0x40')][_0x6ffb('0x47')]);_0x41313d[_0x6ffb('0x31')]=qs[_0x6ffb('0x31')](_0x124896[_0x6ffb('0x40')][_0x6ffb('0x31')]);}_0x41313d[_0x6ffb('0x48')]=qs['sort'](_0x124896[_0x6ffb('0x40')]['sort']);_0x41313d[_0x6ffb('0x49')]=qs[_0x6ffb('0x41')](_[_0x6ffb('0x4a')](_0x124896['query'],_0x397f4b[_0x6ffb('0x41')]),_0x515449);if(_0x124896[_0x6ffb('0x40')][_0x6ffb('0x4b')]){_0x41313d[_0x6ffb('0x49')]=_['merge'](_0x41313d['where'],{'$or':_['map'](_0x515449,function(_0xb4e5bc){if(_0xb4e5bc[_0x6ffb('0x3c')]!==_0x6ffb('0x4c')){var _0x128720={};_0x128720[_0xb4e5bc['name']]={'$like':'%'+_0x124896[_0x6ffb('0x40')][_0x6ffb('0x4b')]+'%'};return _0x128720;}})});}_0x41313d=_['merge']({},_0x41313d,_0x124896[_0x6ffb('0x4d')]);var _0x35c581={'where':_0x41313d['where']};return db[_0x6ffb('0x39')][_0x6ffb('0x30')](_0x35c581)[_0x6ffb('0x23')](function(_0x5cea40){_0x32ce5f[_0x6ffb('0x30')]=_0x5cea40;if(_0x124896[_0x6ffb('0x40')]['includeAll']){_0x41313d[_0x6ffb('0x4e')]=[{'all':!![]}];}return db[_0x6ffb('0x39')][_0x6ffb('0x4f')](_0x41313d);})[_0x6ffb('0x23')](function(_0x2a24d7){_0x32ce5f[_0x6ffb('0x50')]=_0x2a24d7;return _0x32ce5f;})['then'](respondWithFilteredResult(_0x15b9df,_0x41313d))[_0x6ffb('0x51')](handleError(_0x15b9df,null));};exports['show']=function(_0xd4864b,_0x48b870){var _0x5484ce={'raw':!![],'where':{'id':_0xd4864b['params']['id']}},_0x18b24d={};_0x18b24d['model']=_[_0x6ffb('0x52')](db[_0x6ffb('0x39')]['rawAttributes']);_0x18b24d['query']=_[_0x6ffb('0x52')](_0xd4864b[_0x6ffb('0x40')]);_0x18b24d[_0x6ffb('0x41')]=_['intersection'](_0x18b24d[_0x6ffb('0x3e')],_0x18b24d['query']);_0x5484ce[_0x6ffb('0x42')]=_[_0x6ffb('0x43')](_0x18b24d[_0x6ffb('0x3e')],qs['fields'](_0xd4864b[_0x6ffb('0x40')]['fields']));_0x5484ce[_0x6ffb('0x42')]=_0x5484ce[_0x6ffb('0x42')][_0x6ffb('0x53')]?_0x5484ce[_0x6ffb('0x42')]:_0x18b24d[_0x6ffb('0x3e')];if(_0xd4864b['query']['includeAll']){_0x5484ce[_0x6ffb('0x4e')]=[{'all':!![]}];}_0x5484ce=_[_0x6ffb('0x54')]({},_0x5484ce,_0xd4864b[_0x6ffb('0x4d')]);return db[_0x6ffb('0x39')][_0x6ffb('0x55')](_0x5484ce)[_0x6ffb('0x23')](handleEntityNotFound(_0x48b870,null))[_0x6ffb('0x23')](respondWithResult(_0x48b870,null))[_0x6ffb('0x51')](handleError(_0x48b870,null));};exports[_0x6ffb('0x56')]=function(_0x3757de,_0x48e1d3){if(_0x3757de['body']['id']){delete _0x3757de[_0x6ffb('0x57')]['id'];}return db[_0x6ffb('0x39')][_0x6ffb('0x55')]({'where':{'id':_0x3757de[_0x6ffb('0x58')]['id']}})[_0x6ffb('0x23')](handleEntityNotFound(_0x48e1d3,null))['then'](saveUpdates(_0x3757de[_0x6ffb('0x57')],null))[_0x6ffb('0x23')](respondWithResult(_0x48e1d3,null))[_0x6ffb('0x51')](handleError(_0x48e1d3,null));};exports[_0x6ffb('0x35')]=function(_0x21d16c,_0x201005){return db[_0x6ffb('0x39')][_0x6ffb('0x55')]({'where':{'id':_0x21d16c[_0x6ffb('0x58')]['id']}})[_0x6ffb('0x23')](handleEntityNotFound(_0x201005,null))[_0x6ffb('0x23')](removeEntity(_0x201005,null))[_0x6ffb('0x51')](handleError(_0x201005,null));};exports['describe']=function(_0x24526a,_0x703c66){return db[_0x6ffb('0x39')]['describe']()[_0x6ffb('0x23')](respondWithResult(_0x703c66,null))[_0x6ffb('0x51')](handleError(_0x703c66,null));};var interaction_log=require(_0x6ffb('0x15'))(_0x6ffb('0x59'));exports[_0x6ffb('0x5a')]=function(_0x3420f,_0x37739f,_0x412b93){var _0x5bd8ce={'channel':_0x6ffb('0x5b')};if(_0x3420f['body']['id']){delete _0x3420f[_0x6ffb('0x57')]['id'];}_0x3420f[_0x6ffb('0x57')][_0x6ffb('0x5c')]=!![];_0x3420f[_0x6ffb('0x57')][_0x6ffb('0x5d')]=moment()[_0x6ffb('0x5e')](_0x6ffb('0x5f'));_0x3420f[_0x6ffb('0x57')][_0x6ffb('0x60')]=_0x3420f[_0x6ffb('0x57')][_0x6ffb('0x60')]||_0x3420f[_0x6ffb('0x61')]['id'];return db[_0x6ffb('0x39')][_0x6ffb('0x55')]({'where':{'id':_0x3420f[_0x6ffb('0x58')]['id'],'UserId':null},'include':[{'model':db[_0x6ffb('0x62')],'as':_0x6ffb('0x63')}]})[_0x6ffb('0x23')](handleEntityNotFound(_0x37739f,null))[_0x6ffb('0x23')](saveUpdates(_0x3420f['body'],null))[_0x6ffb('0x23')](function(_0x439f18){if(_0x439f18){_0x5bd8ce[_0x6ffb('0x2c')]=_0x439f18[_0x6ffb('0x64')]({'plain':!![]});return db['FaxInteraction']['find']({'where':{'id':_0x439f18['FaxInteractionId']}});}return null;})[_0x6ffb('0x23')](handleEntityNotFound(_0x37739f,null))[_0x6ffb('0x23')](function(_0x17f04){if(_0x17f04){return _0x17f04[_0x6ffb('0x56')]({'UserId':_0x3420f[_0x6ffb('0x57')]['UserId'],'read1stAt':_[_0x6ffb('0x65')](_0x17f04['read1stAt'])?moment()[_0x6ffb('0x5e')](_0x6ffb('0x5f')):undefined});}return null;})[_0x6ffb('0x23')](function(_0x8d0d23){if(_0x8d0d23){_0x5bd8ce[_0x6ffb('0x66')]=_0x8d0d23['get']({'plain':!![]});interaction_log[_0x6ffb('0x24')]('[FAXMESSAGE:ACCEPT]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x3420f[_0x6ffb('0x61')]['id'],_0x3420f[_0x6ffb('0x61')][_0x6ffb('0x3f')],_0x3420f[_0x6ffb('0x61')][_0x6ffb('0x67')],_0x5bd8ce[_0x6ffb('0x66')]['id'],_0x3420f[_0x6ffb('0x57')]?JSON['stringify'](_0x3420f[_0x6ffb('0x57')]):'null');return respondWithRpcPromise(_0x6ffb('0x68'),_0x6ffb('0x69'),_0x5bd8ce);}return null;})['then'](function(_0x59161e){if(_0x59161e){if(_0x3420f[_0x6ffb('0x57')]['manual']){_0x5bd8ce[_0x6ffb('0x2c')][_0x6ffb('0x6a')]=util[_0x6ffb('0x5e')](_0x6ffb('0x6b'),_0x3420f[_0x6ffb('0x61')][_0x6ffb('0x3f')]);_0x5bd8ce['message'][_0x6ffb('0x6c')]=_0x5bd8ce[_0x6ffb('0x6c')];_0x5bd8ce[_0x6ffb('0x2c')][_0x6ffb('0x6d')]=_0x6ffb('0x5a');return respondWithRpcPromise(_0x6ffb('0x6e'),_0x6ffb('0x6e'),{'event':'acceptmessage','message':_0x5bd8ce['message']},client9002)[_0x6ffb('0x23')](function(){return _0x5bd8ce;});}return _0x5bd8ce;}return null;})['then'](respondWithResult(_0x37739f,null))[_0x6ffb('0x51')](handleError(_0x37739f,null));};var interaction_log=require(_0x6ffb('0x15'))(_0x6ffb('0x59'));exports[_0x6ffb('0x34')]=function(_0x50654a,_0x10ee9b,_0x382a28){var _0x18c7b3={'agent':{},'channel':_0x6ffb('0x5b')};if(_0x50654a[_0x6ffb('0x57')]['id']){delete _0x50654a[_0x6ffb('0x57')]['id'];}_0x50654a['body'][_0x6ffb('0x60')]=_0x50654a[_0x6ffb('0x57')][_0x6ffb('0x60')]||_0x50654a[_0x6ffb('0x61')]['id'];_0x18c7b3['agent']['id']=_0x50654a['body']['UserId'];return db['FaxMessage']['find']({'where':{'id':_0x50654a[_0x6ffb('0x58')]['id'],'UserId':null}})['then'](handleEntityNotFound(_0x10ee9b,null))['then'](function(_0x37e74a){if(_0x37e74a){_0x18c7b3[_0x6ffb('0x2c')]=_0x37e74a['get']({'plain':!![]});return db['FaxInteraction'][_0x6ffb('0x55')]({'where':{'id':_0x37e74a[_0x6ffb('0x6f')]}});}return null;})[_0x6ffb('0x23')](handleEntityNotFound(_0x10ee9b,null))[_0x6ffb('0x23')](function(_0x59da01){if(_0x59da01){_0x18c7b3[_0x6ffb('0x66')]=_0x59da01[_0x6ffb('0x64')]({'plain':!![]});interaction_log[_0x6ffb('0x24')](_0x6ffb('0x70'),_0x50654a[_0x6ffb('0x61')]['id'],_0x50654a[_0x6ffb('0x61')][_0x6ffb('0x3f')],_0x50654a[_0x6ffb('0x61')][_0x6ffb('0x67')],_0x18c7b3[_0x6ffb('0x66')]['id'],_0x50654a[_0x6ffb('0x57')]?JSON[_0x6ffb('0x29')](_0x50654a['body']):_0x6ffb('0x71'));return respondWithRpcPromise(_0x6ffb('0x72'),_0x6ffb('0x73'),_0x18c7b3);}return null;})['then'](function(_0x2ff8fb){if(_0x2ff8fb){_0x2ff8fb[_0x6ffb('0x2c')][_0x6ffb('0x6a')]=util[_0x6ffb('0x5e')](_0x6ffb('0x6b'),_0x50654a['user'][_0x6ffb('0x3f')]);_0x2ff8fb[_0x6ffb('0x2c')][_0x6ffb('0x6c')]=_0x18c7b3['channel'];_0x2ff8fb[_0x6ffb('0x2c')][_0x6ffb('0x6d')]=_0x6ffb('0x34');respondWithRpcPromise('EventManager','EventManager',{'event':_0x6ffb('0x74'),'message':_0x2ff8fb[_0x6ffb('0x2c')]},client9002);return _0x18c7b3;}return null;})['then'](respondWithResult(_0x10ee9b,null))[_0x6ffb('0x51')](handleError(_0x10ee9b,null));};exports['create']=function(_0x472e94,_0x500373){var _0x1241f3;return db[_0x6ffb('0x39')][_0x6ffb('0x75')](_0x472e94[_0x6ffb('0x57')],{})['then'](function(_0x1fcac4){_0x1241f3=_0x1fcac4;return db[_0x6ffb('0x62')][_0x6ffb('0x76')]({'where':{'id':_0x1241f3[_0x6ffb('0x77')]}});})['then'](function(_0x50334d){if(_[_0x6ffb('0x65')](_0x50334d)){return;}else{_0x1241f3[_0x6ffb('0x5b')]=_0x50334d[_0x6ffb('0x5b')];return db[_0x6ffb('0x78')][_0x6ffb('0x76')]({'where':{'id':_0x1241f3[_0x6ffb('0x79')]}});}})[_0x6ffb('0x23')](function(_0x87ea52){return respondWithRpcPromise(_0x6ffb('0x7a'),_0x6ffb('0x7a'),{'FaxAccountId':_[_0x6ffb('0x65')](_0x472e94['body'])?undefined:_0x472e94[_0x6ffb('0x57')]['FaxAccountId'],'path':_[_0x6ffb('0x65')](_0x87ea52)?undefined:util[_0x6ffb('0x5e')]('/var/opt/motion2/server/files/attachments/%s',_0x87ea52['basename']),'fax':_[_0x6ffb('0x65')](_0x1241f3['fax'])?undefined:_0x1241f3[_0x6ffb('0x5b')],'AttachmentId':_0x1241f3['AttachmentId']},client9002);})[_0x6ffb('0x23')](respondWithResult(_0x500373,0xc9))[_0x6ffb('0x51')](handleError(_0x500373,null));};exports[_0x6ffb('0x7b')]=function(_0x339d5b,_0xf60a01){var _0x5d350c=path[_0x6ffb('0x7c')](config['root'],_0x6ffb('0x7d'),_0x6ffb('0x7e'),'attachments');return db[_0x6ffb('0x39')][_0x6ffb('0x55')]({'where':{'id':_0x339d5b[_0x6ffb('0x58')]['id']},'include':[{'model':db[_0x6ffb('0x78')],'as':_0x6ffb('0x78')}]})[_0x6ffb('0x23')](handleEntityNotFound(_0xf60a01,null))['then'](function(_0xe07196){if(_0xe07196){return _0xf60a01[_0x6ffb('0x7b')](path[_0x6ffb('0x7c')](_0x5d350c,_0xe07196['Attachment'][_0x6ffb('0x7f')]));}})[_0x6ffb('0x51')](handleError(_0xf60a01,null));};