bb2df8dddcf4aa0034ab193d5ff2ee9b4a8e6a89
[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 _0x5f11=['findAll','rows','catch','show','includeAll','options','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','TriggerAllId','Condition','addAnyCondition','TriggerAnyId','getAllConditions','findOne','filter','getAnyConditions','pick','TriggerId','Action','getActions','eml-format','rimraf','zip-dir','moment','bluebird','util','path','sox','to-csv','ejs','crypto','jsforce','desk.js','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../mysqldb','sendStatus','status','end','json','offset','limit','Content-Range','reject','update','then','destroy','get','Triggers','UserProfileResource','name','index','map','Trigger','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','merge','VIRTUAL','count'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0x5f11,0x74));var _0x15f1=function(_0x4ede7c,_0x1ab530){_0x4ede7c=_0x4ede7c-0x0;var _0x25f157=_0x5f11[_0x4ede7c];return _0x25f157;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x15f1('0x0'));var rimraf=require(_0x15f1('0x1'));var zipdir=require(_0x15f1('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0x15f1('0x3'));var BPromise=require(_0x15f1('0x4'));var Mustache=require('mustache');var util=require(_0x15f1('0x5'));var path=require(_0x15f1('0x6'));var sox=require(_0x15f1('0x7'));var csv=require(_0x15f1('0x8'));var ejs=require(_0x15f1('0x9'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0x15f1('0xa'));var jsforce=require(_0x15f1('0xb'));var deskjs=require(_0x15f1('0xc'));var toCsv=require(_0x15f1('0x8'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require(_0x15f1('0xd'));var authService=require(_0x15f1('0xe'));var qs=require(_0x15f1('0xf'));var as=require(_0x15f1('0x10'));var hardwareService=require(_0x15f1('0x11'));var logger=require('../../config/logger')('api');var utils=require('../../config/utils');var config=require('../../config/environment');var db=require(_0x15f1('0x12'))['db'];function respondWithStatusCode(_0x422fba,_0x44d6f1){_0x44d6f1=_0x44d6f1||0xcc;return function(_0x1c49dc){if(_0x1c49dc){return _0x422fba[_0x15f1('0x13')](_0x44d6f1);}return _0x422fba[_0x15f1('0x14')](_0x44d6f1)[_0x15f1('0x15')]();};}function respondWithResult(_0x5dda32,_0x488823){_0x488823=_0x488823||0xc8;return function(_0x3ebd8b){if(_0x3ebd8b){return _0x5dda32[_0x15f1('0x14')](_0x488823)[_0x15f1('0x16')](_0x3ebd8b);}};}function respondWithFilteredResult(_0x49ac00,_0x426cdc){return function(_0x519fb4){if(_0x519fb4){var _0x4c400c=_0x519fb4['count'],_0xa8f849=_0x426cdc[_0x15f1('0x17')],_0x4cf1e4=_0x426cdc[_0x15f1('0x17')]+_0x426cdc[_0x15f1('0x18')],_0x3272b6;if(_0x4cf1e4>=_0x4c400c){_0x4cf1e4=_0x4c400c;_0x3272b6=0xc8;}else{_0x3272b6=0xce;}_0x49ac00[_0x15f1('0x14')](_0x3272b6);return _0x49ac00['set'](_0x15f1('0x19'),_0xa8f849+'-'+_0x4cf1e4+'/'+_0x4c400c)['json'](_0x519fb4);}return null;};}function patchUpdates(_0x45ed8b){return function(_0x294473){try{jsonpatch['apply'](_0x294473,_0x45ed8b,!![]);}catch(_0x5d5dec){return BPromise[_0x15f1('0x1a')](_0x5d5dec);}return _0x294473['save']();};}function saveUpdates(_0x2f6d01,_0x4df5c7){return function(_0x198750){if(_0x198750){return _0x198750[_0x15f1('0x1b')](_0x2f6d01)[_0x15f1('0x1c')](function(_0x4542df){return _0x4542df;});}return null;};}function removeEntity(_0x1df31b,_0x3bbf70){return function(_0x34efcb){if(_0x34efcb){return _0x34efcb[_0x15f1('0x1d')]()[_0x15f1('0x1c')](function(){var _0x17642b=_0x34efcb[_0x15f1('0x1e')]({'plain':!![]});var _0x45effa=_0x15f1('0x1f');return db[_0x15f1('0x20')]['destroy']({'where':{'type':_0x45effa,'resourceId':_0x17642b['id']}})[_0x15f1('0x1c')](function(){return _0x34efcb;});})[_0x15f1('0x1c')](function(){_0x1df31b[_0x15f1('0x14')](0xcc)[_0x15f1('0x15')]();});}};}function handleEntityNotFound(_0x3a54ae,_0x442caa){return function(_0x54348e){if(!_0x54348e){_0x3a54ae[_0x15f1('0x13')](0x194);}return _0x54348e;};}function handleError(_0x56dced,_0x28a105){_0x28a105=_0x28a105||0x1f4;return function(_0x20a1ee){logger['error'](_0x20a1ee['stack']);if(_0x20a1ee['name']){delete _0x20a1ee[_0x15f1('0x21')];}_0x56dced[_0x15f1('0x14')](_0x28a105)['send'](_0x20a1ee);};}exports[_0x15f1('0x22')]=function(_0x55b12f,_0x5334a5){var _0x44236c={},_0x15c42b={},_0x43a1da={'count':0x0,'rows':[]};var _0x211b87=_[_0x15f1('0x23')](db[_0x15f1('0x24')][_0x15f1('0x25')],function(_0x46e4d4){return{'name':_0x46e4d4[_0x15f1('0x26')],'type':_0x46e4d4['type'][_0x15f1('0x27')]};});_0x15c42b[_0x15f1('0x28')]=_['map'](_0x211b87,_0x15f1('0x21'));_0x15c42b[_0x15f1('0x29')]=_[_0x15f1('0x2a')](_0x55b12f[_0x15f1('0x29')]);_0x15c42b[_0x15f1('0x2b')]=_[_0x15f1('0x2c')](_0x15c42b[_0x15f1('0x28')],_0x15c42b[_0x15f1('0x29')]);_0x44236c[_0x15f1('0x2d')]=_[_0x15f1('0x2c')](_0x15c42b['model'],qs['fields'](_0x55b12f[_0x15f1('0x29')][_0x15f1('0x2e')]));_0x44236c['attributes']=_0x44236c[_0x15f1('0x2d')][_0x15f1('0x2f')]?_0x44236c[_0x15f1('0x2d')]:_0x15c42b['model'];if(!_0x55b12f[_0x15f1('0x29')][_0x15f1('0x30')](_0x15f1('0x31'))){_0x44236c['limit']=qs['limit'](_0x55b12f[_0x15f1('0x29')][_0x15f1('0x18')]);_0x44236c[_0x15f1('0x17')]=qs[_0x15f1('0x17')](_0x55b12f['query'][_0x15f1('0x17')]);}_0x44236c[_0x15f1('0x32')]=qs['sort'](_0x55b12f[_0x15f1('0x29')][_0x15f1('0x33')]);_0x44236c[_0x15f1('0x34')]=qs['filters'](_['pick'](_0x55b12f[_0x15f1('0x29')],_0x15c42b[_0x15f1('0x2b')]),_0x211b87);if(_0x55b12f['query']['filter']){_0x44236c[_0x15f1('0x34')]=_[_0x15f1('0x35')](_0x44236c['where'],{'$or':_['map'](_0x211b87,function(_0x528767){if(_0x528767['type']!==_0x15f1('0x36')){var _0x42c7fe={};_0x42c7fe[_0x528767['name']]={'$like':'%'+_0x55b12f[_0x15f1('0x29')]['filter']+'%'};return _0x42c7fe;}})});}_0x44236c=_[_0x15f1('0x35')]({},_0x44236c,_0x55b12f['options']);var _0x4a5379={'where':_0x44236c[_0x15f1('0x34')]};return db[_0x15f1('0x24')][_0x15f1('0x37')](_0x4a5379)['then'](function(_0x372d1b){_0x43a1da[_0x15f1('0x37')]=_0x372d1b;if(_0x55b12f[_0x15f1('0x29')]['includeAll']){_0x44236c['include']=[{'all':!![]}];}return db[_0x15f1('0x24')][_0x15f1('0x38')](_0x44236c);})['then'](function(_0x47393a){_0x43a1da[_0x15f1('0x39')]=_0x47393a;return _0x43a1da;})[_0x15f1('0x1c')](respondWithFilteredResult(_0x5334a5,_0x44236c))[_0x15f1('0x3a')](handleError(_0x5334a5,null));};exports[_0x15f1('0x3b')]=function(_0x1ee9de,_0x3f3135){var _0x127085={'raw':![],'where':{'id':_0x1ee9de['params']['id']}},_0x387a25={};_0x387a25['model']=_[_0x15f1('0x2a')](db[_0x15f1('0x24')][_0x15f1('0x25')]);_0x387a25['query']=_['keys'](_0x1ee9de[_0x15f1('0x29')]);_0x387a25[_0x15f1('0x2b')]=_[_0x15f1('0x2c')](_0x387a25[_0x15f1('0x28')],_0x387a25[_0x15f1('0x29')]);_0x127085[_0x15f1('0x2d')]=_[_0x15f1('0x2c')](_0x387a25[_0x15f1('0x28')],qs[_0x15f1('0x2e')](_0x1ee9de[_0x15f1('0x29')][_0x15f1('0x2e')]));_0x127085[_0x15f1('0x2d')]=_0x127085['attributes']['length']?_0x127085[_0x15f1('0x2d')]:_0x387a25['model'];if(_0x1ee9de['query'][_0x15f1('0x3c')]){_0x127085['include']=[{'all':!![]}];}_0x127085=_[_0x15f1('0x35')]({},_0x127085,_0x1ee9de[_0x15f1('0x3d')]);return db[_0x15f1('0x24')][_0x15f1('0x3e')](_0x127085)['then'](handleEntityNotFound(_0x3f3135,null))[_0x15f1('0x1c')](respondWithResult(_0x3f3135,null))['catch'](handleError(_0x3f3135,null));};exports[_0x15f1('0x3f')]=function(_0x276a6d,_0x15ba2a){return db['Trigger'][_0x15f1('0x3f')](_0x276a6d[_0x15f1('0x40')],{})['then'](function(_0x2f7f19){var _0x925266=_0x276a6d[_0x15f1('0x41')][_0x15f1('0x1e')]({'plain':!![]});if(!_0x925266)throw new Error(_0x15f1('0x42'));if(_0x925266[_0x15f1('0x43')]===_0x15f1('0x41')){var _0x412278=_0x2f7f19['get']({'plain':!![]});var _0xaace0d=_0x15f1('0x1f');return db[_0x15f1('0x44')][_0x15f1('0x3e')]({'where':{'name':_0xaace0d,'userProfileId':_0x925266[_0x15f1('0x45')]},'raw':!![]})[_0x15f1('0x1c')](function(_0x2476c5){if(_0x2476c5&&_0x2476c5[_0x15f1('0x46')]===0x0){return db[_0x15f1('0x20')][_0x15f1('0x3f')]({'name':_0x412278[_0x15f1('0x21')],'resourceId':_0x412278['id'],'type':_0x2476c5[_0x15f1('0x21')],'sectionId':_0x2476c5['id']},{})[_0x15f1('0x1c')](function(){return _0x2f7f19;});}else{return _0x2f7f19;}})['catch'](function(_0x35d392){logger[_0x15f1('0x47')](_0x15f1('0x48'),_0x35d392);throw _0x35d392;});}return _0x2f7f19;})['then'](respondWithResult(_0x15ba2a,0xc9))[_0x15f1('0x3a')](handleError(_0x15ba2a,null));};exports[_0x15f1('0x1b')]=function(_0x5ad994,_0x2714a7){if(_0x5ad994[_0x15f1('0x40')]['id']){delete _0x5ad994[_0x15f1('0x40')]['id'];}return db[_0x15f1('0x24')][_0x15f1('0x3e')]({'where':{'id':_0x5ad994[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x2714a7,null))[_0x15f1('0x1c')](saveUpdates(_0x5ad994[_0x15f1('0x40')],null))['then'](respondWithResult(_0x2714a7,null))[_0x15f1('0x3a')](handleError(_0x2714a7,null));};exports[_0x15f1('0x1d')]=function(_0x17fdbe,_0x1c7646){return db[_0x15f1('0x24')]['find']({'where':{'id':_0x17fdbe[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x1c7646,null))[_0x15f1('0x1c')](removeEntity(_0x1c7646,null))[_0x15f1('0x3a')](handleError(_0x1c7646,null));};exports['addAllCondition']=function(_0x8ef5f4,_0x2c3f62,_0x4ad73e){if(_0x8ef5f4[_0x15f1('0x40')]['id']){delete _0x8ef5f4[_0x15f1('0x40')]['id'];}return db[_0x15f1('0x24')]['find']({'where':{'id':_0x8ef5f4[_0x15f1('0x49')]['id']}})['then'](handleEntityNotFound(_0x2c3f62,null))['then'](function(_0x3d05ff){if(_0x3d05ff){_0x8ef5f4[_0x15f1('0x40')][_0x15f1('0x4a')]=_0x3d05ff['id'];return db[_0x15f1('0x4b')][_0x15f1('0x3f')](_0x8ef5f4['body']);}})[_0x15f1('0x1c')](respondWithResult(_0x2c3f62,null))[_0x15f1('0x3a')](handleError(_0x2c3f62,null));};exports[_0x15f1('0x4c')]=function(_0x3b2235,_0x1e8e5b,_0x17ecdb){if(_0x3b2235[_0x15f1('0x40')]['id']){delete _0x3b2235[_0x15f1('0x40')]['id'];}return db['Trigger']['find']({'where':{'id':_0x3b2235[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x1e8e5b,null))[_0x15f1('0x1c')](function(_0x40ee11){if(_0x40ee11){_0x3b2235['body'][_0x15f1('0x4d')]=_0x40ee11['id'];return db[_0x15f1('0x4b')]['create'](_0x3b2235['body']);}})['then'](respondWithResult(_0x1e8e5b,null))['catch'](handleError(_0x1e8e5b,null));};exports[_0x15f1('0x4e')]=function(_0x20db15,_0x118f30,_0x57d860){var _0x42bd87={};var _0x38d9d6={};var _0xf4bf08;var _0x242cd2;return db['Trigger'][_0x15f1('0x4f')]({'where':{'id':_0x20db15[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x118f30,null))['then'](function(_0xfd4b64){if(_0xfd4b64){_0xf4bf08=_0xfd4b64;_0x38d9d6['model']=_[_0x15f1('0x2a')](db[_0x15f1('0x4b')][_0x15f1('0x25')]);_0x38d9d6[_0x15f1('0x29')]=_['keys'](_0x20db15['query']);_0x38d9d6['filters']=_[_0x15f1('0x2c')](_0x38d9d6[_0x15f1('0x28')],_0x38d9d6[_0x15f1('0x29')]);_0x42bd87[_0x15f1('0x2d')]=_[_0x15f1('0x2c')](_0x38d9d6[_0x15f1('0x28')],qs[_0x15f1('0x2e')](_0x20db15[_0x15f1('0x29')][_0x15f1('0x2e')]));_0x42bd87['attributes']=_0x42bd87[_0x15f1('0x2d')]['length']?_0x42bd87[_0x15f1('0x2d')]:_0x38d9d6[_0x15f1('0x28')];_0x42bd87[_0x15f1('0x32')]=qs[_0x15f1('0x33')](_0x20db15[_0x15f1('0x29')][_0x15f1('0x33')]);_0x42bd87[_0x15f1('0x34')]=qs[_0x15f1('0x2b')](_['pick'](_0x20db15[_0x15f1('0x29')],_0x38d9d6[_0x15f1('0x2b')]));if(_0x20db15[_0x15f1('0x29')][_0x15f1('0x50')]){_0x42bd87[_0x15f1('0x34')]=_['merge'](_0x42bd87[_0x15f1('0x34')],{'$or':_[_0x15f1('0x23')](_0x42bd87[_0x15f1('0x2d')],function(_0x51284f){var _0x2263e0={};_0x2263e0[_0x51284f]={'$like':'%'+_0x20db15[_0x15f1('0x29')][_0x15f1('0x50')]+'%'};return _0x2263e0;})});}_0x42bd87=_[_0x15f1('0x35')]({},_0x42bd87,_0x20db15[_0x15f1('0x3d')]);return _0xf4bf08['getAllConditions'](_0x42bd87);}})[_0x15f1('0x1c')](function(_0x593c24){if(_0x593c24){_0x242cd2=_0x593c24[_0x15f1('0x2f')];if(!_0x20db15[_0x15f1('0x29')][_0x15f1('0x30')]('nolimit')){_0x42bd87[_0x15f1('0x18')]=qs[_0x15f1('0x18')](_0x20db15[_0x15f1('0x29')]['limit']);_0x42bd87['offset']=qs['offset'](_0x20db15[_0x15f1('0x29')]['offset']);}return _0xf4bf08[_0x15f1('0x4e')](_0x42bd87);}})[_0x15f1('0x1c')](function(_0xfb8743){if(_0xfb8743){return _0xfb8743?{'count':_0x242cd2,'rows':_0xfb8743}:null;}})[_0x15f1('0x1c')](respondWithResult(_0x118f30,null))[_0x15f1('0x3a')](handleError(_0x118f30,null));};exports[_0x15f1('0x51')]=function(_0x327608,_0x536787,_0xf6cf7c){var _0x186d63={};var _0x378e1b={};var _0x2df1bd;var _0x342f88;return db[_0x15f1('0x24')][_0x15f1('0x4f')]({'where':{'id':_0x327608[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x536787,null))[_0x15f1('0x1c')](function(_0x27a825){if(_0x27a825){_0x2df1bd=_0x27a825;_0x378e1b[_0x15f1('0x28')]=_[_0x15f1('0x2a')](db[_0x15f1('0x4b')][_0x15f1('0x25')]);_0x378e1b[_0x15f1('0x29')]=_['keys'](_0x327608[_0x15f1('0x29')]);_0x378e1b[_0x15f1('0x2b')]=_[_0x15f1('0x2c')](_0x378e1b[_0x15f1('0x28')],_0x378e1b['query']);_0x186d63['attributes']=_[_0x15f1('0x2c')](_0x378e1b['model'],qs[_0x15f1('0x2e')](_0x327608[_0x15f1('0x29')][_0x15f1('0x2e')]));_0x186d63[_0x15f1('0x2d')]=_0x186d63[_0x15f1('0x2d')][_0x15f1('0x2f')]?_0x186d63[_0x15f1('0x2d')]:_0x378e1b['model'];_0x186d63[_0x15f1('0x32')]=qs[_0x15f1('0x33')](_0x327608[_0x15f1('0x29')][_0x15f1('0x33')]);_0x186d63[_0x15f1('0x34')]=qs[_0x15f1('0x2b')](_[_0x15f1('0x52')](_0x327608[_0x15f1('0x29')],_0x378e1b['filters']));if(_0x327608[_0x15f1('0x29')]['filter']){_0x186d63[_0x15f1('0x34')]=_[_0x15f1('0x35')](_0x186d63[_0x15f1('0x34')],{'$or':_[_0x15f1('0x23')](_0x186d63[_0x15f1('0x2d')],function(_0x45752a){var _0x251b4a={};_0x251b4a[_0x45752a]={'$like':'%'+_0x327608[_0x15f1('0x29')][_0x15f1('0x50')]+'%'};return _0x251b4a;})});}_0x186d63=_['merge']({},_0x186d63,_0x327608[_0x15f1('0x3d')]);return _0x2df1bd[_0x15f1('0x51')](_0x186d63);}})[_0x15f1('0x1c')](function(_0x14b4ef){if(_0x14b4ef){_0x342f88=_0x14b4ef[_0x15f1('0x2f')];if(!_0x327608[_0x15f1('0x29')][_0x15f1('0x30')](_0x15f1('0x31'))){_0x186d63[_0x15f1('0x18')]=qs[_0x15f1('0x18')](_0x327608[_0x15f1('0x29')]['limit']);_0x186d63['offset']=qs[_0x15f1('0x17')](_0x327608[_0x15f1('0x29')]['offset']);}return _0x2df1bd[_0x15f1('0x51')](_0x186d63);}})['then'](function(_0x1b2f62){if(_0x1b2f62){return _0x1b2f62?{'count':_0x342f88,'rows':_0x1b2f62}:null;}})[_0x15f1('0x1c')](respondWithResult(_0x536787,null))[_0x15f1('0x3a')](handleError(_0x536787,null));};exports['addAction']=function(_0x3a68e7,_0x53eaa4,_0x3f3033){if(_0x3a68e7[_0x15f1('0x40')]['id']){delete _0x3a68e7[_0x15f1('0x40')]['id'];}return db['Trigger'][_0x15f1('0x3e')]({'where':{'id':_0x3a68e7[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x53eaa4,null))[_0x15f1('0x1c')](function(_0x338d6e){if(_0x338d6e){_0x3a68e7['body'][_0x15f1('0x53')]=_0x338d6e['id'];return db[_0x15f1('0x54')][_0x15f1('0x3f')](_0x3a68e7[_0x15f1('0x40')]);}})['then'](respondWithResult(_0x53eaa4,null))[_0x15f1('0x3a')](handleError(_0x53eaa4,null));};exports['getActions']=function(_0x3773df,_0x37f523,_0x30e726){var _0x2b7271={};var _0x25b3b3={};var _0x3bad75;var _0x4eca2e;return db[_0x15f1('0x24')][_0x15f1('0x4f')]({'where':{'id':_0x3773df[_0x15f1('0x49')]['id']}})[_0x15f1('0x1c')](handleEntityNotFound(_0x37f523,null))[_0x15f1('0x1c')](function(_0x3a942b){if(_0x3a942b){_0x3bad75=_0x3a942b;_0x25b3b3['model']=_[_0x15f1('0x2a')](db['Action']['rawAttributes']);_0x25b3b3[_0x15f1('0x29')]=_[_0x15f1('0x2a')](_0x3773df[_0x15f1('0x29')]);_0x25b3b3[_0x15f1('0x2b')]=_[_0x15f1('0x2c')](_0x25b3b3[_0x15f1('0x28')],_0x25b3b3[_0x15f1('0x29')]);_0x2b7271[_0x15f1('0x2d')]=_[_0x15f1('0x2c')](_0x25b3b3[_0x15f1('0x28')],qs['fields'](_0x3773df[_0x15f1('0x29')]['fields']));_0x2b7271[_0x15f1('0x2d')]=_0x2b7271[_0x15f1('0x2d')][_0x15f1('0x2f')]?_0x2b7271['attributes']:_0x25b3b3[_0x15f1('0x28')];_0x2b7271[_0x15f1('0x32')]=qs[_0x15f1('0x33')](_0x3773df[_0x15f1('0x29')][_0x15f1('0x33')]);_0x2b7271['where']=qs[_0x15f1('0x2b')](_[_0x15f1('0x52')](_0x3773df[_0x15f1('0x29')],_0x25b3b3[_0x15f1('0x2b')]));if(_0x3773df['query']['filter']){_0x2b7271[_0x15f1('0x34')]=_['merge'](_0x2b7271[_0x15f1('0x34')],{'$or':_['map'](_0x2b7271[_0x15f1('0x2d')],function(_0x3f8586){var _0x52d86f={};_0x52d86f[_0x3f8586]={'$like':'%'+_0x3773df[_0x15f1('0x29')][_0x15f1('0x50')]+'%'};return _0x52d86f;})});}_0x2b7271=_[_0x15f1('0x35')]({},_0x2b7271,_0x3773df[_0x15f1('0x3d')]);return _0x3bad75[_0x15f1('0x55')](_0x2b7271);}})['then'](function(_0x397a93){if(_0x397a93){_0x4eca2e=_0x397a93[_0x15f1('0x2f')];if(!_0x3773df['query'][_0x15f1('0x30')](_0x15f1('0x31'))){_0x2b7271['limit']=qs[_0x15f1('0x18')](_0x3773df['query'][_0x15f1('0x18')]);_0x2b7271['offset']=qs[_0x15f1('0x17')](_0x3773df[_0x15f1('0x29')][_0x15f1('0x17')]);}return _0x3bad75[_0x15f1('0x55')](_0x2b7271);}})[_0x15f1('0x1c')](function(_0x2ca038){if(_0x2ca038){return _0x2ca038?{'count':_0x4eca2e,'rows':_0x2ca038}:null;}})[_0x15f1('0x1c')](respondWithResult(_0x37f523,null))['catch'](handleError(_0x37f523,null));};