de5b764888ccbb0ea67cea6fac416cd13ad20f09
[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 _0x60b1=['index','map','rawAttributes','type','key','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','where','filter','merge','options','Trigger','includeAll','include','findAll','catch','show','params','find','create','body','user','role','Triggers','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addAllCondition','TriggerAllId','addAnyCondition','Condition','getAllConditions','findOne','sort','pick','getAnyConditions','addAction','TriggerId','getActions','Action','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird','mustache','sox','ejs','lodash','crypto','jsforce','desk.js','to-csv','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','count','offset','limit','set','Content-Range','json','apply','reject','update','then','destroy','get','UserProfileResource','error','stack','name','send'];(function(_0x73a549,_0x2afdbb){var _0x2a35ce=function(_0x50a62e){while(--_0x50a62e){_0x73a549['push'](_0x73a549['shift']());}};_0x2a35ce(++_0x2afdbb);}(_0x60b1,0x19e));var _0x160b=function(_0x3b380d,_0x4bf247){_0x3b380d=_0x3b380d-0x0;var _0x54502b=_0x60b1[_0x3b380d];return _0x54502b;};'use strict';var pdf=require(_0x160b('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x160b('0x1'));var zipdir=require(_0x160b('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x160b('0x3'));var moment=require(_0x160b('0x4'));var BPromise=require(_0x160b('0x5'));var Mustache=require(_0x160b('0x6'));var util=require('util');var path=require('path');var sox=require(_0x160b('0x7'));var csv=require('to-csv');var ejs=require(_0x160b('0x8'));var fs=require('fs');var _=require(_0x160b('0x9'));var squel=require('squel');var crypto=require(_0x160b('0xa'));var jsforce=require(_0x160b('0xb'));var deskjs=require(_0x160b('0xc'));var toCsv=require(_0x160b('0xd'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x160b('0xe'));var authService=require('../../components/auth/service');var qs=require(_0x160b('0xf'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x160b('0x10'));var logger=require(_0x160b('0x11'))(_0x160b('0x12'));var utils=require(_0x160b('0x13'));var config=require(_0x160b('0x14'));var db=require(_0x160b('0x15'))['db'];function respondWithStatusCode(_0x3ece6d,_0x22de03){_0x22de03=_0x22de03||0xcc;return function(_0x35650d){if(_0x35650d){return _0x3ece6d[_0x160b('0x16')](_0x22de03);}return _0x3ece6d['status'](_0x22de03)['end']();};}function respondWithResult(_0xead99d,_0xd5e901){_0xd5e901=_0xd5e901||0xc8;return function(_0x187666){if(_0x187666){return _0xead99d[_0x160b('0x17')](_0xd5e901)['json'](_0x187666);}};}function respondWithFilteredResult(_0x4128ca,_0x30b482){return function(_0x55877e){if(_0x55877e){var _0xce2f0f=_0x55877e[_0x160b('0x18')],_0x158a83=_0x30b482[_0x160b('0x19')],_0x2dc957=_0x30b482[_0x160b('0x19')]+_0x30b482[_0x160b('0x1a')],_0x23567c;if(_0x2dc957>=_0xce2f0f){_0x2dc957=_0xce2f0f;_0x23567c=0xc8;}else{_0x23567c=0xce;}_0x4128ca['status'](_0x23567c);return _0x4128ca[_0x160b('0x1b')](_0x160b('0x1c'),_0x158a83+'-'+_0x2dc957+'/'+_0xce2f0f)[_0x160b('0x1d')](_0x55877e);}return null;};}function patchUpdates(_0x3d3a19){return function(_0x3007cc){try{jsonpatch[_0x160b('0x1e')](_0x3007cc,_0x3d3a19,!![]);}catch(_0x4852af){return BPromise[_0x160b('0x1f')](_0x4852af);}return _0x3007cc['save']();};}function saveUpdates(_0x478796,_0x3c2faa){return function(_0x311507){if(_0x311507){return _0x311507[_0x160b('0x20')](_0x478796)[_0x160b('0x21')](function(_0x42efc3){return _0x42efc3;});}return null;};}function removeEntity(_0x2a9e6a,_0x595b6e){return function(_0x4a18a7){if(_0x4a18a7){return _0x4a18a7[_0x160b('0x22')]()['then'](function(){var _0x12b81a=_0x4a18a7[_0x160b('0x23')]({'plain':!![]});var _0x5ec89b='Triggers';return db[_0x160b('0x24')][_0x160b('0x22')]({'where':{'type':_0x5ec89b,'resourceId':_0x12b81a['id']}})['then'](function(){return _0x4a18a7;});})['then'](function(){_0x2a9e6a[_0x160b('0x17')](0xcc)['end']();});}};}function handleEntityNotFound(_0x716896,_0x5c4b09){return function(_0x51f8f0){if(!_0x51f8f0){_0x716896[_0x160b('0x16')](0x194);}return _0x51f8f0;};}function handleError(_0xbedae0,_0x4a6330){_0x4a6330=_0x4a6330||0x1f4;return function(_0x2e2302){logger[_0x160b('0x25')](_0x2e2302[_0x160b('0x26')]);if(_0x2e2302[_0x160b('0x27')]){delete _0x2e2302[_0x160b('0x27')];}_0xbedae0[_0x160b('0x17')](_0x4a6330)[_0x160b('0x28')](_0x2e2302);};}exports[_0x160b('0x29')]=function(_0x424dad,_0x5dca3e){var _0x300d0c={},_0x9ddd21={},_0x32dc46={'count':0x0,'rows':[]};var _0x50e431=_[_0x160b('0x2a')](db['Trigger'][_0x160b('0x2b')],function(_0x11eb55){return{'name':_0x11eb55['fieldName'],'type':_0x11eb55[_0x160b('0x2c')][_0x160b('0x2d')]};});_0x9ddd21[_0x160b('0x2e')]=_[_0x160b('0x2a')](_0x50e431,_0x160b('0x27'));_0x9ddd21['query']=_[_0x160b('0x2f')](_0x424dad[_0x160b('0x30')]);_0x9ddd21[_0x160b('0x31')]=_[_0x160b('0x32')](_0x9ddd21[_0x160b('0x2e')],_0x9ddd21['query']);_0x300d0c[_0x160b('0x33')]=_[_0x160b('0x32')](_0x9ddd21[_0x160b('0x2e')],qs[_0x160b('0x34')](_0x424dad[_0x160b('0x30')][_0x160b('0x34')]));_0x300d0c[_0x160b('0x33')]=_0x300d0c['attributes'][_0x160b('0x35')]?_0x300d0c[_0x160b('0x33')]:_0x9ddd21['model'];if(!_0x424dad[_0x160b('0x30')][_0x160b('0x36')](_0x160b('0x37'))){_0x300d0c[_0x160b('0x1a')]=qs['limit'](_0x424dad[_0x160b('0x30')][_0x160b('0x1a')]);_0x300d0c[_0x160b('0x19')]=qs[_0x160b('0x19')](_0x424dad[_0x160b('0x30')][_0x160b('0x19')]);}_0x300d0c[_0x160b('0x38')]=qs['sort'](_0x424dad[_0x160b('0x30')]['sort']);_0x300d0c[_0x160b('0x39')]=qs['filters'](_['pick'](_0x424dad[_0x160b('0x30')],_0x9ddd21[_0x160b('0x31')]),_0x50e431);if(_0x424dad['query'][_0x160b('0x3a')]){_0x300d0c[_0x160b('0x39')]=_[_0x160b('0x3b')](_0x300d0c['where'],{'$or':_[_0x160b('0x2a')](_0x50e431,function(_0x1516c5){if(_0x1516c5['type']!=='VIRTUAL'){var _0x9034e4={};_0x9034e4[_0x1516c5[_0x160b('0x27')]]={'$like':'%'+_0x424dad[_0x160b('0x30')][_0x160b('0x3a')]+'%'};return _0x9034e4;}})});}_0x300d0c=_[_0x160b('0x3b')]({},_0x300d0c,_0x424dad[_0x160b('0x3c')]);var _0x42a06b={'where':_0x300d0c[_0x160b('0x39')]};return db[_0x160b('0x3d')][_0x160b('0x18')](_0x42a06b)[_0x160b('0x21')](function(_0x3233a8){_0x32dc46[_0x160b('0x18')]=_0x3233a8;if(_0x424dad[_0x160b('0x30')][_0x160b('0x3e')]){_0x300d0c[_0x160b('0x3f')]=[{'all':!![]}];}return db[_0x160b('0x3d')][_0x160b('0x40')](_0x300d0c);})[_0x160b('0x21')](function(_0xe14a1b){_0x32dc46['rows']=_0xe14a1b;return _0x32dc46;})[_0x160b('0x21')](respondWithFilteredResult(_0x5dca3e,_0x300d0c))[_0x160b('0x41')](handleError(_0x5dca3e,null));};exports[_0x160b('0x42')]=function(_0x45085f,_0x3f6f66){var _0x377bc7={'raw':![],'where':{'id':_0x45085f[_0x160b('0x43')]['id']}},_0x1f6e1a={};_0x1f6e1a[_0x160b('0x2e')]=_[_0x160b('0x2f')](db[_0x160b('0x3d')]['rawAttributes']);_0x1f6e1a['query']=_['keys'](_0x45085f['query']);_0x1f6e1a[_0x160b('0x31')]=_['intersection'](_0x1f6e1a[_0x160b('0x2e')],_0x1f6e1a[_0x160b('0x30')]);_0x377bc7[_0x160b('0x33')]=_[_0x160b('0x32')](_0x1f6e1a[_0x160b('0x2e')],qs[_0x160b('0x34')](_0x45085f[_0x160b('0x30')][_0x160b('0x34')]));_0x377bc7['attributes']=_0x377bc7[_0x160b('0x33')][_0x160b('0x35')]?_0x377bc7[_0x160b('0x33')]:_0x1f6e1a[_0x160b('0x2e')];if(_0x45085f[_0x160b('0x30')]['includeAll']){_0x377bc7[_0x160b('0x3f')]=[{'all':!![]}];}_0x377bc7=_['merge']({},_0x377bc7,_0x45085f[_0x160b('0x3c')]);return db['Trigger'][_0x160b('0x44')](_0x377bc7)['then'](handleEntityNotFound(_0x3f6f66,null))[_0x160b('0x21')](respondWithResult(_0x3f6f66,null))[_0x160b('0x41')](handleError(_0x3f6f66,null));};exports[_0x160b('0x45')]=function(_0x1a0a5d,_0x1f6222){return db['Trigger'][_0x160b('0x45')](_0x1a0a5d[_0x160b('0x46')],{})[_0x160b('0x21')](function(_0xb14b11){var _0xf8d759=_0x1a0a5d[_0x160b('0x47')][_0x160b('0x23')]({'plain':!![]});if(!_0xf8d759)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0xf8d759[_0x160b('0x48')]===_0x160b('0x47')){var _0x5f2200=_0xb14b11['get']({'plain':!![]});var _0x2e8d1e=_0x160b('0x49');return db[_0x160b('0x4a')]['find']({'where':{'name':_0x2e8d1e,'userProfileId':_0xf8d759[_0x160b('0x4b')]},'raw':!![]})[_0x160b('0x21')](function(_0x19d217){if(_0x19d217&&_0x19d217[_0x160b('0x4c')]===0x0){return db[_0x160b('0x24')][_0x160b('0x45')]({'name':_0x5f2200[_0x160b('0x27')],'resourceId':_0x5f2200['id'],'type':_0x19d217[_0x160b('0x27')],'sectionId':_0x19d217['id']},{})[_0x160b('0x21')](function(){return _0xb14b11;});}else{return _0xb14b11;}})['catch'](function(_0x1208d4){logger[_0x160b('0x25')](_0x160b('0x4d'),_0x1208d4);throw _0x1208d4;});}return _0xb14b11;})[_0x160b('0x21')](respondWithResult(_0x1f6222,0xc9))[_0x160b('0x41')](handleError(_0x1f6222,null));};exports[_0x160b('0x20')]=function(_0x564d5a,_0x44c367){if(_0x564d5a[_0x160b('0x46')]['id']){delete _0x564d5a[_0x160b('0x46')]['id'];}return db['Trigger'][_0x160b('0x44')]({'where':{'id':_0x564d5a['params']['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x44c367,null))[_0x160b('0x21')](saveUpdates(_0x564d5a[_0x160b('0x46')],null))[_0x160b('0x21')](respondWithResult(_0x44c367,null))[_0x160b('0x41')](handleError(_0x44c367,null));};exports[_0x160b('0x22')]=function(_0x1f70d7,_0x3a74ec){return db[_0x160b('0x3d')]['find']({'where':{'id':_0x1f70d7[_0x160b('0x43')]['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x3a74ec,null))['then'](removeEntity(_0x3a74ec,null))[_0x160b('0x41')](handleError(_0x3a74ec,null));};exports[_0x160b('0x4e')]=function(_0x15d845,_0x2d1c7c,_0xb97af0){if(_0x15d845['body']['id']){delete _0x15d845[_0x160b('0x46')]['id'];}return db[_0x160b('0x3d')][_0x160b('0x44')]({'where':{'id':_0x15d845['params']['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x2d1c7c,null))[_0x160b('0x21')](function(_0x3f1d54){if(_0x3f1d54){_0x15d845[_0x160b('0x46')][_0x160b('0x4f')]=_0x3f1d54['id'];return db['Condition'][_0x160b('0x45')](_0x15d845[_0x160b('0x46')]);}})[_0x160b('0x21')](respondWithResult(_0x2d1c7c,null))[_0x160b('0x41')](handleError(_0x2d1c7c,null));};exports[_0x160b('0x50')]=function(_0x230576,_0x3d21b0,_0x3ddf00){if(_0x230576[_0x160b('0x46')]['id']){delete _0x230576[_0x160b('0x46')]['id'];}return db[_0x160b('0x3d')][_0x160b('0x44')]({'where':{'id':_0x230576[_0x160b('0x43')]['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x3d21b0,null))[_0x160b('0x21')](function(_0x3e6c28){if(_0x3e6c28){_0x230576[_0x160b('0x46')]['TriggerAnyId']=_0x3e6c28['id'];return db[_0x160b('0x51')]['create'](_0x230576[_0x160b('0x46')]);}})[_0x160b('0x21')](respondWithResult(_0x3d21b0,null))[_0x160b('0x41')](handleError(_0x3d21b0,null));};exports[_0x160b('0x52')]=function(_0x470fbf,_0x50efef,_0x46c0b5){var _0x9800a1={};var _0x27d971={};var _0x34dce2;var _0x3c5ee6;return db[_0x160b('0x3d')][_0x160b('0x53')]({'where':{'id':_0x470fbf['params']['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x50efef,null))['then'](function(_0xc82e8e){if(_0xc82e8e){_0x34dce2=_0xc82e8e;_0x27d971['model']=_[_0x160b('0x2f')](db[_0x160b('0x51')][_0x160b('0x2b')]);_0x27d971[_0x160b('0x30')]=_[_0x160b('0x2f')](_0x470fbf[_0x160b('0x30')]);_0x27d971[_0x160b('0x31')]=_['intersection'](_0x27d971[_0x160b('0x2e')],_0x27d971[_0x160b('0x30')]);_0x9800a1[_0x160b('0x33')]=_[_0x160b('0x32')](_0x27d971[_0x160b('0x2e')],qs[_0x160b('0x34')](_0x470fbf[_0x160b('0x30')][_0x160b('0x34')]));_0x9800a1[_0x160b('0x33')]=_0x9800a1[_0x160b('0x33')]['length']?_0x9800a1[_0x160b('0x33')]:_0x27d971[_0x160b('0x2e')];_0x9800a1[_0x160b('0x38')]=qs[_0x160b('0x54')](_0x470fbf[_0x160b('0x30')][_0x160b('0x54')]);_0x9800a1[_0x160b('0x39')]=qs[_0x160b('0x31')](_[_0x160b('0x55')](_0x470fbf[_0x160b('0x30')],_0x27d971[_0x160b('0x31')]));if(_0x470fbf[_0x160b('0x30')][_0x160b('0x3a')]){_0x9800a1['where']=_['merge'](_0x9800a1[_0x160b('0x39')],{'$or':_[_0x160b('0x2a')](_0x9800a1[_0x160b('0x33')],function(_0x2656e3){var _0x1e7b5f={};_0x1e7b5f[_0x2656e3]={'$like':'%'+_0x470fbf[_0x160b('0x30')]['filter']+'%'};return _0x1e7b5f;})});}_0x9800a1=_[_0x160b('0x3b')]({},_0x9800a1,_0x470fbf[_0x160b('0x3c')]);return _0x34dce2[_0x160b('0x52')](_0x9800a1);}})[_0x160b('0x21')](function(_0x6cc803){if(_0x6cc803){_0x3c5ee6=_0x6cc803[_0x160b('0x35')];if(!_0x470fbf[_0x160b('0x30')][_0x160b('0x36')](_0x160b('0x37'))){_0x9800a1[_0x160b('0x1a')]=qs[_0x160b('0x1a')](_0x470fbf[_0x160b('0x30')]['limit']);_0x9800a1[_0x160b('0x19')]=qs[_0x160b('0x19')](_0x470fbf['query']['offset']);}return _0x34dce2['getAllConditions'](_0x9800a1);}})[_0x160b('0x21')](function(_0x1ed784){if(_0x1ed784){return _0x1ed784?{'count':_0x3c5ee6,'rows':_0x1ed784}:null;}})['then'](respondWithResult(_0x50efef,null))[_0x160b('0x41')](handleError(_0x50efef,null));};exports[_0x160b('0x56')]=function(_0x648272,_0x5b9c9d,_0x3812d4){var _0x2983a6={};var _0x1e24cf={};var _0x69fd1a;var _0x50e82f;return db['Trigger'][_0x160b('0x53')]({'where':{'id':_0x648272[_0x160b('0x43')]['id']}})['then'](handleEntityNotFound(_0x5b9c9d,null))['then'](function(_0x1f587c){if(_0x1f587c){_0x69fd1a=_0x1f587c;_0x1e24cf[_0x160b('0x2e')]=_[_0x160b('0x2f')](db[_0x160b('0x51')]['rawAttributes']);_0x1e24cf[_0x160b('0x30')]=_[_0x160b('0x2f')](_0x648272[_0x160b('0x30')]);_0x1e24cf['filters']=_[_0x160b('0x32')](_0x1e24cf[_0x160b('0x2e')],_0x1e24cf[_0x160b('0x30')]);_0x2983a6['attributes']=_[_0x160b('0x32')](_0x1e24cf[_0x160b('0x2e')],qs['fields'](_0x648272[_0x160b('0x30')][_0x160b('0x34')]));_0x2983a6[_0x160b('0x33')]=_0x2983a6['attributes'][_0x160b('0x35')]?_0x2983a6[_0x160b('0x33')]:_0x1e24cf['model'];_0x2983a6[_0x160b('0x38')]=qs['sort'](_0x648272[_0x160b('0x30')]['sort']);_0x2983a6['where']=qs[_0x160b('0x31')](_['pick'](_0x648272['query'],_0x1e24cf[_0x160b('0x31')]));if(_0x648272[_0x160b('0x30')]['filter']){_0x2983a6[_0x160b('0x39')]=_['merge'](_0x2983a6[_0x160b('0x39')],{'$or':_['map'](_0x2983a6['attributes'],function(_0xb9a20f){var _0x5db038={};_0x5db038[_0xb9a20f]={'$like':'%'+_0x648272[_0x160b('0x30')][_0x160b('0x3a')]+'%'};return _0x5db038;})});}_0x2983a6=_[_0x160b('0x3b')]({},_0x2983a6,_0x648272[_0x160b('0x3c')]);return _0x69fd1a[_0x160b('0x56')](_0x2983a6);}})['then'](function(_0xf5371){if(_0xf5371){_0x50e82f=_0xf5371['length'];if(!_0x648272[_0x160b('0x30')][_0x160b('0x36')]('nolimit')){_0x2983a6[_0x160b('0x1a')]=qs['limit'](_0x648272['query']['limit']);_0x2983a6[_0x160b('0x19')]=qs['offset'](_0x648272[_0x160b('0x30')][_0x160b('0x19')]);}return _0x69fd1a[_0x160b('0x56')](_0x2983a6);}})[_0x160b('0x21')](function(_0x129ffe){if(_0x129ffe){return _0x129ffe?{'count':_0x50e82f,'rows':_0x129ffe}:null;}})[_0x160b('0x21')](respondWithResult(_0x5b9c9d,null))['catch'](handleError(_0x5b9c9d,null));};exports[_0x160b('0x57')]=function(_0x52d32a,_0x234891,_0x375af0){if(_0x52d32a['body']['id']){delete _0x52d32a[_0x160b('0x46')]['id'];}return db[_0x160b('0x3d')][_0x160b('0x44')]({'where':{'id':_0x52d32a[_0x160b('0x43')]['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x234891,null))[_0x160b('0x21')](function(_0x9790b9){if(_0x9790b9){_0x52d32a[_0x160b('0x46')][_0x160b('0x58')]=_0x9790b9['id'];return db['Action'][_0x160b('0x45')](_0x52d32a['body']);}})['then'](respondWithResult(_0x234891,null))[_0x160b('0x41')](handleError(_0x234891,null));};exports[_0x160b('0x59')]=function(_0x17ca33,_0x5ab9e6,_0x3898a0){var _0x519fe6={};var _0x259631={};var _0x97e4a;var _0x4047b8;return db[_0x160b('0x3d')][_0x160b('0x53')]({'where':{'id':_0x17ca33[_0x160b('0x43')]['id']}})[_0x160b('0x21')](handleEntityNotFound(_0x5ab9e6,null))[_0x160b('0x21')](function(_0x190193){if(_0x190193){_0x97e4a=_0x190193;_0x259631[_0x160b('0x2e')]=_['keys'](db[_0x160b('0x5a')]['rawAttributes']);_0x259631[_0x160b('0x30')]=_[_0x160b('0x2f')](_0x17ca33[_0x160b('0x30')]);_0x259631[_0x160b('0x31')]=_[_0x160b('0x32')](_0x259631[_0x160b('0x2e')],_0x259631[_0x160b('0x30')]);_0x519fe6[_0x160b('0x33')]=_[_0x160b('0x32')](_0x259631[_0x160b('0x2e')],qs[_0x160b('0x34')](_0x17ca33[_0x160b('0x30')]['fields']));_0x519fe6[_0x160b('0x33')]=_0x519fe6['attributes'][_0x160b('0x35')]?_0x519fe6['attributes']:_0x259631['model'];_0x519fe6[_0x160b('0x38')]=qs[_0x160b('0x54')](_0x17ca33['query'][_0x160b('0x54')]);_0x519fe6[_0x160b('0x39')]=qs['filters'](_[_0x160b('0x55')](_0x17ca33[_0x160b('0x30')],_0x259631['filters']));if(_0x17ca33[_0x160b('0x30')][_0x160b('0x3a')]){_0x519fe6[_0x160b('0x39')]=_['merge'](_0x519fe6[_0x160b('0x39')],{'$or':_[_0x160b('0x2a')](_0x519fe6[_0x160b('0x33')],function(_0x45053c){var _0x2c7b58={};_0x2c7b58[_0x45053c]={'$like':'%'+_0x17ca33[_0x160b('0x30')][_0x160b('0x3a')]+'%'};return _0x2c7b58;})});}_0x519fe6=_[_0x160b('0x3b')]({},_0x519fe6,_0x17ca33[_0x160b('0x3c')]);return _0x97e4a[_0x160b('0x59')](_0x519fe6);}})['then'](function(_0x4a96ac){if(_0x4a96ac){_0x4047b8=_0x4a96ac['length'];if(!_0x17ca33['query'][_0x160b('0x36')](_0x160b('0x37'))){_0x519fe6[_0x160b('0x1a')]=qs[_0x160b('0x1a')](_0x17ca33['query']['limit']);_0x519fe6[_0x160b('0x19')]=qs['offset'](_0x17ca33[_0x160b('0x30')][_0x160b('0x19')]);}return _0x97e4a['getActions'](_0x519fe6);}})[_0x160b('0x21')](function(_0x38a7a9){if(_0x38a7a9){return _0x38a7a9?{'count':_0x4047b8,'rows':_0x38a7a9}:null;}})['then'](respondWithResult(_0x5ab9e6,null))[_0x160b('0x41')](handleError(_0x5ab9e6,null));};