47015716b50ec4472d13ada6a75409a903275cc1
[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 _0x576b=['send','index','map','ZendeskConfiguration','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','options','includeAll','include','findAll','catch','show','params','find','create','body','destroy','findOne','getFields','ZendeskField','getDescriptions','getTags','setTags','ids','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','to-csv','fs-extra','lodash','squel','crypto','querystring','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','sendStatus','status','offset','undefined','limit','count','set','Content-Range','reject','save','update','then','end','stack','name'];(function(_0xc4193e,_0x431718){var _0x3af225=function(_0xd95ef0){while(--_0xd95ef0){_0xc4193e['push'](_0xc4193e['shift']());}};_0x3af225(++_0x431718);}(_0x576b,0x7c));var _0xb576=function(_0x3f6b05,_0x363cfe){_0x3f6b05=_0x3f6b05-0x0;var _0x37248e=_0x576b[_0x3f6b05];return _0x37248e;};'use strict';var emlformat=require(_0xb576('0x0'));var rimraf=require(_0xb576('0x1'));var zipdir=require(_0xb576('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xb576('0x3'));var moment=require(_0xb576('0x4'));var BPromise=require(_0xb576('0x5'));var Mustache=require(_0xb576('0x6'));var util=require(_0xb576('0x7'));var path=require(_0xb576('0x8'));var sox=require('sox');var csv=require(_0xb576('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb576('0xa'));var _=require(_0xb576('0xb'));var squel=require(_0xb576('0xc'));var crypto=require(_0xb576('0xd'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0xb576('0x9'));var querystring=require(_0xb576('0xe'));var Papa=require('papaparse');var Redis=require(_0xb576('0xf'));var authService=require('../../components/auth/service');var qs=require(_0xb576('0x10'));var as=require(_0xb576('0x11'));var hardwareService=require(_0xb576('0x12'));var logger=require(_0xb576('0x13'))(_0xb576('0x14'));var utils=require(_0xb576('0x15'));var config=require(_0xb576('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x1aaa7c,_0x43bd69){_0x43bd69=_0x43bd69||0xcc;return function(_0x23f39b){if(_0x23f39b){return _0x1aaa7c[_0xb576('0x17')](_0x43bd69);}return _0x1aaa7c['status'](_0x43bd69)['end']();};}function respondWithResult(_0x2a7500,_0x5c0e14){_0x5c0e14=_0x5c0e14||0xc8;return function(_0x180cbb){if(_0x180cbb){return _0x2a7500[_0xb576('0x18')](_0x5c0e14)['json'](_0x180cbb);}};}function respondWithFilteredResult(_0x2e9b9f,_0x2e1774){return function(_0x3103e6){if(_0x3103e6){var _0xd50c21=typeof _0x2e1774[_0xb576('0x19')]===_0xb576('0x1a')&&typeof _0x2e1774[_0xb576('0x1b')]===_0xb576('0x1a');var _0x1ae8ed=_0x3103e6[_0xb576('0x1c')];var _0x452f88=_0xd50c21?0x0:_0x2e1774[_0xb576('0x19')];var _0x459c5b=_0xd50c21?_0x3103e6[_0xb576('0x1c')]:_0x2e1774['offset']+_0x2e1774[_0xb576('0x1b')];var _0x3bc6f2;if(_0x459c5b>=_0x1ae8ed){_0x459c5b=_0x1ae8ed;_0x3bc6f2=0xc8;}else{_0x3bc6f2=0xce;}_0x2e9b9f[_0xb576('0x18')](_0x3bc6f2);return _0x2e9b9f[_0xb576('0x1d')](_0xb576('0x1e'),_0x452f88+'-'+_0x459c5b+'/'+_0x1ae8ed)['json'](_0x3103e6);}return null;};}function patchUpdates(_0x3421de){return function(_0x142993){try{jsonpatch['apply'](_0x142993,_0x3421de,!![]);}catch(_0x1666c1){return BPromise[_0xb576('0x1f')](_0x1666c1);}return _0x142993[_0xb576('0x20')]();};}function saveUpdates(_0x61cb6c,_0x5516c1){return function(_0x27f0ad){if(_0x27f0ad){return _0x27f0ad[_0xb576('0x21')](_0x61cb6c)[_0xb576('0x22')](function(_0x10696a){return _0x10696a;});}return null;};}function removeEntity(_0xcd1db9,_0x411f83){return function(_0x4b2682){if(_0x4b2682){return _0x4b2682['destroy']()[_0xb576('0x22')](function(){_0xcd1db9[_0xb576('0x18')](0xcc)[_0xb576('0x23')]();});}};}function handleEntityNotFound(_0x217d9c,_0x46fdc5){return function(_0x51abe1){if(!_0x51abe1){_0x217d9c['sendStatus'](0x194);}return _0x51abe1;};}function handleError(_0x7f554a,_0x16f078){_0x16f078=_0x16f078||0x1f4;return function(_0x43f81f){logger['error'](_0x43f81f[_0xb576('0x24')]);if(_0x43f81f[_0xb576('0x25')]){delete _0x43f81f[_0xb576('0x25')];}_0x7f554a[_0xb576('0x18')](_0x16f078)[_0xb576('0x26')](_0x43f81f);};}exports[_0xb576('0x27')]=function(_0x56bee5,_0x383802){var _0x11799a={},_0x4f2bc4={},_0x3e8620={'count':0x0,'rows':[]};var _0x9de5a9=_[_0xb576('0x28')](db[_0xb576('0x29')][_0xb576('0x2a')],function(_0x2cdd32){return{'name':_0x2cdd32[_0xb576('0x2b')],'type':_0x2cdd32[_0xb576('0x2c')][_0xb576('0x2d')]};});_0x4f2bc4[_0xb576('0x2e')]=_[_0xb576('0x28')](_0x9de5a9,_0xb576('0x25'));_0x4f2bc4[_0xb576('0x2f')]=_[_0xb576('0x30')](_0x56bee5[_0xb576('0x2f')]);_0x4f2bc4[_0xb576('0x31')]=_[_0xb576('0x32')](_0x4f2bc4[_0xb576('0x2e')],_0x4f2bc4[_0xb576('0x2f')]);_0x11799a[_0xb576('0x33')]=_[_0xb576('0x32')](_0x4f2bc4['model'],qs['fields'](_0x56bee5[_0xb576('0x2f')][_0xb576('0x34')]));_0x11799a['attributes']=_0x11799a[_0xb576('0x33')][_0xb576('0x35')]?_0x11799a[_0xb576('0x33')]:_0x4f2bc4['model'];if(!_0x56bee5[_0xb576('0x2f')][_0xb576('0x36')](_0xb576('0x37'))){_0x11799a[_0xb576('0x1b')]=qs[_0xb576('0x1b')](_0x56bee5[_0xb576('0x2f')]['limit']);_0x11799a[_0xb576('0x19')]=qs[_0xb576('0x19')](_0x56bee5['query'][_0xb576('0x19')]);}_0x11799a[_0xb576('0x38')]=qs[_0xb576('0x39')](_0x56bee5[_0xb576('0x2f')]['sort']);_0x11799a[_0xb576('0x3a')]=qs[_0xb576('0x31')](_[_0xb576('0x3b')](_0x56bee5[_0xb576('0x2f')],_0x4f2bc4[_0xb576('0x31')]),_0x9de5a9);if(_0x56bee5[_0xb576('0x2f')][_0xb576('0x3c')]){_0x11799a[_0xb576('0x3a')]=_['merge'](_0x11799a[_0xb576('0x3a')],{'$or':_[_0xb576('0x28')](_0x9de5a9,function(_0x1b4a59){if(_0x1b4a59[_0xb576('0x2c')]!==_0xb576('0x3d')){var _0x14c377={};_0x14c377[_0x1b4a59[_0xb576('0x25')]]={'$like':'%'+_0x56bee5[_0xb576('0x2f')][_0xb576('0x3c')]+'%'};return _0x14c377;}})});}_0x11799a=_[_0xb576('0x3e')]({},_0x11799a,_0x56bee5[_0xb576('0x3f')]);var _0x171205={'where':_0x11799a[_0xb576('0x3a')]};return db['ZendeskConfiguration']['count'](_0x171205)[_0xb576('0x22')](function(_0x3d9b2e){_0x3e8620['count']=_0x3d9b2e;if(_0x56bee5[_0xb576('0x2f')][_0xb576('0x40')]){_0x11799a[_0xb576('0x41')]=[{'all':!![]}];}return db[_0xb576('0x29')][_0xb576('0x42')](_0x11799a);})[_0xb576('0x22')](function(_0x2b4c73){_0x3e8620['rows']=_0x2b4c73;return _0x3e8620;})[_0xb576('0x22')](respondWithFilteredResult(_0x383802,_0x11799a))[_0xb576('0x43')](handleError(_0x383802,null));};exports[_0xb576('0x44')]=function(_0x299a49,_0xf4dbb3){var _0x7c3f0a={'raw':![],'where':{'id':_0x299a49[_0xb576('0x45')]['id']}},_0x20251f={};_0x20251f[_0xb576('0x2e')]=_[_0xb576('0x30')](db[_0xb576('0x29')]['rawAttributes']);_0x20251f['query']=_['keys'](_0x299a49['query']);_0x20251f['filters']=_[_0xb576('0x32')](_0x20251f[_0xb576('0x2e')],_0x20251f['query']);_0x7c3f0a[_0xb576('0x33')]=_['intersection'](_0x20251f[_0xb576('0x2e')],qs['fields'](_0x299a49[_0xb576('0x2f')][_0xb576('0x34')]));_0x7c3f0a['attributes']=_0x7c3f0a[_0xb576('0x33')][_0xb576('0x35')]?_0x7c3f0a[_0xb576('0x33')]:_0x20251f['model'];if(_0x299a49[_0xb576('0x2f')]['includeAll']){_0x7c3f0a['include']=[{'all':!![]}];}_0x7c3f0a=_[_0xb576('0x3e')]({},_0x7c3f0a,_0x299a49[_0xb576('0x3f')]);return db[_0xb576('0x29')][_0xb576('0x46')](_0x7c3f0a)[_0xb576('0x22')](handleEntityNotFound(_0xf4dbb3,null))[_0xb576('0x22')](respondWithResult(_0xf4dbb3,null))[_0xb576('0x43')](handleError(_0xf4dbb3,null));};exports[_0xb576('0x47')]=function(_0x9cc02d,_0x46bf7d){return db['ZendeskConfiguration']['create'](_0x9cc02d[_0xb576('0x48')],{})[_0xb576('0x22')](respondWithResult(_0x46bf7d,0xc9))[_0xb576('0x43')](handleError(_0x46bf7d,null));};exports[_0xb576('0x21')]=function(_0x3fc207,_0xcdf0eb){if(_0x3fc207[_0xb576('0x48')]['id']){delete _0x3fc207[_0xb576('0x48')]['id'];}return db[_0xb576('0x29')][_0xb576('0x46')]({'where':{'id':_0x3fc207[_0xb576('0x45')]['id']}})[_0xb576('0x22')](handleEntityNotFound(_0xcdf0eb,null))[_0xb576('0x22')](saveUpdates(_0x3fc207[_0xb576('0x48')],null))[_0xb576('0x22')](respondWithResult(_0xcdf0eb,null))['catch'](handleError(_0xcdf0eb,null));};exports[_0xb576('0x49')]=function(_0x934f2f,_0x580e9a){return db[_0xb576('0x29')][_0xb576('0x46')]({'where':{'id':_0x934f2f[_0xb576('0x45')]['id']}})['then'](handleEntityNotFound(_0x580e9a,null))['then'](removeEntity(_0x580e9a,null))[_0xb576('0x43')](handleError(_0x580e9a,null));};exports['getFields']=function(_0x2b082b,_0x465001,_0x520254){var _0x3354d7={};var _0x1877e5={};var _0x2304fa;var _0x5ec828;return db[_0xb576('0x29')][_0xb576('0x4a')]({'where':{'id':_0x2b082b[_0xb576('0x45')]['id']}})['then'](handleEntityNotFound(_0x465001,null))[_0xb576('0x22')](function(_0x29f68f){if(_0x29f68f){_0x2304fa=_0x29f68f;_0x1877e5['model']=_[_0xb576('0x30')](db['ZendeskField'][_0xb576('0x2a')]);_0x1877e5[_0xb576('0x2f')]=_[_0xb576('0x30')](_0x2b082b[_0xb576('0x2f')]);_0x1877e5[_0xb576('0x31')]=_[_0xb576('0x32')](_0x1877e5[_0xb576('0x2e')],_0x1877e5[_0xb576('0x2f')]);_0x3354d7[_0xb576('0x33')]=_[_0xb576('0x32')](_0x1877e5[_0xb576('0x2e')],qs['fields'](_0x2b082b[_0xb576('0x2f')][_0xb576('0x34')]));_0x3354d7[_0xb576('0x33')]=_0x3354d7[_0xb576('0x33')][_0xb576('0x35')]?_0x3354d7[_0xb576('0x33')]:_0x1877e5[_0xb576('0x2e')];_0x3354d7[_0xb576('0x38')]=qs[_0xb576('0x39')](_0x2b082b[_0xb576('0x2f')][_0xb576('0x39')]);_0x3354d7['where']=qs['filters'](_[_0xb576('0x3b')](_0x2b082b[_0xb576('0x2f')],_0x1877e5[_0xb576('0x31')]));if(_0x2b082b[_0xb576('0x2f')][_0xb576('0x3c')]){_0x3354d7['where']=_[_0xb576('0x3e')](_0x3354d7[_0xb576('0x3a')],{'$or':_[_0xb576('0x28')](_0x3354d7['attributes'],function(_0x10c47e){var _0x20d83a={};_0x20d83a[_0x10c47e]={'$like':'%'+_0x2b082b[_0xb576('0x2f')][_0xb576('0x3c')]+'%'};return _0x20d83a;})});}_0x3354d7=_[_0xb576('0x3e')]({},_0x3354d7,_0x2b082b[_0xb576('0x3f')]);return _0x2304fa['getFields'](_0x3354d7);}})[_0xb576('0x22')](function(_0x2e9bd){if(_0x2e9bd){_0x5ec828=_0x2e9bd[_0xb576('0x35')];if(!_0x2b082b[_0xb576('0x2f')]['hasOwnProperty']('nolimit')){_0x3354d7[_0xb576('0x1b')]=qs['limit'](_0x2b082b[_0xb576('0x2f')][_0xb576('0x1b')]);_0x3354d7[_0xb576('0x19')]=qs[_0xb576('0x19')](_0x2b082b[_0xb576('0x2f')][_0xb576('0x19')]);}return _0x2304fa[_0xb576('0x4b')](_0x3354d7);}})[_0xb576('0x22')](function(_0x2c4627){if(_0x2c4627){return _0x2c4627?{'count':_0x5ec828,'rows':_0x2c4627}:null;}})[_0xb576('0x22')](respondWithResult(_0x465001,null))[_0xb576('0x43')](handleError(_0x465001,null));};exports['getSubjects']=function(_0xa09bd8,_0x4a1ac3,_0x114b4b){var _0x33e9a6={};var _0x5624d3={};var _0x21e973;var _0x4e5e2d;return db[_0xb576('0x29')]['findOne']({'where':{'id':_0xa09bd8[_0xb576('0x45')]['id']}})[_0xb576('0x22')](handleEntityNotFound(_0x4a1ac3,null))['then'](function(_0x1bbdd1){if(_0x1bbdd1){_0x21e973=_0x1bbdd1;_0x5624d3[_0xb576('0x2e')]=_[_0xb576('0x30')](db[_0xb576('0x4c')][_0xb576('0x2a')]);_0x5624d3[_0xb576('0x2f')]=_[_0xb576('0x30')](_0xa09bd8[_0xb576('0x2f')]);_0x5624d3[_0xb576('0x31')]=_[_0xb576('0x32')](_0x5624d3[_0xb576('0x2e')],_0x5624d3['query']);_0x33e9a6['attributes']=_[_0xb576('0x32')](_0x5624d3['model'],qs[_0xb576('0x34')](_0xa09bd8[_0xb576('0x2f')]['fields']));_0x33e9a6[_0xb576('0x33')]=_0x33e9a6[_0xb576('0x33')][_0xb576('0x35')]?_0x33e9a6[_0xb576('0x33')]:_0x5624d3[_0xb576('0x2e')];_0x33e9a6[_0xb576('0x38')]=qs[_0xb576('0x39')](_0xa09bd8[_0xb576('0x2f')][_0xb576('0x39')]);_0x33e9a6[_0xb576('0x3a')]=qs[_0xb576('0x31')](_[_0xb576('0x3b')](_0xa09bd8[_0xb576('0x2f')],_0x5624d3[_0xb576('0x31')]));if(_0xa09bd8[_0xb576('0x2f')][_0xb576('0x3c')]){_0x33e9a6[_0xb576('0x3a')]=_[_0xb576('0x3e')](_0x33e9a6['where'],{'$or':_[_0xb576('0x28')](_0x33e9a6['attributes'],function(_0x47ce89){var _0x5969c7={};_0x5969c7[_0x47ce89]={'$like':'%'+_0xa09bd8[_0xb576('0x2f')][_0xb576('0x3c')]+'%'};return _0x5969c7;})});}_0x33e9a6=_[_0xb576('0x3e')]({},_0x33e9a6,_0xa09bd8[_0xb576('0x3f')]);return _0x21e973['getSubjects'](_0x33e9a6);}})[_0xb576('0x22')](function(_0x3eb3c4){if(_0x3eb3c4){_0x4e5e2d=_0x3eb3c4[_0xb576('0x35')];if(!_0xa09bd8['query'][_0xb576('0x36')]('nolimit')){_0x33e9a6[_0xb576('0x1b')]=qs['limit'](_0xa09bd8[_0xb576('0x2f')][_0xb576('0x1b')]);_0x33e9a6[_0xb576('0x19')]=qs[_0xb576('0x19')](_0xa09bd8[_0xb576('0x2f')][_0xb576('0x19')]);}return _0x21e973['getSubjects'](_0x33e9a6);}})[_0xb576('0x22')](function(_0x57923d){if(_0x57923d){return _0x57923d?{'count':_0x4e5e2d,'rows':_0x57923d}:null;}})[_0xb576('0x22')](respondWithResult(_0x4a1ac3,null))['catch'](handleError(_0x4a1ac3,null));};exports[_0xb576('0x4d')]=function(_0x547c72,_0x410a3f,_0x18b67c){var _0x5c8546={};var _0x1e07a6={};var _0x164468;var _0x465bc9;return db[_0xb576('0x29')][_0xb576('0x4a')]({'where':{'id':_0x547c72[_0xb576('0x45')]['id']}})[_0xb576('0x22')](handleEntityNotFound(_0x410a3f,null))[_0xb576('0x22')](function(_0x5ab488){if(_0x5ab488){_0x164468=_0x5ab488;_0x1e07a6['model']=_['keys'](db[_0xb576('0x4c')][_0xb576('0x2a')]);_0x1e07a6['query']=_[_0xb576('0x30')](_0x547c72['query']);_0x1e07a6[_0xb576('0x31')]=_[_0xb576('0x32')](_0x1e07a6[_0xb576('0x2e')],_0x1e07a6[_0xb576('0x2f')]);_0x5c8546[_0xb576('0x33')]=_[_0xb576('0x32')](_0x1e07a6[_0xb576('0x2e')],qs[_0xb576('0x34')](_0x547c72[_0xb576('0x2f')][_0xb576('0x34')]));_0x5c8546[_0xb576('0x33')]=_0x5c8546[_0xb576('0x33')]['length']?_0x5c8546[_0xb576('0x33')]:_0x1e07a6[_0xb576('0x2e')];_0x5c8546[_0xb576('0x38')]=qs[_0xb576('0x39')](_0x547c72['query'][_0xb576('0x39')]);_0x5c8546[_0xb576('0x3a')]=qs[_0xb576('0x31')](_[_0xb576('0x3b')](_0x547c72[_0xb576('0x2f')],_0x1e07a6[_0xb576('0x31')]));if(_0x547c72[_0xb576('0x2f')]['filter']){_0x5c8546[_0xb576('0x3a')]=_['merge'](_0x5c8546['where'],{'$or':_['map'](_0x5c8546['attributes'],function(_0x21061f){var _0x2b2cd4={};_0x2b2cd4[_0x21061f]={'$like':'%'+_0x547c72[_0xb576('0x2f')][_0xb576('0x3c')]+'%'};return _0x2b2cd4;})});}_0x5c8546=_['merge']({},_0x5c8546,_0x547c72['options']);return _0x164468[_0xb576('0x4d')](_0x5c8546);}})[_0xb576('0x22')](function(_0x4143fb){if(_0x4143fb){_0x465bc9=_0x4143fb[_0xb576('0x35')];if(!_0x547c72['query'][_0xb576('0x36')](_0xb576('0x37'))){_0x5c8546[_0xb576('0x1b')]=qs[_0xb576('0x1b')](_0x547c72['query'][_0xb576('0x1b')]);_0x5c8546[_0xb576('0x19')]=qs[_0xb576('0x19')](_0x547c72[_0xb576('0x2f')][_0xb576('0x19')]);}return _0x164468[_0xb576('0x4d')](_0x5c8546);}})[_0xb576('0x22')](function(_0x20bbbc){if(_0x20bbbc){return _0x20bbbc?{'count':_0x465bc9,'rows':_0x20bbbc}:null;}})[_0xb576('0x22')](respondWithResult(_0x410a3f,null))[_0xb576('0x43')](handleError(_0x410a3f,null));};exports[_0xb576('0x4e')]=function(_0x55dbb6,_0x180f9b,_0x4e6705){var _0x33c76b={};var _0x5988e3={};var _0x1ea6dd;var _0x46301f;return db[_0xb576('0x29')]['findOne']({'where':{'id':_0x55dbb6[_0xb576('0x45')]['id']}})[_0xb576('0x22')](handleEntityNotFound(_0x180f9b,null))[_0xb576('0x22')](function(_0xe31ce8){if(_0xe31ce8){_0x1ea6dd=_0xe31ce8;_0x5988e3['model']=_[_0xb576('0x30')](db['Tag'][_0xb576('0x2a')]);_0x5988e3[_0xb576('0x2f')]=_[_0xb576('0x30')](_0x55dbb6[_0xb576('0x2f')]);_0x5988e3[_0xb576('0x31')]=_[_0xb576('0x32')](_0x5988e3['model'],_0x5988e3[_0xb576('0x2f')]);_0x33c76b[_0xb576('0x33')]=_[_0xb576('0x32')](_0x5988e3[_0xb576('0x2e')],qs[_0xb576('0x34')](_0x55dbb6[_0xb576('0x2f')][_0xb576('0x34')]));_0x33c76b[_0xb576('0x33')]=_0x33c76b[_0xb576('0x33')][_0xb576('0x35')]?_0x33c76b['attributes']:_0x5988e3[_0xb576('0x2e')];_0x33c76b[_0xb576('0x38')]=qs[_0xb576('0x39')](_0x55dbb6['query'][_0xb576('0x39')]);_0x33c76b[_0xb576('0x3a')]=qs[_0xb576('0x31')](_[_0xb576('0x3b')](_0x55dbb6[_0xb576('0x2f')],_0x5988e3[_0xb576('0x31')]));if(_0x55dbb6[_0xb576('0x2f')][_0xb576('0x3c')]){_0x33c76b['where']=_[_0xb576('0x3e')](_0x33c76b[_0xb576('0x3a')],{'$or':_['map'](_0x33c76b['attributes'],function(_0x2cbb8c){var _0x63ec76={};_0x63ec76[_0x2cbb8c]={'$like':'%'+_0x55dbb6[_0xb576('0x2f')][_0xb576('0x3c')]+'%'};return _0x63ec76;})});}_0x33c76b=_[_0xb576('0x3e')]({},_0x33c76b,_0x55dbb6['options']);return _0x1ea6dd['getTags'](_0x33c76b);}})[_0xb576('0x22')](function(_0x5266be){if(_0x5266be){_0x46301f=_0x5266be[_0xb576('0x35')];if(!_0x55dbb6[_0xb576('0x2f')][_0xb576('0x36')]('nolimit')){_0x33c76b[_0xb576('0x1b')]=qs[_0xb576('0x1b')](_0x55dbb6['query'][_0xb576('0x1b')]);_0x33c76b[_0xb576('0x19')]=qs[_0xb576('0x19')](_0x55dbb6['query']['offset']);}return _0x1ea6dd[_0xb576('0x4e')](_0x33c76b);}})[_0xb576('0x22')](function(_0x8fbff){if(_0x8fbff){return _0x8fbff?{'count':_0x46301f,'rows':_0x8fbff}:null;}})['then'](respondWithResult(_0x180f9b,null))[_0xb576('0x43')](handleError(_0x180f9b,null));};exports['setTags']=function(_0x190a08,_0x5e369c,_0xe87a96){if(_0x190a08['body']['id']){delete _0x190a08[_0xb576('0x48')]['id'];}return db[_0xb576('0x29')][_0xb576('0x4a')]({'where':{'id':_0x190a08['params']['id']}})[_0xb576('0x22')](handleEntityNotFound(_0x5e369c,null))[_0xb576('0x22')](function(_0x4e6c7d){if(_0x4e6c7d){return _0x4e6c7d[_0xb576('0x4f')](_0x190a08[_0xb576('0x48')][_0xb576('0x50')]||[]);}return null;})['then'](respondWithResult(_0x5e369c,null))[_0xb576('0x43')](handleError(_0x5e369c,null));};