Built motion from commit 85328c08.|2.5.50
[motion2.git] / server / api / intZendeskConfiguration / intZendeskConfiguration.controller.js
index 73c111e..6206a06 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x87fc=['../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','ZendeskConfiguration','rawAttributes','type','key','model','query','keys','filters','intersection','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','filter','options','includeAll','include','findAll','catch','show','params','fields','find','create','body','getFields','findOne','ZendeskField','getDescriptions','getTags','Tag','setTags','ids','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api'];(function(_0x223461,_0x2bca70){var _0x4dbe0a=function(_0x3c3cb6){while(--_0x3c3cb6){_0x223461['push'](_0x223461['shift']());}};_0x4dbe0a(++_0x2bca70);}(_0x87fc,0x13e));var _0xc87f=function(_0x151569,_0x3b7f73){_0x151569=_0x151569-0x0;var _0x2ae4ca=_0x87fc[_0x151569];return _0x2ae4ca;};'use strict';var emlformat=require(_0xc87f('0x0'));var rimraf=require(_0xc87f('0x1'));var zipdir=require(_0xc87f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc87f('0x3'));var moment=require(_0xc87f('0x4'));var BPromise=require(_0xc87f('0x5'));var Mustache=require(_0xc87f('0x6'));var util=require(_0xc87f('0x7'));var path=require(_0xc87f('0x8'));var sox=require(_0xc87f('0x9'));var csv=require(_0xc87f('0xa'));var ejs=require(_0xc87f('0xb'));var fs=require('fs');var fs_extra=require(_0xc87f('0xc'));var _=require(_0xc87f('0xd'));var squel=require('squel');var crypto=require(_0xc87f('0xe'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xc87f('0xa'));var querystring=require(_0xc87f('0xf'));var Papa=require(_0xc87f('0x10'));var Redis=require(_0xc87f('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xc87f('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc87f('0x13'));var logger=require(_0xc87f('0x14'))(_0xc87f('0x15'));var utils=require('../../config/utils');var config=require(_0xc87f('0x16'));var licenseUtil=require(_0xc87f('0x17'));var db=require(_0xc87f('0x18'))['db'];function respondWithStatusCode(_0x197d2a,_0x17d4f6){_0x17d4f6=_0x17d4f6||0xcc;return function(_0x851a58){if(_0x851a58){return _0x197d2a[_0xc87f('0x19')](_0x17d4f6);}return _0x197d2a[_0xc87f('0x1a')](_0x17d4f6)[_0xc87f('0x1b')]();};}function respondWithResult(_0x4f0fa0,_0x361666){_0x361666=_0x361666||0xc8;return function(_0x91bd44){if(_0x91bd44){return _0x4f0fa0[_0xc87f('0x1a')](_0x361666)[_0xc87f('0x1c')](_0x91bd44);}};}function respondWithFilteredResult(_0x5ebafe,_0x1d0958){return function(_0x5d308d){if(_0x5d308d){var _0x1b45e9=typeof _0x1d0958[_0xc87f('0x1d')]===_0xc87f('0x1e')&&typeof _0x1d0958[_0xc87f('0x1f')]===_0xc87f('0x1e');var _0x109c1c=_0x5d308d[_0xc87f('0x20')];var _0x2e2b3d=_0x1b45e9?0x0:_0x1d0958[_0xc87f('0x1d')];var _0x5a6f00=_0x1b45e9?_0x5d308d[_0xc87f('0x20')]:_0x1d0958[_0xc87f('0x1d')]+_0x1d0958[_0xc87f('0x1f')];var _0x876b85;if(_0x5a6f00>=_0x109c1c){_0x5a6f00=_0x109c1c;_0x876b85=0xc8;}else{_0x876b85=0xce;}_0x5ebafe[_0xc87f('0x1a')](_0x876b85);return _0x5ebafe[_0xc87f('0x21')](_0xc87f('0x22'),_0x2e2b3d+'-'+_0x5a6f00+'/'+_0x109c1c)[_0xc87f('0x1c')](_0x5d308d);}return null;};}function patchUpdates(_0x4a7ba3){return function(_0x469964){try{jsonpatch[_0xc87f('0x23')](_0x469964,_0x4a7ba3,!![]);}catch(_0x16409f){return BPromise[_0xc87f('0x24')](_0x16409f);}return _0x469964[_0xc87f('0x25')]();};}function saveUpdates(_0x29b4bd,_0xe5ce01){return function(_0x1f1e46){if(_0x1f1e46){return _0x1f1e46[_0xc87f('0x26')](_0x29b4bd)[_0xc87f('0x27')](function(_0x472749){return _0x472749;});}return null;};}function removeEntity(_0x42cc4d,_0x2f9b61){return function(_0x30af16){if(_0x30af16){return _0x30af16[_0xc87f('0x28')]()['then'](function(){_0x42cc4d['status'](0xcc)[_0xc87f('0x1b')]();});}};}function handleEntityNotFound(_0x48c6d6,_0x5096cd){return function(_0x2f85ce){if(!_0x2f85ce){_0x48c6d6[_0xc87f('0x19')](0x194);}return _0x2f85ce;};}function handleError(_0x513959,_0x942f47){_0x942f47=_0x942f47||0x1f4;return function(_0x2e1e7d){logger[_0xc87f('0x29')](_0x2e1e7d[_0xc87f('0x2a')]);if(_0x2e1e7d[_0xc87f('0x2b')]){delete _0x2e1e7d['name'];}_0x513959[_0xc87f('0x1a')](_0x942f47)[_0xc87f('0x2c')](_0x2e1e7d);};}exports[_0xc87f('0x2d')]=function(_0x29906f,_0x5b0572){var _0x1790f3={},_0x39fea5={},_0x55980d={'count':0x0,'rows':[]};var _0x2cb9ed=_[_0xc87f('0x2e')](db[_0xc87f('0x2f')][_0xc87f('0x30')],function(_0x5ac9c6){return{'name':_0x5ac9c6['fieldName'],'type':_0x5ac9c6[_0xc87f('0x31')][_0xc87f('0x32')]};});_0x39fea5[_0xc87f('0x33')]=_[_0xc87f('0x2e')](_0x2cb9ed,_0xc87f('0x2b'));_0x39fea5[_0xc87f('0x34')]=_[_0xc87f('0x35')](_0x29906f[_0xc87f('0x34')]);_0x39fea5[_0xc87f('0x36')]=_[_0xc87f('0x37')](_0x39fea5[_0xc87f('0x33')],_0x39fea5[_0xc87f('0x34')]);_0x1790f3[_0xc87f('0x38')]=_[_0xc87f('0x37')](_0x39fea5[_0xc87f('0x33')],qs['fields'](_0x29906f[_0xc87f('0x34')]['fields']));_0x1790f3[_0xc87f('0x38')]=_0x1790f3[_0xc87f('0x38')][_0xc87f('0x39')]?_0x1790f3['attributes']:_0x39fea5[_0xc87f('0x33')];if(!_0x29906f[_0xc87f('0x34')][_0xc87f('0x3a')](_0xc87f('0x3b'))){_0x1790f3['limit']=qs[_0xc87f('0x1f')](_0x29906f['query'][_0xc87f('0x1f')]);_0x1790f3[_0xc87f('0x1d')]=qs[_0xc87f('0x1d')](_0x29906f[_0xc87f('0x34')][_0xc87f('0x1d')]);}_0x1790f3[_0xc87f('0x3c')]=qs[_0xc87f('0x3d')](_0x29906f[_0xc87f('0x34')][_0xc87f('0x3d')]);_0x1790f3[_0xc87f('0x3e')]=qs['filters'](_[_0xc87f('0x3f')](_0x29906f['query'],_0x39fea5[_0xc87f('0x36')]),_0x2cb9ed);if(_0x29906f[_0xc87f('0x34')]['filter']){_0x1790f3['where']=_[_0xc87f('0x40')](_0x1790f3[_0xc87f('0x3e')],{'$or':_[_0xc87f('0x2e')](_0x2cb9ed,function(_0x111677){if(_0x111677[_0xc87f('0x31')]!=='VIRTUAL'){var _0x42b999={};_0x42b999[_0x111677['name']]={'$like':'%'+_0x29906f['query'][_0xc87f('0x41')]+'%'};return _0x42b999;}})});}_0x1790f3=_['merge']({},_0x1790f3,_0x29906f[_0xc87f('0x42')]);var _0x10431a={'where':_0x1790f3[_0xc87f('0x3e')]};return db[_0xc87f('0x2f')][_0xc87f('0x20')](_0x10431a)[_0xc87f('0x27')](function(_0x45ce6f){_0x55980d[_0xc87f('0x20')]=_0x45ce6f;if(_0x29906f[_0xc87f('0x34')][_0xc87f('0x43')]){_0x1790f3[_0xc87f('0x44')]=[{'all':!![]}];}return db[_0xc87f('0x2f')][_0xc87f('0x45')](_0x1790f3);})[_0xc87f('0x27')](function(_0x45a7fa){_0x55980d['rows']=_0x45a7fa;return _0x55980d;})[_0xc87f('0x27')](respondWithFilteredResult(_0x5b0572,_0x1790f3))[_0xc87f('0x46')](handleError(_0x5b0572,null));};exports[_0xc87f('0x47')]=function(_0x340e76,_0x343c33){var _0xf5365={'raw':![],'where':{'id':_0x340e76[_0xc87f('0x48')]['id']}},_0x5a4985={};_0x5a4985[_0xc87f('0x33')]=_[_0xc87f('0x35')](db[_0xc87f('0x2f')][_0xc87f('0x30')]);_0x5a4985[_0xc87f('0x34')]=_[_0xc87f('0x35')](_0x340e76['query']);_0x5a4985[_0xc87f('0x36')]=_['intersection'](_0x5a4985[_0xc87f('0x33')],_0x5a4985[_0xc87f('0x34')]);_0xf5365['attributes']=_[_0xc87f('0x37')](_0x5a4985['model'],qs['fields'](_0x340e76['query'][_0xc87f('0x49')]));_0xf5365['attributes']=_0xf5365['attributes'][_0xc87f('0x39')]?_0xf5365[_0xc87f('0x38')]:_0x5a4985[_0xc87f('0x33')];if(_0x340e76[_0xc87f('0x34')]['includeAll']){_0xf5365['include']=[{'all':!![]}];}_0xf5365=_[_0xc87f('0x40')]({},_0xf5365,_0x340e76[_0xc87f('0x42')]);return db[_0xc87f('0x2f')][_0xc87f('0x4a')](_0xf5365)['then'](handleEntityNotFound(_0x343c33,null))['then'](respondWithResult(_0x343c33,null))[_0xc87f('0x46')](handleError(_0x343c33,null));};exports[_0xc87f('0x4b')]=function(_0x1e1e8d,_0x34cdcd){return db[_0xc87f('0x2f')]['create'](_0x1e1e8d[_0xc87f('0x4c')],{})[_0xc87f('0x27')](respondWithResult(_0x34cdcd,0xc9))[_0xc87f('0x46')](handleError(_0x34cdcd,null));};exports[_0xc87f('0x26')]=function(_0x239418,_0x3b3694){if(_0x239418[_0xc87f('0x4c')]['id']){delete _0x239418[_0xc87f('0x4c')]['id'];}return db[_0xc87f('0x2f')]['find']({'where':{'id':_0x239418['params']['id']}})['then'](handleEntityNotFound(_0x3b3694,null))[_0xc87f('0x27')](saveUpdates(_0x239418['body'],null))[_0xc87f('0x27')](respondWithResult(_0x3b3694,null))[_0xc87f('0x46')](handleError(_0x3b3694,null));};exports[_0xc87f('0x28')]=function(_0x2bbff4,_0x586676){return db[_0xc87f('0x2f')]['find']({'where':{'id':_0x2bbff4[_0xc87f('0x48')]['id']}})[_0xc87f('0x27')](handleEntityNotFound(_0x586676,null))[_0xc87f('0x27')](removeEntity(_0x586676,null))[_0xc87f('0x46')](handleError(_0x586676,null));};exports[_0xc87f('0x4d')]=function(_0x546ec1,_0x9b02f7,_0x5aa9cb){var _0x3a8fae={};var _0x4c1bbd={};var _0x19699b;var _0x1e4942;return db['ZendeskConfiguration'][_0xc87f('0x4e')]({'where':{'id':_0x546ec1['params']['id']}})['then'](handleEntityNotFound(_0x9b02f7,null))[_0xc87f('0x27')](function(_0x5770f0){if(_0x5770f0){_0x19699b=_0x5770f0;_0x4c1bbd[_0xc87f('0x33')]=_['keys'](db[_0xc87f('0x4f')][_0xc87f('0x30')]);_0x4c1bbd[_0xc87f('0x34')]=_['keys'](_0x546ec1['query']);_0x4c1bbd[_0xc87f('0x36')]=_[_0xc87f('0x37')](_0x4c1bbd['model'],_0x4c1bbd[_0xc87f('0x34')]);_0x3a8fae[_0xc87f('0x38')]=_['intersection'](_0x4c1bbd[_0xc87f('0x33')],qs[_0xc87f('0x49')](_0x546ec1[_0xc87f('0x34')][_0xc87f('0x49')]));_0x3a8fae[_0xc87f('0x38')]=_0x3a8fae[_0xc87f('0x38')]['length']?_0x3a8fae[_0xc87f('0x38')]:_0x4c1bbd['model'];_0x3a8fae[_0xc87f('0x3c')]=qs[_0xc87f('0x3d')](_0x546ec1['query'][_0xc87f('0x3d')]);_0x3a8fae['where']=qs[_0xc87f('0x36')](_[_0xc87f('0x3f')](_0x546ec1[_0xc87f('0x34')],_0x4c1bbd[_0xc87f('0x36')]));if(_0x546ec1[_0xc87f('0x34')][_0xc87f('0x41')]){_0x3a8fae[_0xc87f('0x3e')]=_[_0xc87f('0x40')](_0x3a8fae['where'],{'$or':_['map'](_0x3a8fae[_0xc87f('0x38')],function(_0x2b27b4){var _0x2db8b7={};_0x2db8b7[_0x2b27b4]={'$like':'%'+_0x546ec1[_0xc87f('0x34')]['filter']+'%'};return _0x2db8b7;})});}_0x3a8fae=_[_0xc87f('0x40')]({},_0x3a8fae,_0x546ec1[_0xc87f('0x42')]);return _0x19699b[_0xc87f('0x4d')](_0x3a8fae);}})[_0xc87f('0x27')](function(_0x2fb6b4){if(_0x2fb6b4){_0x1e4942=_0x2fb6b4[_0xc87f('0x39')];if(!_0x546ec1[_0xc87f('0x34')][_0xc87f('0x3a')](_0xc87f('0x3b'))){_0x3a8fae[_0xc87f('0x1f')]=qs[_0xc87f('0x1f')](_0x546ec1[_0xc87f('0x34')][_0xc87f('0x1f')]);_0x3a8fae[_0xc87f('0x1d')]=qs[_0xc87f('0x1d')](_0x546ec1[_0xc87f('0x34')][_0xc87f('0x1d')]);}return _0x19699b[_0xc87f('0x4d')](_0x3a8fae);}})['then'](function(_0x3671c2){if(_0x3671c2){return _0x3671c2?{'count':_0x1e4942,'rows':_0x3671c2}:null;}})[_0xc87f('0x27')](respondWithResult(_0x9b02f7,null))[_0xc87f('0x46')](handleError(_0x9b02f7,null));};exports['getSubjects']=function(_0x231f54,_0x248a20,_0x22a98e){var _0x3387de={};var _0x2371d0={};var _0x1cb528;var _0x324327;return db[_0xc87f('0x2f')][_0xc87f('0x4e')]({'where':{'id':_0x231f54[_0xc87f('0x48')]['id']}})['then'](handleEntityNotFound(_0x248a20,null))[_0xc87f('0x27')](function(_0x36ad7a){if(_0x36ad7a){_0x1cb528=_0x36ad7a;_0x2371d0[_0xc87f('0x33')]=_[_0xc87f('0x35')](db['ZendeskField'][_0xc87f('0x30')]);_0x2371d0[_0xc87f('0x34')]=_[_0xc87f('0x35')](_0x231f54[_0xc87f('0x34')]);_0x2371d0[_0xc87f('0x36')]=_[_0xc87f('0x37')](_0x2371d0[_0xc87f('0x33')],_0x2371d0['query']);_0x3387de[_0xc87f('0x38')]=_[_0xc87f('0x37')](_0x2371d0[_0xc87f('0x33')],qs[_0xc87f('0x49')](_0x231f54[_0xc87f('0x34')][_0xc87f('0x49')]));_0x3387de[_0xc87f('0x38')]=_0x3387de[_0xc87f('0x38')][_0xc87f('0x39')]?_0x3387de[_0xc87f('0x38')]:_0x2371d0['model'];_0x3387de[_0xc87f('0x3c')]=qs[_0xc87f('0x3d')](_0x231f54[_0xc87f('0x34')][_0xc87f('0x3d')]);_0x3387de[_0xc87f('0x3e')]=qs[_0xc87f('0x36')](_[_0xc87f('0x3f')](_0x231f54[_0xc87f('0x34')],_0x2371d0[_0xc87f('0x36')]));if(_0x231f54['query'][_0xc87f('0x41')]){_0x3387de[_0xc87f('0x3e')]=_[_0xc87f('0x40')](_0x3387de[_0xc87f('0x3e')],{'$or':_[_0xc87f('0x2e')](_0x3387de[_0xc87f('0x38')],function(_0x2d20d5){var _0x177f02={};_0x177f02[_0x2d20d5]={'$like':'%'+_0x231f54[_0xc87f('0x34')]['filter']+'%'};return _0x177f02;})});}_0x3387de=_[_0xc87f('0x40')]({},_0x3387de,_0x231f54['options']);return _0x1cb528['getSubjects'](_0x3387de);}})[_0xc87f('0x27')](function(_0x27cfd8){if(_0x27cfd8){_0x324327=_0x27cfd8[_0xc87f('0x39')];if(!_0x231f54['query'][_0xc87f('0x3a')](_0xc87f('0x3b'))){_0x3387de[_0xc87f('0x1f')]=qs[_0xc87f('0x1f')](_0x231f54['query'][_0xc87f('0x1f')]);_0x3387de[_0xc87f('0x1d')]=qs[_0xc87f('0x1d')](_0x231f54[_0xc87f('0x34')][_0xc87f('0x1d')]);}return _0x1cb528['getSubjects'](_0x3387de);}})[_0xc87f('0x27')](function(_0x2a7221){if(_0x2a7221){return _0x2a7221?{'count':_0x324327,'rows':_0x2a7221}:null;}})[_0xc87f('0x27')](respondWithResult(_0x248a20,null))['catch'](handleError(_0x248a20,null));};exports['getDescriptions']=function(_0x44e86e,_0x1f1c22,_0x52cfd3){var _0x4a6656={};var _0x251314={};var _0x1a7904;var _0x333798;return db['ZendeskConfiguration'][_0xc87f('0x4e')]({'where':{'id':_0x44e86e[_0xc87f('0x48')]['id']}})[_0xc87f('0x27')](handleEntityNotFound(_0x1f1c22,null))[_0xc87f('0x27')](function(_0x17748b){if(_0x17748b){_0x1a7904=_0x17748b;_0x251314['model']=_['keys'](db[_0xc87f('0x4f')][_0xc87f('0x30')]);_0x251314[_0xc87f('0x34')]=_[_0xc87f('0x35')](_0x44e86e[_0xc87f('0x34')]);_0x251314[_0xc87f('0x36')]=_[_0xc87f('0x37')](_0x251314[_0xc87f('0x33')],_0x251314[_0xc87f('0x34')]);_0x4a6656[_0xc87f('0x38')]=_[_0xc87f('0x37')](_0x251314[_0xc87f('0x33')],qs['fields'](_0x44e86e[_0xc87f('0x34')][_0xc87f('0x49')]));_0x4a6656['attributes']=_0x4a6656['attributes']['length']?_0x4a6656[_0xc87f('0x38')]:_0x251314['model'];_0x4a6656['order']=qs[_0xc87f('0x3d')](_0x44e86e['query'][_0xc87f('0x3d')]);_0x4a6656[_0xc87f('0x3e')]=qs[_0xc87f('0x36')](_[_0xc87f('0x3f')](_0x44e86e[_0xc87f('0x34')],_0x251314[_0xc87f('0x36')]));if(_0x44e86e['query'][_0xc87f('0x41')]){_0x4a6656[_0xc87f('0x3e')]=_['merge'](_0x4a6656[_0xc87f('0x3e')],{'$or':_['map'](_0x4a6656[_0xc87f('0x38')],function(_0x2f63bb){var _0x353c98={};_0x353c98[_0x2f63bb]={'$like':'%'+_0x44e86e[_0xc87f('0x34')][_0xc87f('0x41')]+'%'};return _0x353c98;})});}_0x4a6656=_[_0xc87f('0x40')]({},_0x4a6656,_0x44e86e[_0xc87f('0x42')]);return _0x1a7904[_0xc87f('0x50')](_0x4a6656);}})['then'](function(_0x1c0132){if(_0x1c0132){_0x333798=_0x1c0132[_0xc87f('0x39')];if(!_0x44e86e[_0xc87f('0x34')][_0xc87f('0x3a')](_0xc87f('0x3b'))){_0x4a6656['limit']=qs[_0xc87f('0x1f')](_0x44e86e[_0xc87f('0x34')][_0xc87f('0x1f')]);_0x4a6656['offset']=qs['offset'](_0x44e86e[_0xc87f('0x34')][_0xc87f('0x1d')]);}return _0x1a7904['getDescriptions'](_0x4a6656);}})[_0xc87f('0x27')](function(_0x116dec){if(_0x116dec){return _0x116dec?{'count':_0x333798,'rows':_0x116dec}:null;}})[_0xc87f('0x27')](respondWithResult(_0x1f1c22,null))[_0xc87f('0x46')](handleError(_0x1f1c22,null));};exports[_0xc87f('0x51')]=function(_0x3fadb2,_0x39d03a,_0x4290e7){var _0x488f99={};var _0x1fe02c={};var _0x2babe2;var _0xa2d49d;return db[_0xc87f('0x2f')]['findOne']({'where':{'id':_0x3fadb2[_0xc87f('0x48')]['id']}})[_0xc87f('0x27')](handleEntityNotFound(_0x39d03a,null))['then'](function(_0xf31aaa){if(_0xf31aaa){_0x2babe2=_0xf31aaa;_0x1fe02c[_0xc87f('0x33')]=_[_0xc87f('0x35')](db[_0xc87f('0x52')][_0xc87f('0x30')]);_0x1fe02c[_0xc87f('0x34')]=_[_0xc87f('0x35')](_0x3fadb2[_0xc87f('0x34')]);_0x1fe02c[_0xc87f('0x36')]=_['intersection'](_0x1fe02c['model'],_0x1fe02c[_0xc87f('0x34')]);_0x488f99[_0xc87f('0x38')]=_['intersection'](_0x1fe02c['model'],qs[_0xc87f('0x49')](_0x3fadb2[_0xc87f('0x34')]['fields']));_0x488f99['attributes']=_0x488f99['attributes']['length']?_0x488f99[_0xc87f('0x38')]:_0x1fe02c['model'];_0x488f99[_0xc87f('0x3c')]=qs['sort'](_0x3fadb2[_0xc87f('0x34')][_0xc87f('0x3d')]);_0x488f99[_0xc87f('0x3e')]=qs[_0xc87f('0x36')](_[_0xc87f('0x3f')](_0x3fadb2[_0xc87f('0x34')],_0x1fe02c[_0xc87f('0x36')]));if(_0x3fadb2[_0xc87f('0x34')][_0xc87f('0x41')]){_0x488f99['where']=_[_0xc87f('0x40')](_0x488f99[_0xc87f('0x3e')],{'$or':_[_0xc87f('0x2e')](_0x488f99[_0xc87f('0x38')],function(_0x1ad8f4){var _0x2a3aba={};_0x2a3aba[_0x1ad8f4]={'$like':'%'+_0x3fadb2[_0xc87f('0x34')][_0xc87f('0x41')]+'%'};return _0x2a3aba;})});}_0x488f99=_[_0xc87f('0x40')]({},_0x488f99,_0x3fadb2[_0xc87f('0x42')]);return _0x2babe2[_0xc87f('0x51')](_0x488f99);}})[_0xc87f('0x27')](function(_0x57b133){if(_0x57b133){_0xa2d49d=_0x57b133['length'];if(!_0x3fadb2['query']['hasOwnProperty'](_0xc87f('0x3b'))){_0x488f99[_0xc87f('0x1f')]=qs['limit'](_0x3fadb2['query'][_0xc87f('0x1f')]);_0x488f99[_0xc87f('0x1d')]=qs[_0xc87f('0x1d')](_0x3fadb2['query'][_0xc87f('0x1d')]);}return _0x2babe2['getTags'](_0x488f99);}})[_0xc87f('0x27')](function(_0x1eefba){if(_0x1eefba){return _0x1eefba?{'count':_0xa2d49d,'rows':_0x1eefba}:null;}})[_0xc87f('0x27')](respondWithResult(_0x39d03a,null))[_0xc87f('0x46')](handleError(_0x39d03a,null));};exports[_0xc87f('0x53')]=function(_0x4f5d17,_0x4bd516,_0x191b8a){if(_0x4f5d17[_0xc87f('0x4c')]['id']){delete _0x4f5d17[_0xc87f('0x4c')]['id'];}return db['ZendeskConfiguration'][_0xc87f('0x4e')]({'where':{'id':_0x4f5d17[_0xc87f('0x48')]['id']}})[_0xc87f('0x27')](handleEntityNotFound(_0x4bd516,null))[_0xc87f('0x27')](function(_0x304071){if(_0x304071){return _0x304071[_0xc87f('0x53')](_0x4f5d17[_0xc87f('0x4c')][_0xc87f('0x54')]||[]);}return null;})[_0xc87f('0x27')](respondWithResult(_0x4bd516,null))[_0xc87f('0x46')](handleError(_0x4bd516,null));};
\ No newline at end of file
+var _0xa7cb=['fields','attributes','length','hasOwnProperty','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','includeAll','include','findAll','catch','show','params','keys','ZendeskConfiguration','options','find','create','body','findOne','ZendeskField','rawAttributes','getFields','getSubjects','getDescriptions','getTags','setTags','ids','eml-format','fast-json-patch','request-promise','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','name','status','send','map','fieldName','type','key','query','filters','intersection','model'];(function(_0x1c441b,_0x113389){var _0x50b12c=function(_0x45f70a){while(--_0x45f70a){_0x1c441b['push'](_0x1c441b['shift']());}};_0x50b12c(++_0x113389);}(_0xa7cb,0x76));var _0xba7c=function(_0x255c48,_0x2a4449){_0x255c48=_0x255c48-0x0;var _0xaebda3=_0xa7cb[_0x255c48];return _0xaebda3;};'use strict';var emlformat=require(_0xba7c('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xba7c('0x1'));var rp=require(_0xba7c('0x2'));var moment=require(_0xba7c('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xba7c('0x4'));var util=require(_0xba7c('0x5'));var path=require(_0xba7c('0x6'));var sox=require(_0xba7c('0x7'));var csv=require(_0xba7c('0x8'));var ejs=require(_0xba7c('0x9'));var fs=require('fs');var fs_extra=require(_0xba7c('0xa'));var _=require(_0xba7c('0xb'));var squel=require(_0xba7c('0xc'));var crypto=require('crypto');var jsforce=require(_0xba7c('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xba7c('0x8'));var querystring=require('querystring');var Papa=require(_0xba7c('0xe'));var Redis=require(_0xba7c('0xf'));var authService=require(_0xba7c('0x10'));var qs=require(_0xba7c('0x11'));var as=require(_0xba7c('0x12'));var hardwareService=require(_0xba7c('0x13'));var logger=require(_0xba7c('0x14'))(_0xba7c('0x15'));var utils=require('../../config/utils');var config=require(_0xba7c('0x16'));var licenseUtil=require(_0xba7c('0x17'));var db=require(_0xba7c('0x18'))['db'];function respondWithStatusCode(_0x3fe8a6,_0x5e5df8){_0x5e5df8=_0x5e5df8||0xcc;return function(_0x40c9db){if(_0x40c9db){return _0x3fe8a6[_0xba7c('0x19')](_0x5e5df8);}return _0x3fe8a6['status'](_0x5e5df8)[_0xba7c('0x1a')]();};}function respondWithResult(_0x2779b3,_0x3dd949){_0x3dd949=_0x3dd949||0xc8;return function(_0x588273){if(_0x588273){return _0x2779b3['status'](_0x3dd949)[_0xba7c('0x1b')](_0x588273);}};}function respondWithFilteredResult(_0x3d39f2,_0x3b2040){return function(_0xa15f9b){if(_0xa15f9b){var _0x2eda45=typeof _0x3b2040[_0xba7c('0x1c')]===_0xba7c('0x1d')&&typeof _0x3b2040['limit']===_0xba7c('0x1d');var _0x128544=_0xa15f9b['count'];var _0x15360b=_0x2eda45?0x0:_0x3b2040[_0xba7c('0x1c')];var _0xd883c7=_0x2eda45?_0xa15f9b[_0xba7c('0x1e')]:_0x3b2040[_0xba7c('0x1c')]+_0x3b2040[_0xba7c('0x1f')];var _0x6cf6fa;if(_0xd883c7>=_0x128544){_0xd883c7=_0x128544;_0x6cf6fa=0xc8;}else{_0x6cf6fa=0xce;}_0x3d39f2['status'](_0x6cf6fa);return _0x3d39f2[_0xba7c('0x20')](_0xba7c('0x21'),_0x15360b+'-'+_0xd883c7+'/'+_0x128544)[_0xba7c('0x1b')](_0xa15f9b);}return null;};}function patchUpdates(_0x140df0){return function(_0x124113){try{jsonpatch[_0xba7c('0x22')](_0x124113,_0x140df0,!![]);}catch(_0x3af773){return BPromise[_0xba7c('0x23')](_0x3af773);}return _0x124113[_0xba7c('0x24')]();};}function saveUpdates(_0x480817,_0x26e58){return function(_0x355d43){if(_0x355d43){return _0x355d43[_0xba7c('0x25')](_0x480817)[_0xba7c('0x26')](function(_0x1c0c02){return _0x1c0c02;});}return null;};}function removeEntity(_0x36d45b,_0x2b44be){return function(_0x4457d8){if(_0x4457d8){return _0x4457d8[_0xba7c('0x27')]()[_0xba7c('0x26')](function(){_0x36d45b['status'](0xcc)[_0xba7c('0x1a')]();});}};}function handleEntityNotFound(_0xe8ca79,_0x127ed0){return function(_0x553a58){if(!_0x553a58){_0xe8ca79[_0xba7c('0x19')](0x194);}return _0x553a58;};}function handleError(_0x51908a,_0x4bf35f){_0x4bf35f=_0x4bf35f||0x1f4;return function(_0x12f103){logger[_0xba7c('0x28')](_0x12f103['stack']);if(_0x12f103[_0xba7c('0x29')]){delete _0x12f103[_0xba7c('0x29')];}_0x51908a[_0xba7c('0x2a')](_0x4bf35f)[_0xba7c('0x2b')](_0x12f103);};}exports['index']=function(_0x82c7f5,_0x64dda7){var _0x26d328={},_0x4ae7d2={},_0x4b902b={'count':0x0,'rows':[]};var _0x5a1c48=_[_0xba7c('0x2c')](db['ZendeskConfiguration']['rawAttributes'],function(_0x47c761){return{'name':_0x47c761[_0xba7c('0x2d')],'type':_0x47c761[_0xba7c('0x2e')][_0xba7c('0x2f')]};});_0x4ae7d2['model']=_[_0xba7c('0x2c')](_0x5a1c48,_0xba7c('0x29'));_0x4ae7d2[_0xba7c('0x30')]=_['keys'](_0x82c7f5[_0xba7c('0x30')]);_0x4ae7d2[_0xba7c('0x31')]=_[_0xba7c('0x32')](_0x4ae7d2['model'],_0x4ae7d2[_0xba7c('0x30')]);_0x26d328['attributes']=_[_0xba7c('0x32')](_0x4ae7d2[_0xba7c('0x33')],qs[_0xba7c('0x34')](_0x82c7f5[_0xba7c('0x30')]['fields']));_0x26d328[_0xba7c('0x35')]=_0x26d328[_0xba7c('0x35')][_0xba7c('0x36')]?_0x26d328[_0xba7c('0x35')]:_0x4ae7d2[_0xba7c('0x33')];if(!_0x82c7f5[_0xba7c('0x30')][_0xba7c('0x37')](_0xba7c('0x38'))){_0x26d328[_0xba7c('0x1f')]=qs[_0xba7c('0x1f')](_0x82c7f5[_0xba7c('0x30')][_0xba7c('0x1f')]);_0x26d328['offset']=qs['offset'](_0x82c7f5['query'][_0xba7c('0x1c')]);}_0x26d328[_0xba7c('0x39')]=qs[_0xba7c('0x3a')](_0x82c7f5['query'][_0xba7c('0x3a')]);_0x26d328['where']=qs[_0xba7c('0x31')](_[_0xba7c('0x3b')](_0x82c7f5[_0xba7c('0x30')],_0x4ae7d2[_0xba7c('0x31')]),_0x5a1c48);if(_0x82c7f5[_0xba7c('0x30')][_0xba7c('0x3c')]){_0x26d328[_0xba7c('0x3d')]=_[_0xba7c('0x3e')](_0x26d328[_0xba7c('0x3d')],{'$or':_[_0xba7c('0x2c')](_0x5a1c48,function(_0x190055){if(_0x190055[_0xba7c('0x2e')]!==_0xba7c('0x3f')){var _0xdb3fbf={};_0xdb3fbf[_0x190055[_0xba7c('0x29')]]={'$like':'%'+_0x82c7f5[_0xba7c('0x30')][_0xba7c('0x3c')]+'%'};return _0xdb3fbf;}})});}_0x26d328=_[_0xba7c('0x3e')]({},_0x26d328,_0x82c7f5['options']);var _0x5c14cb={'where':_0x26d328[_0xba7c('0x3d')]};return db['ZendeskConfiguration'][_0xba7c('0x1e')](_0x5c14cb)[_0xba7c('0x26')](function(_0x52be7a){_0x4b902b['count']=_0x52be7a;if(_0x82c7f5[_0xba7c('0x30')][_0xba7c('0x40')]){_0x26d328[_0xba7c('0x41')]=[{'all':!![]}];}return db['ZendeskConfiguration'][_0xba7c('0x42')](_0x26d328);})[_0xba7c('0x26')](function(_0x44a37f){_0x4b902b['rows']=_0x44a37f;return _0x4b902b;})['then'](respondWithFilteredResult(_0x64dda7,_0x26d328))[_0xba7c('0x43')](handleError(_0x64dda7,null));};exports[_0xba7c('0x44')]=function(_0x21b939,_0x2ef074){var _0x319ffe={'raw':![],'where':{'id':_0x21b939[_0xba7c('0x45')]['id']}},_0x38e97b={};_0x38e97b[_0xba7c('0x33')]=_[_0xba7c('0x46')](db[_0xba7c('0x47')]['rawAttributes']);_0x38e97b[_0xba7c('0x30')]=_['keys'](_0x21b939[_0xba7c('0x30')]);_0x38e97b[_0xba7c('0x31')]=_[_0xba7c('0x32')](_0x38e97b[_0xba7c('0x33')],_0x38e97b['query']);_0x319ffe[_0xba7c('0x35')]=_[_0xba7c('0x32')](_0x38e97b[_0xba7c('0x33')],qs[_0xba7c('0x34')](_0x21b939[_0xba7c('0x30')][_0xba7c('0x34')]));_0x319ffe[_0xba7c('0x35')]=_0x319ffe[_0xba7c('0x35')]['length']?_0x319ffe[_0xba7c('0x35')]:_0x38e97b['model'];if(_0x21b939[_0xba7c('0x30')][_0xba7c('0x40')]){_0x319ffe[_0xba7c('0x41')]=[{'all':!![]}];}_0x319ffe=_[_0xba7c('0x3e')]({},_0x319ffe,_0x21b939[_0xba7c('0x48')]);return db['ZendeskConfiguration'][_0xba7c('0x49')](_0x319ffe)[_0xba7c('0x26')](handleEntityNotFound(_0x2ef074,null))[_0xba7c('0x26')](respondWithResult(_0x2ef074,null))['catch'](handleError(_0x2ef074,null));};exports['create']=function(_0x53dece,_0x446450){return db[_0xba7c('0x47')][_0xba7c('0x4a')](_0x53dece[_0xba7c('0x4b')],{})[_0xba7c('0x26')](respondWithResult(_0x446450,0xc9))['catch'](handleError(_0x446450,null));};exports[_0xba7c('0x25')]=function(_0x135168,_0x5824ab){if(_0x135168[_0xba7c('0x4b')]['id']){delete _0x135168[_0xba7c('0x4b')]['id'];}return db[_0xba7c('0x47')][_0xba7c('0x49')]({'where':{'id':_0x135168[_0xba7c('0x45')]['id']}})[_0xba7c('0x26')](handleEntityNotFound(_0x5824ab,null))[_0xba7c('0x26')](saveUpdates(_0x135168[_0xba7c('0x4b')],null))[_0xba7c('0x26')](respondWithResult(_0x5824ab,null))['catch'](handleError(_0x5824ab,null));};exports[_0xba7c('0x27')]=function(_0x253ed3,_0x35a5f2){return db[_0xba7c('0x47')]['find']({'where':{'id':_0x253ed3['params']['id']}})[_0xba7c('0x26')](handleEntityNotFound(_0x35a5f2,null))[_0xba7c('0x26')](removeEntity(_0x35a5f2,null))[_0xba7c('0x43')](handleError(_0x35a5f2,null));};exports['getFields']=function(_0x28f9c1,_0x4fd0f4,_0x568e6a){var _0x14df3c={};var _0x3e14b8={};var _0x1ac2cb;var _0x44f5ba;return db[_0xba7c('0x47')][_0xba7c('0x4c')]({'where':{'id':_0x28f9c1['params']['id']}})[_0xba7c('0x26')](handleEntityNotFound(_0x4fd0f4,null))[_0xba7c('0x26')](function(_0x591156){if(_0x591156){_0x1ac2cb=_0x591156;_0x3e14b8[_0xba7c('0x33')]=_[_0xba7c('0x46')](db[_0xba7c('0x4d')][_0xba7c('0x4e')]);_0x3e14b8[_0xba7c('0x30')]=_[_0xba7c('0x46')](_0x28f9c1[_0xba7c('0x30')]);_0x3e14b8[_0xba7c('0x31')]=_[_0xba7c('0x32')](_0x3e14b8[_0xba7c('0x33')],_0x3e14b8['query']);_0x14df3c[_0xba7c('0x35')]=_['intersection'](_0x3e14b8['model'],qs['fields'](_0x28f9c1[_0xba7c('0x30')][_0xba7c('0x34')]));_0x14df3c[_0xba7c('0x35')]=_0x14df3c['attributes'][_0xba7c('0x36')]?_0x14df3c[_0xba7c('0x35')]:_0x3e14b8[_0xba7c('0x33')];_0x14df3c[_0xba7c('0x39')]=qs[_0xba7c('0x3a')](_0x28f9c1[_0xba7c('0x30')][_0xba7c('0x3a')]);_0x14df3c[_0xba7c('0x3d')]=qs[_0xba7c('0x31')](_['pick'](_0x28f9c1[_0xba7c('0x30')],_0x3e14b8['filters']));if(_0x28f9c1[_0xba7c('0x30')][_0xba7c('0x3c')]){_0x14df3c[_0xba7c('0x3d')]=_[_0xba7c('0x3e')](_0x14df3c[_0xba7c('0x3d')],{'$or':_[_0xba7c('0x2c')](_0x14df3c['attributes'],function(_0x8e4514){var _0x39ac04={};_0x39ac04[_0x8e4514]={'$like':'%'+_0x28f9c1[_0xba7c('0x30')]['filter']+'%'};return _0x39ac04;})});}_0x14df3c=_[_0xba7c('0x3e')]({},_0x14df3c,_0x28f9c1['options']);return _0x1ac2cb[_0xba7c('0x4f')](_0x14df3c);}})[_0xba7c('0x26')](function(_0x28aa3f){if(_0x28aa3f){_0x44f5ba=_0x28aa3f[_0xba7c('0x36')];if(!_0x28f9c1[_0xba7c('0x30')]['hasOwnProperty'](_0xba7c('0x38'))){_0x14df3c['limit']=qs[_0xba7c('0x1f')](_0x28f9c1[_0xba7c('0x30')][_0xba7c('0x1f')]);_0x14df3c[_0xba7c('0x1c')]=qs['offset'](_0x28f9c1[_0xba7c('0x30')]['offset']);}return _0x1ac2cb[_0xba7c('0x4f')](_0x14df3c);}})[_0xba7c('0x26')](function(_0x24a0ee){if(_0x24a0ee){return _0x24a0ee?{'count':_0x44f5ba,'rows':_0x24a0ee}:null;}})[_0xba7c('0x26')](respondWithResult(_0x4fd0f4,null))['catch'](handleError(_0x4fd0f4,null));};exports[_0xba7c('0x50')]=function(_0x941a49,_0x581f39,_0x1e5e12){var _0x57f579={};var _0x28cc78={};var _0xf98930;var _0xea235a;return db['ZendeskConfiguration'][_0xba7c('0x4c')]({'where':{'id':_0x941a49[_0xba7c('0x45')]['id']}})['then'](handleEntityNotFound(_0x581f39,null))['then'](function(_0x484da0){if(_0x484da0){_0xf98930=_0x484da0;_0x28cc78[_0xba7c('0x33')]=_[_0xba7c('0x46')](db['ZendeskField'][_0xba7c('0x4e')]);_0x28cc78[_0xba7c('0x30')]=_['keys'](_0x941a49[_0xba7c('0x30')]);_0x28cc78[_0xba7c('0x31')]=_[_0xba7c('0x32')](_0x28cc78[_0xba7c('0x33')],_0x28cc78[_0xba7c('0x30')]);_0x57f579[_0xba7c('0x35')]=_[_0xba7c('0x32')](_0x28cc78[_0xba7c('0x33')],qs[_0xba7c('0x34')](_0x941a49[_0xba7c('0x30')][_0xba7c('0x34')]));_0x57f579[_0xba7c('0x35')]=_0x57f579['attributes']['length']?_0x57f579[_0xba7c('0x35')]:_0x28cc78[_0xba7c('0x33')];_0x57f579['order']=qs[_0xba7c('0x3a')](_0x941a49[_0xba7c('0x30')][_0xba7c('0x3a')]);_0x57f579['where']=qs['filters'](_[_0xba7c('0x3b')](_0x941a49['query'],_0x28cc78['filters']));if(_0x941a49['query']['filter']){_0x57f579[_0xba7c('0x3d')]=_['merge'](_0x57f579[_0xba7c('0x3d')],{'$or':_['map'](_0x57f579[_0xba7c('0x35')],function(_0x264f82){var _0x2777e4={};_0x2777e4[_0x264f82]={'$like':'%'+_0x941a49[_0xba7c('0x30')][_0xba7c('0x3c')]+'%'};return _0x2777e4;})});}_0x57f579=_[_0xba7c('0x3e')]({},_0x57f579,_0x941a49[_0xba7c('0x48')]);return _0xf98930['getSubjects'](_0x57f579);}})[_0xba7c('0x26')](function(_0x181409){if(_0x181409){_0xea235a=_0x181409['length'];if(!_0x941a49['query'][_0xba7c('0x37')](_0xba7c('0x38'))){_0x57f579[_0xba7c('0x1f')]=qs['limit'](_0x941a49[_0xba7c('0x30')][_0xba7c('0x1f')]);_0x57f579[_0xba7c('0x1c')]=qs[_0xba7c('0x1c')](_0x941a49[_0xba7c('0x30')]['offset']);}return _0xf98930[_0xba7c('0x50')](_0x57f579);}})[_0xba7c('0x26')](function(_0x3666e8){if(_0x3666e8){return _0x3666e8?{'count':_0xea235a,'rows':_0x3666e8}:null;}})['then'](respondWithResult(_0x581f39,null))['catch'](handleError(_0x581f39,null));};exports[_0xba7c('0x51')]=function(_0x2f46dc,_0x602461,_0x2c4d52){var _0x3d2b1c={};var _0x2fc119={};var _0x21849f;var _0xb5418c;return db[_0xba7c('0x47')][_0xba7c('0x4c')]({'where':{'id':_0x2f46dc[_0xba7c('0x45')]['id']}})[_0xba7c('0x26')](handleEntityNotFound(_0x602461,null))[_0xba7c('0x26')](function(_0x128308){if(_0x128308){_0x21849f=_0x128308;_0x2fc119['model']=_[_0xba7c('0x46')](db[_0xba7c('0x4d')]['rawAttributes']);_0x2fc119[_0xba7c('0x30')]=_[_0xba7c('0x46')](_0x2f46dc['query']);_0x2fc119[_0xba7c('0x31')]=_[_0xba7c('0x32')](_0x2fc119[_0xba7c('0x33')],_0x2fc119[_0xba7c('0x30')]);_0x3d2b1c['attributes']=_[_0xba7c('0x32')](_0x2fc119[_0xba7c('0x33')],qs[_0xba7c('0x34')](_0x2f46dc[_0xba7c('0x30')][_0xba7c('0x34')]));_0x3d2b1c[_0xba7c('0x35')]=_0x3d2b1c[_0xba7c('0x35')][_0xba7c('0x36')]?_0x3d2b1c['attributes']:_0x2fc119[_0xba7c('0x33')];_0x3d2b1c[_0xba7c('0x39')]=qs[_0xba7c('0x3a')](_0x2f46dc['query'][_0xba7c('0x3a')]);_0x3d2b1c[_0xba7c('0x3d')]=qs[_0xba7c('0x31')](_[_0xba7c('0x3b')](_0x2f46dc[_0xba7c('0x30')],_0x2fc119['filters']));if(_0x2f46dc['query'][_0xba7c('0x3c')]){_0x3d2b1c[_0xba7c('0x3d')]=_[_0xba7c('0x3e')](_0x3d2b1c['where'],{'$or':_['map'](_0x3d2b1c[_0xba7c('0x35')],function(_0x25e4e6){var _0x12adf1={};_0x12adf1[_0x25e4e6]={'$like':'%'+_0x2f46dc['query'][_0xba7c('0x3c')]+'%'};return _0x12adf1;})});}_0x3d2b1c=_[_0xba7c('0x3e')]({},_0x3d2b1c,_0x2f46dc[_0xba7c('0x48')]);return _0x21849f[_0xba7c('0x51')](_0x3d2b1c);}})[_0xba7c('0x26')](function(_0x1ddecf){if(_0x1ddecf){_0xb5418c=_0x1ddecf[_0xba7c('0x36')];if(!_0x2f46dc['query']['hasOwnProperty'](_0xba7c('0x38'))){_0x3d2b1c[_0xba7c('0x1f')]=qs[_0xba7c('0x1f')](_0x2f46dc[_0xba7c('0x30')][_0xba7c('0x1f')]);_0x3d2b1c[_0xba7c('0x1c')]=qs[_0xba7c('0x1c')](_0x2f46dc[_0xba7c('0x30')]['offset']);}return _0x21849f[_0xba7c('0x51')](_0x3d2b1c);}})['then'](function(_0x67621b){if(_0x67621b){return _0x67621b?{'count':_0xb5418c,'rows':_0x67621b}:null;}})[_0xba7c('0x26')](respondWithResult(_0x602461,null))[_0xba7c('0x43')](handleError(_0x602461,null));};exports[_0xba7c('0x52')]=function(_0x58805a,_0x88489,_0x3b9ded){var _0x4f1bdc={};var _0x44054d={};var _0x53b8ab;var _0x248f90;return db[_0xba7c('0x47')][_0xba7c('0x4c')]({'where':{'id':_0x58805a[_0xba7c('0x45')]['id']}})[_0xba7c('0x26')](handleEntityNotFound(_0x88489,null))[_0xba7c('0x26')](function(_0xa44f7a){if(_0xa44f7a){_0x53b8ab=_0xa44f7a;_0x44054d[_0xba7c('0x33')]=_[_0xba7c('0x46')](db['Tag'][_0xba7c('0x4e')]);_0x44054d[_0xba7c('0x30')]=_[_0xba7c('0x46')](_0x58805a[_0xba7c('0x30')]);_0x44054d['filters']=_['intersection'](_0x44054d[_0xba7c('0x33')],_0x44054d[_0xba7c('0x30')]);_0x4f1bdc[_0xba7c('0x35')]=_['intersection'](_0x44054d[_0xba7c('0x33')],qs[_0xba7c('0x34')](_0x58805a[_0xba7c('0x30')][_0xba7c('0x34')]));_0x4f1bdc['attributes']=_0x4f1bdc[_0xba7c('0x35')][_0xba7c('0x36')]?_0x4f1bdc['attributes']:_0x44054d[_0xba7c('0x33')];_0x4f1bdc['order']=qs[_0xba7c('0x3a')](_0x58805a['query'][_0xba7c('0x3a')]);_0x4f1bdc[_0xba7c('0x3d')]=qs['filters'](_[_0xba7c('0x3b')](_0x58805a[_0xba7c('0x30')],_0x44054d[_0xba7c('0x31')]));if(_0x58805a['query'][_0xba7c('0x3c')]){_0x4f1bdc[_0xba7c('0x3d')]=_[_0xba7c('0x3e')](_0x4f1bdc['where'],{'$or':_[_0xba7c('0x2c')](_0x4f1bdc[_0xba7c('0x35')],function(_0x287ad6){var _0x22008d={};_0x22008d[_0x287ad6]={'$like':'%'+_0x58805a[_0xba7c('0x30')][_0xba7c('0x3c')]+'%'};return _0x22008d;})});}_0x4f1bdc=_['merge']({},_0x4f1bdc,_0x58805a[_0xba7c('0x48')]);return _0x53b8ab[_0xba7c('0x52')](_0x4f1bdc);}})[_0xba7c('0x26')](function(_0x4bd755){if(_0x4bd755){_0x248f90=_0x4bd755['length'];if(!_0x58805a[_0xba7c('0x30')]['hasOwnProperty'](_0xba7c('0x38'))){_0x4f1bdc[_0xba7c('0x1f')]=qs['limit'](_0x58805a[_0xba7c('0x30')]['limit']);_0x4f1bdc[_0xba7c('0x1c')]=qs[_0xba7c('0x1c')](_0x58805a[_0xba7c('0x30')][_0xba7c('0x1c')]);}return _0x53b8ab[_0xba7c('0x52')](_0x4f1bdc);}})['then'](function(_0x460cc6){if(_0x460cc6){return _0x460cc6?{'count':_0x248f90,'rows':_0x460cc6}:null;}})[_0xba7c('0x26')](respondWithResult(_0x88489,null))[_0xba7c('0x43')](handleError(_0x88489,null));};exports['setTags']=function(_0x3ea79b,_0x537fab,_0x5ad9ac){if(_0x3ea79b[_0xba7c('0x4b')]['id']){delete _0x3ea79b[_0xba7c('0x4b')]['id'];}return db[_0xba7c('0x47')][_0xba7c('0x4c')]({'where':{'id':_0x3ea79b[_0xba7c('0x45')]['id']}})['then'](handleEntityNotFound(_0x537fab,null))[_0xba7c('0x26')](function(_0x49807f){if(_0x49807f){return _0x49807f[_0xba7c('0x53')](_0x3ea79b['body'][_0xba7c('0x54')]||[]);}return null;})['then'](respondWithResult(_0x537fab,null))[_0xba7c('0x43')](handleError(_0x537fab,null));};
\ No newline at end of file