Built motion from commit b5996064.|2.6.21
[motion2.git] / server / api / intFreshdeskConfiguration / intFreshdeskConfiguration.controller.js
index 75bcb8c..a597847 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3c01=['where','pick','filters','filter','VIRTUAL','merge','options','include','findAll','catch','params','keys','rawAttributes','intersection','includeAll','find','create','body','getFields','findOne','FreshdeskField','getSubjects','getDescriptions','Tag','getTags','setTags','html-pdf','eml-format','fast-json-patch','moment','bluebird','util','path','to-csv','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','jayson/promise','client','test','Sequelize','ValidationError','The\x20password\x20must\x20be\x20at\x20least\x208\x20characters\x20long\x20and\x20have\x201\x20lowercase\x20character,\x201\x20uppercase\x20character,\x201\x20number\x20and\x201\x20special\x20character\x20~!@#$%^&-_=+[{]}.','request','then','info','FreshdeskConfiguration,\x20%s,\x20%s','request\x20sent','debug','FreshdeskConfiguration,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','sendStatus','end','status','json','count','offset','limit','set','Content-Range','apply','reject','save','update','destroy','stack','name','send','index','map','FreshdeskConfiguration','fieldName','type','query','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort'];(function(_0x2eaedf,_0x1b7ceb){var _0x4b054b=function(_0x18c2a4){while(--_0x18c2a4){_0x2eaedf['push'](_0x2eaedf['shift']());}};_0x4b054b(++_0x1b7ceb);}(_0x3c01,0x79));var _0x13c0=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x3c01[_0x20a584];return _0x4b41a8;};'use strict';var pdf=require(_0x13c0('0x0'));var emlformat=require(_0x13c0('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x13c0('0x2'));var rp=require('request-promise');var moment=require(_0x13c0('0x3'));var BPromise=require(_0x13c0('0x4'));var Mustache=require('mustache');var util=require(_0x13c0('0x5'));var path=require(_0x13c0('0x6'));var sox=require('sox');var csv=require(_0x13c0('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x13c0('0x8'));var squel=require(_0x13c0('0x9'));var crypto=require('crypto');var jsforce=require(_0x13c0('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x13c0('0x7'));var querystring=require(_0x13c0('0xb'));var Papa=require(_0x13c0('0xc'));var Redis=require(_0x13c0('0xd'));var authService=require(_0x13c0('0xe'));var qs=require(_0x13c0('0xf'));var as=require(_0x13c0('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x13c0('0x11'))(_0x13c0('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0x13c0('0x13'))['db'];var jayson=require(_0x13c0('0x14'));var client=jayson[_0x13c0('0x15')]['http']({'port':0x232a});function checkPasswordPattern(_0x32314,_0x5afafb,_0x995e60){if(_0x995e60){var _0x4ce0d9=new RegExp(/(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[?!@#\$%\^&\*~\-_=+[{\]\}])(?=.{8,})/);if(_0x4ce0d9[_0x13c0('0x16')](_0x5afafb)){return _0x32314;}else{throw new db[(_0x13c0('0x17'))][(_0x13c0('0x18'))](_0x13c0('0x19'));}}else{return _0x32314;}}function respondWithRpcPromise(_0x3cde55,_0x21d087,_0x48d0e5,_0x1b56dc){return new BPromise(function(_0xe4385d,_0x4baa9c){var _0x4c57f7=_0x1b56dc||client;return _0x4c57f7[_0x13c0('0x1a')](_0x3cde55,_0x48d0e5)[_0x13c0('0x1b')](function(_0x2b3a85){logger[_0x13c0('0x1c')](_0x13c0('0x1d'),_0x21d087,_0x13c0('0x1e'));logger[_0x13c0('0x1f')](_0x13c0('0x20'),_0x21d087,_0x13c0('0x1e'),JSON[_0x13c0('0x21')](_0x2b3a85));if(_0x2b3a85['error']){if(_0x2b3a85['error'][_0x13c0('0x22')]===0x1f4){logger[_0x13c0('0x23')](_0x13c0('0x1d'),_0x21d087,_0x2b3a85[_0x13c0('0x23')][_0x13c0('0x24')]);return _0x4baa9c(_0x2b3a85[_0x13c0('0x23')][_0x13c0('0x24')]);}logger[_0x13c0('0x23')](_0x13c0('0x1d'),_0x21d087,_0x2b3a85[_0x13c0('0x23')][_0x13c0('0x24')]);return _0xe4385d(_0x2b3a85[_0x13c0('0x23')][_0x13c0('0x24')]);}else{logger['info'](_0x13c0('0x1d'),_0x21d087,_0x13c0('0x1e'));_0xe4385d(_0x2b3a85[_0x13c0('0x25')][_0x13c0('0x24')]);}})['catch'](function(_0x565113){logger[_0x13c0('0x23')](_0x13c0('0x1d'),_0x21d087,_0x565113);_0x4baa9c(_0x565113);});});}function respondWithStatusCode(_0xa06b9e,_0x4407d6){_0x4407d6=_0x4407d6||0xcc;return function(_0x317a13){if(_0x317a13){return _0xa06b9e[_0x13c0('0x26')](_0x4407d6);}return _0xa06b9e['status'](_0x4407d6)[_0x13c0('0x27')]();};}function respondWithResult(_0x2e1ec8,_0x16231d){_0x16231d=_0x16231d||0xc8;return function(_0x368c3a){if(_0x368c3a){return _0x2e1ec8[_0x13c0('0x28')](_0x16231d)[_0x13c0('0x29')](_0x368c3a);}};}function respondWithFilteredResult(_0x57e68b,_0x5cdfce){return function(_0xd85df2){if(_0xd85df2){var _0x1f8e57=_0xd85df2[_0x13c0('0x2a')],_0x1e741f=_0x5cdfce[_0x13c0('0x2b')],_0x4449ac=_0x5cdfce['offset']+_0x5cdfce[_0x13c0('0x2c')],_0x16a221;if(_0x4449ac>=_0x1f8e57){_0x4449ac=_0x1f8e57;_0x16a221=0xc8;}else{_0x16a221=0xce;}_0x57e68b[_0x13c0('0x28')](_0x16a221);return _0x57e68b[_0x13c0('0x2d')](_0x13c0('0x2e'),_0x1e741f+'-'+_0x4449ac+'/'+_0x1f8e57)[_0x13c0('0x29')](_0xd85df2);}return null;};}function patchUpdates(_0x1dbcf9){return function(_0x4c3c0d){try{jsonpatch[_0x13c0('0x2f')](_0x4c3c0d,_0x1dbcf9,!![]);}catch(_0x2c1931){return BPromise[_0x13c0('0x30')](_0x2c1931);}return _0x4c3c0d[_0x13c0('0x31')]();};}function saveUpdates(_0xad45ff,_0x435588){return function(_0x2d5ce6){if(_0x2d5ce6){return _0x2d5ce6[_0x13c0('0x32')](_0xad45ff)['then'](function(_0x1b7a37){return _0x1b7a37;});}return null;};}function removeEntity(_0x56afcc,_0x10dfc3){return function(_0x46b870){if(_0x46b870){return _0x46b870[_0x13c0('0x33')]()[_0x13c0('0x1b')](function(){_0x56afcc[_0x13c0('0x28')](0xcc)[_0x13c0('0x27')]();});}};}function handleEntityNotFound(_0x322848,_0x3e8d57){return function(_0x556278){if(!_0x556278){_0x322848[_0x13c0('0x26')](0x194);}return _0x556278;};}function handleError(_0x1e60a6,_0x58231e){_0x58231e=_0x58231e||0x1f4;return function(_0xaa360b){logger[_0x13c0('0x23')](_0xaa360b[_0x13c0('0x34')]);if(_0xaa360b[_0x13c0('0x35')]){delete _0xaa360b['name'];}_0x1e60a6[_0x13c0('0x28')](_0x58231e)[_0x13c0('0x36')](_0xaa360b);};}exports[_0x13c0('0x37')]=function(_0xebf1c4,_0x3036a0){var _0xa5305a={},_0x58319a={},_0x449c4f={'count':0x0,'rows':[]};var _0x35f9e5=_[_0x13c0('0x38')](db[_0x13c0('0x39')]['rawAttributes'],function(_0x3e8513){return{'name':_0x3e8513[_0x13c0('0x3a')],'type':_0x3e8513[_0x13c0('0x3b')]['key']};});_0x58319a['model']=_['map'](_0x35f9e5,'name');_0x58319a[_0x13c0('0x3c')]=_['keys'](_0xebf1c4[_0x13c0('0x3c')]);_0x58319a['filters']=_['intersection'](_0x58319a[_0x13c0('0x3d')],_0x58319a[_0x13c0('0x3c')]);_0xa5305a[_0x13c0('0x3e')]=_['intersection'](_0x58319a[_0x13c0('0x3d')],qs['fields'](_0xebf1c4[_0x13c0('0x3c')][_0x13c0('0x3f')]));_0xa5305a['attributes']=_0xa5305a[_0x13c0('0x3e')][_0x13c0('0x40')]?_0xa5305a[_0x13c0('0x3e')]:_0x58319a[_0x13c0('0x3d')];if(!_0xebf1c4[_0x13c0('0x3c')][_0x13c0('0x41')](_0x13c0('0x42'))){_0xa5305a[_0x13c0('0x2c')]=qs['limit'](_0xebf1c4[_0x13c0('0x3c')][_0x13c0('0x2c')]);_0xa5305a['offset']=qs[_0x13c0('0x2b')](_0xebf1c4[_0x13c0('0x3c')]['offset']);}_0xa5305a[_0x13c0('0x43')]=qs[_0x13c0('0x44')](_0xebf1c4[_0x13c0('0x3c')][_0x13c0('0x44')]);_0xa5305a[_0x13c0('0x45')]=qs['filters'](_[_0x13c0('0x46')](_0xebf1c4['query'],_0x58319a[_0x13c0('0x47')]));if(_0xebf1c4[_0x13c0('0x3c')][_0x13c0('0x48')]){_0xa5305a['where']=_['merge'](_0xa5305a[_0x13c0('0x45')],{'$or':_[_0x13c0('0x38')](_0x35f9e5,function(_0x424d40){if(_0x424d40['type']!==_0x13c0('0x49')){var _0x4e1b55={};_0x4e1b55[_0x424d40[_0x13c0('0x35')]]={'$like':'%'+_0xebf1c4['query']['filter']+'%'};return _0x4e1b55;}})});}_0xa5305a=_[_0x13c0('0x4a')]({},_0xa5305a,_0xebf1c4[_0x13c0('0x4b')]);var _0x18662f={'where':_0xa5305a[_0x13c0('0x45')]};return db[_0x13c0('0x39')][_0x13c0('0x2a')](_0x18662f)[_0x13c0('0x1b')](function(_0x54db43){_0x449c4f[_0x13c0('0x2a')]=_0x54db43;if(_0xebf1c4[_0x13c0('0x3c')]['includeAll']){_0xa5305a[_0x13c0('0x4c')]=[{'all':!![]}];}return db[_0x13c0('0x39')][_0x13c0('0x4d')](_0xa5305a);})[_0x13c0('0x1b')](function(_0x57dfaa){_0x449c4f['rows']=_0x57dfaa;return _0x449c4f;})[_0x13c0('0x1b')](respondWithFilteredResult(_0x3036a0,_0xa5305a))[_0x13c0('0x4e')](handleError(_0x3036a0,null));};exports['show']=function(_0x10c1c1,_0x199312){var _0x5efca0={'raw':![],'where':{'id':_0x10c1c1[_0x13c0('0x4f')]['id']}},_0x49a11b={};_0x49a11b[_0x13c0('0x3d')]=_[_0x13c0('0x50')](db['FreshdeskConfiguration'][_0x13c0('0x51')]);_0x49a11b[_0x13c0('0x3c')]=_[_0x13c0('0x50')](_0x10c1c1['query']);_0x49a11b[_0x13c0('0x47')]=_['intersection'](_0x49a11b[_0x13c0('0x3d')],_0x49a11b[_0x13c0('0x3c')]);_0x5efca0['attributes']=_[_0x13c0('0x52')](_0x49a11b[_0x13c0('0x3d')],qs[_0x13c0('0x3f')](_0x10c1c1[_0x13c0('0x3c')][_0x13c0('0x3f')]));_0x5efca0[_0x13c0('0x3e')]=_0x5efca0['attributes']['length']?_0x5efca0[_0x13c0('0x3e')]:_0x49a11b['model'];if(_0x10c1c1[_0x13c0('0x3c')][_0x13c0('0x53')]){_0x5efca0[_0x13c0('0x4c')]=[{'all':!![]}];}_0x5efca0=_[_0x13c0('0x4a')]({},_0x5efca0,_0x10c1c1[_0x13c0('0x4b')]);return db[_0x13c0('0x39')][_0x13c0('0x54')](_0x5efca0)[_0x13c0('0x1b')](handleEntityNotFound(_0x199312,null))[_0x13c0('0x1b')](respondWithResult(_0x199312,null))[_0x13c0('0x4e')](handleError(_0x199312,null));};exports[_0x13c0('0x55')]=function(_0x5efc23,_0x2e52cd){return db['FreshdeskConfiguration']['create'](_0x5efc23['body'],{})[_0x13c0('0x1b')](respondWithResult(_0x2e52cd,0xc9))[_0x13c0('0x4e')](handleError(_0x2e52cd,null));};exports[_0x13c0('0x32')]=function(_0x5182b8,_0x563965){if(_0x5182b8[_0x13c0('0x56')]['id']){delete _0x5182b8['body']['id'];}return db[_0x13c0('0x39')][_0x13c0('0x54')]({'where':{'id':_0x5182b8['params']['id']}})[_0x13c0('0x1b')](handleEntityNotFound(_0x563965,null))[_0x13c0('0x1b')](saveUpdates(_0x5182b8[_0x13c0('0x56')],null))['then'](respondWithResult(_0x563965,null))[_0x13c0('0x4e')](handleError(_0x563965,null));};exports[_0x13c0('0x33')]=function(_0x4fefc8,_0xbffb60){return db[_0x13c0('0x39')][_0x13c0('0x54')]({'where':{'id':_0x4fefc8[_0x13c0('0x4f')]['id']}})['then'](handleEntityNotFound(_0xbffb60,null))[_0x13c0('0x1b')](removeEntity(_0xbffb60,null))['catch'](handleError(_0xbffb60,null));};exports[_0x13c0('0x57')]=function(_0x1c091f,_0x46ae7e,_0x1e9e1a){var _0x2d82ae={};var _0x671d8e={};var _0x5290e7;var _0x445d01;return db['FreshdeskConfiguration'][_0x13c0('0x58')]({'where':{'id':_0x1c091f[_0x13c0('0x4f')]['id']}})['then'](handleEntityNotFound(_0x46ae7e,null))[_0x13c0('0x1b')](function(_0x323deb){if(_0x323deb){_0x5290e7=_0x323deb;_0x671d8e['model']=_[_0x13c0('0x50')](db[_0x13c0('0x59')][_0x13c0('0x51')]);_0x671d8e['query']=_[_0x13c0('0x50')](_0x1c091f[_0x13c0('0x3c')]);_0x671d8e['filters']=_[_0x13c0('0x52')](_0x671d8e[_0x13c0('0x3d')],_0x671d8e['query']);_0x2d82ae[_0x13c0('0x3e')]=_[_0x13c0('0x52')](_0x671d8e[_0x13c0('0x3d')],qs[_0x13c0('0x3f')](_0x1c091f[_0x13c0('0x3c')][_0x13c0('0x3f')]));_0x2d82ae[_0x13c0('0x3e')]=_0x2d82ae[_0x13c0('0x3e')][_0x13c0('0x40')]?_0x2d82ae[_0x13c0('0x3e')]:_0x671d8e[_0x13c0('0x3d')];_0x2d82ae[_0x13c0('0x43')]=qs[_0x13c0('0x44')](_0x1c091f[_0x13c0('0x3c')][_0x13c0('0x44')]);_0x2d82ae[_0x13c0('0x45')]=qs[_0x13c0('0x47')](_[_0x13c0('0x46')](_0x1c091f['query'],_0x671d8e[_0x13c0('0x47')]));if(_0x1c091f[_0x13c0('0x3c')][_0x13c0('0x48')]){_0x2d82ae['where']=_['merge'](_0x2d82ae[_0x13c0('0x45')],{'$or':_[_0x13c0('0x38')](_0x2d82ae[_0x13c0('0x3e')],function(_0x1d7efa){var _0x30ded9={};_0x30ded9[_0x1d7efa]={'$like':'%'+_0x1c091f[_0x13c0('0x3c')][_0x13c0('0x48')]+'%'};return _0x30ded9;})});}_0x2d82ae=_['merge']({},_0x2d82ae,_0x1c091f[_0x13c0('0x4b')]);return _0x5290e7[_0x13c0('0x57')](_0x2d82ae);}})['then'](function(_0x287f56){if(_0x287f56){_0x445d01=_0x287f56[_0x13c0('0x40')];if(!_0x1c091f['query']['hasOwnProperty']('nolimit')){_0x2d82ae['limit']=qs[_0x13c0('0x2c')](_0x1c091f[_0x13c0('0x3c')][_0x13c0('0x2c')]);_0x2d82ae[_0x13c0('0x2b')]=qs[_0x13c0('0x2b')](_0x1c091f[_0x13c0('0x3c')][_0x13c0('0x2b')]);}return _0x5290e7[_0x13c0('0x57')](_0x2d82ae);}})[_0x13c0('0x1b')](function(_0x473b4e){if(_0x473b4e){return _0x473b4e?{'count':_0x445d01,'rows':_0x473b4e}:null;}})[_0x13c0('0x1b')](respondWithResult(_0x46ae7e,null))[_0x13c0('0x4e')](handleError(_0x46ae7e,null));};exports[_0x13c0('0x5a')]=function(_0x51becb,_0x86edaf,_0x54fa7b){var _0x3b69e7={};var _0x52f353={};var _0x36bba9;var _0x4c348d;return db[_0x13c0('0x39')]['findOne']({'where':{'id':_0x51becb['params']['id']}})[_0x13c0('0x1b')](handleEntityNotFound(_0x86edaf,null))[_0x13c0('0x1b')](function(_0x2024c4){if(_0x2024c4){_0x36bba9=_0x2024c4;_0x52f353[_0x13c0('0x3d')]=_['keys'](db[_0x13c0('0x59')][_0x13c0('0x51')]);_0x52f353['query']=_[_0x13c0('0x50')](_0x51becb['query']);_0x52f353[_0x13c0('0x47')]=_[_0x13c0('0x52')](_0x52f353['model'],_0x52f353[_0x13c0('0x3c')]);_0x3b69e7['attributes']=_[_0x13c0('0x52')](_0x52f353['model'],qs['fields'](_0x51becb[_0x13c0('0x3c')][_0x13c0('0x3f')]));_0x3b69e7[_0x13c0('0x3e')]=_0x3b69e7[_0x13c0('0x3e')][_0x13c0('0x40')]?_0x3b69e7[_0x13c0('0x3e')]:_0x52f353['model'];_0x3b69e7[_0x13c0('0x43')]=qs[_0x13c0('0x44')](_0x51becb[_0x13c0('0x3c')][_0x13c0('0x44')]);_0x3b69e7[_0x13c0('0x45')]=qs[_0x13c0('0x47')](_['pick'](_0x51becb[_0x13c0('0x3c')],_0x52f353['filters']));if(_0x51becb[_0x13c0('0x3c')][_0x13c0('0x48')]){_0x3b69e7['where']=_[_0x13c0('0x4a')](_0x3b69e7[_0x13c0('0x45')],{'$or':_['map'](_0x3b69e7[_0x13c0('0x3e')],function(_0x33fac1){var _0x142f80={};_0x142f80[_0x33fac1]={'$like':'%'+_0x51becb['query'][_0x13c0('0x48')]+'%'};return _0x142f80;})});}_0x3b69e7=_['merge']({},_0x3b69e7,_0x51becb[_0x13c0('0x4b')]);return _0x36bba9[_0x13c0('0x5a')](_0x3b69e7);}})[_0x13c0('0x1b')](function(_0x45d620){if(_0x45d620){_0x4c348d=_0x45d620[_0x13c0('0x40')];if(!_0x51becb['query']['hasOwnProperty'](_0x13c0('0x42'))){_0x3b69e7['limit']=qs['limit'](_0x51becb[_0x13c0('0x3c')]['limit']);_0x3b69e7['offset']=qs['offset'](_0x51becb[_0x13c0('0x3c')][_0x13c0('0x2b')]);}return _0x36bba9[_0x13c0('0x5a')](_0x3b69e7);}})[_0x13c0('0x1b')](function(_0x87292a){if(_0x87292a){return _0x87292a?{'count':_0x4c348d,'rows':_0x87292a}:null;}})[_0x13c0('0x1b')](respondWithResult(_0x86edaf,null))[_0x13c0('0x4e')](handleError(_0x86edaf,null));};exports[_0x13c0('0x5b')]=function(_0x2967a8,_0x320d8c,_0x5d9353){var _0x40852c={};var _0x3a917e={};var _0x529c18;var _0x70c40c;return db[_0x13c0('0x39')][_0x13c0('0x58')]({'where':{'id':_0x2967a8['params']['id']}})[_0x13c0('0x1b')](handleEntityNotFound(_0x320d8c,null))[_0x13c0('0x1b')](function(_0x35cf87){if(_0x35cf87){_0x529c18=_0x35cf87;_0x3a917e[_0x13c0('0x3d')]=_['keys'](db['FreshdeskField'][_0x13c0('0x51')]);_0x3a917e[_0x13c0('0x3c')]=_['keys'](_0x2967a8['query']);_0x3a917e[_0x13c0('0x47')]=_['intersection'](_0x3a917e[_0x13c0('0x3d')],_0x3a917e[_0x13c0('0x3c')]);_0x40852c[_0x13c0('0x3e')]=_[_0x13c0('0x52')](_0x3a917e[_0x13c0('0x3d')],qs[_0x13c0('0x3f')](_0x2967a8[_0x13c0('0x3c')]['fields']));_0x40852c[_0x13c0('0x3e')]=_0x40852c[_0x13c0('0x3e')][_0x13c0('0x40')]?_0x40852c[_0x13c0('0x3e')]:_0x3a917e['model'];_0x40852c['order']=qs['sort'](_0x2967a8[_0x13c0('0x3c')]['sort']);_0x40852c[_0x13c0('0x45')]=qs[_0x13c0('0x47')](_[_0x13c0('0x46')](_0x2967a8[_0x13c0('0x3c')],_0x3a917e['filters']));if(_0x2967a8[_0x13c0('0x3c')]['filter']){_0x40852c[_0x13c0('0x45')]=_[_0x13c0('0x4a')](_0x40852c['where'],{'$or':_['map'](_0x40852c[_0x13c0('0x3e')],function(_0x5b1a48){var _0x5e97bd={};_0x5e97bd[_0x5b1a48]={'$like':'%'+_0x2967a8[_0x13c0('0x3c')][_0x13c0('0x48')]+'%'};return _0x5e97bd;})});}_0x40852c=_['merge']({},_0x40852c,_0x2967a8['options']);return _0x529c18[_0x13c0('0x5b')](_0x40852c);}})[_0x13c0('0x1b')](function(_0x50e6cd){if(_0x50e6cd){_0x70c40c=_0x50e6cd[_0x13c0('0x40')];if(!_0x2967a8['query'][_0x13c0('0x41')]('nolimit')){_0x40852c[_0x13c0('0x2c')]=qs['limit'](_0x2967a8[_0x13c0('0x3c')][_0x13c0('0x2c')]);_0x40852c['offset']=qs[_0x13c0('0x2b')](_0x2967a8[_0x13c0('0x3c')][_0x13c0('0x2b')]);}return _0x529c18[_0x13c0('0x5b')](_0x40852c);}})[_0x13c0('0x1b')](function(_0x550d46){if(_0x550d46){return _0x550d46?{'count':_0x70c40c,'rows':_0x550d46}:null;}})[_0x13c0('0x1b')](respondWithResult(_0x320d8c,null))['catch'](handleError(_0x320d8c,null));};exports['getTags']=function(_0x46ca43,_0x39f1c4,_0x2be553){var _0x5dd558={};var _0x2d8b36={};var _0x5f32ee;var _0x489aad;return db[_0x13c0('0x39')][_0x13c0('0x58')]({'where':{'id':_0x46ca43[_0x13c0('0x4f')]['id']}})[_0x13c0('0x1b')](handleEntityNotFound(_0x39f1c4,null))[_0x13c0('0x1b')](function(_0x1fe43e){if(_0x1fe43e){_0x5f32ee=_0x1fe43e;_0x2d8b36[_0x13c0('0x3d')]=_[_0x13c0('0x50')](db[_0x13c0('0x5c')]['rawAttributes']);_0x2d8b36[_0x13c0('0x3c')]=_[_0x13c0('0x50')](_0x46ca43[_0x13c0('0x3c')]);_0x2d8b36['filters']=_[_0x13c0('0x52')](_0x2d8b36[_0x13c0('0x3d')],_0x2d8b36['query']);_0x5dd558['attributes']=_[_0x13c0('0x52')](_0x2d8b36[_0x13c0('0x3d')],qs[_0x13c0('0x3f')](_0x46ca43[_0x13c0('0x3c')]['fields']));_0x5dd558['attributes']=_0x5dd558[_0x13c0('0x3e')][_0x13c0('0x40')]?_0x5dd558[_0x13c0('0x3e')]:_0x2d8b36[_0x13c0('0x3d')];_0x5dd558['order']=qs[_0x13c0('0x44')](_0x46ca43[_0x13c0('0x3c')][_0x13c0('0x44')]);_0x5dd558[_0x13c0('0x45')]=qs[_0x13c0('0x47')](_[_0x13c0('0x46')](_0x46ca43[_0x13c0('0x3c')],_0x2d8b36[_0x13c0('0x47')]));if(_0x46ca43[_0x13c0('0x3c')][_0x13c0('0x48')]){_0x5dd558[_0x13c0('0x45')]=_[_0x13c0('0x4a')](_0x5dd558[_0x13c0('0x45')],{'$or':_[_0x13c0('0x38')](_0x5dd558['attributes'],function(_0x3081b2){var _0x23f6c9={};_0x23f6c9[_0x3081b2]={'$like':'%'+_0x46ca43[_0x13c0('0x3c')]['filter']+'%'};return _0x23f6c9;})});}_0x5dd558=_[_0x13c0('0x4a')]({},_0x5dd558,_0x46ca43['options']);return _0x5f32ee[_0x13c0('0x5d')](_0x5dd558);}})[_0x13c0('0x1b')](function(_0x515890){if(_0x515890){_0x489aad=_0x515890[_0x13c0('0x40')];if(!_0x46ca43[_0x13c0('0x3c')][_0x13c0('0x41')]('nolimit')){_0x5dd558['limit']=qs[_0x13c0('0x2c')](_0x46ca43[_0x13c0('0x3c')]['limit']);_0x5dd558[_0x13c0('0x2b')]=qs['offset'](_0x46ca43['query']['offset']);}return _0x5f32ee[_0x13c0('0x5d')](_0x5dd558);}})[_0x13c0('0x1b')](function(_0x350856){if(_0x350856){return _0x350856?{'count':_0x489aad,'rows':_0x350856}:null;}})[_0x13c0('0x1b')](respondWithResult(_0x39f1c4,null))['catch'](handleError(_0x39f1c4,null));};exports[_0x13c0('0x5e')]=function(_0x1ccd2d,_0x4375c8,_0x4a7c2d){if(_0x1ccd2d['body']['id']){delete _0x1ccd2d[_0x13c0('0x56')]['id'];}return db[_0x13c0('0x39')][_0x13c0('0x58')]({'where':{'id':_0x1ccd2d[_0x13c0('0x4f')]['id']}})[_0x13c0('0x1b')](handleEntityNotFound(_0x4375c8,null))[_0x13c0('0x1b')](function(_0x732e13){if(_0x732e13){return _0x732e13[_0x13c0('0x5e')](_0x1ccd2d[_0x13c0('0x56')]['ids']||[]);}return null;})[_0x13c0('0x1b')](respondWithResult(_0x4375c8,null))[_0x13c0('0x4e')](handleError(_0x4375c8,null));};
\ No newline at end of file
+var _0x1f98=['end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','update','then','error','stack','name','send','index','map','keys','query','intersection','model','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','type','VIRTUAL','includeAll','include','FreshdeskConfiguration','findAll','rows','catch','show','rawAttributes','length','find','create','body','params','getFields','FreshdeskField','options','getSubjects','nolimit','getDescriptions','getTags','Tag','setTags','findOne','ids','rimraf','zip-dir','moment','bluebird','mustache','path','to-csv','ejs','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status'];(function(_0x52451b,_0x2f8c1c){var _0x335fcd=function(_0x4bcb51){while(--_0x4bcb51){_0x52451b['push'](_0x52451b['shift']());}};_0x335fcd(++_0x2f8c1c);}(_0x1f98,0x130));var _0x81f9=function(_0x3a6474,_0x45a6da){_0x3a6474=_0x3a6474-0x0;var _0x49e783=_0x1f98[_0x3a6474];return _0x49e783;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x81f9('0x0'));var zipdir=require(_0x81f9('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x81f9('0x2'));var BPromise=require(_0x81f9('0x3'));var Mustache=require(_0x81f9('0x4'));var util=require('util');var path=require(_0x81f9('0x5'));var sox=require('sox');var csv=require(_0x81f9('0x6'));var ejs=require(_0x81f9('0x7'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0x81f9('0x8'));var crypto=require(_0x81f9('0x9'));var jsforce=require(_0x81f9('0xa'));var deskjs=require('desk.js');var toCsv=require(_0x81f9('0x6'));var querystring=require(_0x81f9('0xb'));var Papa=require('papaparse');var Redis=require(_0x81f9('0xc'));var authService=require(_0x81f9('0xd'));var qs=require(_0x81f9('0xe'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x81f9('0xf'));var logger=require(_0x81f9('0x10'))(_0x81f9('0x11'));var utils=require(_0x81f9('0x12'));var config=require(_0x81f9('0x13'));var licenseUtil=require(_0x81f9('0x14'));var db=require(_0x81f9('0x15'))['db'];function respondWithStatusCode(_0x47e51f,_0x3502c7){_0x3502c7=_0x3502c7||0xcc;return function(_0x4f3665){if(_0x4f3665){return _0x47e51f[_0x81f9('0x16')](_0x3502c7);}return _0x47e51f[_0x81f9('0x17')](_0x3502c7)[_0x81f9('0x18')]();};}function respondWithResult(_0x3d12d2,_0x415bad){_0x415bad=_0x415bad||0xc8;return function(_0x327f7e){if(_0x327f7e){return _0x3d12d2[_0x81f9('0x17')](_0x415bad)[_0x81f9('0x19')](_0x327f7e);}};}function respondWithFilteredResult(_0x48ee07,_0x2fe5a1){return function(_0xa6af3b){if(_0xa6af3b){var _0x33b6fd=typeof _0x2fe5a1[_0x81f9('0x1a')]===_0x81f9('0x1b')&&typeof _0x2fe5a1[_0x81f9('0x1c')]==='undefined';var _0x23f5de=_0xa6af3b[_0x81f9('0x1d')];var _0x3edd1c=_0x33b6fd?0x0:_0x2fe5a1[_0x81f9('0x1a')];var _0x42a205=_0x33b6fd?_0xa6af3b[_0x81f9('0x1d')]:_0x2fe5a1[_0x81f9('0x1a')]+_0x2fe5a1[_0x81f9('0x1c')];var _0xb401c5;if(_0x42a205>=_0x23f5de){_0x42a205=_0x23f5de;_0xb401c5=0xc8;}else{_0xb401c5=0xce;}_0x48ee07[_0x81f9('0x17')](_0xb401c5);return _0x48ee07['set'](_0x81f9('0x1e'),_0x3edd1c+'-'+_0x42a205+'/'+_0x23f5de)[_0x81f9('0x19')](_0xa6af3b);}return null;};}function patchUpdates(_0x18e52e){return function(_0x136109){try{jsonpatch[_0x81f9('0x1f')](_0x136109,_0x18e52e,!![]);}catch(_0x38b057){return BPromise[_0x81f9('0x20')](_0x38b057);}return _0x136109[_0x81f9('0x21')]();};}function saveUpdates(_0x206515,_0x1a2cc6){return function(_0x216d92){if(_0x216d92){return _0x216d92[_0x81f9('0x22')](_0x206515)[_0x81f9('0x23')](function(_0x37a521){return _0x37a521;});}return null;};}function removeEntity(_0x4d9224,_0x1e2488){return function(_0x4e5b57){if(_0x4e5b57){return _0x4e5b57['destroy']()[_0x81f9('0x23')](function(){_0x4d9224[_0x81f9('0x17')](0xcc)[_0x81f9('0x18')]();});}};}function handleEntityNotFound(_0x345012,_0x42b3c7){return function(_0x2298b0){if(!_0x2298b0){_0x345012[_0x81f9('0x16')](0x194);}return _0x2298b0;};}function handleError(_0x1b5837,_0x5a1695){_0x5a1695=_0x5a1695||0x1f4;return function(_0xf7ccbd){logger[_0x81f9('0x24')](_0xf7ccbd[_0x81f9('0x25')]);if(_0xf7ccbd[_0x81f9('0x26')]){delete _0xf7ccbd[_0x81f9('0x26')];}_0x1b5837[_0x81f9('0x17')](_0x5a1695)[_0x81f9('0x27')](_0xf7ccbd);};}exports[_0x81f9('0x28')]=function(_0x37ed18,_0x2687ed){var _0x1210a8={},_0x3fe355={},_0x3430ce={'count':0x0,'rows':[]};var _0x4d228d=_['map'](db['FreshdeskConfiguration']['rawAttributes'],function(_0x5d2a23){return{'name':_0x5d2a23['fieldName'],'type':_0x5d2a23['type']['key']};});_0x3fe355['model']=_[_0x81f9('0x29')](_0x4d228d,_0x81f9('0x26'));_0x3fe355['query']=_[_0x81f9('0x2a')](_0x37ed18[_0x81f9('0x2b')]);_0x3fe355['filters']=_[_0x81f9('0x2c')](_0x3fe355[_0x81f9('0x2d')],_0x3fe355[_0x81f9('0x2b')]);_0x1210a8[_0x81f9('0x2e')]=_['intersection'](_0x3fe355[_0x81f9('0x2d')],qs[_0x81f9('0x2f')](_0x37ed18[_0x81f9('0x2b')][_0x81f9('0x2f')]));_0x1210a8[_0x81f9('0x2e')]=_0x1210a8['attributes']['length']?_0x1210a8[_0x81f9('0x2e')]:_0x3fe355[_0x81f9('0x2d')];if(!_0x37ed18[_0x81f9('0x2b')][_0x81f9('0x30')]('nolimit')){_0x1210a8[_0x81f9('0x1c')]=qs['limit'](_0x37ed18[_0x81f9('0x2b')][_0x81f9('0x1c')]);_0x1210a8[_0x81f9('0x1a')]=qs[_0x81f9('0x1a')](_0x37ed18[_0x81f9('0x2b')]['offset']);}_0x1210a8[_0x81f9('0x31')]=qs[_0x81f9('0x32')](_0x37ed18[_0x81f9('0x2b')][_0x81f9('0x32')]);_0x1210a8[_0x81f9('0x33')]=qs[_0x81f9('0x34')](_[_0x81f9('0x35')](_0x37ed18[_0x81f9('0x2b')],_0x3fe355[_0x81f9('0x34')]),_0x4d228d);if(_0x37ed18['query'][_0x81f9('0x36')]){_0x1210a8[_0x81f9('0x33')]=_[_0x81f9('0x37')](_0x1210a8[_0x81f9('0x33')],{'$or':_[_0x81f9('0x29')](_0x4d228d,function(_0x356709){if(_0x356709[_0x81f9('0x38')]!==_0x81f9('0x39')){var _0x5dcdea={};_0x5dcdea[_0x356709[_0x81f9('0x26')]]={'$like':'%'+_0x37ed18[_0x81f9('0x2b')][_0x81f9('0x36')]+'%'};return _0x5dcdea;}})});}_0x1210a8=_['merge']({},_0x1210a8,_0x37ed18['options']);var _0x1bd0f7={'where':_0x1210a8[_0x81f9('0x33')]};return db['FreshdeskConfiguration'][_0x81f9('0x1d')](_0x1bd0f7)[_0x81f9('0x23')](function(_0x414e05){_0x3430ce['count']=_0x414e05;if(_0x37ed18['query'][_0x81f9('0x3a')]){_0x1210a8[_0x81f9('0x3b')]=[{'all':!![]}];}return db[_0x81f9('0x3c')][_0x81f9('0x3d')](_0x1210a8);})[_0x81f9('0x23')](function(_0x9e3e17){_0x3430ce[_0x81f9('0x3e')]=_0x9e3e17;return _0x3430ce;})[_0x81f9('0x23')](respondWithFilteredResult(_0x2687ed,_0x1210a8))[_0x81f9('0x3f')](handleError(_0x2687ed,null));};exports[_0x81f9('0x40')]=function(_0x1a6ef4,_0x16ca4f){var _0x1c3856={'raw':![],'where':{'id':_0x1a6ef4['params']['id']}},_0x5bc366={};_0x5bc366[_0x81f9('0x2d')]=_[_0x81f9('0x2a')](db[_0x81f9('0x3c')][_0x81f9('0x41')]);_0x5bc366[_0x81f9('0x2b')]=_[_0x81f9('0x2a')](_0x1a6ef4[_0x81f9('0x2b')]);_0x5bc366['filters']=_[_0x81f9('0x2c')](_0x5bc366[_0x81f9('0x2d')],_0x5bc366[_0x81f9('0x2b')]);_0x1c3856[_0x81f9('0x2e')]=_[_0x81f9('0x2c')](_0x5bc366[_0x81f9('0x2d')],qs['fields'](_0x1a6ef4[_0x81f9('0x2b')][_0x81f9('0x2f')]));_0x1c3856[_0x81f9('0x2e')]=_0x1c3856[_0x81f9('0x2e')][_0x81f9('0x42')]?_0x1c3856[_0x81f9('0x2e')]:_0x5bc366[_0x81f9('0x2d')];if(_0x1a6ef4[_0x81f9('0x2b')][_0x81f9('0x3a')]){_0x1c3856[_0x81f9('0x3b')]=[{'all':!![]}];}_0x1c3856=_[_0x81f9('0x37')]({},_0x1c3856,_0x1a6ef4['options']);return db[_0x81f9('0x3c')][_0x81f9('0x43')](_0x1c3856)[_0x81f9('0x23')](handleEntityNotFound(_0x16ca4f,null))[_0x81f9('0x23')](respondWithResult(_0x16ca4f,null))['catch'](handleError(_0x16ca4f,null));};exports[_0x81f9('0x44')]=function(_0x19116d,_0x50911e){return db['FreshdeskConfiguration']['create'](_0x19116d[_0x81f9('0x45')],{})['then'](respondWithResult(_0x50911e,0xc9))[_0x81f9('0x3f')](handleError(_0x50911e,null));};exports[_0x81f9('0x22')]=function(_0x283885,_0x47cf73){if(_0x283885[_0x81f9('0x45')]['id']){delete _0x283885[_0x81f9('0x45')]['id'];}return db['FreshdeskConfiguration'][_0x81f9('0x43')]({'where':{'id':_0x283885[_0x81f9('0x46')]['id']}})['then'](handleEntityNotFound(_0x47cf73,null))[_0x81f9('0x23')](saveUpdates(_0x283885[_0x81f9('0x45')],null))['then'](respondWithResult(_0x47cf73,null))['catch'](handleError(_0x47cf73,null));};exports['destroy']=function(_0x484019,_0x3afb62){return db[_0x81f9('0x3c')][_0x81f9('0x43')]({'where':{'id':_0x484019[_0x81f9('0x46')]['id']}})['then'](handleEntityNotFound(_0x3afb62,null))[_0x81f9('0x23')](removeEntity(_0x3afb62,null))[_0x81f9('0x3f')](handleError(_0x3afb62,null));};exports[_0x81f9('0x47')]=function(_0x5ca29a,_0x43607d,_0x5bd0d9){var _0x1bc04e={};var _0x692316={};var _0x3ca711;var _0x23d25c;return db['FreshdeskConfiguration']['findOne']({'where':{'id':_0x5ca29a['params']['id']}})['then'](handleEntityNotFound(_0x43607d,null))['then'](function(_0x51cdeb){if(_0x51cdeb){_0x3ca711=_0x51cdeb;_0x692316[_0x81f9('0x2d')]=_['keys'](db[_0x81f9('0x48')][_0x81f9('0x41')]);_0x692316[_0x81f9('0x2b')]=_['keys'](_0x5ca29a[_0x81f9('0x2b')]);_0x692316['filters']=_['intersection'](_0x692316['model'],_0x692316[_0x81f9('0x2b')]);_0x1bc04e[_0x81f9('0x2e')]=_[_0x81f9('0x2c')](_0x692316[_0x81f9('0x2d')],qs[_0x81f9('0x2f')](_0x5ca29a[_0x81f9('0x2b')][_0x81f9('0x2f')]));_0x1bc04e[_0x81f9('0x2e')]=_0x1bc04e[_0x81f9('0x2e')][_0x81f9('0x42')]?_0x1bc04e['attributes']:_0x692316[_0x81f9('0x2d')];_0x1bc04e[_0x81f9('0x31')]=qs['sort'](_0x5ca29a[_0x81f9('0x2b')][_0x81f9('0x32')]);_0x1bc04e['where']=qs[_0x81f9('0x34')](_[_0x81f9('0x35')](_0x5ca29a[_0x81f9('0x2b')],_0x692316[_0x81f9('0x34')]));if(_0x5ca29a[_0x81f9('0x2b')]['filter']){_0x1bc04e[_0x81f9('0x33')]=_[_0x81f9('0x37')](_0x1bc04e[_0x81f9('0x33')],{'$or':_[_0x81f9('0x29')](_0x1bc04e[_0x81f9('0x2e')],function(_0x105777){var _0x524408={};_0x524408[_0x105777]={'$like':'%'+_0x5ca29a[_0x81f9('0x2b')]['filter']+'%'};return _0x524408;})});}_0x1bc04e=_[_0x81f9('0x37')]({},_0x1bc04e,_0x5ca29a[_0x81f9('0x49')]);return _0x3ca711[_0x81f9('0x47')](_0x1bc04e);}})[_0x81f9('0x23')](function(_0x30d149){if(_0x30d149){_0x23d25c=_0x30d149[_0x81f9('0x42')];if(!_0x5ca29a[_0x81f9('0x2b')][_0x81f9('0x30')]('nolimit')){_0x1bc04e[_0x81f9('0x1c')]=qs[_0x81f9('0x1c')](_0x5ca29a[_0x81f9('0x2b')][_0x81f9('0x1c')]);_0x1bc04e[_0x81f9('0x1a')]=qs[_0x81f9('0x1a')](_0x5ca29a[_0x81f9('0x2b')]['offset']);}return _0x3ca711['getFields'](_0x1bc04e);}})['then'](function(_0xe47b0b){if(_0xe47b0b){return _0xe47b0b?{'count':_0x23d25c,'rows':_0xe47b0b}:null;}})[_0x81f9('0x23')](respondWithResult(_0x43607d,null))[_0x81f9('0x3f')](handleError(_0x43607d,null));};exports[_0x81f9('0x4a')]=function(_0x554eed,_0x41e1e2,_0x1aad43){var _0x10661d={};var _0x4b7230={};var _0x24b78b;var _0x22856f;return db[_0x81f9('0x3c')]['findOne']({'where':{'id':_0x554eed[_0x81f9('0x46')]['id']}})[_0x81f9('0x23')](handleEntityNotFound(_0x41e1e2,null))[_0x81f9('0x23')](function(_0x422a78){if(_0x422a78){_0x24b78b=_0x422a78;_0x4b7230['model']=_[_0x81f9('0x2a')](db[_0x81f9('0x48')][_0x81f9('0x41')]);_0x4b7230['query']=_[_0x81f9('0x2a')](_0x554eed[_0x81f9('0x2b')]);_0x4b7230[_0x81f9('0x34')]=_[_0x81f9('0x2c')](_0x4b7230['model'],_0x4b7230[_0x81f9('0x2b')]);_0x10661d[_0x81f9('0x2e')]=_['intersection'](_0x4b7230['model'],qs[_0x81f9('0x2f')](_0x554eed['query']['fields']));_0x10661d[_0x81f9('0x2e')]=_0x10661d[_0x81f9('0x2e')][_0x81f9('0x42')]?_0x10661d[_0x81f9('0x2e')]:_0x4b7230[_0x81f9('0x2d')];_0x10661d[_0x81f9('0x31')]=qs[_0x81f9('0x32')](_0x554eed['query'][_0x81f9('0x32')]);_0x10661d['where']=qs[_0x81f9('0x34')](_['pick'](_0x554eed[_0x81f9('0x2b')],_0x4b7230[_0x81f9('0x34')]));if(_0x554eed[_0x81f9('0x2b')][_0x81f9('0x36')]){_0x10661d['where']=_[_0x81f9('0x37')](_0x10661d['where'],{'$or':_[_0x81f9('0x29')](_0x10661d[_0x81f9('0x2e')],function(_0x5ce865){var _0x56cb33={};_0x56cb33[_0x5ce865]={'$like':'%'+_0x554eed[_0x81f9('0x2b')][_0x81f9('0x36')]+'%'};return _0x56cb33;})});}_0x10661d=_[_0x81f9('0x37')]({},_0x10661d,_0x554eed['options']);return _0x24b78b[_0x81f9('0x4a')](_0x10661d);}})[_0x81f9('0x23')](function(_0x490dde){if(_0x490dde){_0x22856f=_0x490dde['length'];if(!_0x554eed[_0x81f9('0x2b')][_0x81f9('0x30')](_0x81f9('0x4b'))){_0x10661d[_0x81f9('0x1c')]=qs[_0x81f9('0x1c')](_0x554eed[_0x81f9('0x2b')][_0x81f9('0x1c')]);_0x10661d[_0x81f9('0x1a')]=qs['offset'](_0x554eed['query'][_0x81f9('0x1a')]);}return _0x24b78b[_0x81f9('0x4a')](_0x10661d);}})[_0x81f9('0x23')](function(_0x1d35b){if(_0x1d35b){return _0x1d35b?{'count':_0x22856f,'rows':_0x1d35b}:null;}})[_0x81f9('0x23')](respondWithResult(_0x41e1e2,null))['catch'](handleError(_0x41e1e2,null));};exports[_0x81f9('0x4c')]=function(_0x5171fa,_0x3a0e9c,_0x3f8126){var _0x2d7800={};var _0xeb44f3={};var _0x367fd2;var _0x52db40;return db[_0x81f9('0x3c')]['findOne']({'where':{'id':_0x5171fa[_0x81f9('0x46')]['id']}})[_0x81f9('0x23')](handleEntityNotFound(_0x3a0e9c,null))['then'](function(_0x499316){if(_0x499316){_0x367fd2=_0x499316;_0xeb44f3[_0x81f9('0x2d')]=_[_0x81f9('0x2a')](db[_0x81f9('0x48')][_0x81f9('0x41')]);_0xeb44f3['query']=_[_0x81f9('0x2a')](_0x5171fa[_0x81f9('0x2b')]);_0xeb44f3[_0x81f9('0x34')]=_[_0x81f9('0x2c')](_0xeb44f3['model'],_0xeb44f3[_0x81f9('0x2b')]);_0x2d7800[_0x81f9('0x2e')]=_[_0x81f9('0x2c')](_0xeb44f3['model'],qs['fields'](_0x5171fa[_0x81f9('0x2b')][_0x81f9('0x2f')]));_0x2d7800['attributes']=_0x2d7800[_0x81f9('0x2e')]['length']?_0x2d7800[_0x81f9('0x2e')]:_0xeb44f3[_0x81f9('0x2d')];_0x2d7800[_0x81f9('0x31')]=qs['sort'](_0x5171fa[_0x81f9('0x2b')]['sort']);_0x2d7800[_0x81f9('0x33')]=qs[_0x81f9('0x34')](_['pick'](_0x5171fa[_0x81f9('0x2b')],_0xeb44f3[_0x81f9('0x34')]));if(_0x5171fa['query'][_0x81f9('0x36')]){_0x2d7800[_0x81f9('0x33')]=_[_0x81f9('0x37')](_0x2d7800[_0x81f9('0x33')],{'$or':_[_0x81f9('0x29')](_0x2d7800[_0x81f9('0x2e')],function(_0x43f0dd){var _0x3cab09={};_0x3cab09[_0x43f0dd]={'$like':'%'+_0x5171fa[_0x81f9('0x2b')]['filter']+'%'};return _0x3cab09;})});}_0x2d7800=_['merge']({},_0x2d7800,_0x5171fa[_0x81f9('0x49')]);return _0x367fd2[_0x81f9('0x4c')](_0x2d7800);}})[_0x81f9('0x23')](function(_0x10ec67){if(_0x10ec67){_0x52db40=_0x10ec67[_0x81f9('0x42')];if(!_0x5171fa[_0x81f9('0x2b')][_0x81f9('0x30')](_0x81f9('0x4b'))){_0x2d7800[_0x81f9('0x1c')]=qs[_0x81f9('0x1c')](_0x5171fa[_0x81f9('0x2b')][_0x81f9('0x1c')]);_0x2d7800[_0x81f9('0x1a')]=qs[_0x81f9('0x1a')](_0x5171fa[_0x81f9('0x2b')][_0x81f9('0x1a')]);}return _0x367fd2[_0x81f9('0x4c')](_0x2d7800);}})[_0x81f9('0x23')](function(_0x44d690){if(_0x44d690){return _0x44d690?{'count':_0x52db40,'rows':_0x44d690}:null;}})[_0x81f9('0x23')](respondWithResult(_0x3a0e9c,null))[_0x81f9('0x3f')](handleError(_0x3a0e9c,null));};exports[_0x81f9('0x4d')]=function(_0x5619db,_0x40552a,_0x26dd99){var _0x1d336c={};var _0x560f34={};var _0x1519d6;var _0x266109;return db[_0x81f9('0x3c')]['findOne']({'where':{'id':_0x5619db['params']['id']}})[_0x81f9('0x23')](handleEntityNotFound(_0x40552a,null))['then'](function(_0x3c638e){if(_0x3c638e){_0x1519d6=_0x3c638e;_0x560f34['model']=_[_0x81f9('0x2a')](db[_0x81f9('0x4e')][_0x81f9('0x41')]);_0x560f34[_0x81f9('0x2b')]=_['keys'](_0x5619db[_0x81f9('0x2b')]);_0x560f34[_0x81f9('0x34')]=_['intersection'](_0x560f34[_0x81f9('0x2d')],_0x560f34['query']);_0x1d336c[_0x81f9('0x2e')]=_[_0x81f9('0x2c')](_0x560f34[_0x81f9('0x2d')],qs['fields'](_0x5619db[_0x81f9('0x2b')]['fields']));_0x1d336c[_0x81f9('0x2e')]=_0x1d336c[_0x81f9('0x2e')][_0x81f9('0x42')]?_0x1d336c[_0x81f9('0x2e')]:_0x560f34['model'];_0x1d336c[_0x81f9('0x31')]=qs[_0x81f9('0x32')](_0x5619db[_0x81f9('0x2b')][_0x81f9('0x32')]);_0x1d336c[_0x81f9('0x33')]=qs[_0x81f9('0x34')](_[_0x81f9('0x35')](_0x5619db[_0x81f9('0x2b')],_0x560f34['filters']));if(_0x5619db['query']['filter']){_0x1d336c[_0x81f9('0x33')]=_[_0x81f9('0x37')](_0x1d336c[_0x81f9('0x33')],{'$or':_['map'](_0x1d336c[_0x81f9('0x2e')],function(_0x535680){var _0x1a0763={};_0x1a0763[_0x535680]={'$like':'%'+_0x5619db['query'][_0x81f9('0x36')]+'%'};return _0x1a0763;})});}_0x1d336c=_[_0x81f9('0x37')]({},_0x1d336c,_0x5619db['options']);return _0x1519d6['getTags'](_0x1d336c);}})[_0x81f9('0x23')](function(_0x3f6a1e){if(_0x3f6a1e){_0x266109=_0x3f6a1e[_0x81f9('0x42')];if(!_0x5619db[_0x81f9('0x2b')]['hasOwnProperty'](_0x81f9('0x4b'))){_0x1d336c['limit']=qs[_0x81f9('0x1c')](_0x5619db['query'][_0x81f9('0x1c')]);_0x1d336c[_0x81f9('0x1a')]=qs[_0x81f9('0x1a')](_0x5619db[_0x81f9('0x2b')][_0x81f9('0x1a')]);}return _0x1519d6[_0x81f9('0x4d')](_0x1d336c);}})[_0x81f9('0x23')](function(_0x1d0fd4){if(_0x1d0fd4){return _0x1d0fd4?{'count':_0x266109,'rows':_0x1d0fd4}:null;}})[_0x81f9('0x23')](respondWithResult(_0x40552a,null))[_0x81f9('0x3f')](handleError(_0x40552a,null));};exports[_0x81f9('0x4f')]=function(_0x372513,_0xd1983c,_0x3b3b55){if(_0x372513[_0x81f9('0x45')]['id']){delete _0x372513[_0x81f9('0x45')]['id'];}return db[_0x81f9('0x3c')][_0x81f9('0x50')]({'where':{'id':_0x372513[_0x81f9('0x46')]['id']}})[_0x81f9('0x23')](handleEntityNotFound(_0xd1983c,null))[_0x81f9('0x23')](function(_0x16dd3f){if(_0x16dd3f){return _0x16dd3f[_0x81f9('0x4f')](_0x372513[_0x81f9('0x45')][_0x81f9('0x51')]||[]);}return null;})[_0x81f9('0x23')](respondWithResult(_0xd1983c,null))[_0x81f9('0x3f')](handleError(_0xd1983c,null));};
\ No newline at end of file