Built motion from commit f541bb3b.|2.6.14
[motion2.git] / server / api / intZendeskConfiguration / intZendeskConfiguration.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 _0xfaef=['request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/environment','sendStatus','status','end','json','offset','undefined','limit','count','set','update','destroy','then','name','send','map','ZendeskConfiguration','rawAttributes','type','key','model','query','keys','filters','intersection','fields','attributes','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','options','includeAll','include','findAll','rows','catch','show','create','body','find','params','getFields','ZendeskField','length','getSubjects','findOne','getDescriptions','Tag','setTags','ids','eml-format','rimraf','zip-dir'];(function(_0x25df80,_0xa2aec5){var _0x17b6d0=function(_0x446155){while(--_0x446155){_0x25df80['push'](_0x25df80['shift']());}};_0x17b6d0(++_0xa2aec5);}(_0xfaef,0xe4));var _0xffae=function(_0x314329,_0x1f7d08){_0x314329=_0x314329-0x0;var _0x370e08=_0xfaef[_0x314329];return _0x370e08;};'use strict';var emlformat=require(_0xffae('0x0'));var rimraf=require(_0xffae('0x1'));var zipdir=require(_0xffae('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xffae('0x3'));var moment=require('moment');var BPromise=require(_0xffae('0x4'));var Mustache=require(_0xffae('0x5'));var util=require(_0xffae('0x6'));var path=require(_0xffae('0x7'));var sox=require(_0xffae('0x8'));var csv=require(_0xffae('0x9'));var ejs=require(_0xffae('0xa'));var fs=require('fs');var fs_extra=require(_0xffae('0xb'));var _=require(_0xffae('0xc'));var squel=require('squel');var crypto=require(_0xffae('0xd'));var jsforce=require(_0xffae('0xe'));var deskjs=require('desk.js');var toCsv=require(_0xffae('0x9'));var querystring=require(_0xffae('0xf'));var Papa=require('papaparse');var Redis=require(_0xffae('0x10'));var authService=require(_0xffae('0x11'));var qs=require(_0xffae('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xffae('0x13'));var logger=require(_0xffae('0x14'))(_0xffae('0x15'));var utils=require('../../config/utils');var config=require(_0xffae('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x142024,_0x5470e3){_0x5470e3=_0x5470e3||0xcc;return function(_0x12cb31){if(_0x12cb31){return _0x142024[_0xffae('0x17')](_0x5470e3);}return _0x142024[_0xffae('0x18')](_0x5470e3)[_0xffae('0x19')]();};}function respondWithResult(_0x593225,_0x5616f1){_0x5616f1=_0x5616f1||0xc8;return function(_0x3fc6f4){if(_0x3fc6f4){return _0x593225['status'](_0x5616f1)[_0xffae('0x1a')](_0x3fc6f4);}};}function respondWithFilteredResult(_0x20432d,_0x402733){return function(_0x448863){if(_0x448863){var _0xa333db=typeof _0x402733[_0xffae('0x1b')]===_0xffae('0x1c')&&typeof _0x402733[_0xffae('0x1d')]==='undefined';var _0x35c7db=_0x448863[_0xffae('0x1e')];var _0x368da7=_0xa333db?0x0:_0x402733[_0xffae('0x1b')];var _0x45f336=_0xa333db?_0x448863[_0xffae('0x1e')]:_0x402733['offset']+_0x402733[_0xffae('0x1d')];var _0x565ce2;if(_0x45f336>=_0x35c7db){_0x45f336=_0x35c7db;_0x565ce2=0xc8;}else{_0x565ce2=0xce;}_0x20432d[_0xffae('0x18')](_0x565ce2);return _0x20432d[_0xffae('0x1f')]('Content-Range',_0x368da7+'-'+_0x45f336+'/'+_0x35c7db)['json'](_0x448863);}return null;};}function patchUpdates(_0x292080){return function(_0x3ae187){try{jsonpatch['apply'](_0x3ae187,_0x292080,!![]);}catch(_0x50a999){return BPromise['reject'](_0x50a999);}return _0x3ae187['save']();};}function saveUpdates(_0x11a65c,_0x2efebf){return function(_0x499945){if(_0x499945){return _0x499945[_0xffae('0x20')](_0x11a65c)['then'](function(_0x2f8ca9){return _0x2f8ca9;});}return null;};}function removeEntity(_0x80d71d,_0x2f8b35){return function(_0x3c6d55){if(_0x3c6d55){return _0x3c6d55[_0xffae('0x21')]()[_0xffae('0x22')](function(){_0x80d71d['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0xb0962d,_0xe8cdf7){return function(_0x54f1fa){if(!_0x54f1fa){_0xb0962d[_0xffae('0x17')](0x194);}return _0x54f1fa;};}function handleError(_0xf99ca5,_0x5f03c1){_0x5f03c1=_0x5f03c1||0x1f4;return function(_0x3371f8){logger['error'](_0x3371f8['stack']);if(_0x3371f8[_0xffae('0x23')]){delete _0x3371f8[_0xffae('0x23')];}_0xf99ca5['status'](_0x5f03c1)[_0xffae('0x24')](_0x3371f8);};}exports['index']=function(_0x2cd2c8,_0x4b036d){var _0xb7bfff={},_0x349bc4={},_0x1c8a2a={'count':0x0,'rows':[]};var _0x482136=_[_0xffae('0x25')](db[_0xffae('0x26')][_0xffae('0x27')],function(_0xb2b6){return{'name':_0xb2b6['fieldName'],'type':_0xb2b6[_0xffae('0x28')][_0xffae('0x29')]};});_0x349bc4[_0xffae('0x2a')]=_[_0xffae('0x25')](_0x482136,_0xffae('0x23'));_0x349bc4[_0xffae('0x2b')]=_[_0xffae('0x2c')](_0x2cd2c8[_0xffae('0x2b')]);_0x349bc4[_0xffae('0x2d')]=_[_0xffae('0x2e')](_0x349bc4[_0xffae('0x2a')],_0x349bc4[_0xffae('0x2b')]);_0xb7bfff['attributes']=_['intersection'](_0x349bc4[_0xffae('0x2a')],qs[_0xffae('0x2f')](_0x2cd2c8[_0xffae('0x2b')][_0xffae('0x2f')]));_0xb7bfff[_0xffae('0x30')]=_0xb7bfff['attributes']['length']?_0xb7bfff['attributes']:_0x349bc4[_0xffae('0x2a')];if(!_0x2cd2c8[_0xffae('0x2b')][_0xffae('0x31')](_0xffae('0x32'))){_0xb7bfff[_0xffae('0x1d')]=qs[_0xffae('0x1d')](_0x2cd2c8[_0xffae('0x2b')][_0xffae('0x1d')]);_0xb7bfff[_0xffae('0x1b')]=qs[_0xffae('0x1b')](_0x2cd2c8['query'][_0xffae('0x1b')]);}_0xb7bfff[_0xffae('0x33')]=qs[_0xffae('0x34')](_0x2cd2c8[_0xffae('0x2b')][_0xffae('0x34')]);_0xb7bfff[_0xffae('0x35')]=qs[_0xffae('0x2d')](_[_0xffae('0x36')](_0x2cd2c8[_0xffae('0x2b')],_0x349bc4[_0xffae('0x2d')]),_0x482136);if(_0x2cd2c8[_0xffae('0x2b')][_0xffae('0x37')]){_0xb7bfff[_0xffae('0x35')]=_['merge'](_0xb7bfff[_0xffae('0x35')],{'$or':_[_0xffae('0x25')](_0x482136,function(_0x26d80d){if(_0x26d80d[_0xffae('0x28')]!=='VIRTUAL'){var _0x24544e={};_0x24544e[_0x26d80d['name']]={'$like':'%'+_0x2cd2c8['query'][_0xffae('0x37')]+'%'};return _0x24544e;}})});}_0xb7bfff=_[_0xffae('0x38')]({},_0xb7bfff,_0x2cd2c8[_0xffae('0x39')]);var _0x1f6283={'where':_0xb7bfff['where']};return db[_0xffae('0x26')][_0xffae('0x1e')](_0x1f6283)['then'](function(_0x26a93b){_0x1c8a2a['count']=_0x26a93b;if(_0x2cd2c8[_0xffae('0x2b')][_0xffae('0x3a')]){_0xb7bfff[_0xffae('0x3b')]=[{'all':!![]}];}return db['ZendeskConfiguration'][_0xffae('0x3c')](_0xb7bfff);})[_0xffae('0x22')](function(_0x122ce8){_0x1c8a2a[_0xffae('0x3d')]=_0x122ce8;return _0x1c8a2a;})['then'](respondWithFilteredResult(_0x4b036d,_0xb7bfff))[_0xffae('0x3e')](handleError(_0x4b036d,null));};exports[_0xffae('0x3f')]=function(_0x1a764f,_0x2a2d9b){var _0x4f7df4={'raw':![],'where':{'id':_0x1a764f['params']['id']}},_0xbcf97={};_0xbcf97[_0xffae('0x2a')]=_[_0xffae('0x2c')](db[_0xffae('0x26')][_0xffae('0x27')]);_0xbcf97['query']=_[_0xffae('0x2c')](_0x1a764f['query']);_0xbcf97['filters']=_['intersection'](_0xbcf97[_0xffae('0x2a')],_0xbcf97[_0xffae('0x2b')]);_0x4f7df4[_0xffae('0x30')]=_[_0xffae('0x2e')](_0xbcf97[_0xffae('0x2a')],qs[_0xffae('0x2f')](_0x1a764f['query'][_0xffae('0x2f')]));_0x4f7df4[_0xffae('0x30')]=_0x4f7df4['attributes']['length']?_0x4f7df4[_0xffae('0x30')]:_0xbcf97['model'];if(_0x1a764f[_0xffae('0x2b')]['includeAll']){_0x4f7df4[_0xffae('0x3b')]=[{'all':!![]}];}_0x4f7df4=_[_0xffae('0x38')]({},_0x4f7df4,_0x1a764f[_0xffae('0x39')]);return db['ZendeskConfiguration']['find'](_0x4f7df4)[_0xffae('0x22')](handleEntityNotFound(_0x2a2d9b,null))[_0xffae('0x22')](respondWithResult(_0x2a2d9b,null))[_0xffae('0x3e')](handleError(_0x2a2d9b,null));};exports[_0xffae('0x40')]=function(_0x26d5f0,_0x11dd24){return db[_0xffae('0x26')][_0xffae('0x40')](_0x26d5f0[_0xffae('0x41')],{})['then'](respondWithResult(_0x11dd24,0xc9))[_0xffae('0x3e')](handleError(_0x11dd24,null));};exports[_0xffae('0x20')]=function(_0x4df783,_0x211d06){if(_0x4df783[_0xffae('0x41')]['id']){delete _0x4df783['body']['id'];}return db[_0xffae('0x26')][_0xffae('0x42')]({'where':{'id':_0x4df783[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x211d06,null))[_0xffae('0x22')](saveUpdates(_0x4df783['body'],null))['then'](respondWithResult(_0x211d06,null))[_0xffae('0x3e')](handleError(_0x211d06,null));};exports[_0xffae('0x21')]=function(_0xec10cf,_0x928169){return db[_0xffae('0x26')][_0xffae('0x42')]({'where':{'id':_0xec10cf[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x928169,null))[_0xffae('0x22')](removeEntity(_0x928169,null))['catch'](handleError(_0x928169,null));};exports[_0xffae('0x44')]=function(_0x3d529b,_0x131f16,_0x3bb387){var _0x59f6d5={};var _0x4e90f3={};var _0x2b680c;var _0xc05ef7;return db[_0xffae('0x26')]['findOne']({'where':{'id':_0x3d529b[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x131f16,null))[_0xffae('0x22')](function(_0x53908f){if(_0x53908f){_0x2b680c=_0x53908f;_0x4e90f3[_0xffae('0x2a')]=_[_0xffae('0x2c')](db[_0xffae('0x45')][_0xffae('0x27')]);_0x4e90f3['query']=_[_0xffae('0x2c')](_0x3d529b['query']);_0x4e90f3[_0xffae('0x2d')]=_[_0xffae('0x2e')](_0x4e90f3[_0xffae('0x2a')],_0x4e90f3['query']);_0x59f6d5[_0xffae('0x30')]=_[_0xffae('0x2e')](_0x4e90f3[_0xffae('0x2a')],qs[_0xffae('0x2f')](_0x3d529b[_0xffae('0x2b')][_0xffae('0x2f')]));_0x59f6d5[_0xffae('0x30')]=_0x59f6d5['attributes'][_0xffae('0x46')]?_0x59f6d5[_0xffae('0x30')]:_0x4e90f3[_0xffae('0x2a')];_0x59f6d5[_0xffae('0x33')]=qs[_0xffae('0x34')](_0x3d529b[_0xffae('0x2b')][_0xffae('0x34')]);_0x59f6d5[_0xffae('0x35')]=qs['filters'](_[_0xffae('0x36')](_0x3d529b['query'],_0x4e90f3[_0xffae('0x2d')]));if(_0x3d529b[_0xffae('0x2b')]['filter']){_0x59f6d5[_0xffae('0x35')]=_['merge'](_0x59f6d5[_0xffae('0x35')],{'$or':_['map'](_0x59f6d5[_0xffae('0x30')],function(_0x17ae31){var _0x1d9c45={};_0x1d9c45[_0x17ae31]={'$like':'%'+_0x3d529b[_0xffae('0x2b')][_0xffae('0x37')]+'%'};return _0x1d9c45;})});}_0x59f6d5=_[_0xffae('0x38')]({},_0x59f6d5,_0x3d529b[_0xffae('0x39')]);return _0x2b680c[_0xffae('0x44')](_0x59f6d5);}})[_0xffae('0x22')](function(_0x5bc3ff){if(_0x5bc3ff){_0xc05ef7=_0x5bc3ff[_0xffae('0x46')];if(!_0x3d529b['query']['hasOwnProperty'](_0xffae('0x32'))){_0x59f6d5[_0xffae('0x1d')]=qs['limit'](_0x3d529b[_0xffae('0x2b')][_0xffae('0x1d')]);_0x59f6d5[_0xffae('0x1b')]=qs[_0xffae('0x1b')](_0x3d529b['query']['offset']);}return _0x2b680c[_0xffae('0x44')](_0x59f6d5);}})['then'](function(_0x2c0fcc){if(_0x2c0fcc){return _0x2c0fcc?{'count':_0xc05ef7,'rows':_0x2c0fcc}:null;}})[_0xffae('0x22')](respondWithResult(_0x131f16,null))[_0xffae('0x3e')](handleError(_0x131f16,null));};exports[_0xffae('0x47')]=function(_0x3aa803,_0x133d57,_0x3197ad){var _0x5de0a1={};var _0x1320a1={};var _0x126137;var _0x5c520a;return db[_0xffae('0x26')][_0xffae('0x48')]({'where':{'id':_0x3aa803[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x133d57,null))['then'](function(_0x219c8c){if(_0x219c8c){_0x126137=_0x219c8c;_0x1320a1[_0xffae('0x2a')]=_['keys'](db[_0xffae('0x45')][_0xffae('0x27')]);_0x1320a1[_0xffae('0x2b')]=_[_0xffae('0x2c')](_0x3aa803['query']);_0x1320a1[_0xffae('0x2d')]=_[_0xffae('0x2e')](_0x1320a1['model'],_0x1320a1[_0xffae('0x2b')]);_0x5de0a1['attributes']=_['intersection'](_0x1320a1[_0xffae('0x2a')],qs['fields'](_0x3aa803[_0xffae('0x2b')][_0xffae('0x2f')]));_0x5de0a1[_0xffae('0x30')]=_0x5de0a1[_0xffae('0x30')][_0xffae('0x46')]?_0x5de0a1[_0xffae('0x30')]:_0x1320a1[_0xffae('0x2a')];_0x5de0a1[_0xffae('0x33')]=qs[_0xffae('0x34')](_0x3aa803[_0xffae('0x2b')][_0xffae('0x34')]);_0x5de0a1['where']=qs[_0xffae('0x2d')](_[_0xffae('0x36')](_0x3aa803[_0xffae('0x2b')],_0x1320a1[_0xffae('0x2d')]));if(_0x3aa803[_0xffae('0x2b')][_0xffae('0x37')]){_0x5de0a1['where']=_[_0xffae('0x38')](_0x5de0a1['where'],{'$or':_[_0xffae('0x25')](_0x5de0a1['attributes'],function(_0x6656cd){var _0x31a8dd={};_0x31a8dd[_0x6656cd]={'$like':'%'+_0x3aa803[_0xffae('0x2b')]['filter']+'%'};return _0x31a8dd;})});}_0x5de0a1=_[_0xffae('0x38')]({},_0x5de0a1,_0x3aa803[_0xffae('0x39')]);return _0x126137[_0xffae('0x47')](_0x5de0a1);}})[_0xffae('0x22')](function(_0x41f12f){if(_0x41f12f){_0x5c520a=_0x41f12f[_0xffae('0x46')];if(!_0x3aa803[_0xffae('0x2b')][_0xffae('0x31')]('nolimit')){_0x5de0a1[_0xffae('0x1d')]=qs['limit'](_0x3aa803[_0xffae('0x2b')]['limit']);_0x5de0a1[_0xffae('0x1b')]=qs[_0xffae('0x1b')](_0x3aa803['query'][_0xffae('0x1b')]);}return _0x126137[_0xffae('0x47')](_0x5de0a1);}})[_0xffae('0x22')](function(_0x3f5ee6){if(_0x3f5ee6){return _0x3f5ee6?{'count':_0x5c520a,'rows':_0x3f5ee6}:null;}})[_0xffae('0x22')](respondWithResult(_0x133d57,null))[_0xffae('0x3e')](handleError(_0x133d57,null));};exports[_0xffae('0x49')]=function(_0x3102d2,_0x525bf6,_0x195d20){var _0x4b0862={};var _0x45cbb1={};var _0x53f546;var _0x1f0a1c;return db[_0xffae('0x26')][_0xffae('0x48')]({'where':{'id':_0x3102d2[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x525bf6,null))['then'](function(_0xffe52b){if(_0xffe52b){_0x53f546=_0xffe52b;_0x45cbb1['model']=_[_0xffae('0x2c')](db[_0xffae('0x45')][_0xffae('0x27')]);_0x45cbb1[_0xffae('0x2b')]=_['keys'](_0x3102d2[_0xffae('0x2b')]);_0x45cbb1[_0xffae('0x2d')]=_[_0xffae('0x2e')](_0x45cbb1['model'],_0x45cbb1[_0xffae('0x2b')]);_0x4b0862[_0xffae('0x30')]=_['intersection'](_0x45cbb1[_0xffae('0x2a')],qs[_0xffae('0x2f')](_0x3102d2[_0xffae('0x2b')][_0xffae('0x2f')]));_0x4b0862['attributes']=_0x4b0862[_0xffae('0x30')][_0xffae('0x46')]?_0x4b0862[_0xffae('0x30')]:_0x45cbb1[_0xffae('0x2a')];_0x4b0862[_0xffae('0x33')]=qs[_0xffae('0x34')](_0x3102d2['query'][_0xffae('0x34')]);_0x4b0862[_0xffae('0x35')]=qs['filters'](_[_0xffae('0x36')](_0x3102d2[_0xffae('0x2b')],_0x45cbb1['filters']));if(_0x3102d2[_0xffae('0x2b')][_0xffae('0x37')]){_0x4b0862[_0xffae('0x35')]=_[_0xffae('0x38')](_0x4b0862[_0xffae('0x35')],{'$or':_[_0xffae('0x25')](_0x4b0862['attributes'],function(_0x2ee15f){var _0x5ebf5e={};_0x5ebf5e[_0x2ee15f]={'$like':'%'+_0x3102d2[_0xffae('0x2b')][_0xffae('0x37')]+'%'};return _0x5ebf5e;})});}_0x4b0862=_[_0xffae('0x38')]({},_0x4b0862,_0x3102d2[_0xffae('0x39')]);return _0x53f546[_0xffae('0x49')](_0x4b0862);}})[_0xffae('0x22')](function(_0x2ac0f4){if(_0x2ac0f4){_0x1f0a1c=_0x2ac0f4['length'];if(!_0x3102d2[_0xffae('0x2b')][_0xffae('0x31')](_0xffae('0x32'))){_0x4b0862[_0xffae('0x1d')]=qs[_0xffae('0x1d')](_0x3102d2['query'][_0xffae('0x1d')]);_0x4b0862[_0xffae('0x1b')]=qs[_0xffae('0x1b')](_0x3102d2[_0xffae('0x2b')][_0xffae('0x1b')]);}return _0x53f546[_0xffae('0x49')](_0x4b0862);}})[_0xffae('0x22')](function(_0x9ae5df){if(_0x9ae5df){return _0x9ae5df?{'count':_0x1f0a1c,'rows':_0x9ae5df}:null;}})[_0xffae('0x22')](respondWithResult(_0x525bf6,null))[_0xffae('0x3e')](handleError(_0x525bf6,null));};exports['getTags']=function(_0x20f039,_0x4c7efa,_0xa80b7c){var _0x441e1f={};var _0x5e8e6c={};var _0x3722f4;var _0x5194e9;return db[_0xffae('0x26')][_0xffae('0x48')]({'where':{'id':_0x20f039[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x4c7efa,null))[_0xffae('0x22')](function(_0x3a11f8){if(_0x3a11f8){_0x3722f4=_0x3a11f8;_0x5e8e6c[_0xffae('0x2a')]=_[_0xffae('0x2c')](db[_0xffae('0x4a')]['rawAttributes']);_0x5e8e6c['query']=_[_0xffae('0x2c')](_0x20f039[_0xffae('0x2b')]);_0x5e8e6c[_0xffae('0x2d')]=_[_0xffae('0x2e')](_0x5e8e6c['model'],_0x5e8e6c[_0xffae('0x2b')]);_0x441e1f['attributes']=_[_0xffae('0x2e')](_0x5e8e6c[_0xffae('0x2a')],qs[_0xffae('0x2f')](_0x20f039[_0xffae('0x2b')]['fields']));_0x441e1f[_0xffae('0x30')]=_0x441e1f['attributes'][_0xffae('0x46')]?_0x441e1f['attributes']:_0x5e8e6c[_0xffae('0x2a')];_0x441e1f[_0xffae('0x33')]=qs[_0xffae('0x34')](_0x20f039[_0xffae('0x2b')]['sort']);_0x441e1f[_0xffae('0x35')]=qs[_0xffae('0x2d')](_[_0xffae('0x36')](_0x20f039[_0xffae('0x2b')],_0x5e8e6c['filters']));if(_0x20f039[_0xffae('0x2b')]['filter']){_0x441e1f[_0xffae('0x35')]=_['merge'](_0x441e1f[_0xffae('0x35')],{'$or':_['map'](_0x441e1f[_0xffae('0x30')],function(_0x25c3c1){var _0x26a12f={};_0x26a12f[_0x25c3c1]={'$like':'%'+_0x20f039[_0xffae('0x2b')][_0xffae('0x37')]+'%'};return _0x26a12f;})});}_0x441e1f=_[_0xffae('0x38')]({},_0x441e1f,_0x20f039[_0xffae('0x39')]);return _0x3722f4['getTags'](_0x441e1f);}})[_0xffae('0x22')](function(_0x1b0928){if(_0x1b0928){_0x5194e9=_0x1b0928[_0xffae('0x46')];if(!_0x20f039['query'][_0xffae('0x31')](_0xffae('0x32'))){_0x441e1f[_0xffae('0x1d')]=qs[_0xffae('0x1d')](_0x20f039[_0xffae('0x2b')][_0xffae('0x1d')]);_0x441e1f[_0xffae('0x1b')]=qs[_0xffae('0x1b')](_0x20f039['query']['offset']);}return _0x3722f4['getTags'](_0x441e1f);}})[_0xffae('0x22')](function(_0x41e63c){if(_0x41e63c){return _0x41e63c?{'count':_0x5194e9,'rows':_0x41e63c}:null;}})[_0xffae('0x22')](respondWithResult(_0x4c7efa,null))[_0xffae('0x3e')](handleError(_0x4c7efa,null));};exports[_0xffae('0x4b')]=function(_0x453b4c,_0x4af949,_0x4f2a7a){if(_0x453b4c[_0xffae('0x41')]['id']){delete _0x453b4c[_0xffae('0x41')]['id'];}return db[_0xffae('0x26')]['findOne']({'where':{'id':_0x453b4c[_0xffae('0x43')]['id']}})[_0xffae('0x22')](handleEntityNotFound(_0x4af949,null))['then'](function(_0xd37d8d){if(_0xd37d8d){return _0xd37d8d[_0xffae('0x4b')](_0x453b4c[_0xffae('0x41')][_0xffae('0x4c')]||[]);}return null;})['then'](respondWithResult(_0x4af949,null))[_0xffae('0x3e')](handleError(_0x4af949,null));};