Built motion from commit b5413ace.|2.6.9
[motion2.git] / server / api / intFreshdeskConfiguration / intFreshdeskConfiguration.controller.js
index 4423e73..362b6cf 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x210b=['error','message','result','catch','sendStatus','status','end','limit','set','Content-Range','json','apply','reject','update','destroy','stack','name','send','index','map','FreshdeskConfiguration','rawAttributes','fieldName','key','model','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','offset','order','sort','pick','filter','merge','where','type','VIRTUAL','options','count','include','rows','params','keys','includeAll','find','create','body','FreshdeskField','getFields','getSubjects','findOne','getDescriptions','getTags','setTags','ids','eml-format','rimraf','fast-json-patch','request-promise','moment','mustache','path','to-csv','ejs','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../mysqldb','jayson/promise','client','http','test','Sequelize','ValidationError','request','then','info','FreshdeskConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshdeskConfiguration,\x20%s,\x20%s,\x20%s','stringify'];(function(_0x4b2436,_0x452299){var _0x4f5ab2=function(_0x5c6679){while(--_0x5c6679){_0x4b2436['push'](_0x4b2436['shift']());}};_0x4f5ab2(++_0x452299);}(_0x210b,0xfa));var _0xb210=function(_0x18a436,_0x1dbe06){_0x18a436=_0x18a436-0x0;var _0x5c2cf8=_0x210b[_0x18a436];return _0x5c2cf8;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xb210('0x0'));var rimraf=require(_0xb210('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb210('0x2'));var rp=require(_0xb210('0x3'));var moment=require(_0xb210('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xb210('0x5'));var util=require('util');var path=require(_0xb210('0x6'));var sox=require('sox');var csv=require(_0xb210('0x7'));var ejs=require(_0xb210('0x8'));var fs=require('fs');var _=require('lodash');var squel=require(_0xb210('0x9'));var crypto=require(_0xb210('0xa'));var jsforce=require(_0xb210('0xb'));var deskjs=require(_0xb210('0xc'));var toCsv=require(_0xb210('0x7'));var querystring=require(_0xb210('0xd'));var Papa=require(_0xb210('0xe'));var Redis=require(_0xb210('0xf'));var authService=require(_0xb210('0x10'));var qs=require(_0xb210('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xb210('0x12'));var utils=require(_0xb210('0x13'));var config=require('../../config/environment');var db=require(_0xb210('0x14'))['db'];var jayson=require(_0xb210('0x15'));var client=jayson[_0xb210('0x16')][_0xb210('0x17')]({'port':0x232a});function checkPasswordPattern(_0x4c2707,_0x189d4b,_0x395a74){if(_0x395a74){var _0x1ae717=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x1ae717[_0xb210('0x18')](_0x189d4b)){return _0x4c2707;}else{throw new db[(_0xb210('0x19'))][(_0xb210('0x1a'))]('The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.');}}else{return _0x4c2707;}}function respondWithRpcPromise(_0x5b6e38,_0x3725a6,_0x4eafc1,_0x3a1898){return new BPromise(function(_0x12000a,_0x21c1db){var _0x15871d=_0x3a1898||client;return _0x15871d[_0xb210('0x1b')](_0x5b6e38,_0x4eafc1)[_0xb210('0x1c')](function(_0x25245c){logger[_0xb210('0x1d')](_0xb210('0x1e'),_0x3725a6,_0xb210('0x1f'));logger[_0xb210('0x20')](_0xb210('0x21'),_0x3725a6,'request\x20sent',JSON[_0xb210('0x22')](_0x25245c));if(_0x25245c[_0xb210('0x23')]){if(_0x25245c['error']['code']===0x1f4){logger[_0xb210('0x23')](_0xb210('0x1e'),_0x3725a6,_0x25245c[_0xb210('0x23')]['message']);return _0x21c1db(_0x25245c[_0xb210('0x23')][_0xb210('0x24')]);}logger['error'](_0xb210('0x1e'),_0x3725a6,_0x25245c[_0xb210('0x23')][_0xb210('0x24')]);return _0x12000a(_0x25245c[_0xb210('0x23')][_0xb210('0x24')]);}else{logger[_0xb210('0x1d')](_0xb210('0x1e'),_0x3725a6,_0xb210('0x1f'));_0x12000a(_0x25245c[_0xb210('0x25')]['message']);}})[_0xb210('0x26')](function(_0x4cf5fb){logger['error'](_0xb210('0x1e'),_0x3725a6,_0x4cf5fb);_0x21c1db(_0x4cf5fb);});});}function respondWithStatusCode(_0x1c28c4,_0x48e195){_0x48e195=_0x48e195||0xcc;return function(_0x3d7e28){if(_0x3d7e28){return _0x1c28c4[_0xb210('0x27')](_0x48e195);}return _0x1c28c4[_0xb210('0x28')](_0x48e195)[_0xb210('0x29')]();};}function respondWithResult(_0x4bb10b,_0x1da3d5){_0x1da3d5=_0x1da3d5||0xc8;return function(_0x4ac5b0){if(_0x4ac5b0){return _0x4bb10b[_0xb210('0x28')](_0x1da3d5)['json'](_0x4ac5b0);}};}function respondWithFilteredResult(_0x47ac43,_0x1a700f){return function(_0x23d449){if(_0x23d449){var _0x282535=_0x23d449['count'],_0x4a61a0=_0x1a700f['offset'],_0xaa89f2=_0x1a700f['offset']+_0x1a700f[_0xb210('0x2a')],_0x154558;if(_0xaa89f2>=_0x282535){_0xaa89f2=_0x282535;_0x154558=0xc8;}else{_0x154558=0xce;}_0x47ac43[_0xb210('0x28')](_0x154558);return _0x47ac43[_0xb210('0x2b')](_0xb210('0x2c'),_0x4a61a0+'-'+_0xaa89f2+'/'+_0x282535)[_0xb210('0x2d')](_0x23d449);}return null;};}function patchUpdates(_0x59d17c){return function(_0x44a384){try{jsonpatch[_0xb210('0x2e')](_0x44a384,_0x59d17c,!![]);}catch(_0x1b4c03){return BPromise[_0xb210('0x2f')](_0x1b4c03);}return _0x44a384['save']();};}function saveUpdates(_0x109369,_0x46572f){return function(_0x31d847){if(_0x31d847){return _0x31d847[_0xb210('0x30')](_0x109369)['then'](function(_0x1407c4){return _0x1407c4;});}return null;};}function removeEntity(_0x3ff072,_0x585146){return function(_0x430f41){if(_0x430f41){return _0x430f41[_0xb210('0x31')]()['then'](function(){_0x3ff072[_0xb210('0x28')](0xcc)[_0xb210('0x29')]();});}};}function handleEntityNotFound(_0x36fc5a,_0x5650fa){return function(_0x14a45d){if(!_0x14a45d){_0x36fc5a[_0xb210('0x27')](0x194);}return _0x14a45d;};}function handleError(_0x1c203a,_0x3bfac3){_0x3bfac3=_0x3bfac3||0x1f4;return function(_0x207372){logger[_0xb210('0x23')](_0x207372[_0xb210('0x32')]);if(_0x207372['name']){delete _0x207372[_0xb210('0x33')];}_0x1c203a['status'](_0x3bfac3)[_0xb210('0x34')](_0x207372);};}exports[_0xb210('0x35')]=function(_0x16d6b4,_0x80ba0c){var _0x11222e={},_0x2cd092={},_0x1495a2={'count':0x0,'rows':[]};var _0x59da11=_[_0xb210('0x36')](db[_0xb210('0x37')][_0xb210('0x38')],function(_0x564c33){return{'name':_0x564c33[_0xb210('0x39')],'type':_0x564c33['type'][_0xb210('0x3a')]};});_0x2cd092[_0xb210('0x3b')]=_[_0xb210('0x36')](_0x59da11,'name');_0x2cd092[_0xb210('0x3c')]=_['keys'](_0x16d6b4[_0xb210('0x3c')]);_0x2cd092[_0xb210('0x3d')]=_[_0xb210('0x3e')](_0x2cd092[_0xb210('0x3b')],_0x2cd092['query']);_0x11222e[_0xb210('0x3f')]=_[_0xb210('0x3e')](_0x2cd092[_0xb210('0x3b')],qs[_0xb210('0x40')](_0x16d6b4[_0xb210('0x3c')][_0xb210('0x40')]));_0x11222e[_0xb210('0x3f')]=_0x11222e[_0xb210('0x3f')][_0xb210('0x41')]?_0x11222e['attributes']:_0x2cd092[_0xb210('0x3b')];if(!_0x16d6b4[_0xb210('0x3c')][_0xb210('0x42')](_0xb210('0x43'))){_0x11222e[_0xb210('0x2a')]=qs[_0xb210('0x2a')](_0x16d6b4[_0xb210('0x3c')][_0xb210('0x2a')]);_0x11222e[_0xb210('0x44')]=qs[_0xb210('0x44')](_0x16d6b4[_0xb210('0x3c')]['offset']);}_0x11222e[_0xb210('0x45')]=qs[_0xb210('0x46')](_0x16d6b4[_0xb210('0x3c')]['sort']);_0x11222e['where']=qs[_0xb210('0x3d')](_[_0xb210('0x47')](_0x16d6b4['query'],_0x2cd092[_0xb210('0x3d')]));if(_0x16d6b4['query'][_0xb210('0x48')]){_0x11222e['where']=_[_0xb210('0x49')](_0x11222e[_0xb210('0x4a')],{'$or':_[_0xb210('0x36')](_0x59da11,function(_0x3e40cc){if(_0x3e40cc[_0xb210('0x4b')]!==_0xb210('0x4c')){var _0x5f4b51={};_0x5f4b51[_0x3e40cc[_0xb210('0x33')]]={'$like':'%'+_0x16d6b4[_0xb210('0x3c')]['filter']+'%'};return _0x5f4b51;}})});}_0x11222e=_['merge']({},_0x11222e,_0x16d6b4[_0xb210('0x4d')]);var _0x557ee4={'where':_0x11222e[_0xb210('0x4a')]};return db[_0xb210('0x37')][_0xb210('0x4e')](_0x557ee4)[_0xb210('0x1c')](function(_0x5aa616){_0x1495a2[_0xb210('0x4e')]=_0x5aa616;if(_0x16d6b4[_0xb210('0x3c')]['includeAll']){_0x11222e[_0xb210('0x4f')]=[{'all':!![]}];}return db['FreshdeskConfiguration']['findAll'](_0x11222e);})[_0xb210('0x1c')](function(_0x649174){_0x1495a2[_0xb210('0x50')]=_0x649174;return _0x1495a2;})['then'](respondWithFilteredResult(_0x80ba0c,_0x11222e))[_0xb210('0x26')](handleError(_0x80ba0c,null));};exports['show']=function(_0x431dea,_0x937e96){var _0x494d20={'raw':![],'where':{'id':_0x431dea[_0xb210('0x51')]['id']}},_0x4a2723={};_0x4a2723[_0xb210('0x3b')]=_[_0xb210('0x52')](db[_0xb210('0x37')]['rawAttributes']);_0x4a2723[_0xb210('0x3c')]=_[_0xb210('0x52')](_0x431dea[_0xb210('0x3c')]);_0x4a2723[_0xb210('0x3d')]=_[_0xb210('0x3e')](_0x4a2723[_0xb210('0x3b')],_0x4a2723[_0xb210('0x3c')]);_0x494d20[_0xb210('0x3f')]=_['intersection'](_0x4a2723[_0xb210('0x3b')],qs[_0xb210('0x40')](_0x431dea[_0xb210('0x3c')][_0xb210('0x40')]));_0x494d20[_0xb210('0x3f')]=_0x494d20[_0xb210('0x3f')][_0xb210('0x41')]?_0x494d20['attributes']:_0x4a2723[_0xb210('0x3b')];if(_0x431dea[_0xb210('0x3c')][_0xb210('0x53')]){_0x494d20[_0xb210('0x4f')]=[{'all':!![]}];}_0x494d20=_[_0xb210('0x49')]({},_0x494d20,_0x431dea[_0xb210('0x4d')]);return db[_0xb210('0x37')][_0xb210('0x54')](_0x494d20)[_0xb210('0x1c')](handleEntityNotFound(_0x937e96,null))[_0xb210('0x1c')](respondWithResult(_0x937e96,null))[_0xb210('0x26')](handleError(_0x937e96,null));};exports[_0xb210('0x55')]=function(_0x3acd43,_0x380075){return db[_0xb210('0x37')][_0xb210('0x55')](_0x3acd43['body'],{})['then'](respondWithResult(_0x380075,0xc9))[_0xb210('0x26')](handleError(_0x380075,null));};exports[_0xb210('0x30')]=function(_0x69e446,_0x569eba){if(_0x69e446[_0xb210('0x56')]['id']){delete _0x69e446[_0xb210('0x56')]['id'];}return db[_0xb210('0x37')][_0xb210('0x54')]({'where':{'id':_0x69e446['params']['id']}})['then'](handleEntityNotFound(_0x569eba,null))[_0xb210('0x1c')](saveUpdates(_0x69e446['body'],null))[_0xb210('0x1c')](respondWithResult(_0x569eba,null))[_0xb210('0x26')](handleError(_0x569eba,null));};exports[_0xb210('0x31')]=function(_0x337a45,_0x275222){return db['FreshdeskConfiguration'][_0xb210('0x54')]({'where':{'id':_0x337a45[_0xb210('0x51')]['id']}})[_0xb210('0x1c')](handleEntityNotFound(_0x275222,null))[_0xb210('0x1c')](removeEntity(_0x275222,null))['catch'](handleError(_0x275222,null));};exports['getFields']=function(_0x49877a,_0xf84a94,_0x3cbb29){var _0x4758ff={};var _0x136cec={};var _0x32aed6;var _0x511966;return db[_0xb210('0x37')]['findOne']({'where':{'id':_0x49877a[_0xb210('0x51')]['id']}})[_0xb210('0x1c')](handleEntityNotFound(_0xf84a94,null))[_0xb210('0x1c')](function(_0x23a019){if(_0x23a019){_0x32aed6=_0x23a019;_0x136cec[_0xb210('0x3b')]=_['keys'](db[_0xb210('0x57')][_0xb210('0x38')]);_0x136cec[_0xb210('0x3c')]=_[_0xb210('0x52')](_0x49877a[_0xb210('0x3c')]);_0x136cec[_0xb210('0x3d')]=_[_0xb210('0x3e')](_0x136cec[_0xb210('0x3b')],_0x136cec[_0xb210('0x3c')]);_0x4758ff[_0xb210('0x3f')]=_[_0xb210('0x3e')](_0x136cec[_0xb210('0x3b')],qs[_0xb210('0x40')](_0x49877a[_0xb210('0x3c')]['fields']));_0x4758ff[_0xb210('0x3f')]=_0x4758ff[_0xb210('0x3f')][_0xb210('0x41')]?_0x4758ff[_0xb210('0x3f')]:_0x136cec[_0xb210('0x3b')];_0x4758ff[_0xb210('0x45')]=qs[_0xb210('0x46')](_0x49877a[_0xb210('0x3c')]['sort']);_0x4758ff[_0xb210('0x4a')]=qs['filters'](_['pick'](_0x49877a[_0xb210('0x3c')],_0x136cec[_0xb210('0x3d')]));if(_0x49877a[_0xb210('0x3c')][_0xb210('0x48')]){_0x4758ff['where']=_['merge'](_0x4758ff[_0xb210('0x4a')],{'$or':_['map'](_0x4758ff[_0xb210('0x3f')],function(_0x19a696){var _0x258e67={};_0x258e67[_0x19a696]={'$like':'%'+_0x49877a['query'][_0xb210('0x48')]+'%'};return _0x258e67;})});}_0x4758ff=_[_0xb210('0x49')]({},_0x4758ff,_0x49877a[_0xb210('0x4d')]);return _0x32aed6[_0xb210('0x58')](_0x4758ff);}})[_0xb210('0x1c')](function(_0x385775){if(_0x385775){_0x511966=_0x385775[_0xb210('0x41')];if(!_0x49877a[_0xb210('0x3c')][_0xb210('0x42')](_0xb210('0x43'))){_0x4758ff[_0xb210('0x2a')]=qs['limit'](_0x49877a[_0xb210('0x3c')]['limit']);_0x4758ff[_0xb210('0x44')]=qs[_0xb210('0x44')](_0x49877a[_0xb210('0x3c')]['offset']);}return _0x32aed6['getFields'](_0x4758ff);}})[_0xb210('0x1c')](function(_0x1fd07e){if(_0x1fd07e){return _0x1fd07e?{'count':_0x511966,'rows':_0x1fd07e}:null;}})[_0xb210('0x1c')](respondWithResult(_0xf84a94,null))[_0xb210('0x26')](handleError(_0xf84a94,null));};exports[_0xb210('0x59')]=function(_0x5cd75f,_0xef8847,_0x3e2d5c){var _0x582178={};var _0x130102={};var _0x27f7d6;var _0x40d8bb;return db[_0xb210('0x37')][_0xb210('0x5a')]({'where':{'id':_0x5cd75f[_0xb210('0x51')]['id']}})['then'](handleEntityNotFound(_0xef8847,null))[_0xb210('0x1c')](function(_0x531572){if(_0x531572){_0x27f7d6=_0x531572;_0x130102[_0xb210('0x3b')]=_['keys'](db[_0xb210('0x57')][_0xb210('0x38')]);_0x130102[_0xb210('0x3c')]=_[_0xb210('0x52')](_0x5cd75f[_0xb210('0x3c')]);_0x130102[_0xb210('0x3d')]=_[_0xb210('0x3e')](_0x130102['model'],_0x130102['query']);_0x582178[_0xb210('0x3f')]=_[_0xb210('0x3e')](_0x130102[_0xb210('0x3b')],qs[_0xb210('0x40')](_0x5cd75f[_0xb210('0x3c')][_0xb210('0x40')]));_0x582178[_0xb210('0x3f')]=_0x582178[_0xb210('0x3f')][_0xb210('0x41')]?_0x582178[_0xb210('0x3f')]:_0x130102[_0xb210('0x3b')];_0x582178[_0xb210('0x45')]=qs[_0xb210('0x46')](_0x5cd75f[_0xb210('0x3c')]['sort']);_0x582178['where']=qs[_0xb210('0x3d')](_[_0xb210('0x47')](_0x5cd75f[_0xb210('0x3c')],_0x130102[_0xb210('0x3d')]));if(_0x5cd75f[_0xb210('0x3c')][_0xb210('0x48')]){_0x582178[_0xb210('0x4a')]=_[_0xb210('0x49')](_0x582178[_0xb210('0x4a')],{'$or':_['map'](_0x582178['attributes'],function(_0x2fe3b1){var _0x2731d5={};_0x2731d5[_0x2fe3b1]={'$like':'%'+_0x5cd75f[_0xb210('0x3c')][_0xb210('0x48')]+'%'};return _0x2731d5;})});}_0x582178=_[_0xb210('0x49')]({},_0x582178,_0x5cd75f[_0xb210('0x4d')]);return _0x27f7d6['getSubjects'](_0x582178);}})['then'](function(_0x4817da){if(_0x4817da){_0x40d8bb=_0x4817da[_0xb210('0x41')];if(!_0x5cd75f[_0xb210('0x3c')][_0xb210('0x42')](_0xb210('0x43'))){_0x582178[_0xb210('0x2a')]=qs[_0xb210('0x2a')](_0x5cd75f['query'][_0xb210('0x2a')]);_0x582178[_0xb210('0x44')]=qs[_0xb210('0x44')](_0x5cd75f['query'][_0xb210('0x44')]);}return _0x27f7d6[_0xb210('0x59')](_0x582178);}})[_0xb210('0x1c')](function(_0x12cefb){if(_0x12cefb){return _0x12cefb?{'count':_0x40d8bb,'rows':_0x12cefb}:null;}})[_0xb210('0x1c')](respondWithResult(_0xef8847,null))[_0xb210('0x26')](handleError(_0xef8847,null));};exports['getDescriptions']=function(_0x1e936a,_0x4a8055,_0x1873ee){var _0x376173={};var _0x540158={};var _0x56ac03;var _0x227ea7;return db['FreshdeskConfiguration'][_0xb210('0x5a')]({'where':{'id':_0x1e936a[_0xb210('0x51')]['id']}})['then'](handleEntityNotFound(_0x4a8055,null))[_0xb210('0x1c')](function(_0x313ca0){if(_0x313ca0){_0x56ac03=_0x313ca0;_0x540158[_0xb210('0x3b')]=_[_0xb210('0x52')](db[_0xb210('0x57')]['rawAttributes']);_0x540158['query']=_['keys'](_0x1e936a[_0xb210('0x3c')]);_0x540158[_0xb210('0x3d')]=_[_0xb210('0x3e')](_0x540158[_0xb210('0x3b')],_0x540158[_0xb210('0x3c')]);_0x376173[_0xb210('0x3f')]=_[_0xb210('0x3e')](_0x540158[_0xb210('0x3b')],qs[_0xb210('0x40')](_0x1e936a[_0xb210('0x3c')][_0xb210('0x40')]));_0x376173[_0xb210('0x3f')]=_0x376173[_0xb210('0x3f')][_0xb210('0x41')]?_0x376173[_0xb210('0x3f')]:_0x540158['model'];_0x376173[_0xb210('0x45')]=qs[_0xb210('0x46')](_0x1e936a[_0xb210('0x3c')][_0xb210('0x46')]);_0x376173[_0xb210('0x4a')]=qs[_0xb210('0x3d')](_[_0xb210('0x47')](_0x1e936a['query'],_0x540158['filters']));if(_0x1e936a[_0xb210('0x3c')][_0xb210('0x48')]){_0x376173[_0xb210('0x4a')]=_[_0xb210('0x49')](_0x376173[_0xb210('0x4a')],{'$or':_[_0xb210('0x36')](_0x376173['attributes'],function(_0x3521b5){var _0x4cbcb2={};_0x4cbcb2[_0x3521b5]={'$like':'%'+_0x1e936a['query'][_0xb210('0x48')]+'%'};return _0x4cbcb2;})});}_0x376173=_[_0xb210('0x49')]({},_0x376173,_0x1e936a[_0xb210('0x4d')]);return _0x56ac03[_0xb210('0x5b')](_0x376173);}})[_0xb210('0x1c')](function(_0x2db6b3){if(_0x2db6b3){_0x227ea7=_0x2db6b3['length'];if(!_0x1e936a[_0xb210('0x3c')]['hasOwnProperty'](_0xb210('0x43'))){_0x376173[_0xb210('0x2a')]=qs[_0xb210('0x2a')](_0x1e936a[_0xb210('0x3c')]['limit']);_0x376173['offset']=qs[_0xb210('0x44')](_0x1e936a[_0xb210('0x3c')][_0xb210('0x44')]);}return _0x56ac03['getDescriptions'](_0x376173);}})[_0xb210('0x1c')](function(_0x1d86fa){if(_0x1d86fa){return _0x1d86fa?{'count':_0x227ea7,'rows':_0x1d86fa}:null;}})['then'](respondWithResult(_0x4a8055,null))[_0xb210('0x26')](handleError(_0x4a8055,null));};exports['getTags']=function(_0xe525e6,_0x3cf841,_0x5915d5){var _0x122046={};var _0x1dbe3d={};var _0x1a8f5e;var _0x527685;return db[_0xb210('0x37')][_0xb210('0x5a')]({'where':{'id':_0xe525e6[_0xb210('0x51')]['id']}})[_0xb210('0x1c')](handleEntityNotFound(_0x3cf841,null))[_0xb210('0x1c')](function(_0x1495ef){if(_0x1495ef){_0x1a8f5e=_0x1495ef;_0x1dbe3d[_0xb210('0x3b')]=_['keys'](db['Tag'][_0xb210('0x38')]);_0x1dbe3d['query']=_[_0xb210('0x52')](_0xe525e6[_0xb210('0x3c')]);_0x1dbe3d[_0xb210('0x3d')]=_[_0xb210('0x3e')](_0x1dbe3d[_0xb210('0x3b')],_0x1dbe3d[_0xb210('0x3c')]);_0x122046[_0xb210('0x3f')]=_['intersection'](_0x1dbe3d[_0xb210('0x3b')],qs['fields'](_0xe525e6[_0xb210('0x3c')]['fields']));_0x122046[_0xb210('0x3f')]=_0x122046['attributes'][_0xb210('0x41')]?_0x122046[_0xb210('0x3f')]:_0x1dbe3d[_0xb210('0x3b')];_0x122046[_0xb210('0x45')]=qs['sort'](_0xe525e6[_0xb210('0x3c')]['sort']);_0x122046[_0xb210('0x4a')]=qs[_0xb210('0x3d')](_['pick'](_0xe525e6['query'],_0x1dbe3d[_0xb210('0x3d')]));if(_0xe525e6[_0xb210('0x3c')][_0xb210('0x48')]){_0x122046[_0xb210('0x4a')]=_['merge'](_0x122046[_0xb210('0x4a')],{'$or':_[_0xb210('0x36')](_0x122046[_0xb210('0x3f')],function(_0x486c6e){var _0x1ac710={};_0x1ac710[_0x486c6e]={'$like':'%'+_0xe525e6[_0xb210('0x3c')]['filter']+'%'};return _0x1ac710;})});}_0x122046=_[_0xb210('0x49')]({},_0x122046,_0xe525e6[_0xb210('0x4d')]);return _0x1a8f5e[_0xb210('0x5c')](_0x122046);}})[_0xb210('0x1c')](function(_0x181963){if(_0x181963){_0x527685=_0x181963[_0xb210('0x41')];if(!_0xe525e6[_0xb210('0x3c')][_0xb210('0x42')](_0xb210('0x43'))){_0x122046[_0xb210('0x2a')]=qs[_0xb210('0x2a')](_0xe525e6[_0xb210('0x3c')]['limit']);_0x122046[_0xb210('0x44')]=qs[_0xb210('0x44')](_0xe525e6[_0xb210('0x3c')][_0xb210('0x44')]);}return _0x1a8f5e[_0xb210('0x5c')](_0x122046);}})[_0xb210('0x1c')](function(_0x5b9c8b){if(_0x5b9c8b){return _0x5b9c8b?{'count':_0x527685,'rows':_0x5b9c8b}:null;}})[_0xb210('0x1c')](respondWithResult(_0x3cf841,null))[_0xb210('0x26')](handleError(_0x3cf841,null));};exports[_0xb210('0x5d')]=function(_0x43bc49,_0xaece97,_0x171d2e){if(_0x43bc49['body']['id']){delete _0x43bc49[_0xb210('0x56')]['id'];}return db['FreshdeskConfiguration'][_0xb210('0x5a')]({'where':{'id':_0x43bc49[_0xb210('0x51')]['id']}})[_0xb210('0x1c')](handleEntityNotFound(_0xaece97,null))['then'](function(_0x22ae8f){if(_0x22ae8f){return _0x22ae8f['setTags'](_0x43bc49['body'][_0xb210('0x5e')]||[]);}return null;})[_0xb210('0x1c')](respondWithResult(_0xaece97,null))['catch'](handleError(_0xaece97,null));};
\ No newline at end of file
+var _0x80fb=['jsforce','desk.js','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','status','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','end','error','stack','send','index','map','FreshdeskConfiguration','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','nolimit','order','sort','where','filter','VIRTUAL','name','merge','options','includeAll','include','catch','show','params','keys','rawAttributes','length','find','create','body','findOne','pick','getFields','getSubjects','FreshdeskField','getDescriptions','getTags','Tag','setTags','ids','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','path','ejs','fs-extra','lodash','squel','crypto'];(function(_0x170f62,_0x176f4e){var _0x121afc=function(_0x3de408){while(--_0x3de408){_0x170f62['push'](_0x170f62['shift']());}};_0x121afc(++_0x176f4e);}(_0x80fb,0xf6));var _0xb80f=function(_0x174ef5,_0x256e8e){_0x174ef5=_0x174ef5-0x0;var _0x1cc379=_0x80fb[_0x174ef5];return _0x1cc379;};'use strict';var emlformat=require(_0xb80f('0x0'));var rimraf=require(_0xb80f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb80f('0x2'));var rp=require(_0xb80f('0x3'));var moment=require(_0xb80f('0x4'));var BPromise=require(_0xb80f('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0xb80f('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xb80f('0x7'));var fs=require('fs');var fs_extra=require(_0xb80f('0x8'));var _=require(_0xb80f('0x9'));var squel=require(_0xb80f('0xa'));var crypto=require(_0xb80f('0xb'));var jsforce=require(_0xb80f('0xc'));var deskjs=require(_0xb80f('0xd'));var toCsv=require(_0xb80f('0xe'));var querystring=require(_0xb80f('0xf'));var Papa=require('papaparse');var Redis=require(_0xb80f('0x10'));var authService=require(_0xb80f('0x11'));var qs=require(_0xb80f('0x12'));var as=require(_0xb80f('0x13'));var hardwareService=require(_0xb80f('0x14'));var logger=require(_0xb80f('0x15'))(_0xb80f('0x16'));var utils=require(_0xb80f('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xb80f('0x18'))['db'];function respondWithStatusCode(_0x5ca851,_0x5c1429){_0x5c1429=_0x5c1429||0xcc;return function(_0x3332d4){if(_0x3332d4){return _0x5ca851[_0xb80f('0x19')](_0x5c1429);}return _0x5ca851[_0xb80f('0x1a')](_0x5c1429)['end']();};}function respondWithResult(_0x4b30dd,_0x38f551){_0x38f551=_0x38f551||0xc8;return function(_0x4f7015){if(_0x4f7015){return _0x4b30dd[_0xb80f('0x1a')](_0x38f551)['json'](_0x4f7015);}};}function respondWithFilteredResult(_0x4c1b3e,_0x4925ea){return function(_0x2a4850){if(_0x2a4850){var _0x2b5e48=typeof _0x4925ea['offset']===_0xb80f('0x1b')&&typeof _0x4925ea[_0xb80f('0x1c')]===_0xb80f('0x1b');var _0x1d350b=_0x2a4850[_0xb80f('0x1d')];var _0x3e7f9f=_0x2b5e48?0x0:_0x4925ea[_0xb80f('0x1e')];var _0x301b84=_0x2b5e48?_0x2a4850['count']:_0x4925ea['offset']+_0x4925ea[_0xb80f('0x1c')];var _0x3b017c;if(_0x301b84>=_0x1d350b){_0x301b84=_0x1d350b;_0x3b017c=0xc8;}else{_0x3b017c=0xce;}_0x4c1b3e[_0xb80f('0x1a')](_0x3b017c);return _0x4c1b3e[_0xb80f('0x1f')](_0xb80f('0x20'),_0x3e7f9f+'-'+_0x301b84+'/'+_0x1d350b)['json'](_0x2a4850);}return null;};}function patchUpdates(_0x1afb0b){return function(_0x389dc3){try{jsonpatch[_0xb80f('0x21')](_0x389dc3,_0x1afb0b,!![]);}catch(_0x268e02){return BPromise[_0xb80f('0x22')](_0x268e02);}return _0x389dc3[_0xb80f('0x23')]();};}function saveUpdates(_0x185b67,_0x3a6683){return function(_0x114a95){if(_0x114a95){return _0x114a95[_0xb80f('0x24')](_0x185b67)[_0xb80f('0x25')](function(_0x414017){return _0x414017;});}return null;};}function removeEntity(_0x1bf50b,_0x393198){return function(_0x3d5ee0){if(_0x3d5ee0){return _0x3d5ee0[_0xb80f('0x26')]()[_0xb80f('0x25')](function(){_0x1bf50b['status'](0xcc)[_0xb80f('0x27')]();});}};}function handleEntityNotFound(_0x2acf2e,_0x84db64){return function(_0x46c5af){if(!_0x46c5af){_0x2acf2e[_0xb80f('0x19')](0x194);}return _0x46c5af;};}function handleError(_0x172a30,_0x11e2ef){_0x11e2ef=_0x11e2ef||0x1f4;return function(_0xd516cb){logger[_0xb80f('0x28')](_0xd516cb[_0xb80f('0x29')]);if(_0xd516cb['name']){delete _0xd516cb['name'];}_0x172a30[_0xb80f('0x1a')](_0x11e2ef)[_0xb80f('0x2a')](_0xd516cb);};}exports[_0xb80f('0x2b')]=function(_0x1a2934,_0x32fb7a){var _0x34509a={},_0x2828c3={},_0x3291a4={'count':0x0,'rows':[]};var _0x1efb59=_[_0xb80f('0x2c')](db[_0xb80f('0x2d')]['rawAttributes'],function(_0x43fa2a){return{'name':_0x43fa2a[_0xb80f('0x2e')],'type':_0x43fa2a[_0xb80f('0x2f')][_0xb80f('0x30')]};});_0x2828c3[_0xb80f('0x31')]=_[_0xb80f('0x2c')](_0x1efb59,'name');_0x2828c3[_0xb80f('0x32')]=_['keys'](_0x1a2934[_0xb80f('0x32')]);_0x2828c3[_0xb80f('0x33')]=_[_0xb80f('0x34')](_0x2828c3[_0xb80f('0x31')],_0x2828c3['query']);_0x34509a[_0xb80f('0x35')]=_[_0xb80f('0x34')](_0x2828c3['model'],qs[_0xb80f('0x36')](_0x1a2934[_0xb80f('0x32')]['fields']));_0x34509a[_0xb80f('0x35')]=_0x34509a[_0xb80f('0x35')]['length']?_0x34509a[_0xb80f('0x35')]:_0x2828c3['model'];if(!_0x1a2934['query'][_0xb80f('0x37')](_0xb80f('0x38'))){_0x34509a[_0xb80f('0x1c')]=qs[_0xb80f('0x1c')](_0x1a2934[_0xb80f('0x32')][_0xb80f('0x1c')]);_0x34509a[_0xb80f('0x1e')]=qs[_0xb80f('0x1e')](_0x1a2934[_0xb80f('0x32')][_0xb80f('0x1e')]);}_0x34509a[_0xb80f('0x39')]=qs[_0xb80f('0x3a')](_0x1a2934['query'][_0xb80f('0x3a')]);_0x34509a[_0xb80f('0x3b')]=qs['filters'](_['pick'](_0x1a2934[_0xb80f('0x32')],_0x2828c3[_0xb80f('0x33')]),_0x1efb59);if(_0x1a2934[_0xb80f('0x32')][_0xb80f('0x3c')]){_0x34509a[_0xb80f('0x3b')]=_['merge'](_0x34509a['where'],{'$or':_[_0xb80f('0x2c')](_0x1efb59,function(_0x3cc693){if(_0x3cc693[_0xb80f('0x2f')]!==_0xb80f('0x3d')){var _0x283ae6={};_0x283ae6[_0x3cc693[_0xb80f('0x3e')]]={'$like':'%'+_0x1a2934[_0xb80f('0x32')][_0xb80f('0x3c')]+'%'};return _0x283ae6;}})});}_0x34509a=_[_0xb80f('0x3f')]({},_0x34509a,_0x1a2934[_0xb80f('0x40')]);var _0x18889e={'where':_0x34509a[_0xb80f('0x3b')]};return db[_0xb80f('0x2d')][_0xb80f('0x1d')](_0x18889e)[_0xb80f('0x25')](function(_0x43dc0d){_0x3291a4[_0xb80f('0x1d')]=_0x43dc0d;if(_0x1a2934[_0xb80f('0x32')][_0xb80f('0x41')]){_0x34509a[_0xb80f('0x42')]=[{'all':!![]}];}return db[_0xb80f('0x2d')]['findAll'](_0x34509a);})[_0xb80f('0x25')](function(_0x5d5ed6){_0x3291a4['rows']=_0x5d5ed6;return _0x3291a4;})[_0xb80f('0x25')](respondWithFilteredResult(_0x32fb7a,_0x34509a))[_0xb80f('0x43')](handleError(_0x32fb7a,null));};exports[_0xb80f('0x44')]=function(_0x43f8ec,_0x3637b5){var _0x27e613={'raw':![],'where':{'id':_0x43f8ec[_0xb80f('0x45')]['id']}},_0x3fa47d={};_0x3fa47d[_0xb80f('0x31')]=_[_0xb80f('0x46')](db['FreshdeskConfiguration'][_0xb80f('0x47')]);_0x3fa47d['query']=_[_0xb80f('0x46')](_0x43f8ec[_0xb80f('0x32')]);_0x3fa47d[_0xb80f('0x33')]=_[_0xb80f('0x34')](_0x3fa47d[_0xb80f('0x31')],_0x3fa47d[_0xb80f('0x32')]);_0x27e613[_0xb80f('0x35')]=_['intersection'](_0x3fa47d[_0xb80f('0x31')],qs[_0xb80f('0x36')](_0x43f8ec['query'][_0xb80f('0x36')]));_0x27e613[_0xb80f('0x35')]=_0x27e613[_0xb80f('0x35')][_0xb80f('0x48')]?_0x27e613['attributes']:_0x3fa47d[_0xb80f('0x31')];if(_0x43f8ec['query'][_0xb80f('0x41')]){_0x27e613['include']=[{'all':!![]}];}_0x27e613=_[_0xb80f('0x3f')]({},_0x27e613,_0x43f8ec[_0xb80f('0x40')]);return db[_0xb80f('0x2d')][_0xb80f('0x49')](_0x27e613)[_0xb80f('0x25')](handleEntityNotFound(_0x3637b5,null))[_0xb80f('0x25')](respondWithResult(_0x3637b5,null))['catch'](handleError(_0x3637b5,null));};exports[_0xb80f('0x4a')]=function(_0x9fbfc3,_0x724613){return db[_0xb80f('0x2d')]['create'](_0x9fbfc3[_0xb80f('0x4b')],{})[_0xb80f('0x25')](respondWithResult(_0x724613,0xc9))[_0xb80f('0x43')](handleError(_0x724613,null));};exports[_0xb80f('0x24')]=function(_0x468e8b,_0x277879){if(_0x468e8b[_0xb80f('0x4b')]['id']){delete _0x468e8b[_0xb80f('0x4b')]['id'];}return db[_0xb80f('0x2d')]['find']({'where':{'id':_0x468e8b[_0xb80f('0x45')]['id']}})[_0xb80f('0x25')](handleEntityNotFound(_0x277879,null))[_0xb80f('0x25')](saveUpdates(_0x468e8b[_0xb80f('0x4b')],null))[_0xb80f('0x25')](respondWithResult(_0x277879,null))[_0xb80f('0x43')](handleError(_0x277879,null));};exports[_0xb80f('0x26')]=function(_0x4c876a,_0x536506){return db[_0xb80f('0x2d')]['find']({'where':{'id':_0x4c876a['params']['id']}})[_0xb80f('0x25')](handleEntityNotFound(_0x536506,null))[_0xb80f('0x25')](removeEntity(_0x536506,null))[_0xb80f('0x43')](handleError(_0x536506,null));};exports['getFields']=function(_0x28bdf1,_0x1eb871,_0x191992){var _0x175499={};var _0x4b5013={};var _0x79bac5;var _0x6a15b7;return db['FreshdeskConfiguration'][_0xb80f('0x4c')]({'where':{'id':_0x28bdf1[_0xb80f('0x45')]['id']}})['then'](handleEntityNotFound(_0x1eb871,null))['then'](function(_0x26fd7c){if(_0x26fd7c){_0x79bac5=_0x26fd7c;_0x4b5013[_0xb80f('0x31')]=_[_0xb80f('0x46')](db['FreshdeskField'][_0xb80f('0x47')]);_0x4b5013[_0xb80f('0x32')]=_[_0xb80f('0x46')](_0x28bdf1[_0xb80f('0x32')]);_0x4b5013[_0xb80f('0x33')]=_['intersection'](_0x4b5013[_0xb80f('0x31')],_0x4b5013[_0xb80f('0x32')]);_0x175499[_0xb80f('0x35')]=_[_0xb80f('0x34')](_0x4b5013[_0xb80f('0x31')],qs[_0xb80f('0x36')](_0x28bdf1[_0xb80f('0x32')][_0xb80f('0x36')]));_0x175499[_0xb80f('0x35')]=_0x175499[_0xb80f('0x35')][_0xb80f('0x48')]?_0x175499[_0xb80f('0x35')]:_0x4b5013[_0xb80f('0x31')];_0x175499['order']=qs[_0xb80f('0x3a')](_0x28bdf1[_0xb80f('0x32')]['sort']);_0x175499[_0xb80f('0x3b')]=qs['filters'](_[_0xb80f('0x4d')](_0x28bdf1['query'],_0x4b5013[_0xb80f('0x33')]));if(_0x28bdf1[_0xb80f('0x32')]['filter']){_0x175499[_0xb80f('0x3b')]=_[_0xb80f('0x3f')](_0x175499['where'],{'$or':_['map'](_0x175499['attributes'],function(_0x1cd6d7){var _0x1d7694={};_0x1d7694[_0x1cd6d7]={'$like':'%'+_0x28bdf1[_0xb80f('0x32')][_0xb80f('0x3c')]+'%'};return _0x1d7694;})});}_0x175499=_['merge']({},_0x175499,_0x28bdf1[_0xb80f('0x40')]);return _0x79bac5[_0xb80f('0x4e')](_0x175499);}})[_0xb80f('0x25')](function(_0x1733e7){if(_0x1733e7){_0x6a15b7=_0x1733e7[_0xb80f('0x48')];if(!_0x28bdf1['query'][_0xb80f('0x37')](_0xb80f('0x38'))){_0x175499['limit']=qs['limit'](_0x28bdf1[_0xb80f('0x32')]['limit']);_0x175499[_0xb80f('0x1e')]=qs['offset'](_0x28bdf1[_0xb80f('0x32')]['offset']);}return _0x79bac5[_0xb80f('0x4e')](_0x175499);}})[_0xb80f('0x25')](function(_0xe377f9){if(_0xe377f9){return _0xe377f9?{'count':_0x6a15b7,'rows':_0xe377f9}:null;}})[_0xb80f('0x25')](respondWithResult(_0x1eb871,null))[_0xb80f('0x43')](handleError(_0x1eb871,null));};exports[_0xb80f('0x4f')]=function(_0x498ce8,_0x138d8f,_0x53f7b8){var _0x501732={};var _0x3be555={};var _0x54aa3d;var _0x21c18;return db['FreshdeskConfiguration'][_0xb80f('0x4c')]({'where':{'id':_0x498ce8['params']['id']}})[_0xb80f('0x25')](handleEntityNotFound(_0x138d8f,null))[_0xb80f('0x25')](function(_0x31bc64){if(_0x31bc64){_0x54aa3d=_0x31bc64;_0x3be555[_0xb80f('0x31')]=_[_0xb80f('0x46')](db[_0xb80f('0x50')][_0xb80f('0x47')]);_0x3be555[_0xb80f('0x32')]=_['keys'](_0x498ce8[_0xb80f('0x32')]);_0x3be555[_0xb80f('0x33')]=_['intersection'](_0x3be555[_0xb80f('0x31')],_0x3be555[_0xb80f('0x32')]);_0x501732['attributes']=_[_0xb80f('0x34')](_0x3be555[_0xb80f('0x31')],qs[_0xb80f('0x36')](_0x498ce8[_0xb80f('0x32')]['fields']));_0x501732[_0xb80f('0x35')]=_0x501732['attributes'][_0xb80f('0x48')]?_0x501732[_0xb80f('0x35')]:_0x3be555['model'];_0x501732['order']=qs[_0xb80f('0x3a')](_0x498ce8[_0xb80f('0x32')][_0xb80f('0x3a')]);_0x501732[_0xb80f('0x3b')]=qs[_0xb80f('0x33')](_['pick'](_0x498ce8[_0xb80f('0x32')],_0x3be555[_0xb80f('0x33')]));if(_0x498ce8[_0xb80f('0x32')]['filter']){_0x501732[_0xb80f('0x3b')]=_[_0xb80f('0x3f')](_0x501732['where'],{'$or':_[_0xb80f('0x2c')](_0x501732[_0xb80f('0x35')],function(_0xabf14b){var _0x222d29={};_0x222d29[_0xabf14b]={'$like':'%'+_0x498ce8[_0xb80f('0x32')][_0xb80f('0x3c')]+'%'};return _0x222d29;})});}_0x501732=_[_0xb80f('0x3f')]({},_0x501732,_0x498ce8[_0xb80f('0x40')]);return _0x54aa3d[_0xb80f('0x4f')](_0x501732);}})[_0xb80f('0x25')](function(_0x4e031b){if(_0x4e031b){_0x21c18=_0x4e031b['length'];if(!_0x498ce8[_0xb80f('0x32')][_0xb80f('0x37')](_0xb80f('0x38'))){_0x501732[_0xb80f('0x1c')]=qs[_0xb80f('0x1c')](_0x498ce8['query'][_0xb80f('0x1c')]);_0x501732[_0xb80f('0x1e')]=qs['offset'](_0x498ce8[_0xb80f('0x32')][_0xb80f('0x1e')]);}return _0x54aa3d[_0xb80f('0x4f')](_0x501732);}})['then'](function(_0xc4bb1e){if(_0xc4bb1e){return _0xc4bb1e?{'count':_0x21c18,'rows':_0xc4bb1e}:null;}})[_0xb80f('0x25')](respondWithResult(_0x138d8f,null))[_0xb80f('0x43')](handleError(_0x138d8f,null));};exports[_0xb80f('0x51')]=function(_0x20f8d2,_0x365a4c,_0x23ede5){var _0x4e37eb={};var _0xed4ea6={};var _0x13b73f;var _0x8a4ac1;return db[_0xb80f('0x2d')][_0xb80f('0x4c')]({'where':{'id':_0x20f8d2[_0xb80f('0x45')]['id']}})['then'](handleEntityNotFound(_0x365a4c,null))[_0xb80f('0x25')](function(_0x61ffdb){if(_0x61ffdb){_0x13b73f=_0x61ffdb;_0xed4ea6[_0xb80f('0x31')]=_[_0xb80f('0x46')](db[_0xb80f('0x50')][_0xb80f('0x47')]);_0xed4ea6['query']=_['keys'](_0x20f8d2[_0xb80f('0x32')]);_0xed4ea6['filters']=_['intersection'](_0xed4ea6[_0xb80f('0x31')],_0xed4ea6[_0xb80f('0x32')]);_0x4e37eb[_0xb80f('0x35')]=_[_0xb80f('0x34')](_0xed4ea6[_0xb80f('0x31')],qs[_0xb80f('0x36')](_0x20f8d2['query']['fields']));_0x4e37eb[_0xb80f('0x35')]=_0x4e37eb['attributes'][_0xb80f('0x48')]?_0x4e37eb[_0xb80f('0x35')]:_0xed4ea6[_0xb80f('0x31')];_0x4e37eb[_0xb80f('0x39')]=qs[_0xb80f('0x3a')](_0x20f8d2[_0xb80f('0x32')][_0xb80f('0x3a')]);_0x4e37eb[_0xb80f('0x3b')]=qs[_0xb80f('0x33')](_['pick'](_0x20f8d2['query'],_0xed4ea6[_0xb80f('0x33')]));if(_0x20f8d2[_0xb80f('0x32')][_0xb80f('0x3c')]){_0x4e37eb[_0xb80f('0x3b')]=_[_0xb80f('0x3f')](_0x4e37eb[_0xb80f('0x3b')],{'$or':_[_0xb80f('0x2c')](_0x4e37eb['attributes'],function(_0x2c4028){var _0x2a5d36={};_0x2a5d36[_0x2c4028]={'$like':'%'+_0x20f8d2['query'][_0xb80f('0x3c')]+'%'};return _0x2a5d36;})});}_0x4e37eb=_[_0xb80f('0x3f')]({},_0x4e37eb,_0x20f8d2[_0xb80f('0x40')]);return _0x13b73f[_0xb80f('0x51')](_0x4e37eb);}})[_0xb80f('0x25')](function(_0x3ee967){if(_0x3ee967){_0x8a4ac1=_0x3ee967['length'];if(!_0x20f8d2['query'][_0xb80f('0x37')]('nolimit')){_0x4e37eb[_0xb80f('0x1c')]=qs[_0xb80f('0x1c')](_0x20f8d2[_0xb80f('0x32')]['limit']);_0x4e37eb['offset']=qs[_0xb80f('0x1e')](_0x20f8d2[_0xb80f('0x32')][_0xb80f('0x1e')]);}return _0x13b73f['getDescriptions'](_0x4e37eb);}})[_0xb80f('0x25')](function(_0x22c5d8){if(_0x22c5d8){return _0x22c5d8?{'count':_0x8a4ac1,'rows':_0x22c5d8}:null;}})[_0xb80f('0x25')](respondWithResult(_0x365a4c,null))[_0xb80f('0x43')](handleError(_0x365a4c,null));};exports[_0xb80f('0x52')]=function(_0x454f48,_0x1a94e6,_0x7e0d2e){var _0x254979={};var _0x4a0fd0={};var _0x483c97;var _0x135082;return db[_0xb80f('0x2d')]['findOne']({'where':{'id':_0x454f48[_0xb80f('0x45')]['id']}})['then'](handleEntityNotFound(_0x1a94e6,null))[_0xb80f('0x25')](function(_0x3ad9f2){if(_0x3ad9f2){_0x483c97=_0x3ad9f2;_0x4a0fd0[_0xb80f('0x31')]=_[_0xb80f('0x46')](db[_0xb80f('0x53')][_0xb80f('0x47')]);_0x4a0fd0[_0xb80f('0x32')]=_[_0xb80f('0x46')](_0x454f48[_0xb80f('0x32')]);_0x4a0fd0[_0xb80f('0x33')]=_[_0xb80f('0x34')](_0x4a0fd0[_0xb80f('0x31')],_0x4a0fd0['query']);_0x254979[_0xb80f('0x35')]=_['intersection'](_0x4a0fd0[_0xb80f('0x31')],qs['fields'](_0x454f48[_0xb80f('0x32')][_0xb80f('0x36')]));_0x254979[_0xb80f('0x35')]=_0x254979[_0xb80f('0x35')]['length']?_0x254979[_0xb80f('0x35')]:_0x4a0fd0['model'];_0x254979['order']=qs[_0xb80f('0x3a')](_0x454f48[_0xb80f('0x32')][_0xb80f('0x3a')]);_0x254979[_0xb80f('0x3b')]=qs[_0xb80f('0x33')](_[_0xb80f('0x4d')](_0x454f48[_0xb80f('0x32')],_0x4a0fd0[_0xb80f('0x33')]));if(_0x454f48[_0xb80f('0x32')][_0xb80f('0x3c')]){_0x254979['where']=_[_0xb80f('0x3f')](_0x254979[_0xb80f('0x3b')],{'$or':_['map'](_0x254979['attributes'],function(_0x253f71){var _0x227b98={};_0x227b98[_0x253f71]={'$like':'%'+_0x454f48['query']['filter']+'%'};return _0x227b98;})});}_0x254979=_[_0xb80f('0x3f')]({},_0x254979,_0x454f48[_0xb80f('0x40')]);return _0x483c97[_0xb80f('0x52')](_0x254979);}})['then'](function(_0x58b4e){if(_0x58b4e){_0x135082=_0x58b4e[_0xb80f('0x48')];if(!_0x454f48[_0xb80f('0x32')][_0xb80f('0x37')]('nolimit')){_0x254979[_0xb80f('0x1c')]=qs[_0xb80f('0x1c')](_0x454f48[_0xb80f('0x32')][_0xb80f('0x1c')]);_0x254979['offset']=qs['offset'](_0x454f48['query'][_0xb80f('0x1e')]);}return _0x483c97[_0xb80f('0x52')](_0x254979);}})[_0xb80f('0x25')](function(_0x44f82d){if(_0x44f82d){return _0x44f82d?{'count':_0x135082,'rows':_0x44f82d}:null;}})[_0xb80f('0x25')](respondWithResult(_0x1a94e6,null))['catch'](handleError(_0x1a94e6,null));};exports[_0xb80f('0x54')]=function(_0x15bfb5,_0x475084,_0x41e9b8){if(_0x15bfb5['body']['id']){delete _0x15bfb5['body']['id'];}return db[_0xb80f('0x2d')][_0xb80f('0x4c')]({'where':{'id':_0x15bfb5[_0xb80f('0x45')]['id']}})[_0xb80f('0x25')](handleEntityNotFound(_0x475084,null))[_0xb80f('0x25')](function(_0x3c618b){if(_0x3c618b){return _0x3c618b[_0xb80f('0x54')](_0x15bfb5[_0xb80f('0x4b')][_0xb80f('0x55')]||[]);}return null;})[_0xb80f('0x25')](respondWithResult(_0x475084,null))[_0xb80f('0x43')](handleError(_0x475084,null));};
\ No newline at end of file