Built motion from commit 449495f6.|2.6.27
[motion2.git] / server / api / intFreshdeskConfiguration / intFreshdeskConfiguration.controller.js
index 7e10e08..ed891df 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x49f7=['sort','where','pick','filter','merge','options','includeAll','include','show','params','find','create','body','getFields','findOne','FreshdeskField','getSubjects','rawAttributes','getDescriptions','getTags','Tag','setTags','html-pdf','eml-format','zip-dir','fast-json-patch','moment','bluebird','util','path','sox','to-csv','lodash','crypto','jsforce','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','FreshdeskConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshdeskConfiguration,\x20%s,\x20%s,\x20%s','error','code','message','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','stack','name','send','index','map','FreshdeskConfiguration','fieldName','type','key','query','keys','filters','attributes','intersection','fields','length','model','hasOwnProperty','nolimit','order'];(function(_0x482214,_0x2550ff){var _0x38d0cb=function(_0x2ba281){while(--_0x2ba281){_0x482214['push'](_0x482214['shift']());}};_0x38d0cb(++_0x2550ff);}(_0x49f7,0xc8));var _0x749f=function(_0x3a57ac,_0x74a56a){_0x3a57ac=_0x3a57ac-0x0;var _0x3a7b1e=_0x49f7[_0x3a57ac];return _0x3a7b1e;};'use strict';var pdf=require(_0x749f('0x0'));var emlformat=require(_0x749f('0x1'));var rimraf=require('rimraf');var zipdir=require(_0x749f('0x2'));var jsonpatch=require(_0x749f('0x3'));var rp=require('request-promise');var moment=require(_0x749f('0x4'));var BPromise=require(_0x749f('0x5'));var Mustache=require('mustache');var util=require(_0x749f('0x6'));var path=require(_0x749f('0x7'));var sox=require(_0x749f('0x8'));var csv=require(_0x749f('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x749f('0xa'));var squel=require('squel');var crypto=require(_0x749f('0xb'));var jsforce=require(_0x749f('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x749f('0x9'));var querystring=require('querystring');var Papa=require(_0x749f('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x749f('0xe'));var as=require(_0x749f('0xf'));var hardwareService=require(_0x749f('0x10'));var logger=require(_0x749f('0x11'))('api');var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x749f('0x12'));var db=require(_0x749f('0x13'))['db'];var jayson=require(_0x749f('0x14'));var client=jayson[_0x749f('0x15')][_0x749f('0x16')]({'port':0x232a});function respondWithRpcPromise(_0x47b4ca,_0x38af07,_0x10c644,_0x38da37){return new BPromise(function(_0x40f977,_0x4f3b51){var _0x221171=_0x38da37||client;return _0x221171[_0x749f('0x17')](_0x47b4ca,_0x10c644)[_0x749f('0x18')](function(_0x8b4648){logger['info'](_0x749f('0x19'),_0x38af07,_0x749f('0x1a'));logger[_0x749f('0x1b')](_0x749f('0x1c'),_0x38af07,_0x749f('0x1a'),JSON['stringify'](_0x8b4648));if(_0x8b4648[_0x749f('0x1d')]){if(_0x8b4648[_0x749f('0x1d')][_0x749f('0x1e')]===0x1f4){logger[_0x749f('0x1d')](_0x749f('0x19'),_0x38af07,_0x8b4648[_0x749f('0x1d')][_0x749f('0x1f')]);return _0x4f3b51(_0x8b4648[_0x749f('0x1d')][_0x749f('0x1f')]);}logger[_0x749f('0x1d')](_0x749f('0x19'),_0x38af07,_0x8b4648[_0x749f('0x1d')]['message']);return _0x40f977(_0x8b4648[_0x749f('0x1d')][_0x749f('0x1f')]);}else{logger['info'](_0x749f('0x19'),_0x38af07,_0x749f('0x1a'));_0x40f977(_0x8b4648['result'][_0x749f('0x1f')]);}})[_0x749f('0x20')](function(_0x5efe94){logger[_0x749f('0x1d')](_0x749f('0x19'),_0x38af07,_0x5efe94);_0x4f3b51(_0x5efe94);});});}function respondWithStatusCode(_0x22d18b,_0x564975){_0x564975=_0x564975||0xcc;return function(_0x2ec86e){if(_0x2ec86e){return _0x22d18b[_0x749f('0x21')](_0x564975);}return _0x22d18b[_0x749f('0x22')](_0x564975)[_0x749f('0x23')]();};}function respondWithResult(_0x594ed7,_0x7bf4b0){_0x7bf4b0=_0x7bf4b0||0xc8;return function(_0x44ca8e){if(_0x44ca8e){return _0x594ed7[_0x749f('0x22')](_0x7bf4b0)[_0x749f('0x24')](_0x44ca8e);}};}function respondWithFilteredResult(_0x3fc8ed,_0x4604e4){return function(_0x216031){if(_0x216031){var _0x5b4e96=_0x216031[_0x749f('0x25')],_0x829b0d=_0x4604e4[_0x749f('0x26')],_0x21a238=_0x4604e4['offset']+_0x4604e4[_0x749f('0x27')],_0x503c2d;if(_0x21a238>=_0x5b4e96){_0x21a238=_0x5b4e96;_0x503c2d=0xc8;}else{_0x503c2d=0xce;}_0x3fc8ed[_0x749f('0x22')](_0x503c2d);return _0x3fc8ed[_0x749f('0x28')](_0x749f('0x29'),_0x829b0d+'-'+_0x21a238+'/'+_0x5b4e96)[_0x749f('0x24')](_0x216031);}return null;};}function patchUpdates(_0x9c7a83){return function(_0x3bcba7){try{jsonpatch[_0x749f('0x2a')](_0x3bcba7,_0x9c7a83,!![]);}catch(_0xdc252){return BPromise[_0x749f('0x2b')](_0xdc252);}return _0x3bcba7[_0x749f('0x2c')]();};}function saveUpdates(_0x1092e7,_0x3a07ab){return function(_0x1b3681){if(_0x1b3681){return _0x1b3681[_0x749f('0x2d')](_0x1092e7)[_0x749f('0x18')](function(_0x2610c3){return _0x2610c3;});}return null;};}function removeEntity(_0x2473a9,_0x263ab4){return function(_0x398bab){if(_0x398bab){return _0x398bab[_0x749f('0x2e')]()[_0x749f('0x18')](function(){_0x2473a9[_0x749f('0x22')](0xcc)[_0x749f('0x23')]();});}};}function handleEntityNotFound(_0x5d7d60,_0x21c7c6){return function(_0x5c5759){if(!_0x5c5759){_0x5d7d60[_0x749f('0x21')](0x194);}return _0x5c5759;};}function handleError(_0x202c7e,_0x303715){_0x303715=_0x303715||0x1f4;return function(_0x48e252){logger[_0x749f('0x1d')](_0x48e252[_0x749f('0x2f')]);if(_0x48e252[_0x749f('0x30')]){delete _0x48e252[_0x749f('0x30')];}_0x202c7e[_0x749f('0x22')](_0x303715)[_0x749f('0x31')](_0x48e252);};}exports[_0x749f('0x32')]=function(_0x3a6ec8,_0x2342d4){var _0x3ce5da={},_0x20321e={},_0x472c6f={'count':0x0,'rows':[]};var _0x1c2bba=_[_0x749f('0x33')](db[_0x749f('0x34')]['rawAttributes'],function(_0x477360){return{'name':_0x477360[_0x749f('0x35')],'type':_0x477360[_0x749f('0x36')][_0x749f('0x37')]};});_0x20321e['model']=_[_0x749f('0x33')](_0x1c2bba,_0x749f('0x30'));_0x20321e[_0x749f('0x38')]=_[_0x749f('0x39')](_0x3a6ec8[_0x749f('0x38')]);_0x20321e[_0x749f('0x3a')]=_['intersection'](_0x20321e['model'],_0x20321e[_0x749f('0x38')]);_0x3ce5da[_0x749f('0x3b')]=_[_0x749f('0x3c')](_0x20321e['model'],qs[_0x749f('0x3d')](_0x3a6ec8[_0x749f('0x38')][_0x749f('0x3d')]));_0x3ce5da[_0x749f('0x3b')]=_0x3ce5da[_0x749f('0x3b')][_0x749f('0x3e')]?_0x3ce5da[_0x749f('0x3b')]:_0x20321e[_0x749f('0x3f')];if(!_0x3a6ec8[_0x749f('0x38')][_0x749f('0x40')](_0x749f('0x41'))){_0x3ce5da[_0x749f('0x27')]=qs[_0x749f('0x27')](_0x3a6ec8['query']['limit']);_0x3ce5da['offset']=qs[_0x749f('0x26')](_0x3a6ec8['query'][_0x749f('0x26')]);}_0x3ce5da[_0x749f('0x42')]=qs[_0x749f('0x43')](_0x3a6ec8[_0x749f('0x38')][_0x749f('0x43')]);_0x3ce5da[_0x749f('0x44')]=qs[_0x749f('0x3a')](_[_0x749f('0x45')](_0x3a6ec8[_0x749f('0x38')],_0x20321e[_0x749f('0x3a')]),_0x1c2bba);if(_0x3a6ec8[_0x749f('0x38')][_0x749f('0x46')]){_0x3ce5da[_0x749f('0x44')]=_['merge'](_0x3ce5da[_0x749f('0x44')],{'$or':_[_0x749f('0x33')](_0x1c2bba,function(_0x3bec11){if(_0x3bec11[_0x749f('0x36')]!=='VIRTUAL'){var _0x58a906={};_0x58a906[_0x3bec11[_0x749f('0x30')]]={'$like':'%'+_0x3a6ec8[_0x749f('0x38')][_0x749f('0x46')]+'%'};return _0x58a906;}})});}_0x3ce5da=_[_0x749f('0x47')]({},_0x3ce5da,_0x3a6ec8[_0x749f('0x48')]);var _0x4794ab={'where':_0x3ce5da[_0x749f('0x44')]};return db['FreshdeskConfiguration'][_0x749f('0x25')](_0x4794ab)['then'](function(_0xf0b0fa){_0x472c6f[_0x749f('0x25')]=_0xf0b0fa;if(_0x3a6ec8['query'][_0x749f('0x49')]){_0x3ce5da[_0x749f('0x4a')]=[{'all':!![]}];}return db[_0x749f('0x34')]['findAll'](_0x3ce5da);})[_0x749f('0x18')](function(_0x6ba739){_0x472c6f['rows']=_0x6ba739;return _0x472c6f;})['then'](respondWithFilteredResult(_0x2342d4,_0x3ce5da))['catch'](handleError(_0x2342d4,null));};exports[_0x749f('0x4b')]=function(_0x423d4b,_0x175e33){var _0xd75f5={'raw':![],'where':{'id':_0x423d4b[_0x749f('0x4c')]['id']}},_0x103cd0={};_0x103cd0['model']=_[_0x749f('0x39')](db[_0x749f('0x34')]['rawAttributes']);_0x103cd0[_0x749f('0x38')]=_[_0x749f('0x39')](_0x423d4b['query']);_0x103cd0['filters']=_[_0x749f('0x3c')](_0x103cd0[_0x749f('0x3f')],_0x103cd0['query']);_0xd75f5['attributes']=_[_0x749f('0x3c')](_0x103cd0[_0x749f('0x3f')],qs[_0x749f('0x3d')](_0x423d4b[_0x749f('0x38')]['fields']));_0xd75f5[_0x749f('0x3b')]=_0xd75f5[_0x749f('0x3b')][_0x749f('0x3e')]?_0xd75f5[_0x749f('0x3b')]:_0x103cd0['model'];if(_0x423d4b[_0x749f('0x38')][_0x749f('0x49')]){_0xd75f5[_0x749f('0x4a')]=[{'all':!![]}];}_0xd75f5=_[_0x749f('0x47')]({},_0xd75f5,_0x423d4b['options']);return db['FreshdeskConfiguration'][_0x749f('0x4d')](_0xd75f5)[_0x749f('0x18')](handleEntityNotFound(_0x175e33,null))[_0x749f('0x18')](respondWithResult(_0x175e33,null))[_0x749f('0x20')](handleError(_0x175e33,null));};exports[_0x749f('0x4e')]=function(_0x1470ba,_0x283fd2){return db['FreshdeskConfiguration'][_0x749f('0x4e')](_0x1470ba[_0x749f('0x4f')],{})['then'](respondWithResult(_0x283fd2,0xc9))[_0x749f('0x20')](handleError(_0x283fd2,null));};exports[_0x749f('0x2d')]=function(_0x2159d3,_0x24f0f6){if(_0x2159d3[_0x749f('0x4f')]['id']){delete _0x2159d3[_0x749f('0x4f')]['id'];}return db[_0x749f('0x34')]['find']({'where':{'id':_0x2159d3[_0x749f('0x4c')]['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x24f0f6,null))[_0x749f('0x18')](saveUpdates(_0x2159d3[_0x749f('0x4f')],null))[_0x749f('0x18')](respondWithResult(_0x24f0f6,null))[_0x749f('0x20')](handleError(_0x24f0f6,null));};exports[_0x749f('0x2e')]=function(_0x525cab,_0x58dd2c){return db[_0x749f('0x34')][_0x749f('0x4d')]({'where':{'id':_0x525cab['params']['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x58dd2c,null))[_0x749f('0x18')](removeEntity(_0x58dd2c,null))[_0x749f('0x20')](handleError(_0x58dd2c,null));};exports[_0x749f('0x50')]=function(_0x4f7d04,_0x4fa359,_0x4f80dd){var _0x2a1758={};var _0x17d9ee={};var _0x1d2c62;var _0x1cf238;return db['FreshdeskConfiguration'][_0x749f('0x51')]({'where':{'id':_0x4f7d04[_0x749f('0x4c')]['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x4fa359,null))[_0x749f('0x18')](function(_0x1babb3){if(_0x1babb3){_0x1d2c62=_0x1babb3;_0x17d9ee[_0x749f('0x3f')]=_[_0x749f('0x39')](db[_0x749f('0x52')]['rawAttributes']);_0x17d9ee['query']=_['keys'](_0x4f7d04[_0x749f('0x38')]);_0x17d9ee[_0x749f('0x3a')]=_[_0x749f('0x3c')](_0x17d9ee['model'],_0x17d9ee[_0x749f('0x38')]);_0x2a1758[_0x749f('0x3b')]=_[_0x749f('0x3c')](_0x17d9ee[_0x749f('0x3f')],qs[_0x749f('0x3d')](_0x4f7d04[_0x749f('0x38')]['fields']));_0x2a1758[_0x749f('0x3b')]=_0x2a1758['attributes']['length']?_0x2a1758[_0x749f('0x3b')]:_0x17d9ee[_0x749f('0x3f')];_0x2a1758[_0x749f('0x42')]=qs[_0x749f('0x43')](_0x4f7d04[_0x749f('0x38')][_0x749f('0x43')]);_0x2a1758['where']=qs[_0x749f('0x3a')](_[_0x749f('0x45')](_0x4f7d04[_0x749f('0x38')],_0x17d9ee[_0x749f('0x3a')]));if(_0x4f7d04[_0x749f('0x38')][_0x749f('0x46')]){_0x2a1758[_0x749f('0x44')]=_[_0x749f('0x47')](_0x2a1758['where'],{'$or':_[_0x749f('0x33')](_0x2a1758['attributes'],function(_0x12f586){var _0x56ad75={};_0x56ad75[_0x12f586]={'$like':'%'+_0x4f7d04['query'][_0x749f('0x46')]+'%'};return _0x56ad75;})});}_0x2a1758=_[_0x749f('0x47')]({},_0x2a1758,_0x4f7d04[_0x749f('0x48')]);return _0x1d2c62[_0x749f('0x50')](_0x2a1758);}})[_0x749f('0x18')](function(_0x28d14d){if(_0x28d14d){_0x1cf238=_0x28d14d['length'];if(!_0x4f7d04[_0x749f('0x38')]['hasOwnProperty'](_0x749f('0x41'))){_0x2a1758[_0x749f('0x27')]=qs[_0x749f('0x27')](_0x4f7d04[_0x749f('0x38')][_0x749f('0x27')]);_0x2a1758[_0x749f('0x26')]=qs[_0x749f('0x26')](_0x4f7d04[_0x749f('0x38')][_0x749f('0x26')]);}return _0x1d2c62['getFields'](_0x2a1758);}})[_0x749f('0x18')](function(_0x126539){if(_0x126539){return _0x126539?{'count':_0x1cf238,'rows':_0x126539}:null;}})['then'](respondWithResult(_0x4fa359,null))[_0x749f('0x20')](handleError(_0x4fa359,null));};exports[_0x749f('0x53')]=function(_0x558bf0,_0x1065e5,_0x17e8d6){var _0x549365={};var _0x3e885f={};var _0x5d3a36;var _0x442a19;return db[_0x749f('0x34')][_0x749f('0x51')]({'where':{'id':_0x558bf0[_0x749f('0x4c')]['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x1065e5,null))['then'](function(_0x4e2586){if(_0x4e2586){_0x5d3a36=_0x4e2586;_0x3e885f[_0x749f('0x3f')]=_['keys'](db[_0x749f('0x52')][_0x749f('0x54')]);_0x3e885f['query']=_[_0x749f('0x39')](_0x558bf0['query']);_0x3e885f[_0x749f('0x3a')]=_['intersection'](_0x3e885f[_0x749f('0x3f')],_0x3e885f[_0x749f('0x38')]);_0x549365[_0x749f('0x3b')]=_[_0x749f('0x3c')](_0x3e885f['model'],qs[_0x749f('0x3d')](_0x558bf0[_0x749f('0x38')]['fields']));_0x549365[_0x749f('0x3b')]=_0x549365['attributes']['length']?_0x549365[_0x749f('0x3b')]:_0x3e885f[_0x749f('0x3f')];_0x549365[_0x749f('0x42')]=qs[_0x749f('0x43')](_0x558bf0[_0x749f('0x38')][_0x749f('0x43')]);_0x549365[_0x749f('0x44')]=qs['filters'](_[_0x749f('0x45')](_0x558bf0[_0x749f('0x38')],_0x3e885f[_0x749f('0x3a')]));if(_0x558bf0['query'][_0x749f('0x46')]){_0x549365[_0x749f('0x44')]=_['merge'](_0x549365[_0x749f('0x44')],{'$or':_[_0x749f('0x33')](_0x549365['attributes'],function(_0x5786fe){var _0x478129={};_0x478129[_0x5786fe]={'$like':'%'+_0x558bf0['query'][_0x749f('0x46')]+'%'};return _0x478129;})});}_0x549365=_[_0x749f('0x47')]({},_0x549365,_0x558bf0['options']);return _0x5d3a36['getSubjects'](_0x549365);}})[_0x749f('0x18')](function(_0x8db849){if(_0x8db849){_0x442a19=_0x8db849[_0x749f('0x3e')];if(!_0x558bf0[_0x749f('0x38')]['hasOwnProperty'](_0x749f('0x41'))){_0x549365['limit']=qs[_0x749f('0x27')](_0x558bf0[_0x749f('0x38')]['limit']);_0x549365['offset']=qs['offset'](_0x558bf0['query']['offset']);}return _0x5d3a36[_0x749f('0x53')](_0x549365);}})['then'](function(_0x538325){if(_0x538325){return _0x538325?{'count':_0x442a19,'rows':_0x538325}:null;}})[_0x749f('0x18')](respondWithResult(_0x1065e5,null))[_0x749f('0x20')](handleError(_0x1065e5,null));};exports[_0x749f('0x55')]=function(_0x5c1bb5,_0x4b5823,_0xa23b90){var _0x4ae932={};var _0x1482bf={};var _0x36b653;var _0x4b4b79;return db['FreshdeskConfiguration'][_0x749f('0x51')]({'where':{'id':_0x5c1bb5['params']['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x4b5823,null))['then'](function(_0x5b7cca){if(_0x5b7cca){_0x36b653=_0x5b7cca;_0x1482bf[_0x749f('0x3f')]=_['keys'](db[_0x749f('0x52')][_0x749f('0x54')]);_0x1482bf[_0x749f('0x38')]=_[_0x749f('0x39')](_0x5c1bb5[_0x749f('0x38')]);_0x1482bf[_0x749f('0x3a')]=_[_0x749f('0x3c')](_0x1482bf['model'],_0x1482bf['query']);_0x4ae932['attributes']=_['intersection'](_0x1482bf[_0x749f('0x3f')],qs[_0x749f('0x3d')](_0x5c1bb5[_0x749f('0x38')][_0x749f('0x3d')]));_0x4ae932['attributes']=_0x4ae932['attributes'][_0x749f('0x3e')]?_0x4ae932[_0x749f('0x3b')]:_0x1482bf[_0x749f('0x3f')];_0x4ae932[_0x749f('0x42')]=qs[_0x749f('0x43')](_0x5c1bb5[_0x749f('0x38')]['sort']);_0x4ae932[_0x749f('0x44')]=qs['filters'](_[_0x749f('0x45')](_0x5c1bb5[_0x749f('0x38')],_0x1482bf[_0x749f('0x3a')]));if(_0x5c1bb5[_0x749f('0x38')][_0x749f('0x46')]){_0x4ae932[_0x749f('0x44')]=_['merge'](_0x4ae932[_0x749f('0x44')],{'$or':_[_0x749f('0x33')](_0x4ae932['attributes'],function(_0x583b43){var _0x40d8cd={};_0x40d8cd[_0x583b43]={'$like':'%'+_0x5c1bb5[_0x749f('0x38')][_0x749f('0x46')]+'%'};return _0x40d8cd;})});}_0x4ae932=_[_0x749f('0x47')]({},_0x4ae932,_0x5c1bb5[_0x749f('0x48')]);return _0x36b653[_0x749f('0x55')](_0x4ae932);}})[_0x749f('0x18')](function(_0x1f472a){if(_0x1f472a){_0x4b4b79=_0x1f472a[_0x749f('0x3e')];if(!_0x5c1bb5[_0x749f('0x38')]['hasOwnProperty'](_0x749f('0x41'))){_0x4ae932[_0x749f('0x27')]=qs[_0x749f('0x27')](_0x5c1bb5[_0x749f('0x38')][_0x749f('0x27')]);_0x4ae932[_0x749f('0x26')]=qs[_0x749f('0x26')](_0x5c1bb5[_0x749f('0x38')]['offset']);}return _0x36b653[_0x749f('0x55')](_0x4ae932);}})[_0x749f('0x18')](function(_0x43767a){if(_0x43767a){return _0x43767a?{'count':_0x4b4b79,'rows':_0x43767a}:null;}})[_0x749f('0x18')](respondWithResult(_0x4b5823,null))['catch'](handleError(_0x4b5823,null));};exports[_0x749f('0x56')]=function(_0x4d8003,_0x3108d9,_0x1ae578){var _0x21134d={};var _0x1475ed={};var _0xc2f55f;var _0x1cca24;return db[_0x749f('0x34')]['findOne']({'where':{'id':_0x4d8003[_0x749f('0x4c')]['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x3108d9,null))[_0x749f('0x18')](function(_0x414f17){if(_0x414f17){_0xc2f55f=_0x414f17;_0x1475ed[_0x749f('0x3f')]=_[_0x749f('0x39')](db[_0x749f('0x57')][_0x749f('0x54')]);_0x1475ed['query']=_[_0x749f('0x39')](_0x4d8003[_0x749f('0x38')]);_0x1475ed[_0x749f('0x3a')]=_[_0x749f('0x3c')](_0x1475ed[_0x749f('0x3f')],_0x1475ed[_0x749f('0x38')]);_0x21134d[_0x749f('0x3b')]=_[_0x749f('0x3c')](_0x1475ed[_0x749f('0x3f')],qs[_0x749f('0x3d')](_0x4d8003['query'][_0x749f('0x3d')]));_0x21134d[_0x749f('0x3b')]=_0x21134d[_0x749f('0x3b')][_0x749f('0x3e')]?_0x21134d[_0x749f('0x3b')]:_0x1475ed[_0x749f('0x3f')];_0x21134d['order']=qs[_0x749f('0x43')](_0x4d8003[_0x749f('0x38')][_0x749f('0x43')]);_0x21134d['where']=qs[_0x749f('0x3a')](_[_0x749f('0x45')](_0x4d8003[_0x749f('0x38')],_0x1475ed[_0x749f('0x3a')]));if(_0x4d8003[_0x749f('0x38')]['filter']){_0x21134d[_0x749f('0x44')]=_['merge'](_0x21134d['where'],{'$or':_[_0x749f('0x33')](_0x21134d[_0x749f('0x3b')],function(_0x2e31b4){var _0x279257={};_0x279257[_0x2e31b4]={'$like':'%'+_0x4d8003[_0x749f('0x38')][_0x749f('0x46')]+'%'};return _0x279257;})});}_0x21134d=_['merge']({},_0x21134d,_0x4d8003[_0x749f('0x48')]);return _0xc2f55f[_0x749f('0x56')](_0x21134d);}})[_0x749f('0x18')](function(_0x233b57){if(_0x233b57){_0x1cca24=_0x233b57['length'];if(!_0x4d8003['query'][_0x749f('0x40')]('nolimit')){_0x21134d['limit']=qs['limit'](_0x4d8003['query'][_0x749f('0x27')]);_0x21134d['offset']=qs[_0x749f('0x26')](_0x4d8003[_0x749f('0x38')][_0x749f('0x26')]);}return _0xc2f55f['getTags'](_0x21134d);}})[_0x749f('0x18')](function(_0x2fbcae){if(_0x2fbcae){return _0x2fbcae?{'count':_0x1cca24,'rows':_0x2fbcae}:null;}})[_0x749f('0x18')](respondWithResult(_0x3108d9,null))[_0x749f('0x20')](handleError(_0x3108d9,null));};exports[_0x749f('0x58')]=function(_0x67bf5a,_0x3b61f4,_0x49c164){if(_0x67bf5a[_0x749f('0x4f')]['id']){delete _0x67bf5a[_0x749f('0x4f')]['id'];}return db[_0x749f('0x34')][_0x749f('0x51')]({'where':{'id':_0x67bf5a['params']['id']}})[_0x749f('0x18')](handleEntityNotFound(_0x3b61f4,null))[_0x749f('0x18')](function(_0x358456){if(_0x358456){return _0x358456[_0x749f('0x58')](_0x67bf5a[_0x749f('0x4f')]['ids']||[]);}return null;})[_0x749f('0x18')](respondWithResult(_0x3b61f4,null))[_0x749f('0x20')](handleError(_0x3b61f4,null));};
\ No newline at end of file
+var _0x1757=['../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','save','then','destroy','error','name','send','index','map','FreshdeskConfiguration','rawAttributes','fieldName','type','key','model','query','filters','attributes','fields','length','hasOwnProperty','nolimit','order','where','pick','filter','options','include','findAll','rows','show','params','keys','intersection','includeAll','find','create','body','catch','update','getFields','FreshdeskField','sort','merge','getSubjects','findOne','getDescriptions','getTags','Tag','setTags','ids','zip-dir','fast-json-patch','bluebird','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x1757,0x90));var _0x7175=function(_0xd22061,_0x1c30d1){_0xd22061=_0xd22061-0x0;var _0x22037e=_0x1757[_0xd22061];return _0x22037e;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x7175('0x0'));var jsonpatch=require(_0x7175('0x1'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0x7175('0x2'));var Mustache=require('mustache');var util=require(_0x7175('0x3'));var path=require('path');var sox=require(_0x7175('0x4'));var csv=require(_0x7175('0x5'));var ejs=require(_0x7175('0x6'));var fs=require('fs');var fs_extra=require(_0x7175('0x7'));var _=require('lodash');var squel=require(_0x7175('0x8'));var crypto=require(_0x7175('0x9'));var jsforce=require(_0x7175('0xa'));var deskjs=require(_0x7175('0xb'));var toCsv=require('to-csv');var querystring=require(_0x7175('0xc'));var Papa=require(_0x7175('0xd'));var Redis=require(_0x7175('0xe'));var authService=require(_0x7175('0xf'));var qs=require(_0x7175('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require(_0x7175('0x11'))(_0x7175('0x12'));var utils=require(_0x7175('0x13'));var config=require(_0x7175('0x14'));var licenseUtil=require(_0x7175('0x15'));var db=require(_0x7175('0x16'))['db'];function respondWithStatusCode(_0x2e223a,_0x51da34){_0x51da34=_0x51da34||0xcc;return function(_0x470807){if(_0x470807){return _0x2e223a[_0x7175('0x17')](_0x51da34);}return _0x2e223a[_0x7175('0x18')](_0x51da34)[_0x7175('0x19')]();};}function respondWithResult(_0x39ff4b,_0x2a5f3d){_0x2a5f3d=_0x2a5f3d||0xc8;return function(_0xc0abc5){if(_0xc0abc5){return _0x39ff4b[_0x7175('0x18')](_0x2a5f3d)[_0x7175('0x1a')](_0xc0abc5);}};}function respondWithFilteredResult(_0x2cfe55,_0x1cfe27){return function(_0x15554a){if(_0x15554a){var _0x3f3858=typeof _0x1cfe27[_0x7175('0x1b')]===_0x7175('0x1c')&&typeof _0x1cfe27[_0x7175('0x1d')]===_0x7175('0x1c');var _0x36004c=_0x15554a[_0x7175('0x1e')];var _0x50ab1b=_0x3f3858?0x0:_0x1cfe27[_0x7175('0x1b')];var _0x572526=_0x3f3858?_0x15554a[_0x7175('0x1e')]:_0x1cfe27[_0x7175('0x1b')]+_0x1cfe27[_0x7175('0x1d')];var _0xa7f88e;if(_0x572526>=_0x36004c){_0x572526=_0x36004c;_0xa7f88e=0xc8;}else{_0xa7f88e=0xce;}_0x2cfe55[_0x7175('0x18')](_0xa7f88e);return _0x2cfe55[_0x7175('0x1f')](_0x7175('0x20'),_0x50ab1b+'-'+_0x572526+'/'+_0x36004c)['json'](_0x15554a);}return null;};}function patchUpdates(_0x3eb5df){return function(_0x2e4b77){try{jsonpatch['apply'](_0x2e4b77,_0x3eb5df,!![]);}catch(_0x49dfc2){return BPromise['reject'](_0x49dfc2);}return _0x2e4b77[_0x7175('0x21')]();};}function saveUpdates(_0x461589,_0x4f8578){return function(_0x2a8a3a){if(_0x2a8a3a){return _0x2a8a3a['update'](_0x461589)[_0x7175('0x22')](function(_0x2975ff){return _0x2975ff;});}return null;};}function removeEntity(_0x563e09,_0x29c64f){return function(_0x472347){if(_0x472347){return _0x472347[_0x7175('0x23')]()[_0x7175('0x22')](function(){_0x563e09[_0x7175('0x18')](0xcc)[_0x7175('0x19')]();});}};}function handleEntityNotFound(_0x5f0095,_0xcc87b5){return function(_0x3df712){if(!_0x3df712){_0x5f0095[_0x7175('0x17')](0x194);}return _0x3df712;};}function handleError(_0x40275a,_0x1abdee){_0x1abdee=_0x1abdee||0x1f4;return function(_0x48b799){logger[_0x7175('0x24')](_0x48b799['stack']);if(_0x48b799[_0x7175('0x25')]){delete _0x48b799[_0x7175('0x25')];}_0x40275a['status'](_0x1abdee)[_0x7175('0x26')](_0x48b799);};}exports[_0x7175('0x27')]=function(_0x3fb5e5,_0x253642){var _0x4f459a={},_0x5af9a9={},_0xa6e8a0={'count':0x0,'rows':[]};var _0x8b8c68=_[_0x7175('0x28')](db[_0x7175('0x29')][_0x7175('0x2a')],function(_0x37f84e){return{'name':_0x37f84e[_0x7175('0x2b')],'type':_0x37f84e[_0x7175('0x2c')][_0x7175('0x2d')]};});_0x5af9a9[_0x7175('0x2e')]=_[_0x7175('0x28')](_0x8b8c68,_0x7175('0x25'));_0x5af9a9[_0x7175('0x2f')]=_['keys'](_0x3fb5e5[_0x7175('0x2f')]);_0x5af9a9[_0x7175('0x30')]=_['intersection'](_0x5af9a9[_0x7175('0x2e')],_0x5af9a9[_0x7175('0x2f')]);_0x4f459a[_0x7175('0x31')]=_['intersection'](_0x5af9a9['model'],qs[_0x7175('0x32')](_0x3fb5e5['query'][_0x7175('0x32')]));_0x4f459a['attributes']=_0x4f459a[_0x7175('0x31')][_0x7175('0x33')]?_0x4f459a[_0x7175('0x31')]:_0x5af9a9[_0x7175('0x2e')];if(!_0x3fb5e5[_0x7175('0x2f')][_0x7175('0x34')](_0x7175('0x35'))){_0x4f459a[_0x7175('0x1d')]=qs[_0x7175('0x1d')](_0x3fb5e5[_0x7175('0x2f')][_0x7175('0x1d')]);_0x4f459a[_0x7175('0x1b')]=qs[_0x7175('0x1b')](_0x3fb5e5[_0x7175('0x2f')][_0x7175('0x1b')]);}_0x4f459a[_0x7175('0x36')]=qs['sort'](_0x3fb5e5[_0x7175('0x2f')]['sort']);_0x4f459a[_0x7175('0x37')]=qs[_0x7175('0x30')](_[_0x7175('0x38')](_0x3fb5e5['query'],_0x5af9a9[_0x7175('0x30')]),_0x8b8c68);if(_0x3fb5e5['query'][_0x7175('0x39')]){_0x4f459a[_0x7175('0x37')]=_['merge'](_0x4f459a['where'],{'$or':_[_0x7175('0x28')](_0x8b8c68,function(_0xd77928){if(_0xd77928['type']!=='VIRTUAL'){var _0x4ef43c={};_0x4ef43c[_0xd77928[_0x7175('0x25')]]={'$like':'%'+_0x3fb5e5[_0x7175('0x2f')][_0x7175('0x39')]+'%'};return _0x4ef43c;}})});}_0x4f459a=_['merge']({},_0x4f459a,_0x3fb5e5[_0x7175('0x3a')]);var _0x460bae={'where':_0x4f459a[_0x7175('0x37')]};return db[_0x7175('0x29')][_0x7175('0x1e')](_0x460bae)[_0x7175('0x22')](function(_0xaf00a2){_0xa6e8a0['count']=_0xaf00a2;if(_0x3fb5e5[_0x7175('0x2f')]['includeAll']){_0x4f459a[_0x7175('0x3b')]=[{'all':!![]}];}return db['FreshdeskConfiguration'][_0x7175('0x3c')](_0x4f459a);})[_0x7175('0x22')](function(_0x517274){_0xa6e8a0[_0x7175('0x3d')]=_0x517274;return _0xa6e8a0;})[_0x7175('0x22')](respondWithFilteredResult(_0x253642,_0x4f459a))['catch'](handleError(_0x253642,null));};exports[_0x7175('0x3e')]=function(_0x28cb20,_0x3f1d5b){var _0x6dd36a={'raw':![],'where':{'id':_0x28cb20[_0x7175('0x3f')]['id']}},_0x42a710={};_0x42a710[_0x7175('0x2e')]=_[_0x7175('0x40')](db['FreshdeskConfiguration'][_0x7175('0x2a')]);_0x42a710[_0x7175('0x2f')]=_[_0x7175('0x40')](_0x28cb20['query']);_0x42a710['filters']=_[_0x7175('0x41')](_0x42a710['model'],_0x42a710[_0x7175('0x2f')]);_0x6dd36a[_0x7175('0x31')]=_['intersection'](_0x42a710[_0x7175('0x2e')],qs['fields'](_0x28cb20['query'][_0x7175('0x32')]));_0x6dd36a[_0x7175('0x31')]=_0x6dd36a[_0x7175('0x31')][_0x7175('0x33')]?_0x6dd36a['attributes']:_0x42a710[_0x7175('0x2e')];if(_0x28cb20[_0x7175('0x2f')][_0x7175('0x42')]){_0x6dd36a[_0x7175('0x3b')]=[{'all':!![]}];}_0x6dd36a=_['merge']({},_0x6dd36a,_0x28cb20[_0x7175('0x3a')]);return db[_0x7175('0x29')][_0x7175('0x43')](_0x6dd36a)['then'](handleEntityNotFound(_0x3f1d5b,null))[_0x7175('0x22')](respondWithResult(_0x3f1d5b,null))['catch'](handleError(_0x3f1d5b,null));};exports[_0x7175('0x44')]=function(_0x3729cc,_0x153c0b){return db['FreshdeskConfiguration'][_0x7175('0x44')](_0x3729cc[_0x7175('0x45')],{})[_0x7175('0x22')](respondWithResult(_0x153c0b,0xc9))[_0x7175('0x46')](handleError(_0x153c0b,null));};exports[_0x7175('0x47')]=function(_0x38429b,_0xd49d18){if(_0x38429b[_0x7175('0x45')]['id']){delete _0x38429b[_0x7175('0x45')]['id'];}return db[_0x7175('0x29')][_0x7175('0x43')]({'where':{'id':_0x38429b['params']['id']}})[_0x7175('0x22')](handleEntityNotFound(_0xd49d18,null))[_0x7175('0x22')](saveUpdates(_0x38429b[_0x7175('0x45')],null))[_0x7175('0x22')](respondWithResult(_0xd49d18,null))[_0x7175('0x46')](handleError(_0xd49d18,null));};exports[_0x7175('0x23')]=function(_0x168ce6,_0x18855f){return db[_0x7175('0x29')]['find']({'where':{'id':_0x168ce6[_0x7175('0x3f')]['id']}})['then'](handleEntityNotFound(_0x18855f,null))[_0x7175('0x22')](removeEntity(_0x18855f,null))[_0x7175('0x46')](handleError(_0x18855f,null));};exports[_0x7175('0x48')]=function(_0x359d7f,_0x464f8a,_0x3e57c8){var _0x30dbbe={};var _0x1f4eb3={};var _0x5d7062;var _0x4fecea;return db[_0x7175('0x29')]['findOne']({'where':{'id':_0x359d7f[_0x7175('0x3f')]['id']}})[_0x7175('0x22')](handleEntityNotFound(_0x464f8a,null))[_0x7175('0x22')](function(_0x3d0ece){if(_0x3d0ece){_0x5d7062=_0x3d0ece;_0x1f4eb3[_0x7175('0x2e')]=_[_0x7175('0x40')](db[_0x7175('0x49')][_0x7175('0x2a')]);_0x1f4eb3[_0x7175('0x2f')]=_['keys'](_0x359d7f[_0x7175('0x2f')]);_0x1f4eb3['filters']=_['intersection'](_0x1f4eb3['model'],_0x1f4eb3[_0x7175('0x2f')]);_0x30dbbe[_0x7175('0x31')]=_[_0x7175('0x41')](_0x1f4eb3[_0x7175('0x2e')],qs[_0x7175('0x32')](_0x359d7f[_0x7175('0x2f')]['fields']));_0x30dbbe[_0x7175('0x31')]=_0x30dbbe[_0x7175('0x31')][_0x7175('0x33')]?_0x30dbbe[_0x7175('0x31')]:_0x1f4eb3[_0x7175('0x2e')];_0x30dbbe[_0x7175('0x36')]=qs['sort'](_0x359d7f[_0x7175('0x2f')][_0x7175('0x4a')]);_0x30dbbe[_0x7175('0x37')]=qs['filters'](_[_0x7175('0x38')](_0x359d7f[_0x7175('0x2f')],_0x1f4eb3[_0x7175('0x30')]));if(_0x359d7f[_0x7175('0x2f')][_0x7175('0x39')]){_0x30dbbe['where']=_[_0x7175('0x4b')](_0x30dbbe[_0x7175('0x37')],{'$or':_[_0x7175('0x28')](_0x30dbbe[_0x7175('0x31')],function(_0x1c6378){var _0x4071d2={};_0x4071d2[_0x1c6378]={'$like':'%'+_0x359d7f[_0x7175('0x2f')][_0x7175('0x39')]+'%'};return _0x4071d2;})});}_0x30dbbe=_[_0x7175('0x4b')]({},_0x30dbbe,_0x359d7f[_0x7175('0x3a')]);return _0x5d7062['getFields'](_0x30dbbe);}})[_0x7175('0x22')](function(_0x4cbb73){if(_0x4cbb73){_0x4fecea=_0x4cbb73[_0x7175('0x33')];if(!_0x359d7f[_0x7175('0x2f')][_0x7175('0x34')]('nolimit')){_0x30dbbe[_0x7175('0x1d')]=qs[_0x7175('0x1d')](_0x359d7f['query'][_0x7175('0x1d')]);_0x30dbbe['offset']=qs[_0x7175('0x1b')](_0x359d7f[_0x7175('0x2f')][_0x7175('0x1b')]);}return _0x5d7062[_0x7175('0x48')](_0x30dbbe);}})[_0x7175('0x22')](function(_0x5383d8){if(_0x5383d8){return _0x5383d8?{'count':_0x4fecea,'rows':_0x5383d8}:null;}})['then'](respondWithResult(_0x464f8a,null))[_0x7175('0x46')](handleError(_0x464f8a,null));};exports[_0x7175('0x4c')]=function(_0x540fe0,_0x3b04b7,_0xb7f636){var _0x596507={};var _0x55c5e5={};var _0x1f2fcb;var _0x20e1f9;return db[_0x7175('0x29')][_0x7175('0x4d')]({'where':{'id':_0x540fe0[_0x7175('0x3f')]['id']}})[_0x7175('0x22')](handleEntityNotFound(_0x3b04b7,null))[_0x7175('0x22')](function(_0x64c84d){if(_0x64c84d){_0x1f2fcb=_0x64c84d;_0x55c5e5[_0x7175('0x2e')]=_[_0x7175('0x40')](db[_0x7175('0x49')][_0x7175('0x2a')]);_0x55c5e5[_0x7175('0x2f')]=_[_0x7175('0x40')](_0x540fe0[_0x7175('0x2f')]);_0x55c5e5[_0x7175('0x30')]=_[_0x7175('0x41')](_0x55c5e5['model'],_0x55c5e5[_0x7175('0x2f')]);_0x596507[_0x7175('0x31')]=_[_0x7175('0x41')](_0x55c5e5[_0x7175('0x2e')],qs[_0x7175('0x32')](_0x540fe0['query'][_0x7175('0x32')]));_0x596507[_0x7175('0x31')]=_0x596507[_0x7175('0x31')]['length']?_0x596507[_0x7175('0x31')]:_0x55c5e5[_0x7175('0x2e')];_0x596507['order']=qs[_0x7175('0x4a')](_0x540fe0['query'][_0x7175('0x4a')]);_0x596507[_0x7175('0x37')]=qs[_0x7175('0x30')](_['pick'](_0x540fe0[_0x7175('0x2f')],_0x55c5e5[_0x7175('0x30')]));if(_0x540fe0[_0x7175('0x2f')][_0x7175('0x39')]){_0x596507[_0x7175('0x37')]=_[_0x7175('0x4b')](_0x596507[_0x7175('0x37')],{'$or':_[_0x7175('0x28')](_0x596507['attributes'],function(_0x187059){var _0xc18182={};_0xc18182[_0x187059]={'$like':'%'+_0x540fe0[_0x7175('0x2f')][_0x7175('0x39')]+'%'};return _0xc18182;})});}_0x596507=_[_0x7175('0x4b')]({},_0x596507,_0x540fe0[_0x7175('0x3a')]);return _0x1f2fcb['getSubjects'](_0x596507);}})[_0x7175('0x22')](function(_0x3aebac){if(_0x3aebac){_0x20e1f9=_0x3aebac[_0x7175('0x33')];if(!_0x540fe0['query']['hasOwnProperty']('nolimit')){_0x596507[_0x7175('0x1d')]=qs['limit'](_0x540fe0[_0x7175('0x2f')]['limit']);_0x596507[_0x7175('0x1b')]=qs[_0x7175('0x1b')](_0x540fe0[_0x7175('0x2f')][_0x7175('0x1b')]);}return _0x1f2fcb[_0x7175('0x4c')](_0x596507);}})[_0x7175('0x22')](function(_0x1b262e){if(_0x1b262e){return _0x1b262e?{'count':_0x20e1f9,'rows':_0x1b262e}:null;}})['then'](respondWithResult(_0x3b04b7,null))['catch'](handleError(_0x3b04b7,null));};exports['getDescriptions']=function(_0x547635,_0x3bc3a4,_0x166672){var _0x12a97e={};var _0x3380c7={};var _0x55dac4;var _0x2ff496;return db[_0x7175('0x29')]['findOne']({'where':{'id':_0x547635['params']['id']}})[_0x7175('0x22')](handleEntityNotFound(_0x3bc3a4,null))[_0x7175('0x22')](function(_0x4a11a3){if(_0x4a11a3){_0x55dac4=_0x4a11a3;_0x3380c7['model']=_[_0x7175('0x40')](db[_0x7175('0x49')]['rawAttributes']);_0x3380c7[_0x7175('0x2f')]=_[_0x7175('0x40')](_0x547635[_0x7175('0x2f')]);_0x3380c7['filters']=_[_0x7175('0x41')](_0x3380c7[_0x7175('0x2e')],_0x3380c7[_0x7175('0x2f')]);_0x12a97e[_0x7175('0x31')]=_[_0x7175('0x41')](_0x3380c7[_0x7175('0x2e')],qs['fields'](_0x547635['query'][_0x7175('0x32')]));_0x12a97e[_0x7175('0x31')]=_0x12a97e['attributes'][_0x7175('0x33')]?_0x12a97e['attributes']:_0x3380c7['model'];_0x12a97e[_0x7175('0x36')]=qs[_0x7175('0x4a')](_0x547635[_0x7175('0x2f')][_0x7175('0x4a')]);_0x12a97e[_0x7175('0x37')]=qs['filters'](_[_0x7175('0x38')](_0x547635[_0x7175('0x2f')],_0x3380c7[_0x7175('0x30')]));if(_0x547635['query'][_0x7175('0x39')]){_0x12a97e[_0x7175('0x37')]=_[_0x7175('0x4b')](_0x12a97e['where'],{'$or':_[_0x7175('0x28')](_0x12a97e[_0x7175('0x31')],function(_0x566dd4){var _0x5898ed={};_0x5898ed[_0x566dd4]={'$like':'%'+_0x547635['query'][_0x7175('0x39')]+'%'};return _0x5898ed;})});}_0x12a97e=_[_0x7175('0x4b')]({},_0x12a97e,_0x547635['options']);return _0x55dac4[_0x7175('0x4e')](_0x12a97e);}})[_0x7175('0x22')](function(_0x2a2d5f){if(_0x2a2d5f){_0x2ff496=_0x2a2d5f[_0x7175('0x33')];if(!_0x547635['query'][_0x7175('0x34')]('nolimit')){_0x12a97e['limit']=qs['limit'](_0x547635[_0x7175('0x2f')][_0x7175('0x1d')]);_0x12a97e['offset']=qs['offset'](_0x547635[_0x7175('0x2f')][_0x7175('0x1b')]);}return _0x55dac4[_0x7175('0x4e')](_0x12a97e);}})[_0x7175('0x22')](function(_0x35ff94){if(_0x35ff94){return _0x35ff94?{'count':_0x2ff496,'rows':_0x35ff94}:null;}})[_0x7175('0x22')](respondWithResult(_0x3bc3a4,null))[_0x7175('0x46')](handleError(_0x3bc3a4,null));};exports[_0x7175('0x4f')]=function(_0x1c7667,_0x2541e3,_0x1c714b){var _0x2263d1={};var _0x437d39={};var _0x176f64;var _0x4e0059;return db[_0x7175('0x29')]['findOne']({'where':{'id':_0x1c7667[_0x7175('0x3f')]['id']}})[_0x7175('0x22')](handleEntityNotFound(_0x2541e3,null))['then'](function(_0x22bd4a){if(_0x22bd4a){_0x176f64=_0x22bd4a;_0x437d39[_0x7175('0x2e')]=_[_0x7175('0x40')](db[_0x7175('0x50')][_0x7175('0x2a')]);_0x437d39[_0x7175('0x2f')]=_['keys'](_0x1c7667[_0x7175('0x2f')]);_0x437d39[_0x7175('0x30')]=_[_0x7175('0x41')](_0x437d39[_0x7175('0x2e')],_0x437d39[_0x7175('0x2f')]);_0x2263d1[_0x7175('0x31')]=_['intersection'](_0x437d39[_0x7175('0x2e')],qs[_0x7175('0x32')](_0x1c7667[_0x7175('0x2f')][_0x7175('0x32')]));_0x2263d1[_0x7175('0x31')]=_0x2263d1[_0x7175('0x31')][_0x7175('0x33')]?_0x2263d1[_0x7175('0x31')]:_0x437d39[_0x7175('0x2e')];_0x2263d1[_0x7175('0x36')]=qs['sort'](_0x1c7667[_0x7175('0x2f')][_0x7175('0x4a')]);_0x2263d1[_0x7175('0x37')]=qs[_0x7175('0x30')](_['pick'](_0x1c7667[_0x7175('0x2f')],_0x437d39['filters']));if(_0x1c7667[_0x7175('0x2f')][_0x7175('0x39')]){_0x2263d1['where']=_[_0x7175('0x4b')](_0x2263d1[_0x7175('0x37')],{'$or':_[_0x7175('0x28')](_0x2263d1[_0x7175('0x31')],function(_0x590e23){var _0x57882d={};_0x57882d[_0x590e23]={'$like':'%'+_0x1c7667['query']['filter']+'%'};return _0x57882d;})});}_0x2263d1=_['merge']({},_0x2263d1,_0x1c7667['options']);return _0x176f64[_0x7175('0x4f')](_0x2263d1);}})[_0x7175('0x22')](function(_0x454e1d){if(_0x454e1d){_0x4e0059=_0x454e1d[_0x7175('0x33')];if(!_0x1c7667['query']['hasOwnProperty'](_0x7175('0x35'))){_0x2263d1[_0x7175('0x1d')]=qs[_0x7175('0x1d')](_0x1c7667[_0x7175('0x2f')][_0x7175('0x1d')]);_0x2263d1[_0x7175('0x1b')]=qs[_0x7175('0x1b')](_0x1c7667[_0x7175('0x2f')][_0x7175('0x1b')]);}return _0x176f64[_0x7175('0x4f')](_0x2263d1);}})['then'](function(_0x22f444){if(_0x22f444){return _0x22f444?{'count':_0x4e0059,'rows':_0x22f444}:null;}})[_0x7175('0x22')](respondWithResult(_0x2541e3,null))['catch'](handleError(_0x2541e3,null));};exports[_0x7175('0x51')]=function(_0x43d4d1,_0x1be3e9,_0x431215){if(_0x43d4d1[_0x7175('0x45')]['id']){delete _0x43d4d1[_0x7175('0x45')]['id'];}return db['FreshdeskConfiguration'][_0x7175('0x4d')]({'where':{'id':_0x43d4d1[_0x7175('0x3f')]['id']}})['then'](handleEntityNotFound(_0x1be3e9,null))[_0x7175('0x22')](function(_0x372ad1){if(_0x372ad1){return _0x372ad1['setTags'](_0x43d4d1['body'][_0x7175('0x52')]||[]);}return null;})[_0x7175('0x22')](respondWithResult(_0x1be3e9,null))[_0x7175('0x46')](handleError(_0x1be3e9,null));};
\ No newline at end of file