Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / intFreshdeskConfiguration / intFreshdeskConfiguration.controller.js
index e2b3b32..a02950b 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3349=['rimraf','zip-dir','request-promise','moment','bluebird','util','sox','to-csv','fs-extra','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','offset','count','set','apply','reject','then','destroy','stack','name','index','map','FreshdeskConfiguration','rawAttributes','type','key','model','query','keys','filters','attributes','intersection','fields','length','nolimit','order','where','VIRTUAL','filter','options','includeAll','include','findAll','rows','catch','show','merge','find','create','body','update','params','getFields','findOne','FreshdeskField','sort','pick','getSubjects','getDescriptions','Tag','getTags','setTags','ids','eml-format'];(function(_0x5cb3d4,_0x41f1aa){var _0x5c44f1=function(_0x4879e2){while(--_0x4879e2){_0x5cb3d4['push'](_0x5cb3d4['shift']());}};_0x5c44f1(++_0x41f1aa);}(_0x3349,0xa3));var _0x9334=function(_0x2ace4e,_0x4546f3){_0x2ace4e=_0x2ace4e-0x0;var _0x115c09=_0x3349[_0x2ace4e];return _0x115c09;};'use strict';var emlformat=require(_0x9334('0x0'));var rimraf=require(_0x9334('0x1'));var zipdir=require(_0x9334('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9334('0x3'));var moment=require(_0x9334('0x4'));var BPromise=require(_0x9334('0x5'));var Mustache=require('mustache');var util=require(_0x9334('0x6'));var path=require('path');var sox=require(_0x9334('0x7'));var csv=require(_0x9334('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9334('0x9'));var _=require('lodash');var squel=require(_0x9334('0xa'));var crypto=require(_0x9334('0xb'));var jsforce=require('jsforce');var deskjs=require(_0x9334('0xc'));var toCsv=require('to-csv');var querystring=require(_0x9334('0xd'));var Papa=require(_0x9334('0xe'));var Redis=require(_0x9334('0xf'));var authService=require(_0x9334('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x9334('0x11'));var logger=require(_0x9334('0x12'))(_0x9334('0x13'));var utils=require(_0x9334('0x14'));var config=require(_0x9334('0x15'));var licenseUtil=require(_0x9334('0x16'));var db=require(_0x9334('0x17'))['db'];function respondWithStatusCode(_0x5802e7,_0x474ed1){_0x474ed1=_0x474ed1||0xcc;return function(_0x117278){if(_0x117278){return _0x5802e7[_0x9334('0x18')](_0x474ed1);}return _0x5802e7[_0x9334('0x19')](_0x474ed1)[_0x9334('0x1a')]();};}function respondWithResult(_0x4820c5,_0xdd6db){_0xdd6db=_0xdd6db||0xc8;return function(_0x4d6848){if(_0x4d6848){return _0x4820c5[_0x9334('0x19')](_0xdd6db)[_0x9334('0x1b')](_0x4d6848);}};}function respondWithFilteredResult(_0x56c566,_0x5e2dd1){return function(_0x47dd35){if(_0x47dd35){var _0x1ff203=typeof _0x5e2dd1['offset']===_0x9334('0x1c')&&typeof _0x5e2dd1[_0x9334('0x1d')]===_0x9334('0x1c');var _0x24b6a7=_0x47dd35['count'];var _0x59d968=_0x1ff203?0x0:_0x5e2dd1[_0x9334('0x1e')];var _0x1cfef6=_0x1ff203?_0x47dd35[_0x9334('0x1f')]:_0x5e2dd1[_0x9334('0x1e')]+_0x5e2dd1[_0x9334('0x1d')];var _0x3e6b3c;if(_0x1cfef6>=_0x24b6a7){_0x1cfef6=_0x24b6a7;_0x3e6b3c=0xc8;}else{_0x3e6b3c=0xce;}_0x56c566[_0x9334('0x19')](_0x3e6b3c);return _0x56c566[_0x9334('0x20')]('Content-Range',_0x59d968+'-'+_0x1cfef6+'/'+_0x24b6a7)[_0x9334('0x1b')](_0x47dd35);}return null;};}function patchUpdates(_0xb67794){return function(_0x26ba9e){try{jsonpatch[_0x9334('0x21')](_0x26ba9e,_0xb67794,!![]);}catch(_0x293f3a){return BPromise[_0x9334('0x22')](_0x293f3a);}return _0x26ba9e['save']();};}function saveUpdates(_0x385b7f,_0x365aa0){return function(_0x374ba6){if(_0x374ba6){return _0x374ba6['update'](_0x385b7f)[_0x9334('0x23')](function(_0x157a98){return _0x157a98;});}return null;};}function removeEntity(_0x49121e,_0x4ff8eb){return function(_0xf5308b){if(_0xf5308b){return _0xf5308b[_0x9334('0x24')]()[_0x9334('0x23')](function(){_0x49121e['status'](0xcc)[_0x9334('0x1a')]();});}};}function handleEntityNotFound(_0x4ec662,_0x1b3626){return function(_0x50276a){if(!_0x50276a){_0x4ec662[_0x9334('0x18')](0x194);}return _0x50276a;};}function handleError(_0x3841cf,_0x3e3d27){_0x3e3d27=_0x3e3d27||0x1f4;return function(_0x1c7ede){logger['error'](_0x1c7ede[_0x9334('0x25')]);if(_0x1c7ede[_0x9334('0x26')]){delete _0x1c7ede[_0x9334('0x26')];}_0x3841cf['status'](_0x3e3d27)['send'](_0x1c7ede);};}exports[_0x9334('0x27')]=function(_0x41088d,_0x3f1dd6){var _0x3783c7={},_0xd21d77={},_0x187faf={'count':0x0,'rows':[]};var _0x2fbfe3=_[_0x9334('0x28')](db[_0x9334('0x29')][_0x9334('0x2a')],function(_0x1b0c2f){return{'name':_0x1b0c2f['fieldName'],'type':_0x1b0c2f[_0x9334('0x2b')][_0x9334('0x2c')]};});_0xd21d77[_0x9334('0x2d')]=_[_0x9334('0x28')](_0x2fbfe3,'name');_0xd21d77[_0x9334('0x2e')]=_[_0x9334('0x2f')](_0x41088d[_0x9334('0x2e')]);_0xd21d77[_0x9334('0x30')]=_['intersection'](_0xd21d77[_0x9334('0x2d')],_0xd21d77['query']);_0x3783c7[_0x9334('0x31')]=_[_0x9334('0x32')](_0xd21d77['model'],qs[_0x9334('0x33')](_0x41088d[_0x9334('0x2e')][_0x9334('0x33')]));_0x3783c7[_0x9334('0x31')]=_0x3783c7['attributes'][_0x9334('0x34')]?_0x3783c7[_0x9334('0x31')]:_0xd21d77[_0x9334('0x2d')];if(!_0x41088d[_0x9334('0x2e')]['hasOwnProperty'](_0x9334('0x35'))){_0x3783c7[_0x9334('0x1d')]=qs['limit'](_0x41088d['query'][_0x9334('0x1d')]);_0x3783c7[_0x9334('0x1e')]=qs[_0x9334('0x1e')](_0x41088d['query'][_0x9334('0x1e')]);}_0x3783c7[_0x9334('0x36')]=qs['sort'](_0x41088d['query']['sort']);_0x3783c7[_0x9334('0x37')]=qs['filters'](_['pick'](_0x41088d['query'],_0xd21d77[_0x9334('0x30')]),_0x2fbfe3);if(_0x41088d[_0x9334('0x2e')]['filter']){_0x3783c7['where']=_['merge'](_0x3783c7[_0x9334('0x37')],{'$or':_[_0x9334('0x28')](_0x2fbfe3,function(_0x90b2f4){if(_0x90b2f4[_0x9334('0x2b')]!==_0x9334('0x38')){var _0x28fbf3={};_0x28fbf3[_0x90b2f4[_0x9334('0x26')]]={'$like':'%'+_0x41088d['query'][_0x9334('0x39')]+'%'};return _0x28fbf3;}})});}_0x3783c7=_['merge']({},_0x3783c7,_0x41088d[_0x9334('0x3a')]);var _0x4f1237={'where':_0x3783c7[_0x9334('0x37')]};return db[_0x9334('0x29')][_0x9334('0x1f')](_0x4f1237)[_0x9334('0x23')](function(_0x4f66c4){_0x187faf[_0x9334('0x1f')]=_0x4f66c4;if(_0x41088d[_0x9334('0x2e')][_0x9334('0x3b')]){_0x3783c7[_0x9334('0x3c')]=[{'all':!![]}];}return db[_0x9334('0x29')][_0x9334('0x3d')](_0x3783c7);})[_0x9334('0x23')](function(_0x1fe811){_0x187faf[_0x9334('0x3e')]=_0x1fe811;return _0x187faf;})['then'](respondWithFilteredResult(_0x3f1dd6,_0x3783c7))[_0x9334('0x3f')](handleError(_0x3f1dd6,null));};exports[_0x9334('0x40')]=function(_0x4fa881,_0x3108f9){var _0x328462={'raw':![],'where':{'id':_0x4fa881['params']['id']}},_0x11eab7={};_0x11eab7['model']=_['keys'](db[_0x9334('0x29')]['rawAttributes']);_0x11eab7[_0x9334('0x2e')]=_['keys'](_0x4fa881[_0x9334('0x2e')]);_0x11eab7[_0x9334('0x30')]=_[_0x9334('0x32')](_0x11eab7[_0x9334('0x2d')],_0x11eab7[_0x9334('0x2e')]);_0x328462['attributes']=_[_0x9334('0x32')](_0x11eab7[_0x9334('0x2d')],qs[_0x9334('0x33')](_0x4fa881[_0x9334('0x2e')][_0x9334('0x33')]));_0x328462[_0x9334('0x31')]=_0x328462[_0x9334('0x31')][_0x9334('0x34')]?_0x328462[_0x9334('0x31')]:_0x11eab7['model'];if(_0x4fa881[_0x9334('0x2e')][_0x9334('0x3b')]){_0x328462['include']=[{'all':!![]}];}_0x328462=_[_0x9334('0x41')]({},_0x328462,_0x4fa881[_0x9334('0x3a')]);return db[_0x9334('0x29')][_0x9334('0x42')](_0x328462)['then'](handleEntityNotFound(_0x3108f9,null))[_0x9334('0x23')](respondWithResult(_0x3108f9,null))[_0x9334('0x3f')](handleError(_0x3108f9,null));};exports[_0x9334('0x43')]=function(_0x1b8eb8,_0x1e0899){return db[_0x9334('0x29')][_0x9334('0x43')](_0x1b8eb8[_0x9334('0x44')],{})[_0x9334('0x23')](respondWithResult(_0x1e0899,0xc9))[_0x9334('0x3f')](handleError(_0x1e0899,null));};exports[_0x9334('0x45')]=function(_0x488980,_0x5e9e0c){if(_0x488980[_0x9334('0x44')]['id']){delete _0x488980[_0x9334('0x44')]['id'];}return db[_0x9334('0x29')][_0x9334('0x42')]({'where':{'id':_0x488980[_0x9334('0x46')]['id']}})[_0x9334('0x23')](handleEntityNotFound(_0x5e9e0c,null))[_0x9334('0x23')](saveUpdates(_0x488980[_0x9334('0x44')],null))['then'](respondWithResult(_0x5e9e0c,null))[_0x9334('0x3f')](handleError(_0x5e9e0c,null));};exports[_0x9334('0x24')]=function(_0x3660c6,_0x59d891){return db[_0x9334('0x29')][_0x9334('0x42')]({'where':{'id':_0x3660c6[_0x9334('0x46')]['id']}})['then'](handleEntityNotFound(_0x59d891,null))['then'](removeEntity(_0x59d891,null))[_0x9334('0x3f')](handleError(_0x59d891,null));};exports[_0x9334('0x47')]=function(_0x4a1685,_0x4169ad,_0x22fff6){var _0xbfa62d={};var _0x9041e9={};var _0x5ce982;var _0x201462;return db[_0x9334('0x29')][_0x9334('0x48')]({'where':{'id':_0x4a1685[_0x9334('0x46')]['id']}})['then'](handleEntityNotFound(_0x4169ad,null))['then'](function(_0x3f6887){if(_0x3f6887){_0x5ce982=_0x3f6887;_0x9041e9[_0x9334('0x2d')]=_[_0x9334('0x2f')](db[_0x9334('0x49')][_0x9334('0x2a')]);_0x9041e9[_0x9334('0x2e')]=_['keys'](_0x4a1685[_0x9334('0x2e')]);_0x9041e9[_0x9334('0x30')]=_[_0x9334('0x32')](_0x9041e9['model'],_0x9041e9[_0x9334('0x2e')]);_0xbfa62d[_0x9334('0x31')]=_['intersection'](_0x9041e9['model'],qs[_0x9334('0x33')](_0x4a1685[_0x9334('0x2e')][_0x9334('0x33')]));_0xbfa62d['attributes']=_0xbfa62d[_0x9334('0x31')][_0x9334('0x34')]?_0xbfa62d[_0x9334('0x31')]:_0x9041e9[_0x9334('0x2d')];_0xbfa62d[_0x9334('0x36')]=qs[_0x9334('0x4a')](_0x4a1685[_0x9334('0x2e')][_0x9334('0x4a')]);_0xbfa62d[_0x9334('0x37')]=qs['filters'](_[_0x9334('0x4b')](_0x4a1685[_0x9334('0x2e')],_0x9041e9[_0x9334('0x30')]));if(_0x4a1685[_0x9334('0x2e')][_0x9334('0x39')]){_0xbfa62d[_0x9334('0x37')]=_[_0x9334('0x41')](_0xbfa62d[_0x9334('0x37')],{'$or':_[_0x9334('0x28')](_0xbfa62d[_0x9334('0x31')],function(_0x15098c){var _0x3d3025={};_0x3d3025[_0x15098c]={'$like':'%'+_0x4a1685[_0x9334('0x2e')]['filter']+'%'};return _0x3d3025;})});}_0xbfa62d=_['merge']({},_0xbfa62d,_0x4a1685[_0x9334('0x3a')]);return _0x5ce982['getFields'](_0xbfa62d);}})[_0x9334('0x23')](function(_0x13701c){if(_0x13701c){_0x201462=_0x13701c[_0x9334('0x34')];if(!_0x4a1685['query']['hasOwnProperty'](_0x9334('0x35'))){_0xbfa62d[_0x9334('0x1d')]=qs['limit'](_0x4a1685[_0x9334('0x2e')]['limit']);_0xbfa62d[_0x9334('0x1e')]=qs[_0x9334('0x1e')](_0x4a1685[_0x9334('0x2e')]['offset']);}return _0x5ce982[_0x9334('0x47')](_0xbfa62d);}})['then'](function(_0x5c5de5){if(_0x5c5de5){return _0x5c5de5?{'count':_0x201462,'rows':_0x5c5de5}:null;}})[_0x9334('0x23')](respondWithResult(_0x4169ad,null))[_0x9334('0x3f')](handleError(_0x4169ad,null));};exports[_0x9334('0x4c')]=function(_0x41fd93,_0x48b412,_0x59a22f){var _0x8843c7={};var _0x5095a3={};var _0x523997;var _0x5da267;return db[_0x9334('0x29')][_0x9334('0x48')]({'where':{'id':_0x41fd93[_0x9334('0x46')]['id']}})[_0x9334('0x23')](handleEntityNotFound(_0x48b412,null))[_0x9334('0x23')](function(_0x4ce447){if(_0x4ce447){_0x523997=_0x4ce447;_0x5095a3[_0x9334('0x2d')]=_['keys'](db[_0x9334('0x49')][_0x9334('0x2a')]);_0x5095a3[_0x9334('0x2e')]=_[_0x9334('0x2f')](_0x41fd93[_0x9334('0x2e')]);_0x5095a3[_0x9334('0x30')]=_['intersection'](_0x5095a3['model'],_0x5095a3['query']);_0x8843c7[_0x9334('0x31')]=_[_0x9334('0x32')](_0x5095a3['model'],qs[_0x9334('0x33')](_0x41fd93[_0x9334('0x2e')][_0x9334('0x33')]));_0x8843c7['attributes']=_0x8843c7['attributes']['length']?_0x8843c7[_0x9334('0x31')]:_0x5095a3[_0x9334('0x2d')];_0x8843c7[_0x9334('0x36')]=qs[_0x9334('0x4a')](_0x41fd93[_0x9334('0x2e')][_0x9334('0x4a')]);_0x8843c7[_0x9334('0x37')]=qs['filters'](_['pick'](_0x41fd93[_0x9334('0x2e')],_0x5095a3[_0x9334('0x30')]));if(_0x41fd93[_0x9334('0x2e')][_0x9334('0x39')]){_0x8843c7[_0x9334('0x37')]=_[_0x9334('0x41')](_0x8843c7[_0x9334('0x37')],{'$or':_[_0x9334('0x28')](_0x8843c7[_0x9334('0x31')],function(_0x1fd89c){var _0x31d4f3={};_0x31d4f3[_0x1fd89c]={'$like':'%'+_0x41fd93[_0x9334('0x2e')]['filter']+'%'};return _0x31d4f3;})});}_0x8843c7=_['merge']({},_0x8843c7,_0x41fd93[_0x9334('0x3a')]);return _0x523997[_0x9334('0x4c')](_0x8843c7);}})[_0x9334('0x23')](function(_0x9e69ae){if(_0x9e69ae){_0x5da267=_0x9e69ae[_0x9334('0x34')];if(!_0x41fd93[_0x9334('0x2e')]['hasOwnProperty']('nolimit')){_0x8843c7[_0x9334('0x1d')]=qs[_0x9334('0x1d')](_0x41fd93[_0x9334('0x2e')][_0x9334('0x1d')]);_0x8843c7['offset']=qs[_0x9334('0x1e')](_0x41fd93[_0x9334('0x2e')][_0x9334('0x1e')]);}return _0x523997[_0x9334('0x4c')](_0x8843c7);}})[_0x9334('0x23')](function(_0x2b4dc7){if(_0x2b4dc7){return _0x2b4dc7?{'count':_0x5da267,'rows':_0x2b4dc7}:null;}})[_0x9334('0x23')](respondWithResult(_0x48b412,null))[_0x9334('0x3f')](handleError(_0x48b412,null));};exports[_0x9334('0x4d')]=function(_0x1146b5,_0x59362d,_0x460301){var _0x4c6f0b={};var _0x51f0c2={};var _0x165982;var _0x39278a;return db['FreshdeskConfiguration'][_0x9334('0x48')]({'where':{'id':_0x1146b5[_0x9334('0x46')]['id']}})['then'](handleEntityNotFound(_0x59362d,null))[_0x9334('0x23')](function(_0x58a4a1){if(_0x58a4a1){_0x165982=_0x58a4a1;_0x51f0c2[_0x9334('0x2d')]=_[_0x9334('0x2f')](db[_0x9334('0x49')][_0x9334('0x2a')]);_0x51f0c2['query']=_[_0x9334('0x2f')](_0x1146b5['query']);_0x51f0c2[_0x9334('0x30')]=_[_0x9334('0x32')](_0x51f0c2['model'],_0x51f0c2[_0x9334('0x2e')]);_0x4c6f0b[_0x9334('0x31')]=_[_0x9334('0x32')](_0x51f0c2['model'],qs[_0x9334('0x33')](_0x1146b5[_0x9334('0x2e')][_0x9334('0x33')]));_0x4c6f0b['attributes']=_0x4c6f0b[_0x9334('0x31')][_0x9334('0x34')]?_0x4c6f0b[_0x9334('0x31')]:_0x51f0c2['model'];_0x4c6f0b['order']=qs[_0x9334('0x4a')](_0x1146b5[_0x9334('0x2e')][_0x9334('0x4a')]);_0x4c6f0b['where']=qs[_0x9334('0x30')](_[_0x9334('0x4b')](_0x1146b5[_0x9334('0x2e')],_0x51f0c2[_0x9334('0x30')]));if(_0x1146b5[_0x9334('0x2e')][_0x9334('0x39')]){_0x4c6f0b[_0x9334('0x37')]=_['merge'](_0x4c6f0b[_0x9334('0x37')],{'$or':_[_0x9334('0x28')](_0x4c6f0b[_0x9334('0x31')],function(_0x33ab83){var _0x2af3db={};_0x2af3db[_0x33ab83]={'$like':'%'+_0x1146b5[_0x9334('0x2e')]['filter']+'%'};return _0x2af3db;})});}_0x4c6f0b=_[_0x9334('0x41')]({},_0x4c6f0b,_0x1146b5[_0x9334('0x3a')]);return _0x165982[_0x9334('0x4d')](_0x4c6f0b);}})[_0x9334('0x23')](function(_0x1a4b1a){if(_0x1a4b1a){_0x39278a=_0x1a4b1a[_0x9334('0x34')];if(!_0x1146b5[_0x9334('0x2e')]['hasOwnProperty'](_0x9334('0x35'))){_0x4c6f0b[_0x9334('0x1d')]=qs[_0x9334('0x1d')](_0x1146b5[_0x9334('0x2e')][_0x9334('0x1d')]);_0x4c6f0b['offset']=qs[_0x9334('0x1e')](_0x1146b5[_0x9334('0x2e')]['offset']);}return _0x165982['getDescriptions'](_0x4c6f0b);}})['then'](function(_0x35318b){if(_0x35318b){return _0x35318b?{'count':_0x39278a,'rows':_0x35318b}:null;}})[_0x9334('0x23')](respondWithResult(_0x59362d,null))[_0x9334('0x3f')](handleError(_0x59362d,null));};exports['getTags']=function(_0x347934,_0x2fd309,_0x14b7ed){var _0x1598b8={};var _0x599759={};var _0x3d9f38;var _0x51345d;return db[_0x9334('0x29')][_0x9334('0x48')]({'where':{'id':_0x347934[_0x9334('0x46')]['id']}})[_0x9334('0x23')](handleEntityNotFound(_0x2fd309,null))['then'](function(_0x3c7c82){if(_0x3c7c82){_0x3d9f38=_0x3c7c82;_0x599759[_0x9334('0x2d')]=_['keys'](db[_0x9334('0x4e')][_0x9334('0x2a')]);_0x599759[_0x9334('0x2e')]=_[_0x9334('0x2f')](_0x347934['query']);_0x599759['filters']=_[_0x9334('0x32')](_0x599759[_0x9334('0x2d')],_0x599759[_0x9334('0x2e')]);_0x1598b8[_0x9334('0x31')]=_['intersection'](_0x599759[_0x9334('0x2d')],qs[_0x9334('0x33')](_0x347934['query'][_0x9334('0x33')]));_0x1598b8['attributes']=_0x1598b8['attributes'][_0x9334('0x34')]?_0x1598b8[_0x9334('0x31')]:_0x599759[_0x9334('0x2d')];_0x1598b8['order']=qs[_0x9334('0x4a')](_0x347934[_0x9334('0x2e')]['sort']);_0x1598b8['where']=qs[_0x9334('0x30')](_[_0x9334('0x4b')](_0x347934[_0x9334('0x2e')],_0x599759['filters']));if(_0x347934[_0x9334('0x2e')][_0x9334('0x39')]){_0x1598b8['where']=_['merge'](_0x1598b8[_0x9334('0x37')],{'$or':_[_0x9334('0x28')](_0x1598b8[_0x9334('0x31')],function(_0x7c4664){var _0x105f6a={};_0x105f6a[_0x7c4664]={'$like':'%'+_0x347934[_0x9334('0x2e')][_0x9334('0x39')]+'%'};return _0x105f6a;})});}_0x1598b8=_[_0x9334('0x41')]({},_0x1598b8,_0x347934['options']);return _0x3d9f38[_0x9334('0x4f')](_0x1598b8);}})[_0x9334('0x23')](function(_0x424ae4){if(_0x424ae4){_0x51345d=_0x424ae4[_0x9334('0x34')];if(!_0x347934[_0x9334('0x2e')]['hasOwnProperty']('nolimit')){_0x1598b8[_0x9334('0x1d')]=qs['limit'](_0x347934[_0x9334('0x2e')][_0x9334('0x1d')]);_0x1598b8[_0x9334('0x1e')]=qs[_0x9334('0x1e')](_0x347934[_0x9334('0x2e')][_0x9334('0x1e')]);}return _0x3d9f38[_0x9334('0x4f')](_0x1598b8);}})['then'](function(_0x3c3d82){if(_0x3c3d82){return _0x3c3d82?{'count':_0x51345d,'rows':_0x3c3d82}:null;}})['then'](respondWithResult(_0x2fd309,null))[_0x9334('0x3f')](handleError(_0x2fd309,null));};exports[_0x9334('0x50')]=function(_0x5694b7,_0x1f81d8,_0x471251){if(_0x5694b7[_0x9334('0x44')]['id']){delete _0x5694b7[_0x9334('0x44')]['id'];}return db[_0x9334('0x29')][_0x9334('0x48')]({'where':{'id':_0x5694b7[_0x9334('0x46')]['id']}})['then'](handleEntityNotFound(_0x1f81d8,null))[_0x9334('0x23')](function(_0x2d3ce5){if(_0x2d3ce5){return _0x2d3ce5[_0x9334('0x50')](_0x5694b7[_0x9334('0x44')][_0x9334('0x51')]||[]);}return null;})[_0x9334('0x23')](respondWithResult(_0x1f81d8,null))[_0x9334('0x3f')](handleError(_0x1f81d8,null));};
\ No newline at end of file
+var _0xff97=['crypto','jsforce','desk.js','to-csv','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','save','then','destroy','error','stack','name','send','map','FreshdeskConfiguration','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','hasOwnProperty','nolimit','order','sort','pick','filter','where','VIRTUAL','merge','options','catch','length','includeAll','include','find','create','body','params','findOne','FreshdeskField','getFields','getSubjects','getDescriptions','getTags','Tag','setTags','ids','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','ejs','fs-extra','lodash'];(function(_0xe16547,_0x3a3b5f){var _0x5a56d4=function(_0x1e4669){while(--_0x1e4669){_0xe16547['push'](_0xe16547['shift']());}};_0x5a56d4(++_0x3a3b5f);}(_0xff97,0x1d5));var _0x7ff9=function(_0x595c09,_0x2ddd12){_0x595c09=_0x595c09-0x0;var _0x9c4d65=_0xff97[_0x595c09];return _0x9c4d65;};'use strict';var emlformat=require(_0x7ff9('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x7ff9('0x1'));var rp=require(_0x7ff9('0x2'));var moment=require(_0x7ff9('0x3'));var BPromise=require(_0x7ff9('0x4'));var Mustache=require(_0x7ff9('0x5'));var util=require(_0x7ff9('0x6'));var path=require('path');var sox=require(_0x7ff9('0x7'));var csv=require('to-csv');var ejs=require(_0x7ff9('0x8'));var fs=require('fs');var fs_extra=require(_0x7ff9('0x9'));var _=require(_0x7ff9('0xa'));var squel=require('squel');var crypto=require(_0x7ff9('0xb'));var jsforce=require(_0x7ff9('0xc'));var deskjs=require(_0x7ff9('0xd'));var toCsv=require(_0x7ff9('0xe'));var querystring=require('querystring');var Papa=require(_0x7ff9('0xf'));var Redis=require('ioredis');var authService=require(_0x7ff9('0x10'));var qs=require(_0x7ff9('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x7ff9('0x12'));var logger=require(_0x7ff9('0x13'))(_0x7ff9('0x14'));var utils=require('../../config/utils');var config=require(_0x7ff9('0x15'));var licenseUtil=require(_0x7ff9('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1fd133,_0x28eb60){_0x28eb60=_0x28eb60||0xcc;return function(_0x3602be){if(_0x3602be){return _0x1fd133[_0x7ff9('0x17')](_0x28eb60);}return _0x1fd133[_0x7ff9('0x18')](_0x28eb60)[_0x7ff9('0x19')]();};}function respondWithResult(_0x198f0f,_0x443778){_0x443778=_0x443778||0xc8;return function(_0x38601d){if(_0x38601d){return _0x198f0f[_0x7ff9('0x18')](_0x443778)[_0x7ff9('0x1a')](_0x38601d);}};}function respondWithFilteredResult(_0x380b1a,_0x344617){return function(_0x583ad8){if(_0x583ad8){var _0x5d37a1=typeof _0x344617[_0x7ff9('0x1b')]===_0x7ff9('0x1c')&&typeof _0x344617[_0x7ff9('0x1d')]==='undefined';var _0x235d5a=_0x583ad8[_0x7ff9('0x1e')];var _0x1bd2f4=_0x5d37a1?0x0:_0x344617[_0x7ff9('0x1b')];var _0x590a06=_0x5d37a1?_0x583ad8[_0x7ff9('0x1e')]:_0x344617['offset']+_0x344617[_0x7ff9('0x1d')];var _0x1d47b2;if(_0x590a06>=_0x235d5a){_0x590a06=_0x235d5a;_0x1d47b2=0xc8;}else{_0x1d47b2=0xce;}_0x380b1a[_0x7ff9('0x18')](_0x1d47b2);return _0x380b1a[_0x7ff9('0x1f')](_0x7ff9('0x20'),_0x1bd2f4+'-'+_0x590a06+'/'+_0x235d5a)[_0x7ff9('0x1a')](_0x583ad8);}return null;};}function patchUpdates(_0x4f50d3){return function(_0x49a236){try{jsonpatch['apply'](_0x49a236,_0x4f50d3,!![]);}catch(_0x3d3f7e){return BPromise['reject'](_0x3d3f7e);}return _0x49a236[_0x7ff9('0x21')]();};}function saveUpdates(_0x54dcc8,_0xcaa15d){return function(_0x1895c7){if(_0x1895c7){return _0x1895c7['update'](_0x54dcc8)[_0x7ff9('0x22')](function(_0x4a4193){return _0x4a4193;});}return null;};}function removeEntity(_0x3a3649,_0x4ed5e6){return function(_0x20026b){if(_0x20026b){return _0x20026b[_0x7ff9('0x23')]()[_0x7ff9('0x22')](function(){_0x3a3649[_0x7ff9('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x3f4192,_0x5431fc){return function(_0x2725de){if(!_0x2725de){_0x3f4192['sendStatus'](0x194);}return _0x2725de;};}function handleError(_0x2bc895,_0x3ba300){_0x3ba300=_0x3ba300||0x1f4;return function(_0x4b0d8f){logger[_0x7ff9('0x24')](_0x4b0d8f[_0x7ff9('0x25')]);if(_0x4b0d8f[_0x7ff9('0x26')]){delete _0x4b0d8f['name'];}_0x2bc895['status'](_0x3ba300)[_0x7ff9('0x27')](_0x4b0d8f);};}exports['index']=function(_0x210c01,_0x20ea39){var _0x46781a={},_0x1263d4={},_0x7daa7={'count':0x0,'rows':[]};var _0x314423=_[_0x7ff9('0x28')](db[_0x7ff9('0x29')][_0x7ff9('0x2a')],function(_0x2ca7a4){return{'name':_0x2ca7a4[_0x7ff9('0x2b')],'type':_0x2ca7a4[_0x7ff9('0x2c')][_0x7ff9('0x2d')]};});_0x1263d4['model']=_[_0x7ff9('0x28')](_0x314423,_0x7ff9('0x26'));_0x1263d4['query']=_[_0x7ff9('0x2e')](_0x210c01[_0x7ff9('0x2f')]);_0x1263d4[_0x7ff9('0x30')]=_[_0x7ff9('0x31')](_0x1263d4[_0x7ff9('0x32')],_0x1263d4[_0x7ff9('0x2f')]);_0x46781a[_0x7ff9('0x33')]=_['intersection'](_0x1263d4[_0x7ff9('0x32')],qs['fields'](_0x210c01[_0x7ff9('0x2f')][_0x7ff9('0x34')]));_0x46781a[_0x7ff9('0x33')]=_0x46781a[_0x7ff9('0x33')]['length']?_0x46781a[_0x7ff9('0x33')]:_0x1263d4[_0x7ff9('0x32')];if(!_0x210c01[_0x7ff9('0x2f')][_0x7ff9('0x35')](_0x7ff9('0x36'))){_0x46781a[_0x7ff9('0x1d')]=qs['limit'](_0x210c01[_0x7ff9('0x2f')]['limit']);_0x46781a[_0x7ff9('0x1b')]=qs[_0x7ff9('0x1b')](_0x210c01[_0x7ff9('0x2f')][_0x7ff9('0x1b')]);}_0x46781a[_0x7ff9('0x37')]=qs[_0x7ff9('0x38')](_0x210c01[_0x7ff9('0x2f')][_0x7ff9('0x38')]);_0x46781a['where']=qs['filters'](_[_0x7ff9('0x39')](_0x210c01[_0x7ff9('0x2f')],_0x1263d4[_0x7ff9('0x30')]),_0x314423);if(_0x210c01['query'][_0x7ff9('0x3a')]){_0x46781a[_0x7ff9('0x3b')]=_['merge'](_0x46781a[_0x7ff9('0x3b')],{'$or':_[_0x7ff9('0x28')](_0x314423,function(_0x2e49ae){if(_0x2e49ae[_0x7ff9('0x2c')]!==_0x7ff9('0x3c')){var _0x38cf06={};_0x38cf06[_0x2e49ae[_0x7ff9('0x26')]]={'$like':'%'+_0x210c01[_0x7ff9('0x2f')]['filter']+'%'};return _0x38cf06;}})});}_0x46781a=_[_0x7ff9('0x3d')]({},_0x46781a,_0x210c01[_0x7ff9('0x3e')]);var _0x3a9988={'where':_0x46781a[_0x7ff9('0x3b')]};return db[_0x7ff9('0x29')][_0x7ff9('0x1e')](_0x3a9988)[_0x7ff9('0x22')](function(_0x4ea2a5){_0x7daa7[_0x7ff9('0x1e')]=_0x4ea2a5;if(_0x210c01[_0x7ff9('0x2f')]['includeAll']){_0x46781a['include']=[{'all':!![]}];}return db[_0x7ff9('0x29')]['findAll'](_0x46781a);})[_0x7ff9('0x22')](function(_0x462f16){_0x7daa7['rows']=_0x462f16;return _0x7daa7;})[_0x7ff9('0x22')](respondWithFilteredResult(_0x20ea39,_0x46781a))[_0x7ff9('0x3f')](handleError(_0x20ea39,null));};exports['show']=function(_0x3bb3da,_0x1c6796){var _0x12682d={'raw':![],'where':{'id':_0x3bb3da['params']['id']}},_0x22638a={};_0x22638a['model']=_[_0x7ff9('0x2e')](db[_0x7ff9('0x29')][_0x7ff9('0x2a')]);_0x22638a[_0x7ff9('0x2f')]=_[_0x7ff9('0x2e')](_0x3bb3da[_0x7ff9('0x2f')]);_0x22638a[_0x7ff9('0x30')]=_[_0x7ff9('0x31')](_0x22638a[_0x7ff9('0x32')],_0x22638a[_0x7ff9('0x2f')]);_0x12682d[_0x7ff9('0x33')]=_[_0x7ff9('0x31')](_0x22638a[_0x7ff9('0x32')],qs[_0x7ff9('0x34')](_0x3bb3da['query'][_0x7ff9('0x34')]));_0x12682d[_0x7ff9('0x33')]=_0x12682d['attributes'][_0x7ff9('0x40')]?_0x12682d['attributes']:_0x22638a[_0x7ff9('0x32')];if(_0x3bb3da[_0x7ff9('0x2f')][_0x7ff9('0x41')]){_0x12682d[_0x7ff9('0x42')]=[{'all':!![]}];}_0x12682d=_['merge']({},_0x12682d,_0x3bb3da[_0x7ff9('0x3e')]);return db['FreshdeskConfiguration'][_0x7ff9('0x43')](_0x12682d)[_0x7ff9('0x22')](handleEntityNotFound(_0x1c6796,null))[_0x7ff9('0x22')](respondWithResult(_0x1c6796,null))[_0x7ff9('0x3f')](handleError(_0x1c6796,null));};exports[_0x7ff9('0x44')]=function(_0x391553,_0x5d53cd){return db['FreshdeskConfiguration'][_0x7ff9('0x44')](_0x391553[_0x7ff9('0x45')],{})[_0x7ff9('0x22')](respondWithResult(_0x5d53cd,0xc9))[_0x7ff9('0x3f')](handleError(_0x5d53cd,null));};exports['update']=function(_0x4d0653,_0x1ccdbb){if(_0x4d0653[_0x7ff9('0x45')]['id']){delete _0x4d0653[_0x7ff9('0x45')]['id'];}return db['FreshdeskConfiguration']['find']({'where':{'id':_0x4d0653[_0x7ff9('0x46')]['id']}})[_0x7ff9('0x22')](handleEntityNotFound(_0x1ccdbb,null))[_0x7ff9('0x22')](saveUpdates(_0x4d0653[_0x7ff9('0x45')],null))[_0x7ff9('0x22')](respondWithResult(_0x1ccdbb,null))[_0x7ff9('0x3f')](handleError(_0x1ccdbb,null));};exports['destroy']=function(_0x354cb9,_0x4c0191){return db[_0x7ff9('0x29')][_0x7ff9('0x43')]({'where':{'id':_0x354cb9['params']['id']}})[_0x7ff9('0x22')](handleEntityNotFound(_0x4c0191,null))[_0x7ff9('0x22')](removeEntity(_0x4c0191,null))[_0x7ff9('0x3f')](handleError(_0x4c0191,null));};exports['getFields']=function(_0x3fa56e,_0x328c86,_0x5cedd8){var _0xaba2ca={};var _0x5dad13={};var _0x13b9ee;var _0x518417;return db[_0x7ff9('0x29')][_0x7ff9('0x47')]({'where':{'id':_0x3fa56e[_0x7ff9('0x46')]['id']}})[_0x7ff9('0x22')](handleEntityNotFound(_0x328c86,null))['then'](function(_0x3dcaac){if(_0x3dcaac){_0x13b9ee=_0x3dcaac;_0x5dad13[_0x7ff9('0x32')]=_[_0x7ff9('0x2e')](db[_0x7ff9('0x48')][_0x7ff9('0x2a')]);_0x5dad13[_0x7ff9('0x2f')]=_['keys'](_0x3fa56e[_0x7ff9('0x2f')]);_0x5dad13[_0x7ff9('0x30')]=_[_0x7ff9('0x31')](_0x5dad13[_0x7ff9('0x32')],_0x5dad13[_0x7ff9('0x2f')]);_0xaba2ca[_0x7ff9('0x33')]=_['intersection'](_0x5dad13[_0x7ff9('0x32')],qs[_0x7ff9('0x34')](_0x3fa56e[_0x7ff9('0x2f')][_0x7ff9('0x34')]));_0xaba2ca[_0x7ff9('0x33')]=_0xaba2ca[_0x7ff9('0x33')][_0x7ff9('0x40')]?_0xaba2ca[_0x7ff9('0x33')]:_0x5dad13[_0x7ff9('0x32')];_0xaba2ca[_0x7ff9('0x37')]=qs['sort'](_0x3fa56e[_0x7ff9('0x2f')]['sort']);_0xaba2ca['where']=qs[_0x7ff9('0x30')](_[_0x7ff9('0x39')](_0x3fa56e[_0x7ff9('0x2f')],_0x5dad13[_0x7ff9('0x30')]));if(_0x3fa56e['query'][_0x7ff9('0x3a')]){_0xaba2ca[_0x7ff9('0x3b')]=_[_0x7ff9('0x3d')](_0xaba2ca['where'],{'$or':_[_0x7ff9('0x28')](_0xaba2ca['attributes'],function(_0x187a59){var _0x527785={};_0x527785[_0x187a59]={'$like':'%'+_0x3fa56e[_0x7ff9('0x2f')][_0x7ff9('0x3a')]+'%'};return _0x527785;})});}_0xaba2ca=_[_0x7ff9('0x3d')]({},_0xaba2ca,_0x3fa56e[_0x7ff9('0x3e')]);return _0x13b9ee['getFields'](_0xaba2ca);}})[_0x7ff9('0x22')](function(_0x47f2af){if(_0x47f2af){_0x518417=_0x47f2af[_0x7ff9('0x40')];if(!_0x3fa56e[_0x7ff9('0x2f')]['hasOwnProperty'](_0x7ff9('0x36'))){_0xaba2ca[_0x7ff9('0x1d')]=qs['limit'](_0x3fa56e[_0x7ff9('0x2f')][_0x7ff9('0x1d')]);_0xaba2ca[_0x7ff9('0x1b')]=qs[_0x7ff9('0x1b')](_0x3fa56e[_0x7ff9('0x2f')][_0x7ff9('0x1b')]);}return _0x13b9ee[_0x7ff9('0x49')](_0xaba2ca);}})[_0x7ff9('0x22')](function(_0x9ec9fd){if(_0x9ec9fd){return _0x9ec9fd?{'count':_0x518417,'rows':_0x9ec9fd}:null;}})['then'](respondWithResult(_0x328c86,null))[_0x7ff9('0x3f')](handleError(_0x328c86,null));};exports[_0x7ff9('0x4a')]=function(_0x5b76de,_0x3e6e91,_0x6f571f){var _0x559036={};var _0x42d806={};var _0x278602;var _0x4c0998;return db[_0x7ff9('0x29')][_0x7ff9('0x47')]({'where':{'id':_0x5b76de[_0x7ff9('0x46')]['id']}})[_0x7ff9('0x22')](handleEntityNotFound(_0x3e6e91,null))[_0x7ff9('0x22')](function(_0xe97022){if(_0xe97022){_0x278602=_0xe97022;_0x42d806['model']=_[_0x7ff9('0x2e')](db[_0x7ff9('0x48')]['rawAttributes']);_0x42d806[_0x7ff9('0x2f')]=_[_0x7ff9('0x2e')](_0x5b76de[_0x7ff9('0x2f')]);_0x42d806[_0x7ff9('0x30')]=_[_0x7ff9('0x31')](_0x42d806['model'],_0x42d806[_0x7ff9('0x2f')]);_0x559036[_0x7ff9('0x33')]=_[_0x7ff9('0x31')](_0x42d806[_0x7ff9('0x32')],qs['fields'](_0x5b76de[_0x7ff9('0x2f')]['fields']));_0x559036['attributes']=_0x559036['attributes'][_0x7ff9('0x40')]?_0x559036[_0x7ff9('0x33')]:_0x42d806[_0x7ff9('0x32')];_0x559036[_0x7ff9('0x37')]=qs[_0x7ff9('0x38')](_0x5b76de['query'][_0x7ff9('0x38')]);_0x559036[_0x7ff9('0x3b')]=qs[_0x7ff9('0x30')](_[_0x7ff9('0x39')](_0x5b76de[_0x7ff9('0x2f')],_0x42d806['filters']));if(_0x5b76de['query'][_0x7ff9('0x3a')]){_0x559036['where']=_[_0x7ff9('0x3d')](_0x559036[_0x7ff9('0x3b')],{'$or':_[_0x7ff9('0x28')](_0x559036[_0x7ff9('0x33')],function(_0x7ed052){var _0x8306a0={};_0x8306a0[_0x7ed052]={'$like':'%'+_0x5b76de[_0x7ff9('0x2f')][_0x7ff9('0x3a')]+'%'};return _0x8306a0;})});}_0x559036=_[_0x7ff9('0x3d')]({},_0x559036,_0x5b76de[_0x7ff9('0x3e')]);return _0x278602[_0x7ff9('0x4a')](_0x559036);}})[_0x7ff9('0x22')](function(_0xbb11e1){if(_0xbb11e1){_0x4c0998=_0xbb11e1[_0x7ff9('0x40')];if(!_0x5b76de[_0x7ff9('0x2f')][_0x7ff9('0x35')](_0x7ff9('0x36'))){_0x559036[_0x7ff9('0x1d')]=qs['limit'](_0x5b76de['query'][_0x7ff9('0x1d')]);_0x559036[_0x7ff9('0x1b')]=qs[_0x7ff9('0x1b')](_0x5b76de[_0x7ff9('0x2f')][_0x7ff9('0x1b')]);}return _0x278602[_0x7ff9('0x4a')](_0x559036);}})[_0x7ff9('0x22')](function(_0x3806ef){if(_0x3806ef){return _0x3806ef?{'count':_0x4c0998,'rows':_0x3806ef}:null;}})[_0x7ff9('0x22')](respondWithResult(_0x3e6e91,null))[_0x7ff9('0x3f')](handleError(_0x3e6e91,null));};exports['getDescriptions']=function(_0x582492,_0x2b51d,_0x3232e2){var _0x22fa17={};var _0x5ba38a={};var _0x2319db;var _0x5552a4;return db['FreshdeskConfiguration'][_0x7ff9('0x47')]({'where':{'id':_0x582492[_0x7ff9('0x46')]['id']}})[_0x7ff9('0x22')](handleEntityNotFound(_0x2b51d,null))[_0x7ff9('0x22')](function(_0x3fb950){if(_0x3fb950){_0x2319db=_0x3fb950;_0x5ba38a[_0x7ff9('0x32')]=_[_0x7ff9('0x2e')](db['FreshdeskField'][_0x7ff9('0x2a')]);_0x5ba38a[_0x7ff9('0x2f')]=_[_0x7ff9('0x2e')](_0x582492[_0x7ff9('0x2f')]);_0x5ba38a[_0x7ff9('0x30')]=_[_0x7ff9('0x31')](_0x5ba38a[_0x7ff9('0x32')],_0x5ba38a[_0x7ff9('0x2f')]);_0x22fa17[_0x7ff9('0x33')]=_[_0x7ff9('0x31')](_0x5ba38a[_0x7ff9('0x32')],qs[_0x7ff9('0x34')](_0x582492['query']['fields']));_0x22fa17['attributes']=_0x22fa17[_0x7ff9('0x33')][_0x7ff9('0x40')]?_0x22fa17['attributes']:_0x5ba38a[_0x7ff9('0x32')];_0x22fa17[_0x7ff9('0x37')]=qs[_0x7ff9('0x38')](_0x582492['query']['sort']);_0x22fa17['where']=qs['filters'](_[_0x7ff9('0x39')](_0x582492[_0x7ff9('0x2f')],_0x5ba38a['filters']));if(_0x582492[_0x7ff9('0x2f')]['filter']){_0x22fa17[_0x7ff9('0x3b')]=_['merge'](_0x22fa17[_0x7ff9('0x3b')],{'$or':_[_0x7ff9('0x28')](_0x22fa17['attributes'],function(_0x1b0a00){var _0x48d02f={};_0x48d02f[_0x1b0a00]={'$like':'%'+_0x582492[_0x7ff9('0x2f')][_0x7ff9('0x3a')]+'%'};return _0x48d02f;})});}_0x22fa17=_['merge']({},_0x22fa17,_0x582492[_0x7ff9('0x3e')]);return _0x2319db[_0x7ff9('0x4b')](_0x22fa17);}})['then'](function(_0x1b14cd){if(_0x1b14cd){_0x5552a4=_0x1b14cd[_0x7ff9('0x40')];if(!_0x582492['query'][_0x7ff9('0x35')](_0x7ff9('0x36'))){_0x22fa17[_0x7ff9('0x1d')]=qs[_0x7ff9('0x1d')](_0x582492[_0x7ff9('0x2f')]['limit']);_0x22fa17['offset']=qs[_0x7ff9('0x1b')](_0x582492[_0x7ff9('0x2f')]['offset']);}return _0x2319db[_0x7ff9('0x4b')](_0x22fa17);}})[_0x7ff9('0x22')](function(_0x3cebaa){if(_0x3cebaa){return _0x3cebaa?{'count':_0x5552a4,'rows':_0x3cebaa}:null;}})[_0x7ff9('0x22')](respondWithResult(_0x2b51d,null))[_0x7ff9('0x3f')](handleError(_0x2b51d,null));};exports[_0x7ff9('0x4c')]=function(_0x42e41d,_0x1d1fb2,_0x53da03){var _0x5dc7e7={};var _0x1a5cfb={};var _0x19ee2b;var _0x533f3a;return db[_0x7ff9('0x29')][_0x7ff9('0x47')]({'where':{'id':_0x42e41d[_0x7ff9('0x46')]['id']}})[_0x7ff9('0x22')](handleEntityNotFound(_0x1d1fb2,null))[_0x7ff9('0x22')](function(_0x15bb8a){if(_0x15bb8a){_0x19ee2b=_0x15bb8a;_0x1a5cfb[_0x7ff9('0x32')]=_['keys'](db[_0x7ff9('0x4d')][_0x7ff9('0x2a')]);_0x1a5cfb['query']=_[_0x7ff9('0x2e')](_0x42e41d[_0x7ff9('0x2f')]);_0x1a5cfb['filters']=_[_0x7ff9('0x31')](_0x1a5cfb[_0x7ff9('0x32')],_0x1a5cfb[_0x7ff9('0x2f')]);_0x5dc7e7[_0x7ff9('0x33')]=_[_0x7ff9('0x31')](_0x1a5cfb[_0x7ff9('0x32')],qs[_0x7ff9('0x34')](_0x42e41d[_0x7ff9('0x2f')][_0x7ff9('0x34')]));_0x5dc7e7[_0x7ff9('0x33')]=_0x5dc7e7[_0x7ff9('0x33')][_0x7ff9('0x40')]?_0x5dc7e7[_0x7ff9('0x33')]:_0x1a5cfb[_0x7ff9('0x32')];_0x5dc7e7[_0x7ff9('0x37')]=qs[_0x7ff9('0x38')](_0x42e41d[_0x7ff9('0x2f')][_0x7ff9('0x38')]);_0x5dc7e7[_0x7ff9('0x3b')]=qs['filters'](_['pick'](_0x42e41d[_0x7ff9('0x2f')],_0x1a5cfb[_0x7ff9('0x30')]));if(_0x42e41d[_0x7ff9('0x2f')][_0x7ff9('0x3a')]){_0x5dc7e7[_0x7ff9('0x3b')]=_['merge'](_0x5dc7e7['where'],{'$or':_['map'](_0x5dc7e7[_0x7ff9('0x33')],function(_0x11b1d6){var _0x8215bb={};_0x8215bb[_0x11b1d6]={'$like':'%'+_0x42e41d['query'][_0x7ff9('0x3a')]+'%'};return _0x8215bb;})});}_0x5dc7e7=_['merge']({},_0x5dc7e7,_0x42e41d['options']);return _0x19ee2b['getTags'](_0x5dc7e7);}})['then'](function(_0x4597ab){if(_0x4597ab){_0x533f3a=_0x4597ab[_0x7ff9('0x40')];if(!_0x42e41d['query'][_0x7ff9('0x35')](_0x7ff9('0x36'))){_0x5dc7e7[_0x7ff9('0x1d')]=qs[_0x7ff9('0x1d')](_0x42e41d['query']['limit']);_0x5dc7e7[_0x7ff9('0x1b')]=qs[_0x7ff9('0x1b')](_0x42e41d[_0x7ff9('0x2f')][_0x7ff9('0x1b')]);}return _0x19ee2b[_0x7ff9('0x4c')](_0x5dc7e7);}})['then'](function(_0x27cf7d){if(_0x27cf7d){return _0x27cf7d?{'count':_0x533f3a,'rows':_0x27cf7d}:null;}})[_0x7ff9('0x22')](respondWithResult(_0x1d1fb2,null))[_0x7ff9('0x3f')](handleError(_0x1d1fb2,null));};exports[_0x7ff9('0x4e')]=function(_0xbb2b9a,_0x1ef077,_0xe56115){if(_0xbb2b9a['body']['id']){delete _0xbb2b9a[_0x7ff9('0x45')]['id'];}return db[_0x7ff9('0x29')][_0x7ff9('0x47')]({'where':{'id':_0xbb2b9a[_0x7ff9('0x46')]['id']}})['then'](handleEntityNotFound(_0x1ef077,null))['then'](function(_0x59a912){if(_0x59a912){return _0x59a912[_0x7ff9('0x4e')](_0xbb2b9a[_0x7ff9('0x45')][_0x7ff9('0x4f')]||[]);}return null;})['then'](respondWithResult(_0x1ef077,null))['catch'](handleError(_0x1ef077,null));};
\ No newline at end of file