Built motion from commit (unavailable).|2.5.6
[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 _0xac0a=['index','map','ZendeskConfiguration','rawAttributes','fieldName','type','key','model','filters','query','attributes','intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','count','includeAll','include','findAll','rows','show','params','keys','options','find','create','body','getFields','findOne','ZendeskField','filter','getSubjects','getDescriptions','Tag','getTags','setTags','html-pdf','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../mysqldb','jayson/promise','client','http','info','ZendeskConfiguration,\x20%s,\x20%s','request\x20sent','ZendeskConfiguration,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','sendStatus','end','offset','limit','status','set','Content-Range','json','apply','reject','save','update','then','destroy','name'];(function(_0x54b396,_0x3612ee){var _0x532e6d=function(_0xc8286e){while(--_0xc8286e){_0x54b396['push'](_0x54b396['shift']());}};_0x532e6d(++_0x3612ee);}(_0xac0a,0x148));var _0xaac0=function(_0x4676a5,_0x43aa8f){_0x4676a5=_0x4676a5-0x0;var _0x3ee42f=_0xac0a[_0x4676a5];return _0x3ee42f;};'use strict';var pdf=require(_0xaac0('0x0'));var emlformat=require(_0xaac0('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xaac0('0x2'));var rp=require(_0xaac0('0x3'));var moment=require(_0xaac0('0x4'));var BPromise=require(_0xaac0('0x5'));var Mustache=require(_0xaac0('0x6'));var util=require(_0xaac0('0x7'));var path=require(_0xaac0('0x8'));var sox=require('sox');var csv=require(_0xaac0('0x9'));var ejs=require(_0xaac0('0xa'));var fs=require('fs');var _=require(_0xaac0('0xb'));var squel=require(_0xaac0('0xc'));var crypto=require(_0xaac0('0xd'));var jsforce=require('jsforce');var deskjs=require(_0xaac0('0xe'));var toCsv=require(_0xaac0('0x9'));var querystring=require(_0xaac0('0xf'));var Papa=require(_0xaac0('0x10'));var Redis=require(_0xaac0('0x11'));var authService=require(_0xaac0('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xaac0('0x13'));var hardwareService=require(_0xaac0('0x14'));var logger=require(_0xaac0('0x15'))(_0xaac0('0x16'));var utils=require(_0xaac0('0x17'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xaac0('0x18'))['db'];var jayson=require(_0xaac0('0x19'));var client=jayson[_0xaac0('0x1a')][_0xaac0('0x1b')]({'port':0x232a});function respondWithRpcPromise(_0x31124f,_0x2bbd2c,_0x510d10,_0x4bbefd){return new BPromise(function(_0x42d637,_0x92c4cb){var _0x49aa69=_0x4bbefd||client;return _0x49aa69['request'](_0x31124f,_0x510d10)['then'](function(_0x53411e){logger[_0xaac0('0x1c')](_0xaac0('0x1d'),_0x2bbd2c,_0xaac0('0x1e'));logger['debug'](_0xaac0('0x1f'),_0x2bbd2c,_0xaac0('0x1e'),JSON['stringify'](_0x53411e));if(_0x53411e['error']){if(_0x53411e[_0xaac0('0x20')][_0xaac0('0x21')]===0x1f4){logger[_0xaac0('0x20')](_0xaac0('0x1d'),_0x2bbd2c,_0x53411e['error']['message']);return _0x92c4cb(_0x53411e[_0xaac0('0x20')][_0xaac0('0x22')]);}logger[_0xaac0('0x20')](_0xaac0('0x1d'),_0x2bbd2c,_0x53411e[_0xaac0('0x20')][_0xaac0('0x22')]);return _0x42d637(_0x53411e[_0xaac0('0x20')]['message']);}else{logger[_0xaac0('0x1c')](_0xaac0('0x1d'),_0x2bbd2c,_0xaac0('0x1e'));_0x42d637(_0x53411e[_0xaac0('0x23')][_0xaac0('0x22')]);}})[_0xaac0('0x24')](function(_0x17348a){logger[_0xaac0('0x20')](_0xaac0('0x1d'),_0x2bbd2c,_0x17348a);_0x92c4cb(_0x17348a);});});}function respondWithStatusCode(_0x1a4308,_0x27260d){_0x27260d=_0x27260d||0xcc;return function(_0x15ef93){if(_0x15ef93){return _0x1a4308[_0xaac0('0x25')](_0x27260d);}return _0x1a4308['status'](_0x27260d)[_0xaac0('0x26')]();};}function respondWithResult(_0x1d8ba2,_0x71caaf){_0x71caaf=_0x71caaf||0xc8;return function(_0x3e7b82){if(_0x3e7b82){return _0x1d8ba2['status'](_0x71caaf)['json'](_0x3e7b82);}};}function respondWithFilteredResult(_0x104ce4,_0x167b87){return function(_0x291b13){if(_0x291b13){var _0x34007b=_0x291b13['count'],_0x833df8=_0x167b87[_0xaac0('0x27')],_0x4ab8dd=_0x167b87[_0xaac0('0x27')]+_0x167b87[_0xaac0('0x28')],_0x5177df;if(_0x4ab8dd>=_0x34007b){_0x4ab8dd=_0x34007b;_0x5177df=0xc8;}else{_0x5177df=0xce;}_0x104ce4[_0xaac0('0x29')](_0x5177df);return _0x104ce4[_0xaac0('0x2a')](_0xaac0('0x2b'),_0x833df8+'-'+_0x4ab8dd+'/'+_0x34007b)[_0xaac0('0x2c')](_0x291b13);}return null;};}function patchUpdates(_0x490ff9){return function(_0x44a5d8){try{jsonpatch[_0xaac0('0x2d')](_0x44a5d8,_0x490ff9,!![]);}catch(_0x468859){return BPromise[_0xaac0('0x2e')](_0x468859);}return _0x44a5d8[_0xaac0('0x2f')]();};}function saveUpdates(_0x3c77e2,_0x4f924f){return function(_0x2ba813){if(_0x2ba813){return _0x2ba813[_0xaac0('0x30')](_0x3c77e2)[_0xaac0('0x31')](function(_0x1b85ad){return _0x1b85ad;});}return null;};}function removeEntity(_0x525158,_0x330890){return function(_0x5ebb51){if(_0x5ebb51){return _0x5ebb51[_0xaac0('0x32')]()['then'](function(){_0x525158[_0xaac0('0x29')](0xcc)[_0xaac0('0x26')]();});}};}function handleEntityNotFound(_0x2fd39e,_0x33da14){return function(_0x23c687){if(!_0x23c687){_0x2fd39e[_0xaac0('0x25')](0x194);}return _0x23c687;};}function handleError(_0x12a4b1,_0x4c74f2){_0x4c74f2=_0x4c74f2||0x1f4;return function(_0x7cd83f){logger['error'](_0x7cd83f['stack']);if(_0x7cd83f[_0xaac0('0x33')]){delete _0x7cd83f[_0xaac0('0x33')];}_0x12a4b1[_0xaac0('0x29')](_0x4c74f2)['send'](_0x7cd83f);};}exports[_0xaac0('0x34')]=function(_0x5f1300,_0x1db34a){var _0x422392={},_0x234121={},_0x47fdd2={'count':0x0,'rows':[]};var _0x195a24=_[_0xaac0('0x35')](db[_0xaac0('0x36')][_0xaac0('0x37')],function(_0x1bd6de){return{'name':_0x1bd6de[_0xaac0('0x38')],'type':_0x1bd6de[_0xaac0('0x39')][_0xaac0('0x3a')]};});_0x234121[_0xaac0('0x3b')]=_[_0xaac0('0x35')](_0x195a24,_0xaac0('0x33'));_0x234121['query']=_['keys'](_0x5f1300['query']);_0x234121[_0xaac0('0x3c')]=_['intersection'](_0x234121[_0xaac0('0x3b')],_0x234121[_0xaac0('0x3d')]);_0x422392[_0xaac0('0x3e')]=_[_0xaac0('0x3f')](_0x234121[_0xaac0('0x3b')],qs[_0xaac0('0x40')](_0x5f1300['query']['fields']));_0x422392[_0xaac0('0x3e')]=_0x422392['attributes'][_0xaac0('0x41')]?_0x422392[_0xaac0('0x3e')]:_0x234121[_0xaac0('0x3b')];if(!_0x5f1300['query'][_0xaac0('0x42')](_0xaac0('0x43'))){_0x422392[_0xaac0('0x28')]=qs[_0xaac0('0x28')](_0x5f1300[_0xaac0('0x3d')][_0xaac0('0x28')]);_0x422392[_0xaac0('0x27')]=qs[_0xaac0('0x27')](_0x5f1300[_0xaac0('0x3d')][_0xaac0('0x27')]);}_0x422392[_0xaac0('0x44')]=qs['sort'](_0x5f1300[_0xaac0('0x3d')][_0xaac0('0x45')]);_0x422392[_0xaac0('0x46')]=qs[_0xaac0('0x3c')](_[_0xaac0('0x47')](_0x5f1300['query'],_0x234121['filters']),_0x195a24);if(_0x5f1300[_0xaac0('0x3d')]['filter']){_0x422392[_0xaac0('0x46')]=_[_0xaac0('0x48')](_0x422392[_0xaac0('0x46')],{'$or':_[_0xaac0('0x35')](_0x195a24,function(_0x24fd2d){if(_0x24fd2d[_0xaac0('0x39')]!==_0xaac0('0x49')){var _0x244989={};_0x244989[_0x24fd2d[_0xaac0('0x33')]]={'$like':'%'+_0x5f1300[_0xaac0('0x3d')]['filter']+'%'};return _0x244989;}})});}_0x422392=_[_0xaac0('0x48')]({},_0x422392,_0x5f1300['options']);var _0x15957c={'where':_0x422392[_0xaac0('0x46')]};return db[_0xaac0('0x36')]['count'](_0x15957c)[_0xaac0('0x31')](function(_0x5bc480){_0x47fdd2[_0xaac0('0x4a')]=_0x5bc480;if(_0x5f1300['query'][_0xaac0('0x4b')]){_0x422392[_0xaac0('0x4c')]=[{'all':!![]}];}return db['ZendeskConfiguration'][_0xaac0('0x4d')](_0x422392);})[_0xaac0('0x31')](function(_0x3b957f){_0x47fdd2[_0xaac0('0x4e')]=_0x3b957f;return _0x47fdd2;})[_0xaac0('0x31')](respondWithFilteredResult(_0x1db34a,_0x422392))[_0xaac0('0x24')](handleError(_0x1db34a,null));};exports[_0xaac0('0x4f')]=function(_0x114e71,_0x32629f){var _0x50bdbc={'raw':![],'where':{'id':_0x114e71[_0xaac0('0x50')]['id']}},_0x233665={};_0x233665[_0xaac0('0x3b')]=_[_0xaac0('0x51')](db[_0xaac0('0x36')][_0xaac0('0x37')]);_0x233665[_0xaac0('0x3d')]=_[_0xaac0('0x51')](_0x114e71['query']);_0x233665[_0xaac0('0x3c')]=_[_0xaac0('0x3f')](_0x233665[_0xaac0('0x3b')],_0x233665[_0xaac0('0x3d')]);_0x50bdbc[_0xaac0('0x3e')]=_[_0xaac0('0x3f')](_0x233665['model'],qs[_0xaac0('0x40')](_0x114e71['query']['fields']));_0x50bdbc[_0xaac0('0x3e')]=_0x50bdbc[_0xaac0('0x3e')][_0xaac0('0x41')]?_0x50bdbc[_0xaac0('0x3e')]:_0x233665[_0xaac0('0x3b')];if(_0x114e71[_0xaac0('0x3d')][_0xaac0('0x4b')]){_0x50bdbc[_0xaac0('0x4c')]=[{'all':!![]}];}_0x50bdbc=_['merge']({},_0x50bdbc,_0x114e71[_0xaac0('0x52')]);return db['ZendeskConfiguration'][_0xaac0('0x53')](_0x50bdbc)[_0xaac0('0x31')](handleEntityNotFound(_0x32629f,null))[_0xaac0('0x31')](respondWithResult(_0x32629f,null))[_0xaac0('0x24')](handleError(_0x32629f,null));};exports[_0xaac0('0x54')]=function(_0x53cd9d,_0x388461){return db[_0xaac0('0x36')]['create'](_0x53cd9d['body'],{})[_0xaac0('0x31')](respondWithResult(_0x388461,0xc9))[_0xaac0('0x24')](handleError(_0x388461,null));};exports[_0xaac0('0x30')]=function(_0x5e1420,_0x18509c){if(_0x5e1420[_0xaac0('0x55')]['id']){delete _0x5e1420[_0xaac0('0x55')]['id'];}return db['ZendeskConfiguration'][_0xaac0('0x53')]({'where':{'id':_0x5e1420[_0xaac0('0x50')]['id']}})[_0xaac0('0x31')](handleEntityNotFound(_0x18509c,null))['then'](saveUpdates(_0x5e1420['body'],null))[_0xaac0('0x31')](respondWithResult(_0x18509c,null))[_0xaac0('0x24')](handleError(_0x18509c,null));};exports[_0xaac0('0x32')]=function(_0x2e9d95,_0x521d89){return db[_0xaac0('0x36')][_0xaac0('0x53')]({'where':{'id':_0x2e9d95[_0xaac0('0x50')]['id']}})[_0xaac0('0x31')](handleEntityNotFound(_0x521d89,null))['then'](removeEntity(_0x521d89,null))[_0xaac0('0x24')](handleError(_0x521d89,null));};exports[_0xaac0('0x56')]=function(_0x4ce3d7,_0x459fa6,_0x3847a0){var _0x1b9e39={};var _0x9de985={};var _0x30924a;var _0x503843;return db[_0xaac0('0x36')][_0xaac0('0x57')]({'where':{'id':_0x4ce3d7[_0xaac0('0x50')]['id']}})[_0xaac0('0x31')](handleEntityNotFound(_0x459fa6,null))[_0xaac0('0x31')](function(_0x1c1951){if(_0x1c1951){_0x30924a=_0x1c1951;_0x9de985[_0xaac0('0x3b')]=_[_0xaac0('0x51')](db[_0xaac0('0x58')][_0xaac0('0x37')]);_0x9de985['query']=_[_0xaac0('0x51')](_0x4ce3d7['query']);_0x9de985[_0xaac0('0x3c')]=_[_0xaac0('0x3f')](_0x9de985['model'],_0x9de985[_0xaac0('0x3d')]);_0x1b9e39[_0xaac0('0x3e')]=_[_0xaac0('0x3f')](_0x9de985[_0xaac0('0x3b')],qs[_0xaac0('0x40')](_0x4ce3d7[_0xaac0('0x3d')][_0xaac0('0x40')]));_0x1b9e39['attributes']=_0x1b9e39[_0xaac0('0x3e')][_0xaac0('0x41')]?_0x1b9e39[_0xaac0('0x3e')]:_0x9de985['model'];_0x1b9e39[_0xaac0('0x44')]=qs['sort'](_0x4ce3d7[_0xaac0('0x3d')][_0xaac0('0x45')]);_0x1b9e39['where']=qs[_0xaac0('0x3c')](_['pick'](_0x4ce3d7['query'],_0x9de985[_0xaac0('0x3c')]));if(_0x4ce3d7[_0xaac0('0x3d')]['filter']){_0x1b9e39[_0xaac0('0x46')]=_[_0xaac0('0x48')](_0x1b9e39[_0xaac0('0x46')],{'$or':_[_0xaac0('0x35')](_0x1b9e39[_0xaac0('0x3e')],function(_0x21010b){var _0x2126ca={};_0x2126ca[_0x21010b]={'$like':'%'+_0x4ce3d7['query'][_0xaac0('0x59')]+'%'};return _0x2126ca;})});}_0x1b9e39=_[_0xaac0('0x48')]({},_0x1b9e39,_0x4ce3d7['options']);return _0x30924a[_0xaac0('0x56')](_0x1b9e39);}})[_0xaac0('0x31')](function(_0x32477d){if(_0x32477d){_0x503843=_0x32477d[_0xaac0('0x41')];if(!_0x4ce3d7['query'][_0xaac0('0x42')](_0xaac0('0x43'))){_0x1b9e39['limit']=qs[_0xaac0('0x28')](_0x4ce3d7[_0xaac0('0x3d')]['limit']);_0x1b9e39[_0xaac0('0x27')]=qs[_0xaac0('0x27')](_0x4ce3d7[_0xaac0('0x3d')][_0xaac0('0x27')]);}return _0x30924a[_0xaac0('0x56')](_0x1b9e39);}})['then'](function(_0x4cd7bf){if(_0x4cd7bf){return _0x4cd7bf?{'count':_0x503843,'rows':_0x4cd7bf}:null;}})['then'](respondWithResult(_0x459fa6,null))[_0xaac0('0x24')](handleError(_0x459fa6,null));};exports['getSubjects']=function(_0x1a853d,_0x48c68e,_0x351a98){var _0x9a5db3={};var _0x1d9c46={};var _0x45ffd3;var _0x2376f5;return db[_0xaac0('0x36')][_0xaac0('0x57')]({'where':{'id':_0x1a853d['params']['id']}})[_0xaac0('0x31')](handleEntityNotFound(_0x48c68e,null))[_0xaac0('0x31')](function(_0x252e9b){if(_0x252e9b){_0x45ffd3=_0x252e9b;_0x1d9c46[_0xaac0('0x3b')]=_[_0xaac0('0x51')](db[_0xaac0('0x58')][_0xaac0('0x37')]);_0x1d9c46[_0xaac0('0x3d')]=_[_0xaac0('0x51')](_0x1a853d[_0xaac0('0x3d')]);_0x1d9c46['filters']=_[_0xaac0('0x3f')](_0x1d9c46[_0xaac0('0x3b')],_0x1d9c46['query']);_0x9a5db3[_0xaac0('0x3e')]=_[_0xaac0('0x3f')](_0x1d9c46[_0xaac0('0x3b')],qs[_0xaac0('0x40')](_0x1a853d[_0xaac0('0x3d')][_0xaac0('0x40')]));_0x9a5db3[_0xaac0('0x3e')]=_0x9a5db3[_0xaac0('0x3e')][_0xaac0('0x41')]?_0x9a5db3['attributes']:_0x1d9c46[_0xaac0('0x3b')];_0x9a5db3[_0xaac0('0x44')]=qs[_0xaac0('0x45')](_0x1a853d[_0xaac0('0x3d')]['sort']);_0x9a5db3[_0xaac0('0x46')]=qs['filters'](_['pick'](_0x1a853d[_0xaac0('0x3d')],_0x1d9c46[_0xaac0('0x3c')]));if(_0x1a853d['query'][_0xaac0('0x59')]){_0x9a5db3['where']=_[_0xaac0('0x48')](_0x9a5db3[_0xaac0('0x46')],{'$or':_[_0xaac0('0x35')](_0x9a5db3[_0xaac0('0x3e')],function(_0x16d081){var _0x31b2bb={};_0x31b2bb[_0x16d081]={'$like':'%'+_0x1a853d[_0xaac0('0x3d')]['filter']+'%'};return _0x31b2bb;})});}_0x9a5db3=_[_0xaac0('0x48')]({},_0x9a5db3,_0x1a853d[_0xaac0('0x52')]);return _0x45ffd3[_0xaac0('0x5a')](_0x9a5db3);}})['then'](function(_0x5b7015){if(_0x5b7015){_0x2376f5=_0x5b7015[_0xaac0('0x41')];if(!_0x1a853d[_0xaac0('0x3d')][_0xaac0('0x42')](_0xaac0('0x43'))){_0x9a5db3[_0xaac0('0x28')]=qs[_0xaac0('0x28')](_0x1a853d[_0xaac0('0x3d')][_0xaac0('0x28')]);_0x9a5db3[_0xaac0('0x27')]=qs[_0xaac0('0x27')](_0x1a853d['query'][_0xaac0('0x27')]);}return _0x45ffd3[_0xaac0('0x5a')](_0x9a5db3);}})[_0xaac0('0x31')](function(_0x2fe2f3){if(_0x2fe2f3){return _0x2fe2f3?{'count':_0x2376f5,'rows':_0x2fe2f3}:null;}})[_0xaac0('0x31')](respondWithResult(_0x48c68e,null))[_0xaac0('0x24')](handleError(_0x48c68e,null));};exports['getDescriptions']=function(_0x53aa0c,_0x884229,_0x53a4b1){var _0x39276b={};var _0x869634={};var _0x1bacd4;var _0x5365f5;return db[_0xaac0('0x36')][_0xaac0('0x57')]({'where':{'id':_0x53aa0c[_0xaac0('0x50')]['id']}})[_0xaac0('0x31')](handleEntityNotFound(_0x884229,null))[_0xaac0('0x31')](function(_0x5ecce0){if(_0x5ecce0){_0x1bacd4=_0x5ecce0;_0x869634[_0xaac0('0x3b')]=_[_0xaac0('0x51')](db[_0xaac0('0x58')][_0xaac0('0x37')]);_0x869634[_0xaac0('0x3d')]=_['keys'](_0x53aa0c['query']);_0x869634['filters']=_[_0xaac0('0x3f')](_0x869634[_0xaac0('0x3b')],_0x869634['query']);_0x39276b[_0xaac0('0x3e')]=_[_0xaac0('0x3f')](_0x869634[_0xaac0('0x3b')],qs[_0xaac0('0x40')](_0x53aa0c['query'][_0xaac0('0x40')]));_0x39276b['attributes']=_0x39276b[_0xaac0('0x3e')][_0xaac0('0x41')]?_0x39276b[_0xaac0('0x3e')]:_0x869634['model'];_0x39276b[_0xaac0('0x44')]=qs[_0xaac0('0x45')](_0x53aa0c['query'][_0xaac0('0x45')]);_0x39276b[_0xaac0('0x46')]=qs[_0xaac0('0x3c')](_[_0xaac0('0x47')](_0x53aa0c[_0xaac0('0x3d')],_0x869634[_0xaac0('0x3c')]));if(_0x53aa0c[_0xaac0('0x3d')][_0xaac0('0x59')]){_0x39276b[_0xaac0('0x46')]=_[_0xaac0('0x48')](_0x39276b[_0xaac0('0x46')],{'$or':_[_0xaac0('0x35')](_0x39276b[_0xaac0('0x3e')],function(_0xeb13d4){var _0x30ad2b={};_0x30ad2b[_0xeb13d4]={'$like':'%'+_0x53aa0c['query'][_0xaac0('0x59')]+'%'};return _0x30ad2b;})});}_0x39276b=_[_0xaac0('0x48')]({},_0x39276b,_0x53aa0c[_0xaac0('0x52')]);return _0x1bacd4['getDescriptions'](_0x39276b);}})[_0xaac0('0x31')](function(_0x3275be){if(_0x3275be){_0x5365f5=_0x3275be['length'];if(!_0x53aa0c['query']['hasOwnProperty']('nolimit')){_0x39276b[_0xaac0('0x28')]=qs[_0xaac0('0x28')](_0x53aa0c[_0xaac0('0x3d')][_0xaac0('0x28')]);_0x39276b[_0xaac0('0x27')]=qs[_0xaac0('0x27')](_0x53aa0c[_0xaac0('0x3d')][_0xaac0('0x27')]);}return _0x1bacd4[_0xaac0('0x5b')](_0x39276b);}})['then'](function(_0x3f1904){if(_0x3f1904){return _0x3f1904?{'count':_0x5365f5,'rows':_0x3f1904}:null;}})[_0xaac0('0x31')](respondWithResult(_0x884229,null))['catch'](handleError(_0x884229,null));};exports['getTags']=function(_0x149ee5,_0x341832,_0x46b10d){var _0x8283f5={};var _0x186e5d={};var _0x2b81c6;var _0x1fada6;return db[_0xaac0('0x36')]['findOne']({'where':{'id':_0x149ee5[_0xaac0('0x50')]['id']}})['then'](handleEntityNotFound(_0x341832,null))['then'](function(_0x4bb3fa){if(_0x4bb3fa){_0x2b81c6=_0x4bb3fa;_0x186e5d[_0xaac0('0x3b')]=_[_0xaac0('0x51')](db[_0xaac0('0x5c')]['rawAttributes']);_0x186e5d[_0xaac0('0x3d')]=_['keys'](_0x149ee5[_0xaac0('0x3d')]);_0x186e5d[_0xaac0('0x3c')]=_[_0xaac0('0x3f')](_0x186e5d[_0xaac0('0x3b')],_0x186e5d['query']);_0x8283f5[_0xaac0('0x3e')]=_[_0xaac0('0x3f')](_0x186e5d[_0xaac0('0x3b')],qs[_0xaac0('0x40')](_0x149ee5[_0xaac0('0x3d')]['fields']));_0x8283f5[_0xaac0('0x3e')]=_0x8283f5[_0xaac0('0x3e')][_0xaac0('0x41')]?_0x8283f5[_0xaac0('0x3e')]:_0x186e5d[_0xaac0('0x3b')];_0x8283f5[_0xaac0('0x44')]=qs['sort'](_0x149ee5[_0xaac0('0x3d')][_0xaac0('0x45')]);_0x8283f5['where']=qs[_0xaac0('0x3c')](_[_0xaac0('0x47')](_0x149ee5[_0xaac0('0x3d')],_0x186e5d[_0xaac0('0x3c')]));if(_0x149ee5[_0xaac0('0x3d')][_0xaac0('0x59')]){_0x8283f5['where']=_['merge'](_0x8283f5[_0xaac0('0x46')],{'$or':_['map'](_0x8283f5['attributes'],function(_0x3edd45){var _0x52f548={};_0x52f548[_0x3edd45]={'$like':'%'+_0x149ee5[_0xaac0('0x3d')][_0xaac0('0x59')]+'%'};return _0x52f548;})});}_0x8283f5=_[_0xaac0('0x48')]({},_0x8283f5,_0x149ee5['options']);return _0x2b81c6[_0xaac0('0x5d')](_0x8283f5);}})[_0xaac0('0x31')](function(_0x27a8c4){if(_0x27a8c4){_0x1fada6=_0x27a8c4[_0xaac0('0x41')];if(!_0x149ee5[_0xaac0('0x3d')][_0xaac0('0x42')](_0xaac0('0x43'))){_0x8283f5[_0xaac0('0x28')]=qs['limit'](_0x149ee5['query']['limit']);_0x8283f5[_0xaac0('0x27')]=qs[_0xaac0('0x27')](_0x149ee5['query'][_0xaac0('0x27')]);}return _0x2b81c6['getTags'](_0x8283f5);}})[_0xaac0('0x31')](function(_0x1af235){if(_0x1af235){return _0x1af235?{'count':_0x1fada6,'rows':_0x1af235}:null;}})[_0xaac0('0x31')](respondWithResult(_0x341832,null))['catch'](handleError(_0x341832,null));};exports[_0xaac0('0x5e')]=function(_0x6450ca,_0x1faca6,_0x2ebba2){if(_0x6450ca['body']['id']){delete _0x6450ca[_0xaac0('0x55')]['id'];}return db[_0xaac0('0x36')][_0xaac0('0x57')]({'where':{'id':_0x6450ca['params']['id']}})[_0xaac0('0x31')](handleEntityNotFound(_0x1faca6,null))['then'](function(_0x3e18ae){if(_0x3e18ae){return _0x3e18ae[_0xaac0('0x5e')](_0x6450ca[_0xaac0('0x55')]['ids']||[]);}return null;})[_0xaac0('0x31')](respondWithResult(_0x1faca6,null))['catch'](handleError(_0x1faca6,null));};