d352d2ade401366fd98d3bdc432180bfc2343014
[motion2.git] / server / api / trigger / trigger.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 _0x185b=['catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','autoAssociation','update','destroy','addAllCondition','TriggerAllId','Condition','addAnyCondition','TriggerAnyId','getAllConditions','findOne','getAnyConditions','Action','getActions','eml-format','rimraf','fast-json-patch','request-promise','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','save','get','Triggers','UserProfileResource','then','error','stack','name','Trigger','rawAttributes','fieldName','type','key','model','map','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','params'];(function(_0xfd3560,_0x18c1b8){var _0x18cb05=function(_0x5ae595){while(--_0x5ae595){_0xfd3560['push'](_0xfd3560['shift']());}};_0x18cb05(++_0x18c1b8);}(_0x185b,0x6f));var _0xb185=function(_0x2070da,_0x45e586){_0x2070da=_0x2070da-0x0;var _0x4f9fe1=_0x185b[_0x2070da];return _0x4f9fe1;};'use strict';var emlformat=require(_0xb185('0x0'));var rimraf=require(_0xb185('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb185('0x2'));var rp=require(_0xb185('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xb185('0x4'));var util=require(_0xb185('0x5'));var path=require(_0xb185('0x6'));var sox=require(_0xb185('0x7'));var csv=require(_0xb185('0x8'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xb185('0x9'));var _=require(_0xb185('0xa'));var squel=require('squel');var crypto=require(_0xb185('0xb'));var jsforce=require('jsforce');var deskjs=require(_0xb185('0xc'));var toCsv=require(_0xb185('0x8'));var querystring=require(_0xb185('0xd'));var Papa=require('papaparse');var Redis=require(_0xb185('0xe'));var authService=require(_0xb185('0xf'));var qs=require(_0xb185('0x10'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xb185('0x11'));var logger=require(_0xb185('0x12'))(_0xb185('0x13'));var utils=require(_0xb185('0x14'));var config=require(_0xb185('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xb185('0x16'))['db'];function respondWithStatusCode(_0x21e79c,_0x1cbfb1){_0x1cbfb1=_0x1cbfb1||0xcc;return function(_0x52c988){if(_0x52c988){return _0x21e79c[_0xb185('0x17')](_0x1cbfb1);}return _0x21e79c[_0xb185('0x18')](_0x1cbfb1)[_0xb185('0x19')]();};}function respondWithResult(_0x12ca96,_0x17ee03){_0x17ee03=_0x17ee03||0xc8;return function(_0x4c2851){if(_0x4c2851){return _0x12ca96['status'](_0x17ee03)[_0xb185('0x1a')](_0x4c2851);}};}function respondWithFilteredResult(_0x2f94fa,_0x5a9428){return function(_0x2e313f){if(_0x2e313f){var _0x28adbb=typeof _0x5a9428[_0xb185('0x1b')]===_0xb185('0x1c')&&typeof _0x5a9428[_0xb185('0x1d')]===_0xb185('0x1c');var _0x5f209f=_0x2e313f['count'];var _0x213ade=_0x28adbb?0x0:_0x5a9428[_0xb185('0x1b')];var _0x8a134a=_0x28adbb?_0x2e313f[_0xb185('0x1e')]:_0x5a9428['offset']+_0x5a9428[_0xb185('0x1d')];var _0x3fe6b8;if(_0x8a134a>=_0x5f209f){_0x8a134a=_0x5f209f;_0x3fe6b8=0xc8;}else{_0x3fe6b8=0xce;}_0x2f94fa[_0xb185('0x18')](_0x3fe6b8);return _0x2f94fa[_0xb185('0x1f')]('Content-Range',_0x213ade+'-'+_0x8a134a+'/'+_0x5f209f)[_0xb185('0x1a')](_0x2e313f);}return null;};}function patchUpdates(_0x5e3030){return function(_0x169e32){try{jsonpatch[_0xb185('0x20')](_0x169e32,_0x5e3030,!![]);}catch(_0x306849){return BPromise[_0xb185('0x21')](_0x306849);}return _0x169e32[_0xb185('0x22')]();};}function saveUpdates(_0x22ced3,_0x5aa519){return function(_0x59cb2a){if(_0x59cb2a){return _0x59cb2a['update'](_0x22ced3)['then'](function(_0x4291eb){return _0x4291eb;});}return null;};}function removeEntity(_0x37f5ec,_0x19cc69){return function(_0x5d66fa){if(_0x5d66fa){return _0x5d66fa['destroy']()['then'](function(){var _0x171380=_0x5d66fa[_0xb185('0x23')]({'plain':!![]});var _0x272904=_0xb185('0x24');return db[_0xb185('0x25')]['destroy']({'where':{'type':_0x272904,'resourceId':_0x171380['id']}})['then'](function(){return _0x5d66fa;});})[_0xb185('0x26')](function(){_0x37f5ec['status'](0xcc)[_0xb185('0x19')]();});}};}function handleEntityNotFound(_0x1cb898,_0x540d94){return function(_0x47e32f){if(!_0x47e32f){_0x1cb898[_0xb185('0x17')](0x194);}return _0x47e32f;};}function handleError(_0x505c27,_0x2ae33c){_0x2ae33c=_0x2ae33c||0x1f4;return function(_0xabc737){logger[_0xb185('0x27')](_0xabc737[_0xb185('0x28')]);if(_0xabc737[_0xb185('0x29')]){delete _0xabc737['name'];}_0x505c27[_0xb185('0x18')](_0x2ae33c)['send'](_0xabc737);};}exports['index']=function(_0xf4c46d,_0x34f319){var _0x23fb07={},_0x26e907={},_0x496ed6={'count':0x0,'rows':[]};var _0x2148ab=_['map'](db[_0xb185('0x2a')][_0xb185('0x2b')],function(_0x3250c4){return{'name':_0x3250c4[_0xb185('0x2c')],'type':_0x3250c4[_0xb185('0x2d')][_0xb185('0x2e')]};});_0x26e907[_0xb185('0x2f')]=_[_0xb185('0x30')](_0x2148ab,_0xb185('0x29'));_0x26e907['query']=_[_0xb185('0x31')](_0xf4c46d[_0xb185('0x32')]);_0x26e907[_0xb185('0x33')]=_[_0xb185('0x34')](_0x26e907[_0xb185('0x2f')],_0x26e907['query']);_0x23fb07['attributes']=_['intersection'](_0x26e907[_0xb185('0x2f')],qs['fields'](_0xf4c46d[_0xb185('0x32')][_0xb185('0x35')]));_0x23fb07[_0xb185('0x36')]=_0x23fb07['attributes'][_0xb185('0x37')]?_0x23fb07['attributes']:_0x26e907['model'];if(!_0xf4c46d[_0xb185('0x32')][_0xb185('0x38')](_0xb185('0x39'))){_0x23fb07[_0xb185('0x1d')]=qs[_0xb185('0x1d')](_0xf4c46d[_0xb185('0x32')][_0xb185('0x1d')]);_0x23fb07[_0xb185('0x1b')]=qs[_0xb185('0x1b')](_0xf4c46d['query'][_0xb185('0x1b')]);}_0x23fb07[_0xb185('0x3a')]=qs['sort'](_0xf4c46d['query'][_0xb185('0x3b')]);_0x23fb07[_0xb185('0x3c')]=qs[_0xb185('0x33')](_[_0xb185('0x3d')](_0xf4c46d[_0xb185('0x32')],_0x26e907[_0xb185('0x33')]),_0x2148ab);if(_0xf4c46d[_0xb185('0x32')][_0xb185('0x3e')]){_0x23fb07[_0xb185('0x3c')]=_[_0xb185('0x3f')](_0x23fb07[_0xb185('0x3c')],{'$or':_['map'](_0x2148ab,function(_0x4a1e59){if(_0x4a1e59['type']!==_0xb185('0x40')){var _0x137cb3={};_0x137cb3[_0x4a1e59[_0xb185('0x29')]]={'$like':'%'+_0xf4c46d['query'][_0xb185('0x3e')]+'%'};return _0x137cb3;}})});}_0x23fb07=_['merge']({},_0x23fb07,_0xf4c46d[_0xb185('0x41')]);var _0x11afc4={'where':_0x23fb07[_0xb185('0x3c')]};return db[_0xb185('0x2a')][_0xb185('0x1e')](_0x11afc4)[_0xb185('0x26')](function(_0x55f858){_0x496ed6[_0xb185('0x1e')]=_0x55f858;if(_0xf4c46d[_0xb185('0x32')][_0xb185('0x42')]){_0x23fb07[_0xb185('0x43')]=[{'all':!![]}];}return db[_0xb185('0x2a')][_0xb185('0x44')](_0x23fb07);})[_0xb185('0x26')](function(_0x4c490e){_0x496ed6[_0xb185('0x45')]=_0x4c490e;return _0x496ed6;})[_0xb185('0x26')](respondWithFilteredResult(_0x34f319,_0x23fb07))['catch'](handleError(_0x34f319,null));};exports['show']=function(_0xfe18b2,_0x182a1d){var _0x5447ef={'raw':![],'where':{'id':_0xfe18b2[_0xb185('0x46')]['id']}},_0x42a1eb={};_0x42a1eb[_0xb185('0x2f')]=_[_0xb185('0x31')](db['Trigger']['rawAttributes']);_0x42a1eb[_0xb185('0x32')]=_[_0xb185('0x31')](_0xfe18b2[_0xb185('0x32')]);_0x42a1eb[_0xb185('0x33')]=_[_0xb185('0x34')](_0x42a1eb[_0xb185('0x2f')],_0x42a1eb[_0xb185('0x32')]);_0x5447ef['attributes']=_[_0xb185('0x34')](_0x42a1eb['model'],qs[_0xb185('0x35')](_0xfe18b2['query']['fields']));_0x5447ef[_0xb185('0x36')]=_0x5447ef['attributes']['length']?_0x5447ef[_0xb185('0x36')]:_0x42a1eb[_0xb185('0x2f')];if(_0xfe18b2['query']['includeAll']){_0x5447ef[_0xb185('0x43')]=[{'all':!![]}];}_0x5447ef=_[_0xb185('0x3f')]({},_0x5447ef,_0xfe18b2[_0xb185('0x41')]);return db[_0xb185('0x2a')]['find'](_0x5447ef)['then'](handleEntityNotFound(_0x182a1d,null))[_0xb185('0x26')](respondWithResult(_0x182a1d,null))[_0xb185('0x47')](handleError(_0x182a1d,null));};exports[_0xb185('0x48')]=function(_0x57a272,_0x3a1368){return db[_0xb185('0x2a')][_0xb185('0x48')](_0x57a272[_0xb185('0x49')],{})[_0xb185('0x26')](function(_0x4a306a){var _0x443f1a=_0x57a272[_0xb185('0x4a')]['get']({'plain':!![]});if(!_0x443f1a)throw new Error(_0xb185('0x4b'));if(_0x443f1a['role']===_0xb185('0x4a')){var _0x3f73a3=_0x4a306a[_0xb185('0x23')]({'plain':!![]});var _0x53c691='Triggers';return db[_0xb185('0x4c')][_0xb185('0x4d')]({'where':{'name':_0x53c691,'userProfileId':_0x443f1a['userProfileId']},'raw':!![]})[_0xb185('0x26')](function(_0x4bb4f4){if(_0x4bb4f4&&_0x4bb4f4[_0xb185('0x4e')]===0x0){return db[_0xb185('0x25')][_0xb185('0x48')]({'name':_0x3f73a3[_0xb185('0x29')],'resourceId':_0x3f73a3['id'],'type':_0x4bb4f4[_0xb185('0x29')],'sectionId':_0x4bb4f4['id']},{})[_0xb185('0x26')](function(){return _0x4a306a;});}else{return _0x4a306a;}})[_0xb185('0x47')](function(_0x23ff19){logger['error']('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x23ff19);throw _0x23ff19;});}return _0x4a306a;})[_0xb185('0x26')](respondWithResult(_0x3a1368,0xc9))[_0xb185('0x47')](handleError(_0x3a1368,null));};exports[_0xb185('0x4f')]=function(_0x2289a2,_0x45b439){if(_0x2289a2[_0xb185('0x49')]['id']){delete _0x2289a2[_0xb185('0x49')]['id'];}return db[_0xb185('0x2a')]['find']({'where':{'id':_0x2289a2[_0xb185('0x46')]['id']}})[_0xb185('0x26')](handleEntityNotFound(_0x45b439,null))['then'](saveUpdates(_0x2289a2['body'],null))[_0xb185('0x26')](respondWithResult(_0x45b439,null))['catch'](handleError(_0x45b439,null));};exports[_0xb185('0x50')]=function(_0x13a43c,_0x2c49e4){return db[_0xb185('0x2a')]['find']({'where':{'id':_0x13a43c['params']['id']}})[_0xb185('0x26')](handleEntityNotFound(_0x2c49e4,null))['then'](removeEntity(_0x2c49e4,null))['catch'](handleError(_0x2c49e4,null));};exports[_0xb185('0x51')]=function(_0x29002a,_0x621f33,_0x98a8c9){if(_0x29002a[_0xb185('0x49')]['id']){delete _0x29002a[_0xb185('0x49')]['id'];}return db[_0xb185('0x2a')][_0xb185('0x4d')]({'where':{'id':_0x29002a[_0xb185('0x46')]['id']}})[_0xb185('0x26')](handleEntityNotFound(_0x621f33,null))[_0xb185('0x26')](function(_0x59c633){if(_0x59c633){_0x29002a[_0xb185('0x49')][_0xb185('0x52')]=_0x59c633['id'];return db[_0xb185('0x53')][_0xb185('0x48')](_0x29002a[_0xb185('0x49')]);}})['then'](respondWithResult(_0x621f33,null))[_0xb185('0x47')](handleError(_0x621f33,null));};exports[_0xb185('0x54')]=function(_0x372730,_0xb834f3,_0x418252){if(_0x372730[_0xb185('0x49')]['id']){delete _0x372730[_0xb185('0x49')]['id'];}return db['Trigger'][_0xb185('0x4d')]({'where':{'id':_0x372730[_0xb185('0x46')]['id']}})[_0xb185('0x26')](handleEntityNotFound(_0xb834f3,null))['then'](function(_0x4cdab8){if(_0x4cdab8){_0x372730[_0xb185('0x49')][_0xb185('0x55')]=_0x4cdab8['id'];return db['Condition'][_0xb185('0x48')](_0x372730[_0xb185('0x49')]);}})[_0xb185('0x26')](respondWithResult(_0xb834f3,null))[_0xb185('0x47')](handleError(_0xb834f3,null));};exports[_0xb185('0x56')]=function(_0x176094,_0x452ba0,_0x252f62){var _0x53974e={};var _0xc8b9e2={};var _0x1b183b;var _0x146c6f;return db[_0xb185('0x2a')][_0xb185('0x57')]({'where':{'id':_0x176094[_0xb185('0x46')]['id']}})['then'](handleEntityNotFound(_0x452ba0,null))[_0xb185('0x26')](function(_0x349442){if(_0x349442){_0x1b183b=_0x349442;_0xc8b9e2[_0xb185('0x2f')]=_[_0xb185('0x31')](db[_0xb185('0x53')][_0xb185('0x2b')]);_0xc8b9e2['query']=_[_0xb185('0x31')](_0x176094[_0xb185('0x32')]);_0xc8b9e2[_0xb185('0x33')]=_[_0xb185('0x34')](_0xc8b9e2['model'],_0xc8b9e2[_0xb185('0x32')]);_0x53974e[_0xb185('0x36')]=_[_0xb185('0x34')](_0xc8b9e2[_0xb185('0x2f')],qs[_0xb185('0x35')](_0x176094[_0xb185('0x32')]['fields']));_0x53974e[_0xb185('0x36')]=_0x53974e[_0xb185('0x36')][_0xb185('0x37')]?_0x53974e[_0xb185('0x36')]:_0xc8b9e2[_0xb185('0x2f')];_0x53974e[_0xb185('0x3a')]=qs['sort'](_0x176094[_0xb185('0x32')]['sort']);_0x53974e[_0xb185('0x3c')]=qs[_0xb185('0x33')](_[_0xb185('0x3d')](_0x176094[_0xb185('0x32')],_0xc8b9e2[_0xb185('0x33')]));if(_0x176094[_0xb185('0x32')][_0xb185('0x3e')]){_0x53974e['where']=_['merge'](_0x53974e[_0xb185('0x3c')],{'$or':_[_0xb185('0x30')](_0x53974e[_0xb185('0x36')],function(_0x3ef1ea){var _0x4fad44={};_0x4fad44[_0x3ef1ea]={'$like':'%'+_0x176094[_0xb185('0x32')][_0xb185('0x3e')]+'%'};return _0x4fad44;})});}_0x53974e=_[_0xb185('0x3f')]({},_0x53974e,_0x176094[_0xb185('0x41')]);return _0x1b183b[_0xb185('0x56')](_0x53974e);}})[_0xb185('0x26')](function(_0x44db4d){if(_0x44db4d){_0x146c6f=_0x44db4d[_0xb185('0x37')];if(!_0x176094['query'][_0xb185('0x38')](_0xb185('0x39'))){_0x53974e[_0xb185('0x1d')]=qs['limit'](_0x176094[_0xb185('0x32')][_0xb185('0x1d')]);_0x53974e[_0xb185('0x1b')]=qs[_0xb185('0x1b')](_0x176094['query'][_0xb185('0x1b')]);}return _0x1b183b[_0xb185('0x56')](_0x53974e);}})[_0xb185('0x26')](function(_0x214db7){if(_0x214db7){return _0x214db7?{'count':_0x146c6f,'rows':_0x214db7}:null;}})['then'](respondWithResult(_0x452ba0,null))[_0xb185('0x47')](handleError(_0x452ba0,null));};exports[_0xb185('0x58')]=function(_0x1cc57b,_0x4d512a,_0x2ae50a){var _0x45427d={};var _0x1c1766={};var _0x1be0d7;var _0x6dd20d;return db['Trigger'][_0xb185('0x57')]({'where':{'id':_0x1cc57b[_0xb185('0x46')]['id']}})[_0xb185('0x26')](handleEntityNotFound(_0x4d512a,null))[_0xb185('0x26')](function(_0x3f2ba0){if(_0x3f2ba0){_0x1be0d7=_0x3f2ba0;_0x1c1766['model']=_[_0xb185('0x31')](db[_0xb185('0x53')][_0xb185('0x2b')]);_0x1c1766[_0xb185('0x32')]=_[_0xb185('0x31')](_0x1cc57b[_0xb185('0x32')]);_0x1c1766[_0xb185('0x33')]=_[_0xb185('0x34')](_0x1c1766[_0xb185('0x2f')],_0x1c1766[_0xb185('0x32')]);_0x45427d[_0xb185('0x36')]=_[_0xb185('0x34')](_0x1c1766['model'],qs[_0xb185('0x35')](_0x1cc57b[_0xb185('0x32')][_0xb185('0x35')]));_0x45427d[_0xb185('0x36')]=_0x45427d[_0xb185('0x36')]['length']?_0x45427d['attributes']:_0x1c1766[_0xb185('0x2f')];_0x45427d[_0xb185('0x3a')]=qs[_0xb185('0x3b')](_0x1cc57b[_0xb185('0x32')][_0xb185('0x3b')]);_0x45427d[_0xb185('0x3c')]=qs[_0xb185('0x33')](_[_0xb185('0x3d')](_0x1cc57b[_0xb185('0x32')],_0x1c1766[_0xb185('0x33')]));if(_0x1cc57b[_0xb185('0x32')]['filter']){_0x45427d[_0xb185('0x3c')]=_[_0xb185('0x3f')](_0x45427d['where'],{'$or':_['map'](_0x45427d[_0xb185('0x36')],function(_0x37e704){var _0xa3bb86={};_0xa3bb86[_0x37e704]={'$like':'%'+_0x1cc57b['query']['filter']+'%'};return _0xa3bb86;})});}_0x45427d=_['merge']({},_0x45427d,_0x1cc57b[_0xb185('0x41')]);return _0x1be0d7['getAnyConditions'](_0x45427d);}})[_0xb185('0x26')](function(_0x3c27b7){if(_0x3c27b7){_0x6dd20d=_0x3c27b7['length'];if(!_0x1cc57b[_0xb185('0x32')]['hasOwnProperty'](_0xb185('0x39'))){_0x45427d[_0xb185('0x1d')]=qs[_0xb185('0x1d')](_0x1cc57b[_0xb185('0x32')][_0xb185('0x1d')]);_0x45427d[_0xb185('0x1b')]=qs[_0xb185('0x1b')](_0x1cc57b[_0xb185('0x32')][_0xb185('0x1b')]);}return _0x1be0d7[_0xb185('0x58')](_0x45427d);}})[_0xb185('0x26')](function(_0x1d865e){if(_0x1d865e){return _0x1d865e?{'count':_0x6dd20d,'rows':_0x1d865e}:null;}})[_0xb185('0x26')](respondWithResult(_0x4d512a,null))[_0xb185('0x47')](handleError(_0x4d512a,null));};exports['addAction']=function(_0x2fac14,_0x3467bc,_0x462229){if(_0x2fac14[_0xb185('0x49')]['id']){delete _0x2fac14[_0xb185('0x49')]['id'];}return db[_0xb185('0x2a')][_0xb185('0x4d')]({'where':{'id':_0x2fac14[_0xb185('0x46')]['id']}})['then'](handleEntityNotFound(_0x3467bc,null))[_0xb185('0x26')](function(_0x4e4ce8){if(_0x4e4ce8){_0x2fac14[_0xb185('0x49')]['TriggerId']=_0x4e4ce8['id'];return db[_0xb185('0x59')][_0xb185('0x48')](_0x2fac14[_0xb185('0x49')]);}})[_0xb185('0x26')](respondWithResult(_0x3467bc,null))[_0xb185('0x47')](handleError(_0x3467bc,null));};exports['getActions']=function(_0x55e2cb,_0x291bf0,_0xdfab61){var _0x2ea3aa={};var _0xe4dcb={};var _0x5edfe5;var _0x3fbca0;return db[_0xb185('0x2a')]['findOne']({'where':{'id':_0x55e2cb['params']['id']}})['then'](handleEntityNotFound(_0x291bf0,null))['then'](function(_0x5eecbe){if(_0x5eecbe){_0x5edfe5=_0x5eecbe;_0xe4dcb[_0xb185('0x2f')]=_[_0xb185('0x31')](db[_0xb185('0x59')][_0xb185('0x2b')]);_0xe4dcb[_0xb185('0x32')]=_['keys'](_0x55e2cb['query']);_0xe4dcb[_0xb185('0x33')]=_[_0xb185('0x34')](_0xe4dcb[_0xb185('0x2f')],_0xe4dcb['query']);_0x2ea3aa[_0xb185('0x36')]=_[_0xb185('0x34')](_0xe4dcb[_0xb185('0x2f')],qs[_0xb185('0x35')](_0x55e2cb[_0xb185('0x32')][_0xb185('0x35')]));_0x2ea3aa[_0xb185('0x36')]=_0x2ea3aa[_0xb185('0x36')]['length']?_0x2ea3aa[_0xb185('0x36')]:_0xe4dcb[_0xb185('0x2f')];_0x2ea3aa['order']=qs[_0xb185('0x3b')](_0x55e2cb[_0xb185('0x32')]['sort']);_0x2ea3aa[_0xb185('0x3c')]=qs[_0xb185('0x33')](_[_0xb185('0x3d')](_0x55e2cb['query'],_0xe4dcb[_0xb185('0x33')]));if(_0x55e2cb[_0xb185('0x32')]['filter']){_0x2ea3aa['where']=_['merge'](_0x2ea3aa[_0xb185('0x3c')],{'$or':_[_0xb185('0x30')](_0x2ea3aa[_0xb185('0x36')],function(_0x58cbac){var _0x24f343={};_0x24f343[_0x58cbac]={'$like':'%'+_0x55e2cb[_0xb185('0x32')]['filter']+'%'};return _0x24f343;})});}_0x2ea3aa=_[_0xb185('0x3f')]({},_0x2ea3aa,_0x55e2cb[_0xb185('0x41')]);return _0x5edfe5['getActions'](_0x2ea3aa);}})[_0xb185('0x26')](function(_0x5906dc){if(_0x5906dc){_0x3fbca0=_0x5906dc[_0xb185('0x37')];if(!_0x55e2cb['query'][_0xb185('0x38')](_0xb185('0x39'))){_0x2ea3aa[_0xb185('0x1d')]=qs['limit'](_0x55e2cb[_0xb185('0x32')][_0xb185('0x1d')]);_0x2ea3aa['offset']=qs[_0xb185('0x1b')](_0x55e2cb[_0xb185('0x32')][_0xb185('0x1b')]);}return _0x5edfe5[_0xb185('0x5a')](_0x2ea3aa);}})[_0xb185('0x26')](function(_0x5f5ab5){if(_0x5f5ab5){return _0x5f5ab5?{'count':_0x3fbca0,'rows':_0x5f5ab5}:null;}})[_0xb185('0x26')](respondWithResult(_0x291bf0,null))[_0xb185('0x47')](handleError(_0x291bf0,null));};