Built motion from commit bab6f49e.|2.6.17
[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 _0x8fc5=['type','key','query','keys','filters','intersection','fields','length','model','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','rows','params','rawAttributes','attributes','catch','create','body','find','getFields','nolimit','findOne','ZendeskField','getSubjects','hasOwnProperty','getDescriptions','Tag','getTags','setTags','ids','zip-dir','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','fs-extra','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','limit','count','offset','Content-Range','json','apply','save','update','then','destroy','stack','name','send','map','ZendeskConfiguration','fieldName'];(function(_0x368012,_0x7cabbf){var _0x57a0b5=function(_0x57c1cb){while(--_0x57c1cb){_0x368012['push'](_0x368012['shift']());}};_0x57a0b5(++_0x7cabbf);}(_0x8fc5,0x163));var _0x58fc=function(_0x2ff624,_0x15b871){_0x2ff624=_0x2ff624-0x0;var _0x3dd2c2=_0x8fc5[_0x2ff624];return _0x3dd2c2;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x58fc('0x0'));var jsonpatch=require(_0x58fc('0x1'));var rp=require(_0x58fc('0x2'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x58fc('0x3'));var util=require(_0x58fc('0x4'));var path=require(_0x58fc('0x5'));var sox=require(_0x58fc('0x6'));var csv=require(_0x58fc('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x58fc('0x8'));var _=require(_0x58fc('0x9'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x58fc('0xa'));var deskjs=require(_0x58fc('0xb'));var toCsv=require(_0x58fc('0x7'));var querystring=require(_0x58fc('0xc'));var Papa=require('papaparse');var Redis=require(_0x58fc('0xd'));var authService=require(_0x58fc('0xe'));var qs=require('../../components/parsers/qs');var as=require(_0x58fc('0xf'));var hardwareService=require(_0x58fc('0x10'));var logger=require(_0x58fc('0x11'))('api');var utils=require('../../config/utils');var config=require(_0x58fc('0x12'));var licenseUtil=require(_0x58fc('0x13'));var db=require(_0x58fc('0x14'))['db'];function respondWithStatusCode(_0x36090b,_0x4123de){_0x4123de=_0x4123de||0xcc;return function(_0x2ce0c8){if(_0x2ce0c8){return _0x36090b[_0x58fc('0x15')](_0x4123de);}return _0x36090b[_0x58fc('0x16')](_0x4123de)[_0x58fc('0x17')]();};}function respondWithResult(_0x344abe,_0x1fc509){_0x1fc509=_0x1fc509||0xc8;return function(_0x2e4f7d){if(_0x2e4f7d){return _0x344abe['status'](_0x1fc509)['json'](_0x2e4f7d);}};}function respondWithFilteredResult(_0x59ddd0,_0x41d623){return function(_0x547ed9){if(_0x547ed9){var _0x4004fa=typeof _0x41d623['offset']==='undefined'&&typeof _0x41d623[_0x58fc('0x18')]==='undefined';var _0x118b9b=_0x547ed9[_0x58fc('0x19')];var _0x3c1032=_0x4004fa?0x0:_0x41d623[_0x58fc('0x1a')];var _0x230d1a=_0x4004fa?_0x547ed9[_0x58fc('0x19')]:_0x41d623[_0x58fc('0x1a')]+_0x41d623['limit'];var _0x2b79eb;if(_0x230d1a>=_0x118b9b){_0x230d1a=_0x118b9b;_0x2b79eb=0xc8;}else{_0x2b79eb=0xce;}_0x59ddd0[_0x58fc('0x16')](_0x2b79eb);return _0x59ddd0['set'](_0x58fc('0x1b'),_0x3c1032+'-'+_0x230d1a+'/'+_0x118b9b)[_0x58fc('0x1c')](_0x547ed9);}return null;};}function patchUpdates(_0x46958d){return function(_0x300fe2){try{jsonpatch[_0x58fc('0x1d')](_0x300fe2,_0x46958d,!![]);}catch(_0x2cf52a){return BPromise['reject'](_0x2cf52a);}return _0x300fe2[_0x58fc('0x1e')]();};}function saveUpdates(_0x5927c3,_0x4b6830){return function(_0x9779d9){if(_0x9779d9){return _0x9779d9[_0x58fc('0x1f')](_0x5927c3)[_0x58fc('0x20')](function(_0x38b04a){return _0x38b04a;});}return null;};}function removeEntity(_0x3a0b79,_0x54b63a){return function(_0x4073c7){if(_0x4073c7){return _0x4073c7[_0x58fc('0x21')]()[_0x58fc('0x20')](function(){_0x3a0b79[_0x58fc('0x16')](0xcc)[_0x58fc('0x17')]();});}};}function handleEntityNotFound(_0x592312,_0x33dda0){return function(_0x5eb0dc){if(!_0x5eb0dc){_0x592312[_0x58fc('0x15')](0x194);}return _0x5eb0dc;};}function handleError(_0x44a430,_0x42cc43){_0x42cc43=_0x42cc43||0x1f4;return function(_0x7d4509){logger['error'](_0x7d4509[_0x58fc('0x22')]);if(_0x7d4509[_0x58fc('0x23')]){delete _0x7d4509[_0x58fc('0x23')];}_0x44a430[_0x58fc('0x16')](_0x42cc43)[_0x58fc('0x24')](_0x7d4509);};}exports['index']=function(_0x5e75a9,_0x2713b7){var _0x155e8d={},_0x4798d5={},_0x38a2bc={'count':0x0,'rows':[]};var _0xb2a5f2=_[_0x58fc('0x25')](db[_0x58fc('0x26')]['rawAttributes'],function(_0x5c6ea8){return{'name':_0x5c6ea8[_0x58fc('0x27')],'type':_0x5c6ea8[_0x58fc('0x28')][_0x58fc('0x29')]};});_0x4798d5['model']=_[_0x58fc('0x25')](_0xb2a5f2,'name');_0x4798d5[_0x58fc('0x2a')]=_[_0x58fc('0x2b')](_0x5e75a9[_0x58fc('0x2a')]);_0x4798d5[_0x58fc('0x2c')]=_[_0x58fc('0x2d')](_0x4798d5['model'],_0x4798d5['query']);_0x155e8d['attributes']=_[_0x58fc('0x2d')](_0x4798d5['model'],qs['fields'](_0x5e75a9['query'][_0x58fc('0x2e')]));_0x155e8d['attributes']=_0x155e8d['attributes'][_0x58fc('0x2f')]?_0x155e8d['attributes']:_0x4798d5[_0x58fc('0x30')];if(!_0x5e75a9['query']['hasOwnProperty']('nolimit')){_0x155e8d['limit']=qs[_0x58fc('0x18')](_0x5e75a9['query'][_0x58fc('0x18')]);_0x155e8d[_0x58fc('0x1a')]=qs[_0x58fc('0x1a')](_0x5e75a9[_0x58fc('0x2a')]['offset']);}_0x155e8d[_0x58fc('0x31')]=qs[_0x58fc('0x32')](_0x5e75a9[_0x58fc('0x2a')][_0x58fc('0x32')]);_0x155e8d[_0x58fc('0x33')]=qs[_0x58fc('0x2c')](_[_0x58fc('0x34')](_0x5e75a9[_0x58fc('0x2a')],_0x4798d5[_0x58fc('0x2c')]),_0xb2a5f2);if(_0x5e75a9['query'][_0x58fc('0x35')]){_0x155e8d[_0x58fc('0x33')]=_['merge'](_0x155e8d[_0x58fc('0x33')],{'$or':_[_0x58fc('0x25')](_0xb2a5f2,function(_0x358a78){if(_0x358a78[_0x58fc('0x28')]!==_0x58fc('0x36')){var _0x24c041={};_0x24c041[_0x358a78[_0x58fc('0x23')]]={'$like':'%'+_0x5e75a9[_0x58fc('0x2a')][_0x58fc('0x35')]+'%'};return _0x24c041;}})});}_0x155e8d=_[_0x58fc('0x37')]({},_0x155e8d,_0x5e75a9[_0x58fc('0x38')]);var _0x4bf9e7={'where':_0x155e8d[_0x58fc('0x33')]};return db[_0x58fc('0x26')][_0x58fc('0x19')](_0x4bf9e7)[_0x58fc('0x20')](function(_0x9c482){_0x38a2bc[_0x58fc('0x19')]=_0x9c482;if(_0x5e75a9[_0x58fc('0x2a')][_0x58fc('0x39')]){_0x155e8d[_0x58fc('0x3a')]=[{'all':!![]}];}return db[_0x58fc('0x26')][_0x58fc('0x3b')](_0x155e8d);})[_0x58fc('0x20')](function(_0x49be6f){_0x38a2bc[_0x58fc('0x3c')]=_0x49be6f;return _0x38a2bc;})[_0x58fc('0x20')](respondWithFilteredResult(_0x2713b7,_0x155e8d))['catch'](handleError(_0x2713b7,null));};exports['show']=function(_0x76528b,_0x31a260){var _0x4476c8={'raw':![],'where':{'id':_0x76528b[_0x58fc('0x3d')]['id']}},_0x326d0c={};_0x326d0c[_0x58fc('0x30')]=_['keys'](db[_0x58fc('0x26')][_0x58fc('0x3e')]);_0x326d0c[_0x58fc('0x2a')]=_[_0x58fc('0x2b')](_0x76528b['query']);_0x326d0c[_0x58fc('0x2c')]=_[_0x58fc('0x2d')](_0x326d0c[_0x58fc('0x30')],_0x326d0c[_0x58fc('0x2a')]);_0x4476c8['attributes']=_['intersection'](_0x326d0c['model'],qs['fields'](_0x76528b['query']['fields']));_0x4476c8['attributes']=_0x4476c8[_0x58fc('0x3f')][_0x58fc('0x2f')]?_0x4476c8[_0x58fc('0x3f')]:_0x326d0c[_0x58fc('0x30')];if(_0x76528b[_0x58fc('0x2a')][_0x58fc('0x39')]){_0x4476c8['include']=[{'all':!![]}];}_0x4476c8=_[_0x58fc('0x37')]({},_0x4476c8,_0x76528b['options']);return db[_0x58fc('0x26')]['find'](_0x4476c8)['then'](handleEntityNotFound(_0x31a260,null))['then'](respondWithResult(_0x31a260,null))[_0x58fc('0x40')](handleError(_0x31a260,null));};exports[_0x58fc('0x41')]=function(_0x181ecc,_0x555e4d){return db[_0x58fc('0x26')][_0x58fc('0x41')](_0x181ecc[_0x58fc('0x42')],{})[_0x58fc('0x20')](respondWithResult(_0x555e4d,0xc9))['catch'](handleError(_0x555e4d,null));};exports[_0x58fc('0x1f')]=function(_0x2dde0b,_0x4fcd05){if(_0x2dde0b[_0x58fc('0x42')]['id']){delete _0x2dde0b[_0x58fc('0x42')]['id'];}return db[_0x58fc('0x26')][_0x58fc('0x43')]({'where':{'id':_0x2dde0b[_0x58fc('0x3d')]['id']}})[_0x58fc('0x20')](handleEntityNotFound(_0x4fcd05,null))['then'](saveUpdates(_0x2dde0b[_0x58fc('0x42')],null))[_0x58fc('0x20')](respondWithResult(_0x4fcd05,null))[_0x58fc('0x40')](handleError(_0x4fcd05,null));};exports['destroy']=function(_0x1208e1,_0x3c12e0){return db[_0x58fc('0x26')]['find']({'where':{'id':_0x1208e1['params']['id']}})[_0x58fc('0x20')](handleEntityNotFound(_0x3c12e0,null))['then'](removeEntity(_0x3c12e0,null))[_0x58fc('0x40')](handleError(_0x3c12e0,null));};exports[_0x58fc('0x44')]=function(_0x75ce54,_0x4395ba,_0x4a78a8){var _0x33d64f={};var _0x430ded={};var _0x352cc3;var _0x4e035e;return db[_0x58fc('0x26')]['findOne']({'where':{'id':_0x75ce54[_0x58fc('0x3d')]['id']}})[_0x58fc('0x20')](handleEntityNotFound(_0x4395ba,null))['then'](function(_0x5bcfea){if(_0x5bcfea){_0x352cc3=_0x5bcfea;_0x430ded[_0x58fc('0x30')]=_[_0x58fc('0x2b')](db['ZendeskField'][_0x58fc('0x3e')]);_0x430ded[_0x58fc('0x2a')]=_[_0x58fc('0x2b')](_0x75ce54[_0x58fc('0x2a')]);_0x430ded['filters']=_[_0x58fc('0x2d')](_0x430ded[_0x58fc('0x30')],_0x430ded[_0x58fc('0x2a')]);_0x33d64f[_0x58fc('0x3f')]=_[_0x58fc('0x2d')](_0x430ded[_0x58fc('0x30')],qs['fields'](_0x75ce54['query'][_0x58fc('0x2e')]));_0x33d64f[_0x58fc('0x3f')]=_0x33d64f['attributes'][_0x58fc('0x2f')]?_0x33d64f[_0x58fc('0x3f')]:_0x430ded['model'];_0x33d64f['order']=qs['sort'](_0x75ce54[_0x58fc('0x2a')][_0x58fc('0x32')]);_0x33d64f[_0x58fc('0x33')]=qs['filters'](_['pick'](_0x75ce54[_0x58fc('0x2a')],_0x430ded['filters']));if(_0x75ce54[_0x58fc('0x2a')][_0x58fc('0x35')]){_0x33d64f[_0x58fc('0x33')]=_[_0x58fc('0x37')](_0x33d64f[_0x58fc('0x33')],{'$or':_[_0x58fc('0x25')](_0x33d64f['attributes'],function(_0x3788aa){var _0x3770e4={};_0x3770e4[_0x3788aa]={'$like':'%'+_0x75ce54['query'][_0x58fc('0x35')]+'%'};return _0x3770e4;})});}_0x33d64f=_[_0x58fc('0x37')]({},_0x33d64f,_0x75ce54[_0x58fc('0x38')]);return _0x352cc3[_0x58fc('0x44')](_0x33d64f);}})[_0x58fc('0x20')](function(_0x277a13){if(_0x277a13){_0x4e035e=_0x277a13['length'];if(!_0x75ce54['query']['hasOwnProperty'](_0x58fc('0x45'))){_0x33d64f[_0x58fc('0x18')]=qs['limit'](_0x75ce54['query']['limit']);_0x33d64f[_0x58fc('0x1a')]=qs[_0x58fc('0x1a')](_0x75ce54['query'][_0x58fc('0x1a')]);}return _0x352cc3[_0x58fc('0x44')](_0x33d64f);}})[_0x58fc('0x20')](function(_0x1e9401){if(_0x1e9401){return _0x1e9401?{'count':_0x4e035e,'rows':_0x1e9401}:null;}})['then'](respondWithResult(_0x4395ba,null))[_0x58fc('0x40')](handleError(_0x4395ba,null));};exports['getSubjects']=function(_0x4469d5,_0x4dc284,_0x92712){var _0x1bd178={};var _0x23a315={};var _0xe339c2;var _0x5da750;return db[_0x58fc('0x26')][_0x58fc('0x46')]({'where':{'id':_0x4469d5[_0x58fc('0x3d')]['id']}})[_0x58fc('0x20')](handleEntityNotFound(_0x4dc284,null))['then'](function(_0x4d0909){if(_0x4d0909){_0xe339c2=_0x4d0909;_0x23a315[_0x58fc('0x30')]=_['keys'](db[_0x58fc('0x47')]['rawAttributes']);_0x23a315[_0x58fc('0x2a')]=_['keys'](_0x4469d5[_0x58fc('0x2a')]);_0x23a315[_0x58fc('0x2c')]=_[_0x58fc('0x2d')](_0x23a315['model'],_0x23a315[_0x58fc('0x2a')]);_0x1bd178[_0x58fc('0x3f')]=_[_0x58fc('0x2d')](_0x23a315[_0x58fc('0x30')],qs[_0x58fc('0x2e')](_0x4469d5[_0x58fc('0x2a')][_0x58fc('0x2e')]));_0x1bd178[_0x58fc('0x3f')]=_0x1bd178[_0x58fc('0x3f')][_0x58fc('0x2f')]?_0x1bd178[_0x58fc('0x3f')]:_0x23a315[_0x58fc('0x30')];_0x1bd178[_0x58fc('0x31')]=qs[_0x58fc('0x32')](_0x4469d5[_0x58fc('0x2a')][_0x58fc('0x32')]);_0x1bd178[_0x58fc('0x33')]=qs[_0x58fc('0x2c')](_[_0x58fc('0x34')](_0x4469d5['query'],_0x23a315[_0x58fc('0x2c')]));if(_0x4469d5['query'][_0x58fc('0x35')]){_0x1bd178['where']=_[_0x58fc('0x37')](_0x1bd178[_0x58fc('0x33')],{'$or':_[_0x58fc('0x25')](_0x1bd178['attributes'],function(_0x1a928c){var _0x12166c={};_0x12166c[_0x1a928c]={'$like':'%'+_0x4469d5[_0x58fc('0x2a')]['filter']+'%'};return _0x12166c;})});}_0x1bd178=_['merge']({},_0x1bd178,_0x4469d5[_0x58fc('0x38')]);return _0xe339c2[_0x58fc('0x48')](_0x1bd178);}})[_0x58fc('0x20')](function(_0x4717d4){if(_0x4717d4){_0x5da750=_0x4717d4[_0x58fc('0x2f')];if(!_0x4469d5[_0x58fc('0x2a')][_0x58fc('0x49')]('nolimit')){_0x1bd178[_0x58fc('0x18')]=qs[_0x58fc('0x18')](_0x4469d5[_0x58fc('0x2a')][_0x58fc('0x18')]);_0x1bd178[_0x58fc('0x1a')]=qs[_0x58fc('0x1a')](_0x4469d5[_0x58fc('0x2a')][_0x58fc('0x1a')]);}return _0xe339c2['getSubjects'](_0x1bd178);}})[_0x58fc('0x20')](function(_0x1897a3){if(_0x1897a3){return _0x1897a3?{'count':_0x5da750,'rows':_0x1897a3}:null;}})[_0x58fc('0x20')](respondWithResult(_0x4dc284,null))[_0x58fc('0x40')](handleError(_0x4dc284,null));};exports[_0x58fc('0x4a')]=function(_0x4dcb2d,_0x3ad502,_0x3510f5){var _0x46e15a={};var _0x5c1bf3={};var _0x37c286;var _0x53397d;return db['ZendeskConfiguration'][_0x58fc('0x46')]({'where':{'id':_0x4dcb2d['params']['id']}})['then'](handleEntityNotFound(_0x3ad502,null))[_0x58fc('0x20')](function(_0x3846da){if(_0x3846da){_0x37c286=_0x3846da;_0x5c1bf3['model']=_[_0x58fc('0x2b')](db['ZendeskField'][_0x58fc('0x3e')]);_0x5c1bf3[_0x58fc('0x2a')]=_[_0x58fc('0x2b')](_0x4dcb2d[_0x58fc('0x2a')]);_0x5c1bf3[_0x58fc('0x2c')]=_[_0x58fc('0x2d')](_0x5c1bf3[_0x58fc('0x30')],_0x5c1bf3['query']);_0x46e15a['attributes']=_[_0x58fc('0x2d')](_0x5c1bf3['model'],qs[_0x58fc('0x2e')](_0x4dcb2d[_0x58fc('0x2a')][_0x58fc('0x2e')]));_0x46e15a[_0x58fc('0x3f')]=_0x46e15a[_0x58fc('0x3f')][_0x58fc('0x2f')]?_0x46e15a[_0x58fc('0x3f')]:_0x5c1bf3[_0x58fc('0x30')];_0x46e15a[_0x58fc('0x31')]=qs['sort'](_0x4dcb2d[_0x58fc('0x2a')][_0x58fc('0x32')]);_0x46e15a[_0x58fc('0x33')]=qs[_0x58fc('0x2c')](_[_0x58fc('0x34')](_0x4dcb2d[_0x58fc('0x2a')],_0x5c1bf3['filters']));if(_0x4dcb2d[_0x58fc('0x2a')][_0x58fc('0x35')]){_0x46e15a[_0x58fc('0x33')]=_[_0x58fc('0x37')](_0x46e15a[_0x58fc('0x33')],{'$or':_[_0x58fc('0x25')](_0x46e15a[_0x58fc('0x3f')],function(_0x3c54f5){var _0x2a1a55={};_0x2a1a55[_0x3c54f5]={'$like':'%'+_0x4dcb2d[_0x58fc('0x2a')]['filter']+'%'};return _0x2a1a55;})});}_0x46e15a=_[_0x58fc('0x37')]({},_0x46e15a,_0x4dcb2d[_0x58fc('0x38')]);return _0x37c286['getDescriptions'](_0x46e15a);}})[_0x58fc('0x20')](function(_0x48ed49){if(_0x48ed49){_0x53397d=_0x48ed49[_0x58fc('0x2f')];if(!_0x4dcb2d['query'][_0x58fc('0x49')](_0x58fc('0x45'))){_0x46e15a[_0x58fc('0x18')]=qs[_0x58fc('0x18')](_0x4dcb2d[_0x58fc('0x2a')][_0x58fc('0x18')]);_0x46e15a['offset']=qs['offset'](_0x4dcb2d[_0x58fc('0x2a')]['offset']);}return _0x37c286['getDescriptions'](_0x46e15a);}})[_0x58fc('0x20')](function(_0x14d28c){if(_0x14d28c){return _0x14d28c?{'count':_0x53397d,'rows':_0x14d28c}:null;}})[_0x58fc('0x20')](respondWithResult(_0x3ad502,null))['catch'](handleError(_0x3ad502,null));};exports['getTags']=function(_0x47459f,_0x25c85a,_0x29000d){var _0xcdcc46={};var _0x50b1f0={};var _0x5d283d;var _0xa7b177;return db['ZendeskConfiguration'][_0x58fc('0x46')]({'where':{'id':_0x47459f[_0x58fc('0x3d')]['id']}})[_0x58fc('0x20')](handleEntityNotFound(_0x25c85a,null))['then'](function(_0x5c619b){if(_0x5c619b){_0x5d283d=_0x5c619b;_0x50b1f0['model']=_[_0x58fc('0x2b')](db[_0x58fc('0x4b')][_0x58fc('0x3e')]);_0x50b1f0[_0x58fc('0x2a')]=_['keys'](_0x47459f['query']);_0x50b1f0['filters']=_['intersection'](_0x50b1f0[_0x58fc('0x30')],_0x50b1f0[_0x58fc('0x2a')]);_0xcdcc46[_0x58fc('0x3f')]=_['intersection'](_0x50b1f0[_0x58fc('0x30')],qs['fields'](_0x47459f['query'][_0x58fc('0x2e')]));_0xcdcc46[_0x58fc('0x3f')]=_0xcdcc46[_0x58fc('0x3f')][_0x58fc('0x2f')]?_0xcdcc46[_0x58fc('0x3f')]:_0x50b1f0[_0x58fc('0x30')];_0xcdcc46[_0x58fc('0x31')]=qs[_0x58fc('0x32')](_0x47459f['query'][_0x58fc('0x32')]);_0xcdcc46[_0x58fc('0x33')]=qs['filters'](_['pick'](_0x47459f['query'],_0x50b1f0['filters']));if(_0x47459f[_0x58fc('0x2a')][_0x58fc('0x35')]){_0xcdcc46[_0x58fc('0x33')]=_[_0x58fc('0x37')](_0xcdcc46[_0x58fc('0x33')],{'$or':_['map'](_0xcdcc46[_0x58fc('0x3f')],function(_0x1e4d04){var _0x388d2f={};_0x388d2f[_0x1e4d04]={'$like':'%'+_0x47459f['query'][_0x58fc('0x35')]+'%'};return _0x388d2f;})});}_0xcdcc46=_['merge']({},_0xcdcc46,_0x47459f[_0x58fc('0x38')]);return _0x5d283d[_0x58fc('0x4c')](_0xcdcc46);}})['then'](function(_0x5015e4){if(_0x5015e4){_0xa7b177=_0x5015e4[_0x58fc('0x2f')];if(!_0x47459f['query'][_0x58fc('0x49')]('nolimit')){_0xcdcc46[_0x58fc('0x18')]=qs[_0x58fc('0x18')](_0x47459f[_0x58fc('0x2a')]['limit']);_0xcdcc46[_0x58fc('0x1a')]=qs[_0x58fc('0x1a')](_0x47459f[_0x58fc('0x2a')][_0x58fc('0x1a')]);}return _0x5d283d[_0x58fc('0x4c')](_0xcdcc46);}})[_0x58fc('0x20')](function(_0x49ec41){if(_0x49ec41){return _0x49ec41?{'count':_0xa7b177,'rows':_0x49ec41}:null;}})[_0x58fc('0x20')](respondWithResult(_0x25c85a,null))[_0x58fc('0x40')](handleError(_0x25c85a,null));};exports[_0x58fc('0x4d')]=function(_0x3fc2df,_0x30eb87,_0x27c408){if(_0x3fc2df[_0x58fc('0x42')]['id']){delete _0x3fc2df['body']['id'];}return db[_0x58fc('0x26')][_0x58fc('0x46')]({'where':{'id':_0x3fc2df[_0x58fc('0x3d')]['id']}})[_0x58fc('0x20')](handleEntityNotFound(_0x30eb87,null))[_0x58fc('0x20')](function(_0x197a11){if(_0x197a11){return _0x197a11['setTags'](_0x3fc2df['body'][_0x58fc('0x4e')]||[]);}return null;})[_0x58fc('0x20')](respondWithResult(_0x30eb87,null))[_0x58fc('0x40')](handleError(_0x30eb87,null));};