Built motion from commit (unavailable).|2.5.27
[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 _0xff0a=['rows','show','find','create','body','params','getFields','findOne','pick','getSubjects','ZendeskField','getDescriptions','getTags','setTags','ids','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','jayson/promise','client','http','request','then','info','request\x20sent','ZendeskConfiguration,\x20%s,\x20%s,\x20%s','error','code','ZendeskConfiguration,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','count','offset','limit','set','Content-Range','json','reject','save','update','destroy','stack','name','index','map','ZendeskConfiguration','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','filter','where','VIRTUAL','merge','options','includeAll','include','findAll'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xff0a,0x183));var _0xaff0=function(_0x122096,_0x60c295){_0x122096=_0x122096-0x0;var _0x3d1966=_0xff0a[_0x122096];return _0x3d1966;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xaff0('0x0'));var zipdir=require(_0xaff0('0x1'));var jsonpatch=require(_0xaff0('0x2'));var rp=require(_0xaff0('0x3'));var moment=require(_0xaff0('0x4'));var BPromise=require(_0xaff0('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require('sox');var csv=require(_0xaff0('0x6'));var ejs=require(_0xaff0('0x7'));var fs=require('fs');var fs_extra=require(_0xaff0('0x8'));var _=require(_0xaff0('0x9'));var squel=require(_0xaff0('0xa'));var crypto=require('crypto');var jsforce=require(_0xaff0('0xb'));var deskjs=require(_0xaff0('0xc'));var toCsv=require('to-csv');var querystring=require(_0xaff0('0xd'));var Papa=require(_0xaff0('0xe'));var Redis=require(_0xaff0('0xf'));var authService=require(_0xaff0('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xaff0('0x11'));var hardwareService=require(_0xaff0('0x12'));var logger=require('../../config/logger')(_0xaff0('0x13'));var utils=require(_0xaff0('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xaff0('0x15'));var db=require(_0xaff0('0x16'))['db'];var jayson=require(_0xaff0('0x17'));var client=jayson[_0xaff0('0x18')][_0xaff0('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x3e64df,_0x1416ea,_0x335fc3,_0x355714){return new BPromise(function(_0x1187e0,_0x5de59f){var _0x603c66=_0x355714||client;return _0x603c66[_0xaff0('0x1a')](_0x3e64df,_0x335fc3)[_0xaff0('0x1b')](function(_0x413265){logger[_0xaff0('0x1c')]('ZendeskConfiguration,\x20%s,\x20%s',_0x1416ea,_0xaff0('0x1d'));logger['debug'](_0xaff0('0x1e'),_0x1416ea,_0xaff0('0x1d'),JSON['stringify'](_0x413265));if(_0x413265['error']){if(_0x413265[_0xaff0('0x1f')][_0xaff0('0x20')]===0x1f4){logger[_0xaff0('0x1f')](_0xaff0('0x21'),_0x1416ea,_0x413265[_0xaff0('0x1f')][_0xaff0('0x22')]);return _0x5de59f(_0x413265[_0xaff0('0x1f')][_0xaff0('0x22')]);}logger[_0xaff0('0x1f')](_0xaff0('0x21'),_0x1416ea,_0x413265[_0xaff0('0x1f')][_0xaff0('0x22')]);return _0x1187e0(_0x413265['error'][_0xaff0('0x22')]);}else{logger[_0xaff0('0x1c')](_0xaff0('0x21'),_0x1416ea,'request\x20sent');_0x1187e0(_0x413265[_0xaff0('0x23')][_0xaff0('0x22')]);}})[_0xaff0('0x24')](function(_0x294b46){logger[_0xaff0('0x1f')](_0xaff0('0x21'),_0x1416ea,_0x294b46);_0x5de59f(_0x294b46);});});}function respondWithStatusCode(_0x47799e,_0x4a43d2){_0x4a43d2=_0x4a43d2||0xcc;return function(_0x10a584){if(_0x10a584){return _0x47799e[_0xaff0('0x25')](_0x4a43d2);}return _0x47799e[_0xaff0('0x26')](_0x4a43d2)[_0xaff0('0x27')]();};}function respondWithResult(_0x5c6631,_0xf47e40){_0xf47e40=_0xf47e40||0xc8;return function(_0x1e1ac2){if(_0x1e1ac2){return _0x5c6631[_0xaff0('0x26')](_0xf47e40)['json'](_0x1e1ac2);}};}function respondWithFilteredResult(_0x2a9fa8,_0x5542ff){return function(_0x2a01dc){if(_0x2a01dc){var _0xf93421=_0x2a01dc[_0xaff0('0x28')],_0x212d01=_0x5542ff['offset'],_0x528ac9=_0x5542ff[_0xaff0('0x29')]+_0x5542ff[_0xaff0('0x2a')],_0x6e9ecb;if(_0x528ac9>=_0xf93421){_0x528ac9=_0xf93421;_0x6e9ecb=0xc8;}else{_0x6e9ecb=0xce;}_0x2a9fa8[_0xaff0('0x26')](_0x6e9ecb);return _0x2a9fa8[_0xaff0('0x2b')](_0xaff0('0x2c'),_0x212d01+'-'+_0x528ac9+'/'+_0xf93421)[_0xaff0('0x2d')](_0x2a01dc);}return null;};}function patchUpdates(_0x10fce3){return function(_0x2e9b6d){try{jsonpatch['apply'](_0x2e9b6d,_0x10fce3,!![]);}catch(_0x171f04){return BPromise[_0xaff0('0x2e')](_0x171f04);}return _0x2e9b6d[_0xaff0('0x2f')]();};}function saveUpdates(_0x265027,_0x4ec30d){return function(_0x2ba15c){if(_0x2ba15c){return _0x2ba15c[_0xaff0('0x30')](_0x265027)[_0xaff0('0x1b')](function(_0xecf28b){return _0xecf28b;});}return null;};}function removeEntity(_0x263015,_0x39d251){return function(_0x4af711){if(_0x4af711){return _0x4af711[_0xaff0('0x31')]()[_0xaff0('0x1b')](function(){_0x263015[_0xaff0('0x26')](0xcc)[_0xaff0('0x27')]();});}};}function handleEntityNotFound(_0xb6121,_0x30054d){return function(_0x160a6c){if(!_0x160a6c){_0xb6121[_0xaff0('0x25')](0x194);}return _0x160a6c;};}function handleError(_0x3a22c1,_0x3a8209){_0x3a8209=_0x3a8209||0x1f4;return function(_0x3104d7){logger[_0xaff0('0x1f')](_0x3104d7[_0xaff0('0x32')]);if(_0x3104d7[_0xaff0('0x33')]){delete _0x3104d7[_0xaff0('0x33')];}_0x3a22c1[_0xaff0('0x26')](_0x3a8209)['send'](_0x3104d7);};}exports[_0xaff0('0x34')]=function(_0x2368f9,_0x3362a2){var _0x48a0be={},_0x46e06e={},_0x10a603={'count':0x0,'rows':[]};var _0x5f2d96=_[_0xaff0('0x35')](db[_0xaff0('0x36')][_0xaff0('0x37')],function(_0x106c43){return{'name':_0x106c43[_0xaff0('0x38')],'type':_0x106c43['type'][_0xaff0('0x39')]};});_0x46e06e[_0xaff0('0x3a')]=_[_0xaff0('0x35')](_0x5f2d96,'name');_0x46e06e[_0xaff0('0x3b')]=_[_0xaff0('0x3c')](_0x2368f9[_0xaff0('0x3b')]);_0x46e06e[_0xaff0('0x3d')]=_[_0xaff0('0x3e')](_0x46e06e['model'],_0x46e06e[_0xaff0('0x3b')]);_0x48a0be[_0xaff0('0x3f')]=_[_0xaff0('0x3e')](_0x46e06e['model'],qs['fields'](_0x2368f9['query'][_0xaff0('0x40')]));_0x48a0be[_0xaff0('0x3f')]=_0x48a0be[_0xaff0('0x3f')][_0xaff0('0x41')]?_0x48a0be['attributes']:_0x46e06e[_0xaff0('0x3a')];if(!_0x2368f9[_0xaff0('0x3b')][_0xaff0('0x42')](_0xaff0('0x43'))){_0x48a0be[_0xaff0('0x2a')]=qs['limit'](_0x2368f9[_0xaff0('0x3b')][_0xaff0('0x2a')]);_0x48a0be['offset']=qs[_0xaff0('0x29')](_0x2368f9[_0xaff0('0x3b')]['offset']);}_0x48a0be[_0xaff0('0x44')]=qs[_0xaff0('0x45')](_0x2368f9[_0xaff0('0x3b')][_0xaff0('0x45')]);_0x48a0be['where']=qs[_0xaff0('0x3d')](_['pick'](_0x2368f9[_0xaff0('0x3b')],_0x46e06e[_0xaff0('0x3d')]),_0x5f2d96);if(_0x2368f9[_0xaff0('0x3b')][_0xaff0('0x46')]){_0x48a0be[_0xaff0('0x47')]=_['merge'](_0x48a0be[_0xaff0('0x47')],{'$or':_[_0xaff0('0x35')](_0x5f2d96,function(_0x59dc21){if(_0x59dc21['type']!==_0xaff0('0x48')){var _0x594a41={};_0x594a41[_0x59dc21[_0xaff0('0x33')]]={'$like':'%'+_0x2368f9[_0xaff0('0x3b')][_0xaff0('0x46')]+'%'};return _0x594a41;}})});}_0x48a0be=_[_0xaff0('0x49')]({},_0x48a0be,_0x2368f9[_0xaff0('0x4a')]);var _0x5a17ae={'where':_0x48a0be[_0xaff0('0x47')]};return db[_0xaff0('0x36')][_0xaff0('0x28')](_0x5a17ae)['then'](function(_0x15b884){_0x10a603[_0xaff0('0x28')]=_0x15b884;if(_0x2368f9['query'][_0xaff0('0x4b')]){_0x48a0be[_0xaff0('0x4c')]=[{'all':!![]}];}return db[_0xaff0('0x36')][_0xaff0('0x4d')](_0x48a0be);})[_0xaff0('0x1b')](function(_0x29a191){_0x10a603[_0xaff0('0x4e')]=_0x29a191;return _0x10a603;})[_0xaff0('0x1b')](respondWithFilteredResult(_0x3362a2,_0x48a0be))['catch'](handleError(_0x3362a2,null));};exports[_0xaff0('0x4f')]=function(_0x3c399b,_0x298a72){var _0x13c5a1={'raw':![],'where':{'id':_0x3c399b['params']['id']}},_0x26cf5f={};_0x26cf5f['model']=_[_0xaff0('0x3c')](db['ZendeskConfiguration']['rawAttributes']);_0x26cf5f[_0xaff0('0x3b')]=_['keys'](_0x3c399b[_0xaff0('0x3b')]);_0x26cf5f[_0xaff0('0x3d')]=_[_0xaff0('0x3e')](_0x26cf5f[_0xaff0('0x3a')],_0x26cf5f[_0xaff0('0x3b')]);_0x13c5a1[_0xaff0('0x3f')]=_['intersection'](_0x26cf5f[_0xaff0('0x3a')],qs['fields'](_0x3c399b[_0xaff0('0x3b')][_0xaff0('0x40')]));_0x13c5a1[_0xaff0('0x3f')]=_0x13c5a1['attributes'][_0xaff0('0x41')]?_0x13c5a1[_0xaff0('0x3f')]:_0x26cf5f[_0xaff0('0x3a')];if(_0x3c399b[_0xaff0('0x3b')][_0xaff0('0x4b')]){_0x13c5a1[_0xaff0('0x4c')]=[{'all':!![]}];}_0x13c5a1=_[_0xaff0('0x49')]({},_0x13c5a1,_0x3c399b['options']);return db[_0xaff0('0x36')][_0xaff0('0x50')](_0x13c5a1)[_0xaff0('0x1b')](handleEntityNotFound(_0x298a72,null))['then'](respondWithResult(_0x298a72,null))[_0xaff0('0x24')](handleError(_0x298a72,null));};exports['create']=function(_0x309aeb,_0x27dbe4){return db['ZendeskConfiguration'][_0xaff0('0x51')](_0x309aeb[_0xaff0('0x52')],{})[_0xaff0('0x1b')](respondWithResult(_0x27dbe4,0xc9))[_0xaff0('0x24')](handleError(_0x27dbe4,null));};exports['update']=function(_0x2847ee,_0x49106a){if(_0x2847ee[_0xaff0('0x52')]['id']){delete _0x2847ee[_0xaff0('0x52')]['id'];}return db['ZendeskConfiguration']['find']({'where':{'id':_0x2847ee[_0xaff0('0x53')]['id']}})[_0xaff0('0x1b')](handleEntityNotFound(_0x49106a,null))[_0xaff0('0x1b')](saveUpdates(_0x2847ee[_0xaff0('0x52')],null))[_0xaff0('0x1b')](respondWithResult(_0x49106a,null))[_0xaff0('0x24')](handleError(_0x49106a,null));};exports[_0xaff0('0x31')]=function(_0x784d09,_0x2d7af2){return db[_0xaff0('0x36')][_0xaff0('0x50')]({'where':{'id':_0x784d09[_0xaff0('0x53')]['id']}})[_0xaff0('0x1b')](handleEntityNotFound(_0x2d7af2,null))[_0xaff0('0x1b')](removeEntity(_0x2d7af2,null))[_0xaff0('0x24')](handleError(_0x2d7af2,null));};exports[_0xaff0('0x54')]=function(_0x1ae71c,_0x3c2fb9,_0x1bf14a){var _0x1f6096={};var _0x2cd9d7={};var _0x56475f;var _0x118994;return db[_0xaff0('0x36')][_0xaff0('0x55')]({'where':{'id':_0x1ae71c[_0xaff0('0x53')]['id']}})[_0xaff0('0x1b')](handleEntityNotFound(_0x3c2fb9,null))[_0xaff0('0x1b')](function(_0x5b6271){if(_0x5b6271){_0x56475f=_0x5b6271;_0x2cd9d7[_0xaff0('0x3a')]=_['keys'](db['ZendeskField'][_0xaff0('0x37')]);_0x2cd9d7[_0xaff0('0x3b')]=_[_0xaff0('0x3c')](_0x1ae71c[_0xaff0('0x3b')]);_0x2cd9d7[_0xaff0('0x3d')]=_[_0xaff0('0x3e')](_0x2cd9d7[_0xaff0('0x3a')],_0x2cd9d7['query']);_0x1f6096[_0xaff0('0x3f')]=_[_0xaff0('0x3e')](_0x2cd9d7[_0xaff0('0x3a')],qs[_0xaff0('0x40')](_0x1ae71c['query']['fields']));_0x1f6096[_0xaff0('0x3f')]=_0x1f6096['attributes'][_0xaff0('0x41')]?_0x1f6096[_0xaff0('0x3f')]:_0x2cd9d7['model'];_0x1f6096[_0xaff0('0x44')]=qs[_0xaff0('0x45')](_0x1ae71c[_0xaff0('0x3b')]['sort']);_0x1f6096[_0xaff0('0x47')]=qs[_0xaff0('0x3d')](_[_0xaff0('0x56')](_0x1ae71c[_0xaff0('0x3b')],_0x2cd9d7[_0xaff0('0x3d')]));if(_0x1ae71c['query'][_0xaff0('0x46')]){_0x1f6096[_0xaff0('0x47')]=_['merge'](_0x1f6096['where'],{'$or':_[_0xaff0('0x35')](_0x1f6096[_0xaff0('0x3f')],function(_0x5b5470){var _0x3f1fa2={};_0x3f1fa2[_0x5b5470]={'$like':'%'+_0x1ae71c[_0xaff0('0x3b')][_0xaff0('0x46')]+'%'};return _0x3f1fa2;})});}_0x1f6096=_[_0xaff0('0x49')]({},_0x1f6096,_0x1ae71c['options']);return _0x56475f['getFields'](_0x1f6096);}})[_0xaff0('0x1b')](function(_0x35d013){if(_0x35d013){_0x118994=_0x35d013[_0xaff0('0x41')];if(!_0x1ae71c[_0xaff0('0x3b')][_0xaff0('0x42')]('nolimit')){_0x1f6096[_0xaff0('0x2a')]=qs[_0xaff0('0x2a')](_0x1ae71c[_0xaff0('0x3b')]['limit']);_0x1f6096[_0xaff0('0x29')]=qs[_0xaff0('0x29')](_0x1ae71c[_0xaff0('0x3b')]['offset']);}return _0x56475f[_0xaff0('0x54')](_0x1f6096);}})[_0xaff0('0x1b')](function(_0xc28c7f){if(_0xc28c7f){return _0xc28c7f?{'count':_0x118994,'rows':_0xc28c7f}:null;}})[_0xaff0('0x1b')](respondWithResult(_0x3c2fb9,null))[_0xaff0('0x24')](handleError(_0x3c2fb9,null));};exports[_0xaff0('0x57')]=function(_0x51e2f4,_0x3d2d4f,_0x17e7e3){var _0x3e1b16={};var _0x560f09={};var _0x386e50;var _0x566018;return db[_0xaff0('0x36')]['findOne']({'where':{'id':_0x51e2f4[_0xaff0('0x53')]['id']}})[_0xaff0('0x1b')](handleEntityNotFound(_0x3d2d4f,null))['then'](function(_0x4bef1d){if(_0x4bef1d){_0x386e50=_0x4bef1d;_0x560f09[_0xaff0('0x3a')]=_[_0xaff0('0x3c')](db[_0xaff0('0x58')][_0xaff0('0x37')]);_0x560f09['query']=_[_0xaff0('0x3c')](_0x51e2f4['query']);_0x560f09[_0xaff0('0x3d')]=_[_0xaff0('0x3e')](_0x560f09[_0xaff0('0x3a')],_0x560f09['query']);_0x3e1b16[_0xaff0('0x3f')]=_['intersection'](_0x560f09[_0xaff0('0x3a')],qs[_0xaff0('0x40')](_0x51e2f4[_0xaff0('0x3b')][_0xaff0('0x40')]));_0x3e1b16['attributes']=_0x3e1b16['attributes'][_0xaff0('0x41')]?_0x3e1b16['attributes']:_0x560f09[_0xaff0('0x3a')];_0x3e1b16['order']=qs[_0xaff0('0x45')](_0x51e2f4[_0xaff0('0x3b')][_0xaff0('0x45')]);_0x3e1b16[_0xaff0('0x47')]=qs['filters'](_[_0xaff0('0x56')](_0x51e2f4['query'],_0x560f09[_0xaff0('0x3d')]));if(_0x51e2f4[_0xaff0('0x3b')]['filter']){_0x3e1b16[_0xaff0('0x47')]=_[_0xaff0('0x49')](_0x3e1b16[_0xaff0('0x47')],{'$or':_[_0xaff0('0x35')](_0x3e1b16[_0xaff0('0x3f')],function(_0x760479){var _0x2d0aba={};_0x2d0aba[_0x760479]={'$like':'%'+_0x51e2f4[_0xaff0('0x3b')]['filter']+'%'};return _0x2d0aba;})});}_0x3e1b16=_['merge']({},_0x3e1b16,_0x51e2f4[_0xaff0('0x4a')]);return _0x386e50[_0xaff0('0x57')](_0x3e1b16);}})['then'](function(_0x519714){if(_0x519714){_0x566018=_0x519714[_0xaff0('0x41')];if(!_0x51e2f4[_0xaff0('0x3b')][_0xaff0('0x42')](_0xaff0('0x43'))){_0x3e1b16[_0xaff0('0x2a')]=qs['limit'](_0x51e2f4[_0xaff0('0x3b')]['limit']);_0x3e1b16[_0xaff0('0x29')]=qs[_0xaff0('0x29')](_0x51e2f4['query'][_0xaff0('0x29')]);}return _0x386e50[_0xaff0('0x57')](_0x3e1b16);}})[_0xaff0('0x1b')](function(_0x36c0bd){if(_0x36c0bd){return _0x36c0bd?{'count':_0x566018,'rows':_0x36c0bd}:null;}})[_0xaff0('0x1b')](respondWithResult(_0x3d2d4f,null))[_0xaff0('0x24')](handleError(_0x3d2d4f,null));};exports[_0xaff0('0x59')]=function(_0x3b9c70,_0x17201c,_0x581bbe){var _0x55a7ac={};var _0x223ff6={};var _0x1faf25;var _0x33a091;return db[_0xaff0('0x36')][_0xaff0('0x55')]({'where':{'id':_0x3b9c70[_0xaff0('0x53')]['id']}})['then'](handleEntityNotFound(_0x17201c,null))[_0xaff0('0x1b')](function(_0x5de574){if(_0x5de574){_0x1faf25=_0x5de574;_0x223ff6[_0xaff0('0x3a')]=_[_0xaff0('0x3c')](db[_0xaff0('0x58')][_0xaff0('0x37')]);_0x223ff6[_0xaff0('0x3b')]=_['keys'](_0x3b9c70[_0xaff0('0x3b')]);_0x223ff6['filters']=_['intersection'](_0x223ff6[_0xaff0('0x3a')],_0x223ff6[_0xaff0('0x3b')]);_0x55a7ac[_0xaff0('0x3f')]=_['intersection'](_0x223ff6[_0xaff0('0x3a')],qs[_0xaff0('0x40')](_0x3b9c70[_0xaff0('0x3b')][_0xaff0('0x40')]));_0x55a7ac[_0xaff0('0x3f')]=_0x55a7ac['attributes'][_0xaff0('0x41')]?_0x55a7ac[_0xaff0('0x3f')]:_0x223ff6[_0xaff0('0x3a')];_0x55a7ac['order']=qs[_0xaff0('0x45')](_0x3b9c70[_0xaff0('0x3b')][_0xaff0('0x45')]);_0x55a7ac[_0xaff0('0x47')]=qs['filters'](_[_0xaff0('0x56')](_0x3b9c70['query'],_0x223ff6[_0xaff0('0x3d')]));if(_0x3b9c70['query'][_0xaff0('0x46')]){_0x55a7ac[_0xaff0('0x47')]=_['merge'](_0x55a7ac['where'],{'$or':_[_0xaff0('0x35')](_0x55a7ac[_0xaff0('0x3f')],function(_0x15c5b2){var _0x3eb044={};_0x3eb044[_0x15c5b2]={'$like':'%'+_0x3b9c70[_0xaff0('0x3b')][_0xaff0('0x46')]+'%'};return _0x3eb044;})});}_0x55a7ac=_[_0xaff0('0x49')]({},_0x55a7ac,_0x3b9c70['options']);return _0x1faf25[_0xaff0('0x59')](_0x55a7ac);}})[_0xaff0('0x1b')](function(_0x276ff2){if(_0x276ff2){_0x33a091=_0x276ff2['length'];if(!_0x3b9c70[_0xaff0('0x3b')][_0xaff0('0x42')](_0xaff0('0x43'))){_0x55a7ac[_0xaff0('0x2a')]=qs['limit'](_0x3b9c70[_0xaff0('0x3b')]['limit']);_0x55a7ac[_0xaff0('0x29')]=qs[_0xaff0('0x29')](_0x3b9c70['query']['offset']);}return _0x1faf25[_0xaff0('0x59')](_0x55a7ac);}})[_0xaff0('0x1b')](function(_0x1333c4){if(_0x1333c4){return _0x1333c4?{'count':_0x33a091,'rows':_0x1333c4}:null;}})[_0xaff0('0x1b')](respondWithResult(_0x17201c,null))[_0xaff0('0x24')](handleError(_0x17201c,null));};exports[_0xaff0('0x5a')]=function(_0x1e58de,_0x26658e,_0x3a88db){var _0x5ac6e9={};var _0x9e136e={};var _0x33d7ee;var _0x514bc5;return db[_0xaff0('0x36')]['findOne']({'where':{'id':_0x1e58de[_0xaff0('0x53')]['id']}})['then'](handleEntityNotFound(_0x26658e,null))[_0xaff0('0x1b')](function(_0x3c2705){if(_0x3c2705){_0x33d7ee=_0x3c2705;_0x9e136e[_0xaff0('0x3a')]=_[_0xaff0('0x3c')](db['Tag']['rawAttributes']);_0x9e136e[_0xaff0('0x3b')]=_['keys'](_0x1e58de[_0xaff0('0x3b')]);_0x9e136e[_0xaff0('0x3d')]=_[_0xaff0('0x3e')](_0x9e136e[_0xaff0('0x3a')],_0x9e136e[_0xaff0('0x3b')]);_0x5ac6e9[_0xaff0('0x3f')]=_[_0xaff0('0x3e')](_0x9e136e[_0xaff0('0x3a')],qs[_0xaff0('0x40')](_0x1e58de['query'][_0xaff0('0x40')]));_0x5ac6e9[_0xaff0('0x3f')]=_0x5ac6e9['attributes']['length']?_0x5ac6e9['attributes']:_0x9e136e[_0xaff0('0x3a')];_0x5ac6e9[_0xaff0('0x44')]=qs[_0xaff0('0x45')](_0x1e58de[_0xaff0('0x3b')][_0xaff0('0x45')]);_0x5ac6e9[_0xaff0('0x47')]=qs[_0xaff0('0x3d')](_['pick'](_0x1e58de['query'],_0x9e136e[_0xaff0('0x3d')]));if(_0x1e58de[_0xaff0('0x3b')][_0xaff0('0x46')]){_0x5ac6e9[_0xaff0('0x47')]=_[_0xaff0('0x49')](_0x5ac6e9['where'],{'$or':_['map'](_0x5ac6e9[_0xaff0('0x3f')],function(_0x17ea90){var _0x5d5509={};_0x5d5509[_0x17ea90]={'$like':'%'+_0x1e58de[_0xaff0('0x3b')][_0xaff0('0x46')]+'%'};return _0x5d5509;})});}_0x5ac6e9=_['merge']({},_0x5ac6e9,_0x1e58de[_0xaff0('0x4a')]);return _0x33d7ee[_0xaff0('0x5a')](_0x5ac6e9);}})[_0xaff0('0x1b')](function(_0x6fef09){if(_0x6fef09){_0x514bc5=_0x6fef09[_0xaff0('0x41')];if(!_0x1e58de[_0xaff0('0x3b')][_0xaff0('0x42')](_0xaff0('0x43'))){_0x5ac6e9['limit']=qs['limit'](_0x1e58de['query'][_0xaff0('0x2a')]);_0x5ac6e9[_0xaff0('0x29')]=qs[_0xaff0('0x29')](_0x1e58de['query']['offset']);}return _0x33d7ee[_0xaff0('0x5a')](_0x5ac6e9);}})[_0xaff0('0x1b')](function(_0x338f55){if(_0x338f55){return _0x338f55?{'count':_0x514bc5,'rows':_0x338f55}:null;}})[_0xaff0('0x1b')](respondWithResult(_0x26658e,null))[_0xaff0('0x24')](handleError(_0x26658e,null));};exports[_0xaff0('0x5b')]=function(_0x3e1508,_0x257ae3,_0x555c50){if(_0x3e1508[_0xaff0('0x52')]['id']){delete _0x3e1508[_0xaff0('0x52')]['id'];}return db[_0xaff0('0x36')]['findOne']({'where':{'id':_0x3e1508['params']['id']}})[_0xaff0('0x1b')](handleEntityNotFound(_0x257ae3,null))[_0xaff0('0x1b')](function(_0x37b212){if(_0x37b212){return _0x37b212[_0xaff0('0x5b')](_0x3e1508[_0xaff0('0x52')][_0xaff0('0x5c')]||[]);}return null;})['then'](respondWithResult(_0x257ae3,null))[_0xaff0('0x24')](handleError(_0x257ae3,null));};