ae1d160d8e6af0d523263ce9f5754f3fabcc21ce
[motion2.git] / server / api / intFreshdeskConfiguration / intFreshdeskConfiguration.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x398b=['query','keys','filters','intersection','attributes','fields','length','order','sort','where','merge','type','VIRTUAL','filter','options','FreshdeskConfiguration','includeAll','include','findAll','catch','show','params','create','body','find','destroy','getFields','findOne','FreshdeskField','hasOwnProperty','nolimit','getSubjects','pick','getDescriptions','getTags','Tag','setTags','ids','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','path','sox','fs-extra','crypto','jsforce','desk.js','to-csv','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','undefined','offset','count','limit','set','Content-Range','json','reject','save','update','then','stack','name','send','index','map','rawAttributes','fieldName','model'];(function(_0x6e1239,_0x3562ac){var _0x418150=function(_0x279f06){while(--_0x279f06){_0x6e1239['push'](_0x6e1239['shift']());}};_0x418150(++_0x3562ac);}(_0x398b,0x1b6));var _0xb398=function(_0x2d48fa,_0x103065){_0x2d48fa=_0x2d48fa-0x0;var _0x4645b7=_0x398b[_0x2d48fa];return _0x4645b7;};'use strict';var emlformat=require(_0xb398('0x0'));var rimraf=require(_0xb398('0x1'));var zipdir=require(_0xb398('0x2'));var jsonpatch=require(_0xb398('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xb398('0x4'));var Mustache=require(_0xb398('0x5'));var util=require('util');var path=require(_0xb398('0x6'));var sox=require(_0xb398('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb398('0x8'));var _=require('lodash');var squel=require('squel');var crypto=require(_0xb398('0x9'));var jsforce=require(_0xb398('0xa'));var deskjs=require(_0xb398('0xb'));var toCsv=require(_0xb398('0xc'));var querystring=require('querystring');var Papa=require(_0xb398('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xb398('0xe'));var as=require(_0xb398('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xb398('0x10'));var utils=require(_0xb398('0x11'));var config=require(_0xb398('0x12'));var licenseUtil=require(_0xb398('0x13'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x79e2ad,_0x3fcbd1){_0x3fcbd1=_0x3fcbd1||0xcc;return function(_0x4d01e9){if(_0x4d01e9){return _0x79e2ad[_0xb398('0x14')](_0x3fcbd1);}return _0x79e2ad[_0xb398('0x15')](_0x3fcbd1)[_0xb398('0x16')]();};}function respondWithResult(_0x22c72f,_0x5d53ff){_0x5d53ff=_0x5d53ff||0xc8;return function(_0x347305){if(_0x347305){return _0x22c72f['status'](_0x5d53ff)['json'](_0x347305);}};}function respondWithFilteredResult(_0x1abe86,_0x4e2a41){return function(_0x3d3413){if(_0x3d3413){var _0x570fbb=typeof _0x4e2a41['offset']===_0xb398('0x17')&&typeof _0x4e2a41['limit']===_0xb398('0x17');var _0x2f3517=_0x3d3413['count'];var _0x1ac750=_0x570fbb?0x0:_0x4e2a41[_0xb398('0x18')];var _0xbf5005=_0x570fbb?_0x3d3413[_0xb398('0x19')]:_0x4e2a41[_0xb398('0x18')]+_0x4e2a41[_0xb398('0x1a')];var _0x5913a0;if(_0xbf5005>=_0x2f3517){_0xbf5005=_0x2f3517;_0x5913a0=0xc8;}else{_0x5913a0=0xce;}_0x1abe86['status'](_0x5913a0);return _0x1abe86[_0xb398('0x1b')](_0xb398('0x1c'),_0x1ac750+'-'+_0xbf5005+'/'+_0x2f3517)[_0xb398('0x1d')](_0x3d3413);}return null;};}function patchUpdates(_0x3aad2b){return function(_0x368d97){try{jsonpatch['apply'](_0x368d97,_0x3aad2b,!![]);}catch(_0x515b71){return BPromise[_0xb398('0x1e')](_0x515b71);}return _0x368d97[_0xb398('0x1f')]();};}function saveUpdates(_0x52cfcc,_0x3541e4){return function(_0x44af5e){if(_0x44af5e){return _0x44af5e[_0xb398('0x20')](_0x52cfcc)[_0xb398('0x21')](function(_0x492dbb){return _0x492dbb;});}return null;};}function removeEntity(_0x2bbfe9,_0x4a930c){return function(_0x48b6e0){if(_0x48b6e0){return _0x48b6e0['destroy']()[_0xb398('0x21')](function(){_0x2bbfe9['status'](0xcc)[_0xb398('0x16')]();});}};}function handleEntityNotFound(_0x36d5f3,_0x361d10){return function(_0x3765a5){if(!_0x3765a5){_0x36d5f3[_0xb398('0x14')](0x194);}return _0x3765a5;};}function handleError(_0x452bd1,_0x38628b){_0x38628b=_0x38628b||0x1f4;return function(_0xf59af8){logger['error'](_0xf59af8[_0xb398('0x22')]);if(_0xf59af8[_0xb398('0x23')]){delete _0xf59af8[_0xb398('0x23')];}_0x452bd1['status'](_0x38628b)[_0xb398('0x24')](_0xf59af8);};}exports[_0xb398('0x25')]=function(_0xea819,_0x23221f){var _0x425cac={},_0x3cbc14={},_0x25a31e={'count':0x0,'rows':[]};var _0x4df9a8=_[_0xb398('0x26')](db['FreshdeskConfiguration'][_0xb398('0x27')],function(_0x3912e6){return{'name':_0x3912e6[_0xb398('0x28')],'type':_0x3912e6['type']['key']};});_0x3cbc14[_0xb398('0x29')]=_[_0xb398('0x26')](_0x4df9a8,_0xb398('0x23'));_0x3cbc14[_0xb398('0x2a')]=_[_0xb398('0x2b')](_0xea819[_0xb398('0x2a')]);_0x3cbc14[_0xb398('0x2c')]=_[_0xb398('0x2d')](_0x3cbc14['model'],_0x3cbc14[_0xb398('0x2a')]);_0x425cac[_0xb398('0x2e')]=_['intersection'](_0x3cbc14[_0xb398('0x29')],qs[_0xb398('0x2f')](_0xea819[_0xb398('0x2a')][_0xb398('0x2f')]));_0x425cac['attributes']=_0x425cac[_0xb398('0x2e')][_0xb398('0x30')]?_0x425cac[_0xb398('0x2e')]:_0x3cbc14[_0xb398('0x29')];if(!_0xea819[_0xb398('0x2a')]['hasOwnProperty']('nolimit')){_0x425cac[_0xb398('0x1a')]=qs['limit'](_0xea819[_0xb398('0x2a')]['limit']);_0x425cac[_0xb398('0x18')]=qs[_0xb398('0x18')](_0xea819[_0xb398('0x2a')]['offset']);}_0x425cac[_0xb398('0x31')]=qs[_0xb398('0x32')](_0xea819[_0xb398('0x2a')][_0xb398('0x32')]);_0x425cac[_0xb398('0x33')]=qs[_0xb398('0x2c')](_['pick'](_0xea819[_0xb398('0x2a')],_0x3cbc14[_0xb398('0x2c')]),_0x4df9a8);if(_0xea819[_0xb398('0x2a')]['filter']){_0x425cac[_0xb398('0x33')]=_[_0xb398('0x34')](_0x425cac['where'],{'$or':_[_0xb398('0x26')](_0x4df9a8,function(_0x167cd3){if(_0x167cd3[_0xb398('0x35')]!==_0xb398('0x36')){var _0x1dae69={};_0x1dae69[_0x167cd3[_0xb398('0x23')]]={'$like':'%'+_0xea819[_0xb398('0x2a')][_0xb398('0x37')]+'%'};return _0x1dae69;}})});}_0x425cac=_['merge']({},_0x425cac,_0xea819[_0xb398('0x38')]);var _0x2cf98f={'where':_0x425cac[_0xb398('0x33')]};return db[_0xb398('0x39')][_0xb398('0x19')](_0x2cf98f)['then'](function(_0x4663d1){_0x25a31e[_0xb398('0x19')]=_0x4663d1;if(_0xea819[_0xb398('0x2a')][_0xb398('0x3a')]){_0x425cac[_0xb398('0x3b')]=[{'all':!![]}];}return db[_0xb398('0x39')][_0xb398('0x3c')](_0x425cac);})['then'](function(_0x4d4ef7){_0x25a31e['rows']=_0x4d4ef7;return _0x25a31e;})[_0xb398('0x21')](respondWithFilteredResult(_0x23221f,_0x425cac))[_0xb398('0x3d')](handleError(_0x23221f,null));};exports[_0xb398('0x3e')]=function(_0x248676,_0x3c58dc){var _0x3f2c52={'raw':![],'where':{'id':_0x248676[_0xb398('0x3f')]['id']}},_0x49d5d9={};_0x49d5d9[_0xb398('0x29')]=_[_0xb398('0x2b')](db['FreshdeskConfiguration']['rawAttributes']);_0x49d5d9[_0xb398('0x2a')]=_[_0xb398('0x2b')](_0x248676[_0xb398('0x2a')]);_0x49d5d9[_0xb398('0x2c')]=_['intersection'](_0x49d5d9[_0xb398('0x29')],_0x49d5d9[_0xb398('0x2a')]);_0x3f2c52[_0xb398('0x2e')]=_[_0xb398('0x2d')](_0x49d5d9['model'],qs['fields'](_0x248676[_0xb398('0x2a')][_0xb398('0x2f')]));_0x3f2c52[_0xb398('0x2e')]=_0x3f2c52[_0xb398('0x2e')]['length']?_0x3f2c52[_0xb398('0x2e')]:_0x49d5d9['model'];if(_0x248676[_0xb398('0x2a')][_0xb398('0x3a')]){_0x3f2c52[_0xb398('0x3b')]=[{'all':!![]}];}_0x3f2c52=_[_0xb398('0x34')]({},_0x3f2c52,_0x248676[_0xb398('0x38')]);return db[_0xb398('0x39')]['find'](_0x3f2c52)[_0xb398('0x21')](handleEntityNotFound(_0x3c58dc,null))[_0xb398('0x21')](respondWithResult(_0x3c58dc,null))[_0xb398('0x3d')](handleError(_0x3c58dc,null));};exports['create']=function(_0x5e8001,_0x392606){return db[_0xb398('0x39')][_0xb398('0x40')](_0x5e8001[_0xb398('0x41')],{})[_0xb398('0x21')](respondWithResult(_0x392606,0xc9))[_0xb398('0x3d')](handleError(_0x392606,null));};exports[_0xb398('0x20')]=function(_0x409b81,_0x31f76e){if(_0x409b81[_0xb398('0x41')]['id']){delete _0x409b81[_0xb398('0x41')]['id'];}return db['FreshdeskConfiguration'][_0xb398('0x42')]({'where':{'id':_0x409b81[_0xb398('0x3f')]['id']}})[_0xb398('0x21')](handleEntityNotFound(_0x31f76e,null))[_0xb398('0x21')](saveUpdates(_0x409b81[_0xb398('0x41')],null))[_0xb398('0x21')](respondWithResult(_0x31f76e,null))[_0xb398('0x3d')](handleError(_0x31f76e,null));};exports[_0xb398('0x43')]=function(_0x3adf1f,_0x59ee37){return db[_0xb398('0x39')][_0xb398('0x42')]({'where':{'id':_0x3adf1f[_0xb398('0x3f')]['id']}})[_0xb398('0x21')](handleEntityNotFound(_0x59ee37,null))[_0xb398('0x21')](removeEntity(_0x59ee37,null))[_0xb398('0x3d')](handleError(_0x59ee37,null));};exports[_0xb398('0x44')]=function(_0x406bd0,_0x341ede,_0x5203c2){var _0x5dee42={};var _0x29b20c={};var _0x6960af;var _0x5ad750;return db['FreshdeskConfiguration'][_0xb398('0x45')]({'where':{'id':_0x406bd0[_0xb398('0x3f')]['id']}})[_0xb398('0x21')](handleEntityNotFound(_0x341ede,null))['then'](function(_0x71c774){if(_0x71c774){_0x6960af=_0x71c774;_0x29b20c[_0xb398('0x29')]=_[_0xb398('0x2b')](db[_0xb398('0x46')]['rawAttributes']);_0x29b20c[_0xb398('0x2a')]=_[_0xb398('0x2b')](_0x406bd0[_0xb398('0x2a')]);_0x29b20c[_0xb398('0x2c')]=_['intersection'](_0x29b20c[_0xb398('0x29')],_0x29b20c[_0xb398('0x2a')]);_0x5dee42[_0xb398('0x2e')]=_[_0xb398('0x2d')](_0x29b20c[_0xb398('0x29')],qs[_0xb398('0x2f')](_0x406bd0[_0xb398('0x2a')][_0xb398('0x2f')]));_0x5dee42[_0xb398('0x2e')]=_0x5dee42[_0xb398('0x2e')][_0xb398('0x30')]?_0x5dee42[_0xb398('0x2e')]:_0x29b20c[_0xb398('0x29')];_0x5dee42[_0xb398('0x31')]=qs[_0xb398('0x32')](_0x406bd0[_0xb398('0x2a')]['sort']);_0x5dee42['where']=qs[_0xb398('0x2c')](_['pick'](_0x406bd0[_0xb398('0x2a')],_0x29b20c[_0xb398('0x2c')]));if(_0x406bd0[_0xb398('0x2a')]['filter']){_0x5dee42['where']=_['merge'](_0x5dee42[_0xb398('0x33')],{'$or':_['map'](_0x5dee42[_0xb398('0x2e')],function(_0x3618c4){var _0x128286={};_0x128286[_0x3618c4]={'$like':'%'+_0x406bd0[_0xb398('0x2a')][_0xb398('0x37')]+'%'};return _0x128286;})});}_0x5dee42=_['merge']({},_0x5dee42,_0x406bd0[_0xb398('0x38')]);return _0x6960af[_0xb398('0x44')](_0x5dee42);}})[_0xb398('0x21')](function(_0x54d469){if(_0x54d469){_0x5ad750=_0x54d469[_0xb398('0x30')];if(!_0x406bd0[_0xb398('0x2a')][_0xb398('0x47')](_0xb398('0x48'))){_0x5dee42[_0xb398('0x1a')]=qs[_0xb398('0x1a')](_0x406bd0['query'][_0xb398('0x1a')]);_0x5dee42[_0xb398('0x18')]=qs[_0xb398('0x18')](_0x406bd0[_0xb398('0x2a')]['offset']);}return _0x6960af[_0xb398('0x44')](_0x5dee42);}})[_0xb398('0x21')](function(_0x358f3d){if(_0x358f3d){return _0x358f3d?{'count':_0x5ad750,'rows':_0x358f3d}:null;}})[_0xb398('0x21')](respondWithResult(_0x341ede,null))['catch'](handleError(_0x341ede,null));};exports[_0xb398('0x49')]=function(_0x51599b,_0x311b17,_0x4fda46){var _0x4c2472={};var _0x2f6f26={};var _0x503c1e;var _0x2477cd;return db['FreshdeskConfiguration']['findOne']({'where':{'id':_0x51599b[_0xb398('0x3f')]['id']}})[_0xb398('0x21')](handleEntityNotFound(_0x311b17,null))[_0xb398('0x21')](function(_0x67e9ae){if(_0x67e9ae){_0x503c1e=_0x67e9ae;_0x2f6f26['model']=_[_0xb398('0x2b')](db[_0xb398('0x46')][_0xb398('0x27')]);_0x2f6f26[_0xb398('0x2a')]=_['keys'](_0x51599b[_0xb398('0x2a')]);_0x2f6f26[_0xb398('0x2c')]=_[_0xb398('0x2d')](_0x2f6f26[_0xb398('0x29')],_0x2f6f26[_0xb398('0x2a')]);_0x4c2472['attributes']=_['intersection'](_0x2f6f26['model'],qs[_0xb398('0x2f')](_0x51599b[_0xb398('0x2a')][_0xb398('0x2f')]));_0x4c2472[_0xb398('0x2e')]=_0x4c2472[_0xb398('0x2e')]['length']?_0x4c2472['attributes']:_0x2f6f26[_0xb398('0x29')];_0x4c2472['order']=qs[_0xb398('0x32')](_0x51599b[_0xb398('0x2a')][_0xb398('0x32')]);_0x4c2472['where']=qs[_0xb398('0x2c')](_[_0xb398('0x4a')](_0x51599b[_0xb398('0x2a')],_0x2f6f26['filters']));if(_0x51599b['query'][_0xb398('0x37')]){_0x4c2472[_0xb398('0x33')]=_['merge'](_0x4c2472[_0xb398('0x33')],{'$or':_[_0xb398('0x26')](_0x4c2472[_0xb398('0x2e')],function(_0x836e40){var _0x1a9c06={};_0x1a9c06[_0x836e40]={'$like':'%'+_0x51599b[_0xb398('0x2a')]['filter']+'%'};return _0x1a9c06;})});}_0x4c2472=_[_0xb398('0x34')]({},_0x4c2472,_0x51599b[_0xb398('0x38')]);return _0x503c1e[_0xb398('0x49')](_0x4c2472);}})['then'](function(_0x5e253d){if(_0x5e253d){_0x2477cd=_0x5e253d[_0xb398('0x30')];if(!_0x51599b[_0xb398('0x2a')][_0xb398('0x47')](_0xb398('0x48'))){_0x4c2472[_0xb398('0x1a')]=qs[_0xb398('0x1a')](_0x51599b['query'][_0xb398('0x1a')]);_0x4c2472['offset']=qs[_0xb398('0x18')](_0x51599b['query']['offset']);}return _0x503c1e[_0xb398('0x49')](_0x4c2472);}})[_0xb398('0x21')](function(_0x4ac0f5){if(_0x4ac0f5){return _0x4ac0f5?{'count':_0x2477cd,'rows':_0x4ac0f5}:null;}})[_0xb398('0x21')](respondWithResult(_0x311b17,null))[_0xb398('0x3d')](handleError(_0x311b17,null));};exports[_0xb398('0x4b')]=function(_0x861b44,_0x4e1204,_0x159221){var _0x49683d={};var _0x2b0b3e={};var _0x167ad8;var _0xb709f9;return db[_0xb398('0x39')][_0xb398('0x45')]({'where':{'id':_0x861b44[_0xb398('0x3f')]['id']}})['then'](handleEntityNotFound(_0x4e1204,null))[_0xb398('0x21')](function(_0x4bd810){if(_0x4bd810){_0x167ad8=_0x4bd810;_0x2b0b3e[_0xb398('0x29')]=_['keys'](db[_0xb398('0x46')][_0xb398('0x27')]);_0x2b0b3e['query']=_['keys'](_0x861b44[_0xb398('0x2a')]);_0x2b0b3e[_0xb398('0x2c')]=_['intersection'](_0x2b0b3e['model'],_0x2b0b3e['query']);_0x49683d[_0xb398('0x2e')]=_[_0xb398('0x2d')](_0x2b0b3e[_0xb398('0x29')],qs[_0xb398('0x2f')](_0x861b44['query']['fields']));_0x49683d[_0xb398('0x2e')]=_0x49683d[_0xb398('0x2e')]['length']?_0x49683d[_0xb398('0x2e')]:_0x2b0b3e[_0xb398('0x29')];_0x49683d['order']=qs[_0xb398('0x32')](_0x861b44['query']['sort']);_0x49683d['where']=qs[_0xb398('0x2c')](_[_0xb398('0x4a')](_0x861b44[_0xb398('0x2a')],_0x2b0b3e['filters']));if(_0x861b44[_0xb398('0x2a')][_0xb398('0x37')]){_0x49683d[_0xb398('0x33')]=_[_0xb398('0x34')](_0x49683d[_0xb398('0x33')],{'$or':_[_0xb398('0x26')](_0x49683d[_0xb398('0x2e')],function(_0x2c9175){var _0x467c29={};_0x467c29[_0x2c9175]={'$like':'%'+_0x861b44[_0xb398('0x2a')][_0xb398('0x37')]+'%'};return _0x467c29;})});}_0x49683d=_['merge']({},_0x49683d,_0x861b44['options']);return _0x167ad8[_0xb398('0x4b')](_0x49683d);}})[_0xb398('0x21')](function(_0x1793d7){if(_0x1793d7){_0xb709f9=_0x1793d7[_0xb398('0x30')];if(!_0x861b44[_0xb398('0x2a')][_0xb398('0x47')](_0xb398('0x48'))){_0x49683d[_0xb398('0x1a')]=qs[_0xb398('0x1a')](_0x861b44[_0xb398('0x2a')][_0xb398('0x1a')]);_0x49683d['offset']=qs['offset'](_0x861b44[_0xb398('0x2a')][_0xb398('0x18')]);}return _0x167ad8[_0xb398('0x4b')](_0x49683d);}})[_0xb398('0x21')](function(_0x1f5b9d){if(_0x1f5b9d){return _0x1f5b9d?{'count':_0xb709f9,'rows':_0x1f5b9d}:null;}})['then'](respondWithResult(_0x4e1204,null))[_0xb398('0x3d')](handleError(_0x4e1204,null));};exports[_0xb398('0x4c')]=function(_0x2f5a5a,_0x122814,_0x5305cc){var _0x24feda={};var _0x3acd96={};var _0x3efa1e;var _0x5cd292;return db[_0xb398('0x39')][_0xb398('0x45')]({'where':{'id':_0x2f5a5a[_0xb398('0x3f')]['id']}})['then'](handleEntityNotFound(_0x122814,null))['then'](function(_0x828d99){if(_0x828d99){_0x3efa1e=_0x828d99;_0x3acd96[_0xb398('0x29')]=_[_0xb398('0x2b')](db[_0xb398('0x4d')]['rawAttributes']);_0x3acd96[_0xb398('0x2a')]=_['keys'](_0x2f5a5a[_0xb398('0x2a')]);_0x3acd96['filters']=_[_0xb398('0x2d')](_0x3acd96[_0xb398('0x29')],_0x3acd96['query']);_0x24feda[_0xb398('0x2e')]=_['intersection'](_0x3acd96[_0xb398('0x29')],qs['fields'](_0x2f5a5a[_0xb398('0x2a')][_0xb398('0x2f')]));_0x24feda['attributes']=_0x24feda[_0xb398('0x2e')][_0xb398('0x30')]?_0x24feda[_0xb398('0x2e')]:_0x3acd96[_0xb398('0x29')];_0x24feda[_0xb398('0x31')]=qs['sort'](_0x2f5a5a[_0xb398('0x2a')][_0xb398('0x32')]);_0x24feda[_0xb398('0x33')]=qs[_0xb398('0x2c')](_['pick'](_0x2f5a5a[_0xb398('0x2a')],_0x3acd96[_0xb398('0x2c')]));if(_0x2f5a5a[_0xb398('0x2a')][_0xb398('0x37')]){_0x24feda['where']=_[_0xb398('0x34')](_0x24feda[_0xb398('0x33')],{'$or':_['map'](_0x24feda[_0xb398('0x2e')],function(_0x39a039){var _0x3381dc={};_0x3381dc[_0x39a039]={'$like':'%'+_0x2f5a5a[_0xb398('0x2a')][_0xb398('0x37')]+'%'};return _0x3381dc;})});}_0x24feda=_[_0xb398('0x34')]({},_0x24feda,_0x2f5a5a[_0xb398('0x38')]);return _0x3efa1e['getTags'](_0x24feda);}})[_0xb398('0x21')](function(_0x43b486){if(_0x43b486){_0x5cd292=_0x43b486[_0xb398('0x30')];if(!_0x2f5a5a[_0xb398('0x2a')][_0xb398('0x47')](_0xb398('0x48'))){_0x24feda['limit']=qs[_0xb398('0x1a')](_0x2f5a5a[_0xb398('0x2a')][_0xb398('0x1a')]);_0x24feda[_0xb398('0x18')]=qs['offset'](_0x2f5a5a[_0xb398('0x2a')]['offset']);}return _0x3efa1e[_0xb398('0x4c')](_0x24feda);}})[_0xb398('0x21')](function(_0x914b01){if(_0x914b01){return _0x914b01?{'count':_0x5cd292,'rows':_0x914b01}:null;}})[_0xb398('0x21')](respondWithResult(_0x122814,null))['catch'](handleError(_0x122814,null));};exports[_0xb398('0x4e')]=function(_0x3960e5,_0x1b4aba,_0x176e2b){if(_0x3960e5[_0xb398('0x41')]['id']){delete _0x3960e5[_0xb398('0x41')]['id'];}return db[_0xb398('0x39')][_0xb398('0x45')]({'where':{'id':_0x3960e5[_0xb398('0x3f')]['id']}})['then'](handleEntityNotFound(_0x1b4aba,null))[_0xb398('0x21')](function(_0xc673b3){if(_0xc673b3){return _0xc673b3['setTags'](_0x3960e5[_0xb398('0x41')][_0xb398('0x4f')]||[]);}return null;})[_0xb398('0x21')](respondWithResult(_0x1b4aba,null))['catch'](handleError(_0x1b4aba,null));};