Built motion from commit 9e1399f3.|2.5.37
[motion2.git] / server / api / intDeskConfiguration / intDeskConfiguration.controller.js
index 29d383c..88b8296 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x8709=['count','offset','limit','set','apply','reject','save','destroy','stack','name','map','DeskConfiguration','rawAttributes','fieldName','type','key','query','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','VIRTUAL','filter','merge','includeAll','include','rows','params','keys','filters','intersection','options','find','create','body','update','getFields','findOne','DeskField','getSubjects','getDescriptions','Tag','getTags','setTags','ids','eml-format','zip-dir','moment','bluebird','mustache','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','jayson/promise','client','http','request','then','info','DeskConfiguration,\x20%s,\x20%s','request\x20sent','debug','DeskConfiguration,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','sendStatus','status','end','json'];(function(_0x11a7ff,_0x581246){var _0x4bb0fe=function(_0x6091c7){while(--_0x6091c7){_0x11a7ff['push'](_0x11a7ff['shift']());}};_0x4bb0fe(++_0x581246);}(_0x8709,0x1ab));var _0x9870=function(_0x39b68b,_0x4ad96d){_0x39b68b=_0x39b68b-0x0;var _0xae091f=_0x8709[_0x39b68b];return _0xae091f;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x9870('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x9870('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x9870('0x2'));var BPromise=require(_0x9870('0x3'));var Mustache=require(_0x9870('0x4'));var util=require('util');var path=require(_0x9870('0x5'));var sox=require(_0x9870('0x6'));var csv=require(_0x9870('0x7'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x9870('0x8'));var squel=require(_0x9870('0x9'));var crypto=require(_0x9870('0xa'));var jsforce=require(_0x9870('0xb'));var deskjs=require(_0x9870('0xc'));var toCsv=require('to-csv');var querystring=require(_0x9870('0xd'));var Papa=require('papaparse');var Redis=require(_0x9870('0xe'));var authService=require(_0x9870('0xf'));var qs=require(_0x9870('0x10'));var as=require(_0x9870('0x11'));var hardwareService=require(_0x9870('0x12'));var logger=require(_0x9870('0x13'))(_0x9870('0x14'));var utils=require(_0x9870('0x15'));var config=require(_0x9870('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];var jayson=require(_0x9870('0x17'));var client=jayson[_0x9870('0x18')][_0x9870('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x3bdf2d,_0x507edb,_0x32143d,_0x3b5b87){return new BPromise(function(_0x4da740,_0x1115b4){var _0x512e4e=_0x3b5b87||client;return _0x512e4e[_0x9870('0x1a')](_0x3bdf2d,_0x32143d)[_0x9870('0x1b')](function(_0x9180d9){logger[_0x9870('0x1c')](_0x9870('0x1d'),_0x507edb,_0x9870('0x1e'));logger[_0x9870('0x1f')](_0x9870('0x20'),_0x507edb,_0x9870('0x1e'),JSON[_0x9870('0x21')](_0x9180d9));if(_0x9180d9['error']){if(_0x9180d9[_0x9870('0x22')][_0x9870('0x23')]===0x1f4){logger[_0x9870('0x22')](_0x9870('0x1d'),_0x507edb,_0x9180d9[_0x9870('0x22')]['message']);return _0x1115b4(_0x9180d9['error'][_0x9870('0x24')]);}logger['error'](_0x9870('0x1d'),_0x507edb,_0x9180d9[_0x9870('0x22')][_0x9870('0x24')]);return _0x4da740(_0x9180d9[_0x9870('0x22')][_0x9870('0x24')]);}else{logger[_0x9870('0x1c')]('DeskConfiguration,\x20%s,\x20%s',_0x507edb,_0x9870('0x1e'));_0x4da740(_0x9180d9[_0x9870('0x25')][_0x9870('0x24')]);}})[_0x9870('0x26')](function(_0x3c91e3){logger[_0x9870('0x22')](_0x9870('0x1d'),_0x507edb,_0x3c91e3);_0x1115b4(_0x3c91e3);});});}function respondWithStatusCode(_0x258314,_0xb6217f){_0xb6217f=_0xb6217f||0xcc;return function(_0x1b836a){if(_0x1b836a){return _0x258314[_0x9870('0x27')](_0xb6217f);}return _0x258314[_0x9870('0x28')](_0xb6217f)[_0x9870('0x29')]();};}function respondWithResult(_0xd6b8d3,_0x1b348a){_0x1b348a=_0x1b348a||0xc8;return function(_0x13dc54){if(_0x13dc54){return _0xd6b8d3[_0x9870('0x28')](_0x1b348a)[_0x9870('0x2a')](_0x13dc54);}};}function respondWithFilteredResult(_0x1c87f4,_0x46ed90){return function(_0x4c354a){if(_0x4c354a){var _0x3f5046=_0x4c354a[_0x9870('0x2b')],_0x4042cb=_0x46ed90[_0x9870('0x2c')],_0x47fb14=_0x46ed90['offset']+_0x46ed90[_0x9870('0x2d')],_0xbbdd23;if(_0x47fb14>=_0x3f5046){_0x47fb14=_0x3f5046;_0xbbdd23=0xc8;}else{_0xbbdd23=0xce;}_0x1c87f4[_0x9870('0x28')](_0xbbdd23);return _0x1c87f4[_0x9870('0x2e')]('Content-Range',_0x4042cb+'-'+_0x47fb14+'/'+_0x3f5046)[_0x9870('0x2a')](_0x4c354a);}return null;};}function patchUpdates(_0x10990f){return function(_0x44fcb9){try{jsonpatch[_0x9870('0x2f')](_0x44fcb9,_0x10990f,!![]);}catch(_0x4b4491){return BPromise[_0x9870('0x30')](_0x4b4491);}return _0x44fcb9[_0x9870('0x31')]();};}function saveUpdates(_0x2389d9,_0x46b47f){return function(_0x30508a){if(_0x30508a){return _0x30508a['update'](_0x2389d9)['then'](function(_0x3aff0b){return _0x3aff0b;});}return null;};}function removeEntity(_0x55cba7,_0x4806fd){return function(_0x2a69fe){if(_0x2a69fe){return _0x2a69fe[_0x9870('0x32')]()[_0x9870('0x1b')](function(){_0x55cba7[_0x9870('0x28')](0xcc)[_0x9870('0x29')]();});}};}function handleEntityNotFound(_0x3e2dd1,_0x38ff13){return function(_0x23e03c){if(!_0x23e03c){_0x3e2dd1[_0x9870('0x27')](0x194);}return _0x23e03c;};}function handleError(_0x56da62,_0x366a47){_0x366a47=_0x366a47||0x1f4;return function(_0x518ee2){logger[_0x9870('0x22')](_0x518ee2[_0x9870('0x33')]);if(_0x518ee2[_0x9870('0x34')]){delete _0x518ee2['name'];}_0x56da62['status'](_0x366a47)['send'](_0x518ee2);};}exports['index']=function(_0x516970,_0x3cd68b){var _0x46ed26={},_0x494a1e={},_0xc5654b={'count':0x0,'rows':[]};var _0x335e3d=_[_0x9870('0x35')](db[_0x9870('0x36')][_0x9870('0x37')],function(_0x48a4c1){return{'name':_0x48a4c1[_0x9870('0x38')],'type':_0x48a4c1[_0x9870('0x39')][_0x9870('0x3a')]};});_0x494a1e['model']=_['map'](_0x335e3d,'name');_0x494a1e[_0x9870('0x3b')]=_['keys'](_0x516970[_0x9870('0x3b')]);_0x494a1e['filters']=_['intersection'](_0x494a1e[_0x9870('0x3c')],_0x494a1e[_0x9870('0x3b')]);_0x46ed26['attributes']=_['intersection'](_0x494a1e[_0x9870('0x3c')],qs['fields'](_0x516970[_0x9870('0x3b')][_0x9870('0x3d')]));_0x46ed26[_0x9870('0x3e')]=_0x46ed26[_0x9870('0x3e')][_0x9870('0x3f')]?_0x46ed26[_0x9870('0x3e')]:_0x494a1e[_0x9870('0x3c')];if(!_0x516970['query'][_0x9870('0x40')](_0x9870('0x41'))){_0x46ed26['limit']=qs[_0x9870('0x2d')](_0x516970['query'][_0x9870('0x2d')]);_0x46ed26[_0x9870('0x2c')]=qs[_0x9870('0x2c')](_0x516970[_0x9870('0x3b')]['offset']);}_0x46ed26[_0x9870('0x42')]=qs[_0x9870('0x43')](_0x516970[_0x9870('0x3b')][_0x9870('0x43')]);_0x46ed26[_0x9870('0x44')]=qs['filters'](_[_0x9870('0x45')](_0x516970[_0x9870('0x3b')],_0x494a1e['filters']),_0x335e3d);if(_0x516970[_0x9870('0x3b')]['filter']){_0x46ed26[_0x9870('0x44')]=_['merge'](_0x46ed26[_0x9870('0x44')],{'$or':_[_0x9870('0x35')](_0x335e3d,function(_0x4eb233){if(_0x4eb233[_0x9870('0x39')]!==_0x9870('0x46')){var _0x483ade={};_0x483ade[_0x4eb233[_0x9870('0x34')]]={'$like':'%'+_0x516970[_0x9870('0x3b')][_0x9870('0x47')]+'%'};return _0x483ade;}})});}_0x46ed26=_[_0x9870('0x48')]({},_0x46ed26,_0x516970['options']);var _0x3bd068={'where':_0x46ed26[_0x9870('0x44')]};return db['DeskConfiguration'][_0x9870('0x2b')](_0x3bd068)['then'](function(_0xd509a){_0xc5654b[_0x9870('0x2b')]=_0xd509a;if(_0x516970['query'][_0x9870('0x49')]){_0x46ed26[_0x9870('0x4a')]=[{'all':!![]}];}return db[_0x9870('0x36')]['findAll'](_0x46ed26);})[_0x9870('0x1b')](function(_0x476c7e){_0xc5654b[_0x9870('0x4b')]=_0x476c7e;return _0xc5654b;})[_0x9870('0x1b')](respondWithFilteredResult(_0x3cd68b,_0x46ed26))[_0x9870('0x26')](handleError(_0x3cd68b,null));};exports['show']=function(_0x5d15e7,_0x41f971){var _0xbfef30={'raw':![],'where':{'id':_0x5d15e7[_0x9870('0x4c')]['id']}},_0x35044f={};_0x35044f[_0x9870('0x3c')]=_[_0x9870('0x4d')](db[_0x9870('0x36')][_0x9870('0x37')]);_0x35044f[_0x9870('0x3b')]=_[_0x9870('0x4d')](_0x5d15e7['query']);_0x35044f[_0x9870('0x4e')]=_[_0x9870('0x4f')](_0x35044f['model'],_0x35044f[_0x9870('0x3b')]);_0xbfef30[_0x9870('0x3e')]=_[_0x9870('0x4f')](_0x35044f[_0x9870('0x3c')],qs[_0x9870('0x3d')](_0x5d15e7[_0x9870('0x3b')][_0x9870('0x3d')]));_0xbfef30[_0x9870('0x3e')]=_0xbfef30[_0x9870('0x3e')][_0x9870('0x3f')]?_0xbfef30[_0x9870('0x3e')]:_0x35044f[_0x9870('0x3c')];if(_0x5d15e7[_0x9870('0x3b')]['includeAll']){_0xbfef30[_0x9870('0x4a')]=[{'all':!![]}];}_0xbfef30=_[_0x9870('0x48')]({},_0xbfef30,_0x5d15e7[_0x9870('0x50')]);return db['DeskConfiguration'][_0x9870('0x51')](_0xbfef30)['then'](handleEntityNotFound(_0x41f971,null))[_0x9870('0x1b')](respondWithResult(_0x41f971,null))['catch'](handleError(_0x41f971,null));};exports[_0x9870('0x52')]=function(_0x5aed00,_0x1668a6){return db[_0x9870('0x36')][_0x9870('0x52')](_0x5aed00[_0x9870('0x53')],{})[_0x9870('0x1b')](respondWithResult(_0x1668a6,0xc9))['catch'](handleError(_0x1668a6,null));};exports[_0x9870('0x54')]=function(_0xde0c6d,_0x59e1bc){if(_0xde0c6d[_0x9870('0x53')]['id']){delete _0xde0c6d[_0x9870('0x53')]['id'];}return db[_0x9870('0x36')][_0x9870('0x51')]({'where':{'id':_0xde0c6d[_0x9870('0x4c')]['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x59e1bc,null))[_0x9870('0x1b')](saveUpdates(_0xde0c6d[_0x9870('0x53')],null))['then'](respondWithResult(_0x59e1bc,null))[_0x9870('0x26')](handleError(_0x59e1bc,null));};exports[_0x9870('0x32')]=function(_0x2bf4f7,_0x274f5c){return db[_0x9870('0x36')]['find']({'where':{'id':_0x2bf4f7[_0x9870('0x4c')]['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x274f5c,null))['then'](removeEntity(_0x274f5c,null))[_0x9870('0x26')](handleError(_0x274f5c,null));};exports[_0x9870('0x55')]=function(_0x3e4802,_0x1c559b,_0x5f49e2){var _0x34d770={};var _0x1133ba={};var _0x2e4717;var _0x381f35;return db[_0x9870('0x36')][_0x9870('0x56')]({'where':{'id':_0x3e4802[_0x9870('0x4c')]['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x1c559b,null))['then'](function(_0x3930e5){if(_0x3930e5){_0x2e4717=_0x3930e5;_0x1133ba[_0x9870('0x3c')]=_['keys'](db[_0x9870('0x57')][_0x9870('0x37')]);_0x1133ba[_0x9870('0x3b')]=_[_0x9870('0x4d')](_0x3e4802[_0x9870('0x3b')]);_0x1133ba[_0x9870('0x4e')]=_[_0x9870('0x4f')](_0x1133ba[_0x9870('0x3c')],_0x1133ba[_0x9870('0x3b')]);_0x34d770[_0x9870('0x3e')]=_[_0x9870('0x4f')](_0x1133ba[_0x9870('0x3c')],qs[_0x9870('0x3d')](_0x3e4802[_0x9870('0x3b')]['fields']));_0x34d770[_0x9870('0x3e')]=_0x34d770[_0x9870('0x3e')]['length']?_0x34d770[_0x9870('0x3e')]:_0x1133ba['model'];_0x34d770['order']=qs[_0x9870('0x43')](_0x3e4802['query'][_0x9870('0x43')]);_0x34d770[_0x9870('0x44')]=qs[_0x9870('0x4e')](_['pick'](_0x3e4802[_0x9870('0x3b')],_0x1133ba[_0x9870('0x4e')]));if(_0x3e4802[_0x9870('0x3b')]['filter']){_0x34d770[_0x9870('0x44')]=_[_0x9870('0x48')](_0x34d770[_0x9870('0x44')],{'$or':_[_0x9870('0x35')](_0x34d770[_0x9870('0x3e')],function(_0x5c3ea4){var _0x39c47a={};_0x39c47a[_0x5c3ea4]={'$like':'%'+_0x3e4802[_0x9870('0x3b')][_0x9870('0x47')]+'%'};return _0x39c47a;})});}_0x34d770=_['merge']({},_0x34d770,_0x3e4802[_0x9870('0x50')]);return _0x2e4717['getFields'](_0x34d770);}})[_0x9870('0x1b')](function(_0xe9aa64){if(_0xe9aa64){_0x381f35=_0xe9aa64['length'];if(!_0x3e4802[_0x9870('0x3b')][_0x9870('0x40')](_0x9870('0x41'))){_0x34d770[_0x9870('0x2d')]=qs[_0x9870('0x2d')](_0x3e4802['query'][_0x9870('0x2d')]);_0x34d770[_0x9870('0x2c')]=qs['offset'](_0x3e4802[_0x9870('0x3b')][_0x9870('0x2c')]);}return _0x2e4717[_0x9870('0x55')](_0x34d770);}})[_0x9870('0x1b')](function(_0x1d7249){if(_0x1d7249){return _0x1d7249?{'count':_0x381f35,'rows':_0x1d7249}:null;}})[_0x9870('0x1b')](respondWithResult(_0x1c559b,null))[_0x9870('0x26')](handleError(_0x1c559b,null));};exports[_0x9870('0x58')]=function(_0x4d9e92,_0x499979,_0x17f891){var _0x56c1c6={};var _0x3a3eed={};var _0x132602;var _0x4607af;return db['DeskConfiguration']['findOne']({'where':{'id':_0x4d9e92[_0x9870('0x4c')]['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x499979,null))[_0x9870('0x1b')](function(_0x147459){if(_0x147459){_0x132602=_0x147459;_0x3a3eed['model']=_['keys'](db[_0x9870('0x57')]['rawAttributes']);_0x3a3eed[_0x9870('0x3b')]=_['keys'](_0x4d9e92[_0x9870('0x3b')]);_0x3a3eed[_0x9870('0x4e')]=_[_0x9870('0x4f')](_0x3a3eed[_0x9870('0x3c')],_0x3a3eed['query']);_0x56c1c6['attributes']=_[_0x9870('0x4f')](_0x3a3eed[_0x9870('0x3c')],qs[_0x9870('0x3d')](_0x4d9e92[_0x9870('0x3b')]['fields']));_0x56c1c6[_0x9870('0x3e')]=_0x56c1c6[_0x9870('0x3e')][_0x9870('0x3f')]?_0x56c1c6['attributes']:_0x3a3eed[_0x9870('0x3c')];_0x56c1c6[_0x9870('0x42')]=qs[_0x9870('0x43')](_0x4d9e92[_0x9870('0x3b')][_0x9870('0x43')]);_0x56c1c6[_0x9870('0x44')]=qs['filters'](_[_0x9870('0x45')](_0x4d9e92[_0x9870('0x3b')],_0x3a3eed[_0x9870('0x4e')]));if(_0x4d9e92['query'][_0x9870('0x47')]){_0x56c1c6[_0x9870('0x44')]=_['merge'](_0x56c1c6[_0x9870('0x44')],{'$or':_['map'](_0x56c1c6[_0x9870('0x3e')],function(_0x3317dc){var _0xa0eaf3={};_0xa0eaf3[_0x3317dc]={'$like':'%'+_0x4d9e92[_0x9870('0x3b')][_0x9870('0x47')]+'%'};return _0xa0eaf3;})});}_0x56c1c6=_[_0x9870('0x48')]({},_0x56c1c6,_0x4d9e92[_0x9870('0x50')]);return _0x132602['getSubjects'](_0x56c1c6);}})['then'](function(_0x4afe66){if(_0x4afe66){_0x4607af=_0x4afe66[_0x9870('0x3f')];if(!_0x4d9e92['query'][_0x9870('0x40')](_0x9870('0x41'))){_0x56c1c6['limit']=qs[_0x9870('0x2d')](_0x4d9e92[_0x9870('0x3b')][_0x9870('0x2d')]);_0x56c1c6[_0x9870('0x2c')]=qs[_0x9870('0x2c')](_0x4d9e92[_0x9870('0x3b')][_0x9870('0x2c')]);}return _0x132602[_0x9870('0x58')](_0x56c1c6);}})[_0x9870('0x1b')](function(_0xfbba98){if(_0xfbba98){return _0xfbba98?{'count':_0x4607af,'rows':_0xfbba98}:null;}})[_0x9870('0x1b')](respondWithResult(_0x499979,null))[_0x9870('0x26')](handleError(_0x499979,null));};exports[_0x9870('0x59')]=function(_0x2cbad7,_0x5ea2e5,_0x5256d1){var _0x436a80={};var _0x3e61e0={};var _0x5998e4;var _0x3345d6;return db[_0x9870('0x36')][_0x9870('0x56')]({'where':{'id':_0x2cbad7[_0x9870('0x4c')]['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x5ea2e5,null))[_0x9870('0x1b')](function(_0x5aab17){if(_0x5aab17){_0x5998e4=_0x5aab17;_0x3e61e0['model']=_[_0x9870('0x4d')](db['DeskField']['rawAttributes']);_0x3e61e0['query']=_[_0x9870('0x4d')](_0x2cbad7[_0x9870('0x3b')]);_0x3e61e0['filters']=_[_0x9870('0x4f')](_0x3e61e0[_0x9870('0x3c')],_0x3e61e0[_0x9870('0x3b')]);_0x436a80['attributes']=_[_0x9870('0x4f')](_0x3e61e0[_0x9870('0x3c')],qs['fields'](_0x2cbad7[_0x9870('0x3b')][_0x9870('0x3d')]));_0x436a80[_0x9870('0x3e')]=_0x436a80[_0x9870('0x3e')][_0x9870('0x3f')]?_0x436a80[_0x9870('0x3e')]:_0x3e61e0[_0x9870('0x3c')];_0x436a80[_0x9870('0x42')]=qs[_0x9870('0x43')](_0x2cbad7[_0x9870('0x3b')][_0x9870('0x43')]);_0x436a80[_0x9870('0x44')]=qs[_0x9870('0x4e')](_[_0x9870('0x45')](_0x2cbad7[_0x9870('0x3b')],_0x3e61e0[_0x9870('0x4e')]));if(_0x2cbad7[_0x9870('0x3b')]['filter']){_0x436a80[_0x9870('0x44')]=_[_0x9870('0x48')](_0x436a80[_0x9870('0x44')],{'$or':_[_0x9870('0x35')](_0x436a80[_0x9870('0x3e')],function(_0x5e3a29){var _0x523a38={};_0x523a38[_0x5e3a29]={'$like':'%'+_0x2cbad7[_0x9870('0x3b')][_0x9870('0x47')]+'%'};return _0x523a38;})});}_0x436a80=_['merge']({},_0x436a80,_0x2cbad7[_0x9870('0x50')]);return _0x5998e4[_0x9870('0x59')](_0x436a80);}})[_0x9870('0x1b')](function(_0x167c0d){if(_0x167c0d){_0x3345d6=_0x167c0d['length'];if(!_0x2cbad7[_0x9870('0x3b')][_0x9870('0x40')](_0x9870('0x41'))){_0x436a80[_0x9870('0x2d')]=qs['limit'](_0x2cbad7['query'][_0x9870('0x2d')]);_0x436a80[_0x9870('0x2c')]=qs['offset'](_0x2cbad7[_0x9870('0x3b')]['offset']);}return _0x5998e4['getDescriptions'](_0x436a80);}})[_0x9870('0x1b')](function(_0x1481be){if(_0x1481be){return _0x1481be?{'count':_0x3345d6,'rows':_0x1481be}:null;}})[_0x9870('0x1b')](respondWithResult(_0x5ea2e5,null))[_0x9870('0x26')](handleError(_0x5ea2e5,null));};exports['getTags']=function(_0x5c8dca,_0x32feac,_0x2bf29f){var _0x30d81f={};var _0x3be2c6={};var _0x4b04c3;var _0x41b8d2;return db['DeskConfiguration']['findOne']({'where':{'id':_0x5c8dca[_0x9870('0x4c')]['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x32feac,null))['then'](function(_0x50fc4f){if(_0x50fc4f){_0x4b04c3=_0x50fc4f;_0x3be2c6[_0x9870('0x3c')]=_[_0x9870('0x4d')](db[_0x9870('0x5a')][_0x9870('0x37')]);_0x3be2c6[_0x9870('0x3b')]=_['keys'](_0x5c8dca[_0x9870('0x3b')]);_0x3be2c6['filters']=_[_0x9870('0x4f')](_0x3be2c6[_0x9870('0x3c')],_0x3be2c6[_0x9870('0x3b')]);_0x30d81f[_0x9870('0x3e')]=_['intersection'](_0x3be2c6[_0x9870('0x3c')],qs[_0x9870('0x3d')](_0x5c8dca[_0x9870('0x3b')][_0x9870('0x3d')]));_0x30d81f['attributes']=_0x30d81f['attributes'][_0x9870('0x3f')]?_0x30d81f[_0x9870('0x3e')]:_0x3be2c6[_0x9870('0x3c')];_0x30d81f[_0x9870('0x42')]=qs[_0x9870('0x43')](_0x5c8dca[_0x9870('0x3b')][_0x9870('0x43')]);_0x30d81f[_0x9870('0x44')]=qs[_0x9870('0x4e')](_['pick'](_0x5c8dca[_0x9870('0x3b')],_0x3be2c6['filters']));if(_0x5c8dca[_0x9870('0x3b')][_0x9870('0x47')]){_0x30d81f[_0x9870('0x44')]=_[_0x9870('0x48')](_0x30d81f[_0x9870('0x44')],{'$or':_[_0x9870('0x35')](_0x30d81f['attributes'],function(_0x5d222e){var _0x5094cf={};_0x5094cf[_0x5d222e]={'$like':'%'+_0x5c8dca[_0x9870('0x3b')][_0x9870('0x47')]+'%'};return _0x5094cf;})});}_0x30d81f=_[_0x9870('0x48')]({},_0x30d81f,_0x5c8dca['options']);return _0x4b04c3[_0x9870('0x5b')](_0x30d81f);}})[_0x9870('0x1b')](function(_0x588901){if(_0x588901){_0x41b8d2=_0x588901[_0x9870('0x3f')];if(!_0x5c8dca[_0x9870('0x3b')]['hasOwnProperty']('nolimit')){_0x30d81f[_0x9870('0x2d')]=qs[_0x9870('0x2d')](_0x5c8dca[_0x9870('0x3b')]['limit']);_0x30d81f[_0x9870('0x2c')]=qs[_0x9870('0x2c')](_0x5c8dca[_0x9870('0x3b')][_0x9870('0x2c')]);}return _0x4b04c3[_0x9870('0x5b')](_0x30d81f);}})[_0x9870('0x1b')](function(_0x312eee){if(_0x312eee){return _0x312eee?{'count':_0x41b8d2,'rows':_0x312eee}:null;}})['then'](respondWithResult(_0x32feac,null))[_0x9870('0x26')](handleError(_0x32feac,null));};exports['setTags']=function(_0x43b73e,_0x5f3c4b,_0x2df4c1){if(_0x43b73e['body']['id']){delete _0x43b73e['body']['id'];}return db[_0x9870('0x36')][_0x9870('0x56')]({'where':{'id':_0x43b73e['params']['id']}})[_0x9870('0x1b')](handleEntityNotFound(_0x5f3c4b,null))[_0x9870('0x1b')](function(_0x36d997){if(_0x36d997){return _0x36d997[_0x9870('0x5c')](_0x43b73e['body'][_0x9870('0x5d')]||[]);}return null;})[_0x9870('0x1b')](respondWithResult(_0x5f3c4b,null))[_0x9870('0x26')](handleError(_0x5f3c4b,null));};
\ No newline at end of file
+var _0x4138=['request-promise','moment','bluebird','mustache','util','path','sox','fs-extra','lodash','crypto','jsforce','desk.js','to-csv','querystring','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','end','json','undefined','count','offset','apply','reject','update','then','destroy','error','name','index','map','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','catch','params','DeskConfiguration','rawAttributes','includeAll','find','create','body','getFields','DeskField','getSubjects','findOne','order','getDescriptions','getTags','setTags','ids','eml-format','rimraf','zip-dir'];(function(_0x1facfa,_0x1acf7d){var _0x9ec701=function(_0x115e37){while(--_0x115e37){_0x1facfa['push'](_0x1facfa['shift']());}};_0x9ec701(++_0x1acf7d);}(_0x4138,0x13d));var _0x8413=function(_0x6131cd,_0x4c26a1){_0x6131cd=_0x6131cd-0x0;var _0x47e916=_0x4138[_0x6131cd];return _0x47e916;};'use strict';var emlformat=require(_0x8413('0x0'));var rimraf=require(_0x8413('0x1'));var zipdir=require(_0x8413('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x8413('0x3'));var moment=require(_0x8413('0x4'));var BPromise=require(_0x8413('0x5'));var Mustache=require(_0x8413('0x6'));var util=require(_0x8413('0x7'));var path=require(_0x8413('0x8'));var sox=require(_0x8413('0x9'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x8413('0xa'));var _=require(_0x8413('0xb'));var squel=require('squel');var crypto=require(_0x8413('0xc'));var jsforce=require(_0x8413('0xd'));var deskjs=require(_0x8413('0xe'));var toCsv=require(_0x8413('0xf'));var querystring=require(_0x8413('0x10'));var Papa=require('papaparse');var Redis=require(_0x8413('0x11'));var authService=require('../../components/auth/service');var qs=require(_0x8413('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8413('0x13'));var logger=require(_0x8413('0x14'))(_0x8413('0x15'));var utils=require(_0x8413('0x16'));var config=require(_0x8413('0x17'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x7e90a8,_0x6a1f8d){_0x6a1f8d=_0x6a1f8d||0xcc;return function(_0x26691a){if(_0x26691a){return _0x7e90a8[_0x8413('0x18')](_0x6a1f8d);}return _0x7e90a8[_0x8413('0x19')](_0x6a1f8d)[_0x8413('0x1a')]();};}function respondWithResult(_0x53219d,_0x44fc82){_0x44fc82=_0x44fc82||0xc8;return function(_0x37c639){if(_0x37c639){return _0x53219d[_0x8413('0x19')](_0x44fc82)[_0x8413('0x1b')](_0x37c639);}};}function respondWithFilteredResult(_0x47df62,_0x237fd8){return function(_0x335821){if(_0x335821){var _0x3cbf81=typeof _0x237fd8['offset']===_0x8413('0x1c')&&typeof _0x237fd8['limit']==='undefined';var _0x1c1ddb=_0x335821[_0x8413('0x1d')];var _0x1742a4=_0x3cbf81?0x0:_0x237fd8[_0x8413('0x1e')];var _0xa7522a=_0x3cbf81?_0x335821[_0x8413('0x1d')]:_0x237fd8[_0x8413('0x1e')]+_0x237fd8['limit'];var _0x48ca63;if(_0xa7522a>=_0x1c1ddb){_0xa7522a=_0x1c1ddb;_0x48ca63=0xc8;}else{_0x48ca63=0xce;}_0x47df62['status'](_0x48ca63);return _0x47df62['set']('Content-Range',_0x1742a4+'-'+_0xa7522a+'/'+_0x1c1ddb)[_0x8413('0x1b')](_0x335821);}return null;};}function patchUpdates(_0x3e9fb7){return function(_0x29852c){try{jsonpatch[_0x8413('0x1f')](_0x29852c,_0x3e9fb7,!![]);}catch(_0x388bfb){return BPromise[_0x8413('0x20')](_0x388bfb);}return _0x29852c['save']();};}function saveUpdates(_0x28cec3,_0x10900e){return function(_0x14d9f9){if(_0x14d9f9){return _0x14d9f9[_0x8413('0x21')](_0x28cec3)[_0x8413('0x22')](function(_0x4912fd){return _0x4912fd;});}return null;};}function removeEntity(_0x5b9d2d,_0x35c3ce){return function(_0x263d76){if(_0x263d76){return _0x263d76[_0x8413('0x23')]()['then'](function(){_0x5b9d2d[_0x8413('0x19')](0xcc)[_0x8413('0x1a')]();});}};}function handleEntityNotFound(_0x5230e9,_0x43f220){return function(_0x23e0ba){if(!_0x23e0ba){_0x5230e9[_0x8413('0x18')](0x194);}return _0x23e0ba;};}function handleError(_0xc53c50,_0x3d4693){_0x3d4693=_0x3d4693||0x1f4;return function(_0x4a9569){logger[_0x8413('0x24')](_0x4a9569['stack']);if(_0x4a9569['name']){delete _0x4a9569[_0x8413('0x25')];}_0xc53c50[_0x8413('0x19')](_0x3d4693)['send'](_0x4a9569);};}exports[_0x8413('0x26')]=function(_0x549594,_0x1edda9){var _0x25f789={},_0x3240b3={},_0x218f20={'count':0x0,'rows':[]};var _0x984792=_[_0x8413('0x27')](db['DeskConfiguration']['rawAttributes'],function(_0xb27c01){return{'name':_0xb27c01[_0x8413('0x28')],'type':_0xb27c01[_0x8413('0x29')][_0x8413('0x2a')]};});_0x3240b3[_0x8413('0x2b')]=_[_0x8413('0x27')](_0x984792,'name');_0x3240b3[_0x8413('0x2c')]=_[_0x8413('0x2d')](_0x549594[_0x8413('0x2c')]);_0x3240b3[_0x8413('0x2e')]=_[_0x8413('0x2f')](_0x3240b3[_0x8413('0x2b')],_0x3240b3[_0x8413('0x2c')]);_0x25f789[_0x8413('0x30')]=_[_0x8413('0x2f')](_0x3240b3[_0x8413('0x2b')],qs[_0x8413('0x31')](_0x549594[_0x8413('0x2c')][_0x8413('0x31')]));_0x25f789[_0x8413('0x30')]=_0x25f789[_0x8413('0x30')][_0x8413('0x32')]?_0x25f789[_0x8413('0x30')]:_0x3240b3['model'];if(!_0x549594[_0x8413('0x2c')][_0x8413('0x33')](_0x8413('0x34'))){_0x25f789[_0x8413('0x35')]=qs[_0x8413('0x35')](_0x549594[_0x8413('0x2c')][_0x8413('0x35')]);_0x25f789[_0x8413('0x1e')]=qs[_0x8413('0x1e')](_0x549594[_0x8413('0x2c')]['offset']);}_0x25f789['order']=qs[_0x8413('0x36')](_0x549594[_0x8413('0x2c')][_0x8413('0x36')]);_0x25f789[_0x8413('0x37')]=qs[_0x8413('0x2e')](_[_0x8413('0x38')](_0x549594[_0x8413('0x2c')],_0x3240b3[_0x8413('0x2e')]),_0x984792);if(_0x549594[_0x8413('0x2c')][_0x8413('0x39')]){_0x25f789[_0x8413('0x37')]=_[_0x8413('0x3a')](_0x25f789['where'],{'$or':_['map'](_0x984792,function(_0x53ecd2){if(_0x53ecd2['type']!==_0x8413('0x3b')){var _0x274f89={};_0x274f89[_0x53ecd2[_0x8413('0x25')]]={'$like':'%'+_0x549594[_0x8413('0x2c')][_0x8413('0x39')]+'%'};return _0x274f89;}})});}_0x25f789=_[_0x8413('0x3a')]({},_0x25f789,_0x549594[_0x8413('0x3c')]);var _0x2ef913={'where':_0x25f789[_0x8413('0x37')]};return db['DeskConfiguration']['count'](_0x2ef913)['then'](function(_0x5e0e1a){_0x218f20[_0x8413('0x1d')]=_0x5e0e1a;if(_0x549594[_0x8413('0x2c')]['includeAll']){_0x25f789[_0x8413('0x3d')]=[{'all':!![]}];}return db['DeskConfiguration']['findAll'](_0x25f789);})[_0x8413('0x22')](function(_0x5dff02){_0x218f20[_0x8413('0x3e')]=_0x5dff02;return _0x218f20;})[_0x8413('0x22')](respondWithFilteredResult(_0x1edda9,_0x25f789))[_0x8413('0x3f')](handleError(_0x1edda9,null));};exports['show']=function(_0x24e5fb,_0x28c6e5){var _0x263e74={'raw':![],'where':{'id':_0x24e5fb[_0x8413('0x40')]['id']}},_0x3be0a3={};_0x3be0a3['model']=_[_0x8413('0x2d')](db[_0x8413('0x41')][_0x8413('0x42')]);_0x3be0a3[_0x8413('0x2c')]=_[_0x8413('0x2d')](_0x24e5fb[_0x8413('0x2c')]);_0x3be0a3[_0x8413('0x2e')]=_['intersection'](_0x3be0a3['model'],_0x3be0a3[_0x8413('0x2c')]);_0x263e74[_0x8413('0x30')]=_[_0x8413('0x2f')](_0x3be0a3[_0x8413('0x2b')],qs[_0x8413('0x31')](_0x24e5fb[_0x8413('0x2c')]['fields']));_0x263e74['attributes']=_0x263e74['attributes'][_0x8413('0x32')]?_0x263e74[_0x8413('0x30')]:_0x3be0a3[_0x8413('0x2b')];if(_0x24e5fb['query'][_0x8413('0x43')]){_0x263e74[_0x8413('0x3d')]=[{'all':!![]}];}_0x263e74=_[_0x8413('0x3a')]({},_0x263e74,_0x24e5fb[_0x8413('0x3c')]);return db[_0x8413('0x41')][_0x8413('0x44')](_0x263e74)[_0x8413('0x22')](handleEntityNotFound(_0x28c6e5,null))[_0x8413('0x22')](respondWithResult(_0x28c6e5,null))[_0x8413('0x3f')](handleError(_0x28c6e5,null));};exports[_0x8413('0x45')]=function(_0x3d62d5,_0xe79689){return db['DeskConfiguration']['create'](_0x3d62d5[_0x8413('0x46')],{})[_0x8413('0x22')](respondWithResult(_0xe79689,0xc9))[_0x8413('0x3f')](handleError(_0xe79689,null));};exports[_0x8413('0x21')]=function(_0x82f797,_0x41c264){if(_0x82f797[_0x8413('0x46')]['id']){delete _0x82f797[_0x8413('0x46')]['id'];}return db['DeskConfiguration'][_0x8413('0x44')]({'where':{'id':_0x82f797[_0x8413('0x40')]['id']}})['then'](handleEntityNotFound(_0x41c264,null))[_0x8413('0x22')](saveUpdates(_0x82f797[_0x8413('0x46')],null))[_0x8413('0x22')](respondWithResult(_0x41c264,null))['catch'](handleError(_0x41c264,null));};exports[_0x8413('0x23')]=function(_0x4075c2,_0x58ad13){return db[_0x8413('0x41')][_0x8413('0x44')]({'where':{'id':_0x4075c2[_0x8413('0x40')]['id']}})[_0x8413('0x22')](handleEntityNotFound(_0x58ad13,null))[_0x8413('0x22')](removeEntity(_0x58ad13,null))[_0x8413('0x3f')](handleError(_0x58ad13,null));};exports[_0x8413('0x47')]=function(_0x2bc2f5,_0xde504d,_0x43ebd9){var _0x2434e0={};var _0x978a07={};var _0x2e29f2;var _0xd01ad4;return db['DeskConfiguration']['findOne']({'where':{'id':_0x2bc2f5[_0x8413('0x40')]['id']}})[_0x8413('0x22')](handleEntityNotFound(_0xde504d,null))[_0x8413('0x22')](function(_0x116b77){if(_0x116b77){_0x2e29f2=_0x116b77;_0x978a07['model']=_['keys'](db[_0x8413('0x48')][_0x8413('0x42')]);_0x978a07[_0x8413('0x2c')]=_[_0x8413('0x2d')](_0x2bc2f5[_0x8413('0x2c')]);_0x978a07[_0x8413('0x2e')]=_[_0x8413('0x2f')](_0x978a07[_0x8413('0x2b')],_0x978a07[_0x8413('0x2c')]);_0x2434e0[_0x8413('0x30')]=_['intersection'](_0x978a07['model'],qs[_0x8413('0x31')](_0x2bc2f5[_0x8413('0x2c')][_0x8413('0x31')]));_0x2434e0[_0x8413('0x30')]=_0x2434e0['attributes']['length']?_0x2434e0[_0x8413('0x30')]:_0x978a07[_0x8413('0x2b')];_0x2434e0['order']=qs[_0x8413('0x36')](_0x2bc2f5['query'][_0x8413('0x36')]);_0x2434e0[_0x8413('0x37')]=qs['filters'](_[_0x8413('0x38')](_0x2bc2f5[_0x8413('0x2c')],_0x978a07[_0x8413('0x2e')]));if(_0x2bc2f5['query']['filter']){_0x2434e0[_0x8413('0x37')]=_[_0x8413('0x3a')](_0x2434e0[_0x8413('0x37')],{'$or':_[_0x8413('0x27')](_0x2434e0[_0x8413('0x30')],function(_0x26ba77){var _0x3627ca={};_0x3627ca[_0x26ba77]={'$like':'%'+_0x2bc2f5['query'][_0x8413('0x39')]+'%'};return _0x3627ca;})});}_0x2434e0=_[_0x8413('0x3a')]({},_0x2434e0,_0x2bc2f5['options']);return _0x2e29f2['getFields'](_0x2434e0);}})[_0x8413('0x22')](function(_0x2b2ea0){if(_0x2b2ea0){_0xd01ad4=_0x2b2ea0[_0x8413('0x32')];if(!_0x2bc2f5[_0x8413('0x2c')][_0x8413('0x33')](_0x8413('0x34'))){_0x2434e0['limit']=qs['limit'](_0x2bc2f5[_0x8413('0x2c')][_0x8413('0x35')]);_0x2434e0[_0x8413('0x1e')]=qs[_0x8413('0x1e')](_0x2bc2f5['query'][_0x8413('0x1e')]);}return _0x2e29f2[_0x8413('0x47')](_0x2434e0);}})[_0x8413('0x22')](function(_0x1d3a7b){if(_0x1d3a7b){return _0x1d3a7b?{'count':_0xd01ad4,'rows':_0x1d3a7b}:null;}})['then'](respondWithResult(_0xde504d,null))[_0x8413('0x3f')](handleError(_0xde504d,null));};exports[_0x8413('0x49')]=function(_0x304092,_0x58ca3f,_0x5632e4){var _0x3d2aec={};var _0xeee5b3={};var _0x1dcb36;var _0x463511;return db[_0x8413('0x41')][_0x8413('0x4a')]({'where':{'id':_0x304092[_0x8413('0x40')]['id']}})[_0x8413('0x22')](handleEntityNotFound(_0x58ca3f,null))[_0x8413('0x22')](function(_0x231f2e){if(_0x231f2e){_0x1dcb36=_0x231f2e;_0xeee5b3['model']=_[_0x8413('0x2d')](db[_0x8413('0x48')]['rawAttributes']);_0xeee5b3[_0x8413('0x2c')]=_['keys'](_0x304092[_0x8413('0x2c')]);_0xeee5b3[_0x8413('0x2e')]=_['intersection'](_0xeee5b3[_0x8413('0x2b')],_0xeee5b3[_0x8413('0x2c')]);_0x3d2aec[_0x8413('0x30')]=_[_0x8413('0x2f')](_0xeee5b3[_0x8413('0x2b')],qs[_0x8413('0x31')](_0x304092[_0x8413('0x2c')][_0x8413('0x31')]));_0x3d2aec['attributes']=_0x3d2aec['attributes'][_0x8413('0x32')]?_0x3d2aec[_0x8413('0x30')]:_0xeee5b3['model'];_0x3d2aec[_0x8413('0x4b')]=qs[_0x8413('0x36')](_0x304092[_0x8413('0x2c')][_0x8413('0x36')]);_0x3d2aec[_0x8413('0x37')]=qs['filters'](_[_0x8413('0x38')](_0x304092[_0x8413('0x2c')],_0xeee5b3[_0x8413('0x2e')]));if(_0x304092[_0x8413('0x2c')][_0x8413('0x39')]){_0x3d2aec['where']=_[_0x8413('0x3a')](_0x3d2aec[_0x8413('0x37')],{'$or':_[_0x8413('0x27')](_0x3d2aec['attributes'],function(_0x2c1113){var _0x307c0f={};_0x307c0f[_0x2c1113]={'$like':'%'+_0x304092[_0x8413('0x2c')]['filter']+'%'};return _0x307c0f;})});}_0x3d2aec=_['merge']({},_0x3d2aec,_0x304092[_0x8413('0x3c')]);return _0x1dcb36[_0x8413('0x49')](_0x3d2aec);}})[_0x8413('0x22')](function(_0x2e8d46){if(_0x2e8d46){_0x463511=_0x2e8d46[_0x8413('0x32')];if(!_0x304092[_0x8413('0x2c')]['hasOwnProperty'](_0x8413('0x34'))){_0x3d2aec[_0x8413('0x35')]=qs['limit'](_0x304092['query'][_0x8413('0x35')]);_0x3d2aec[_0x8413('0x1e')]=qs[_0x8413('0x1e')](_0x304092['query'][_0x8413('0x1e')]);}return _0x1dcb36[_0x8413('0x49')](_0x3d2aec);}})[_0x8413('0x22')](function(_0x172f91){if(_0x172f91){return _0x172f91?{'count':_0x463511,'rows':_0x172f91}:null;}})[_0x8413('0x22')](respondWithResult(_0x58ca3f,null))[_0x8413('0x3f')](handleError(_0x58ca3f,null));};exports[_0x8413('0x4c')]=function(_0x323473,_0x556066,_0x4df461){var _0x51c135={};var _0x1e9f6a={};var _0x32d921;var _0x3e16e9;return db[_0x8413('0x41')][_0x8413('0x4a')]({'where':{'id':_0x323473[_0x8413('0x40')]['id']}})[_0x8413('0x22')](handleEntityNotFound(_0x556066,null))[_0x8413('0x22')](function(_0x4211ab){if(_0x4211ab){_0x32d921=_0x4211ab;_0x1e9f6a[_0x8413('0x2b')]=_[_0x8413('0x2d')](db[_0x8413('0x48')]['rawAttributes']);_0x1e9f6a[_0x8413('0x2c')]=_['keys'](_0x323473[_0x8413('0x2c')]);_0x1e9f6a['filters']=_[_0x8413('0x2f')](_0x1e9f6a['model'],_0x1e9f6a[_0x8413('0x2c')]);_0x51c135['attributes']=_[_0x8413('0x2f')](_0x1e9f6a[_0x8413('0x2b')],qs[_0x8413('0x31')](_0x323473[_0x8413('0x2c')][_0x8413('0x31')]));_0x51c135['attributes']=_0x51c135[_0x8413('0x30')][_0x8413('0x32')]?_0x51c135[_0x8413('0x30')]:_0x1e9f6a['model'];_0x51c135[_0x8413('0x4b')]=qs[_0x8413('0x36')](_0x323473[_0x8413('0x2c')]['sort']);_0x51c135['where']=qs['filters'](_['pick'](_0x323473[_0x8413('0x2c')],_0x1e9f6a[_0x8413('0x2e')]));if(_0x323473['query'][_0x8413('0x39')]){_0x51c135[_0x8413('0x37')]=_[_0x8413('0x3a')](_0x51c135['where'],{'$or':_['map'](_0x51c135[_0x8413('0x30')],function(_0x2735f9){var _0x4df524={};_0x4df524[_0x2735f9]={'$like':'%'+_0x323473[_0x8413('0x2c')][_0x8413('0x39')]+'%'};return _0x4df524;})});}_0x51c135=_[_0x8413('0x3a')]({},_0x51c135,_0x323473[_0x8413('0x3c')]);return _0x32d921[_0x8413('0x4c')](_0x51c135);}})['then'](function(_0x3102e6){if(_0x3102e6){_0x3e16e9=_0x3102e6['length'];if(!_0x323473[_0x8413('0x2c')][_0x8413('0x33')](_0x8413('0x34'))){_0x51c135[_0x8413('0x35')]=qs['limit'](_0x323473[_0x8413('0x2c')][_0x8413('0x35')]);_0x51c135[_0x8413('0x1e')]=qs[_0x8413('0x1e')](_0x323473[_0x8413('0x2c')]['offset']);}return _0x32d921[_0x8413('0x4c')](_0x51c135);}})[_0x8413('0x22')](function(_0x5da386){if(_0x5da386){return _0x5da386?{'count':_0x3e16e9,'rows':_0x5da386}:null;}})[_0x8413('0x22')](respondWithResult(_0x556066,null))[_0x8413('0x3f')](handleError(_0x556066,null));};exports['getTags']=function(_0x45ede1,_0x390446,_0x3d6923){var _0x336d8d={};var _0x569b7b={};var _0x3e931d;var _0x4faa8e;return db[_0x8413('0x41')][_0x8413('0x4a')]({'where':{'id':_0x45ede1[_0x8413('0x40')]['id']}})['then'](handleEntityNotFound(_0x390446,null))[_0x8413('0x22')](function(_0x3af297){if(_0x3af297){_0x3e931d=_0x3af297;_0x569b7b[_0x8413('0x2b')]=_[_0x8413('0x2d')](db['Tag'][_0x8413('0x42')]);_0x569b7b[_0x8413('0x2c')]=_[_0x8413('0x2d')](_0x45ede1[_0x8413('0x2c')]);_0x569b7b[_0x8413('0x2e')]=_['intersection'](_0x569b7b[_0x8413('0x2b')],_0x569b7b['query']);_0x336d8d[_0x8413('0x30')]=_[_0x8413('0x2f')](_0x569b7b[_0x8413('0x2b')],qs[_0x8413('0x31')](_0x45ede1[_0x8413('0x2c')][_0x8413('0x31')]));_0x336d8d[_0x8413('0x30')]=_0x336d8d[_0x8413('0x30')][_0x8413('0x32')]?_0x336d8d['attributes']:_0x569b7b[_0x8413('0x2b')];_0x336d8d[_0x8413('0x4b')]=qs['sort'](_0x45ede1[_0x8413('0x2c')][_0x8413('0x36')]);_0x336d8d[_0x8413('0x37')]=qs[_0x8413('0x2e')](_['pick'](_0x45ede1['query'],_0x569b7b['filters']));if(_0x45ede1[_0x8413('0x2c')][_0x8413('0x39')]){_0x336d8d['where']=_[_0x8413('0x3a')](_0x336d8d[_0x8413('0x37')],{'$or':_[_0x8413('0x27')](_0x336d8d[_0x8413('0x30')],function(_0x5f3e0b){var _0x3e5bac={};_0x3e5bac[_0x5f3e0b]={'$like':'%'+_0x45ede1[_0x8413('0x2c')][_0x8413('0x39')]+'%'};return _0x3e5bac;})});}_0x336d8d=_[_0x8413('0x3a')]({},_0x336d8d,_0x45ede1[_0x8413('0x3c')]);return _0x3e931d[_0x8413('0x4d')](_0x336d8d);}})[_0x8413('0x22')](function(_0x340651){if(_0x340651){_0x4faa8e=_0x340651[_0x8413('0x32')];if(!_0x45ede1['query']['hasOwnProperty']('nolimit')){_0x336d8d[_0x8413('0x35')]=qs[_0x8413('0x35')](_0x45ede1['query'][_0x8413('0x35')]);_0x336d8d[_0x8413('0x1e')]=qs['offset'](_0x45ede1[_0x8413('0x2c')][_0x8413('0x1e')]);}return _0x3e931d[_0x8413('0x4d')](_0x336d8d);}})[_0x8413('0x22')](function(_0x1f6b57){if(_0x1f6b57){return _0x1f6b57?{'count':_0x4faa8e,'rows':_0x1f6b57}:null;}})[_0x8413('0x22')](respondWithResult(_0x390446,null))['catch'](handleError(_0x390446,null));};exports[_0x8413('0x4e')]=function(_0x582120,_0x5720c5,_0x448f9a){if(_0x582120[_0x8413('0x46')]['id']){delete _0x582120[_0x8413('0x46')]['id'];}return db[_0x8413('0x41')][_0x8413('0x4a')]({'where':{'id':_0x582120[_0x8413('0x40')]['id']}})[_0x8413('0x22')](handleEntityNotFound(_0x5720c5,null))[_0x8413('0x22')](function(_0x4f1207){if(_0x4f1207){return _0x4f1207[_0x8413('0x4e')](_0x582120[_0x8413('0x46')][_0x8413('0x4f')]||[]);}return null;})['then'](respondWithResult(_0x5720c5,null))['catch'](handleError(_0x5720c5,null));};
\ No newline at end of file