Built motion from commit (unavailable).|2.3.91
[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 _0xff0b=['ioredis','../../components/parsers/qs','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','set','Content-Range','apply','reject','save','update','then','UserProfileResource','error','stack','name','index','rawAttributes','model','keys','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','filters','pick','map','type','VIRTUAL','field','filter','merge','options','count','includeAll','include','findAll','rows','catch','show','params','Trigger','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','get','UserProfileSection','find','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','destroy','addAllCondition','TriggerAllId','Condition','addAnyCondition','TriggerAnyId','getAllConditions','findOne','getAnyConditions','addAction','TriggerId','getActions','Action','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','sox','to-csv','lodash','squel','crypto','desk.js','papaparse'];(function(_0x30c649,_0x2ebbac){var _0x3edfb9=function(_0xab82f5){while(--_0xab82f5){_0x30c649['push'](_0x30c649['shift']());}};_0x3edfb9(++_0x2ebbac);}(_0xff0b,0x1c0));var _0xbff0=function(_0x53e4a9,_0x523ec9){_0x53e4a9=_0x53e4a9-0x0;var _0x1365ed=_0xff0b[_0x53e4a9];return _0x1365ed;};'use strict';var pdf=require(_0xbff0('0x0'));var emlformat=require(_0xbff0('0x1'));var rimraf=require(_0xbff0('0x2'));var zipdir=require(_0xbff0('0x3'));var jsonpatch=require(_0xbff0('0x4'));var rp=require(_0xbff0('0x5'));var moment=require(_0xbff0('0x6'));var BPromise=require(_0xbff0('0x7'));var Mustache=require('mustache');var util=require(_0xbff0('0x8'));var path=require(_0xbff0('0x9'));var sox=require(_0xbff0('0xa'));var csv=require(_0xbff0('0xb'));var ejs=require('ejs');var fs=require('fs');var _=require(_0xbff0('0xc'));var squel=require(_0xbff0('0xd'));var crypto=require(_0xbff0('0xe'));var jsforce=require('jsforce');var deskjs=require(_0xbff0('0xf'));var toCsv=require(_0xbff0('0xb'));var querystring=require('querystring');var Papa=require(_0xbff0('0x10'));var authService=require('../../components/auth/service');var hardwareService=require('../../config/license/hardware');var Redis=require(_0xbff0('0x11'));var qs=require(_0xbff0('0x12'));var logger=require(_0xbff0('0x13'))('api');var utils=require(_0xbff0('0x14'));var config=require(_0xbff0('0x15'));var db=require(_0xbff0('0x16'))['db'];function respondWithStatusCode(_0x537e13,_0x5afe42){_0x5afe42=_0x5afe42||0xcc;return function(_0x5cb36f){if(_0x5cb36f){return _0x537e13[_0xbff0('0x17')](_0x5afe42);}return _0x537e13[_0xbff0('0x18')](_0x5afe42)[_0xbff0('0x19')]();};}function respondWithResult(_0x56c440,_0x33c6c5){_0x33c6c5=_0x33c6c5||0xc8;return function(_0x1767d9){if(_0x1767d9){return _0x56c440[_0xbff0('0x18')](_0x33c6c5)[_0xbff0('0x1a')](_0x1767d9);}};}function respondWithFilteredResult(_0x6a5dd6,_0x58dd87){return function(_0x2fed96){if(_0x2fed96){var _0x5a99f1=_0x2fed96['count'],_0x202637=_0x58dd87['offset'],_0x59f672=_0x58dd87[_0xbff0('0x1b')]+_0x58dd87['limit'],_0x247d46;if(_0x59f672>=_0x5a99f1){_0x59f672=_0x5a99f1;_0x247d46=0xc8;}else{_0x247d46=0xce;}_0x6a5dd6[_0xbff0('0x18')](_0x247d46);return _0x6a5dd6[_0xbff0('0x1c')](_0xbff0('0x1d'),_0x202637+'-'+_0x59f672+'/'+_0x5a99f1)[_0xbff0('0x1a')](_0x2fed96);}return null;};}function patchUpdates(_0x3a98e2){return function(_0x30e8c4){try{jsonpatch[_0xbff0('0x1e')](_0x30e8c4,_0x3a98e2,!![]);}catch(_0x4ab5d9){return BPromise[_0xbff0('0x1f')](_0x4ab5d9);}return _0x30e8c4[_0xbff0('0x20')]();};}function saveUpdates(_0x5c9119,_0x5a3677){return function(_0x142654){if(_0x142654){return _0x142654[_0xbff0('0x21')](_0x5c9119)[_0xbff0('0x22')](function(_0x891d60){return _0x891d60;});}return null;};}function removeEntity(_0x5e243a,_0x2f3279){return function(_0x12de75){if(_0x12de75){return _0x12de75['destroy']()['then'](function(){var _0x821e15=_0x12de75['get']({'plain':!![]});var _0x2eadb1='Triggers';return db[_0xbff0('0x23')]['destroy']({'where':{'type':_0x2eadb1,'resourceId':_0x821e15['id']}})[_0xbff0('0x22')](function(){return _0x12de75;});})[_0xbff0('0x22')](function(){_0x5e243a[_0xbff0('0x18')](0xcc)[_0xbff0('0x19')]();});}};}function handleEntityNotFound(_0x1c489e,_0x462760){return function(_0x2e6701){if(!_0x2e6701){_0x1c489e['sendStatus'](0x194);}return _0x2e6701;};}function handleError(_0x25f8f6,_0x488994){_0x488994=_0x488994||0x1f4;return function(_0x354372){logger[_0xbff0('0x24')](_0x354372[_0xbff0('0x25')]);if(_0x354372[_0xbff0('0x26')]){delete _0x354372[_0xbff0('0x26')];}_0x25f8f6[_0xbff0('0x18')](_0x488994)['send'](_0x354372);};}exports[_0xbff0('0x27')]=function(_0x1b6457,_0x1cc3be){var _0x6662e3={},_0x66eea={},_0x211d6e={'count':0x0,'rows':[]};var _0x9f9a26=db['Trigger'][_0xbff0('0x28')];_0x66eea[_0xbff0('0x29')]=_[_0xbff0('0x2a')](_0x9f9a26);_0x66eea[_0xbff0('0x2b')]=_[_0xbff0('0x2a')](_0x1b6457[_0xbff0('0x2b')]);_0x66eea['filters']=_[_0xbff0('0x2c')](_0x66eea[_0xbff0('0x29')],_0x66eea['query']);_0x6662e3['attributes']=_[_0xbff0('0x2c')](_0x66eea[_0xbff0('0x29')],qs[_0xbff0('0x2d')](_0x1b6457[_0xbff0('0x2b')][_0xbff0('0x2d')]));_0x6662e3[_0xbff0('0x2e')]=_0x6662e3[_0xbff0('0x2e')][_0xbff0('0x2f')]?_0x6662e3['attributes']:_0x66eea[_0xbff0('0x29')];if(!_0x1b6457['query'][_0xbff0('0x30')](_0xbff0('0x31'))){_0x6662e3['limit']=qs[_0xbff0('0x32')](_0x1b6457[_0xbff0('0x2b')][_0xbff0('0x32')]);_0x6662e3['offset']=qs[_0xbff0('0x1b')](_0x1b6457['query']['offset']);}_0x6662e3[_0xbff0('0x33')]=qs[_0xbff0('0x34')](_0x1b6457[_0xbff0('0x2b')][_0xbff0('0x34')]);_0x6662e3[_0xbff0('0x35')]=qs[_0xbff0('0x36')](_[_0xbff0('0x37')](_0x1b6457[_0xbff0('0x2b')],_0x66eea['filters']));if(_0x1b6457['query']['filter']){_0x6662e3[_0xbff0('0x35')]=_['merge'](_0x6662e3[_0xbff0('0x35')],{'$or':_[_0xbff0('0x38')](_0x9f9a26,function(_0x44610b){if(_0x44610b[_0xbff0('0x39')]['key']!==_0xbff0('0x3a')){var _0x1c2071={};_0x1c2071[_0x44610b[_0xbff0('0x3b')]]={'$like':'%'+_0x1b6457['query'][_0xbff0('0x3c')]+'%'};return _0x1c2071;}})});}_0x6662e3=_[_0xbff0('0x3d')]({},_0x6662e3,_0x1b6457[_0xbff0('0x3e')]);var _0x274a19={'where':_0x6662e3[_0xbff0('0x35')]};return db['Trigger']['count'](_0x274a19)[_0xbff0('0x22')](function(_0x439730){_0x211d6e[_0xbff0('0x3f')]=_0x439730;if(_0x1b6457[_0xbff0('0x2b')][_0xbff0('0x40')]){_0x6662e3[_0xbff0('0x41')]=[{'all':!![]}];}return db['Trigger'][_0xbff0('0x42')](_0x6662e3);})[_0xbff0('0x22')](function(_0x446442){_0x211d6e[_0xbff0('0x43')]=_0x446442;return _0x211d6e;})[_0xbff0('0x22')](respondWithFilteredResult(_0x1cc3be,_0x6662e3))[_0xbff0('0x44')](handleError(_0x1cc3be,null));};exports[_0xbff0('0x45')]=function(_0x58fd09,_0x16d0b5){var _0x47eb91={'raw':![],'where':{'id':_0x58fd09[_0xbff0('0x46')]['id']}},_0x54dfb0={};_0x54dfb0['model']=_['keys'](db[_0xbff0('0x47')][_0xbff0('0x28')]);_0x54dfb0[_0xbff0('0x2b')]=_[_0xbff0('0x2a')](_0x58fd09[_0xbff0('0x2b')]);_0x54dfb0[_0xbff0('0x36')]=_[_0xbff0('0x2c')](_0x54dfb0['model'],_0x54dfb0[_0xbff0('0x2b')]);_0x47eb91[_0xbff0('0x2e')]=_[_0xbff0('0x2c')](_0x54dfb0['model'],qs[_0xbff0('0x2d')](_0x58fd09['query'][_0xbff0('0x2d')]));_0x47eb91['attributes']=_0x47eb91[_0xbff0('0x2e')][_0xbff0('0x2f')]?_0x47eb91['attributes']:_0x54dfb0[_0xbff0('0x29')];if(_0x58fd09[_0xbff0('0x2b')][_0xbff0('0x40')]){_0x47eb91['include']=[{'all':!![]}];}_0x47eb91=_[_0xbff0('0x3d')]({},_0x47eb91,_0x58fd09[_0xbff0('0x3e')]);return db[_0xbff0('0x47')]['find'](_0x47eb91)[_0xbff0('0x22')](handleEntityNotFound(_0x16d0b5,null))[_0xbff0('0x22')](respondWithResult(_0x16d0b5,null))[_0xbff0('0x44')](handleError(_0x16d0b5,null));};exports[_0xbff0('0x48')]=function(_0x56f05b,_0x56602c){return db['Trigger'][_0xbff0('0x48')](_0x56f05b[_0xbff0('0x49')],{})[_0xbff0('0x22')](function(_0x49c2a8){var _0x36214c=_0x56f05b[_0xbff0('0x4a')]['get']({'plain':!![]});if(!_0x36214c)throw new Error(_0xbff0('0x4b'));if(_0x36214c['role']===_0xbff0('0x4a')){var _0x3628cf=_0x49c2a8[_0xbff0('0x4c')]({'plain':!![]});var _0x2ca3c1='Triggers';return db[_0xbff0('0x4d')][_0xbff0('0x4e')]({'where':{'name':_0x2ca3c1,'userProfileId':_0x36214c['userProfileId']},'raw':!![]})[_0xbff0('0x22')](function(_0x29c297){if(_0x29c297&&_0x29c297['autoAssociation']===0x0){return db[_0xbff0('0x23')][_0xbff0('0x48')]({'name':_0x3628cf[_0xbff0('0x26')],'resourceId':_0x3628cf['id'],'type':_0x29c297['name'],'sectionId':_0x29c297['id']},{})['then'](function(){return _0x49c2a8;});}else{return _0x49c2a8;}})[_0xbff0('0x44')](function(_0x1aa79c){logger[_0xbff0('0x24')](_0xbff0('0x4f'),_0x1aa79c);throw _0x1aa79c;});}return _0x49c2a8;})[_0xbff0('0x22')](respondWithResult(_0x56602c,0xc9))[_0xbff0('0x44')](handleError(_0x56602c,null));};exports[_0xbff0('0x21')]=function(_0x50bec4,_0x74ecba){if(_0x50bec4['body']['id']){delete _0x50bec4[_0xbff0('0x49')]['id'];}return db['Trigger'][_0xbff0('0x4e')]({'where':{'id':_0x50bec4['params']['id']}})['then'](handleEntityNotFound(_0x74ecba,null))['then'](saveUpdates(_0x50bec4[_0xbff0('0x49')],null))[_0xbff0('0x22')](respondWithResult(_0x74ecba,null))[_0xbff0('0x44')](handleError(_0x74ecba,null));};exports[_0xbff0('0x50')]=function(_0x3e84ff,_0x5e4d98){return db[_0xbff0('0x47')][_0xbff0('0x4e')]({'where':{'id':_0x3e84ff[_0xbff0('0x46')]['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x5e4d98,null))[_0xbff0('0x22')](removeEntity(_0x5e4d98,null))[_0xbff0('0x44')](handleError(_0x5e4d98,null));};exports[_0xbff0('0x51')]=function(_0x59e265,_0x1136e5,_0xa1d56f){if(_0x59e265[_0xbff0('0x49')]['id']){delete _0x59e265['body']['id'];}return db[_0xbff0('0x47')][_0xbff0('0x4e')]({'where':{'id':_0x59e265[_0xbff0('0x46')]['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x1136e5,null))[_0xbff0('0x22')](function(_0x5a6059){if(_0x5a6059){_0x59e265[_0xbff0('0x49')][_0xbff0('0x52')]=_0x5a6059['id'];return db[_0xbff0('0x53')][_0xbff0('0x48')](_0x59e265[_0xbff0('0x49')]);}})['then'](respondWithResult(_0x1136e5,null))[_0xbff0('0x44')](handleError(_0x1136e5,null));};exports[_0xbff0('0x54')]=function(_0x29cf7b,_0x5f1dcb,_0x2b8bb6){if(_0x29cf7b[_0xbff0('0x49')]['id']){delete _0x29cf7b[_0xbff0('0x49')]['id'];}return db[_0xbff0('0x47')][_0xbff0('0x4e')]({'where':{'id':_0x29cf7b[_0xbff0('0x46')]['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x5f1dcb,null))['then'](function(_0x26fca9){if(_0x26fca9){_0x29cf7b[_0xbff0('0x49')][_0xbff0('0x55')]=_0x26fca9['id'];return db[_0xbff0('0x53')]['create'](_0x29cf7b[_0xbff0('0x49')]);}})['then'](respondWithResult(_0x5f1dcb,null))[_0xbff0('0x44')](handleError(_0x5f1dcb,null));};exports[_0xbff0('0x56')]=function(_0x390164,_0x39a2d3,_0x49fe02){var _0x2b28d0={};var _0x427007={};var _0x8c1c8b;var _0x1c61dc;return db['Trigger'][_0xbff0('0x57')]({'where':{'id':_0x390164[_0xbff0('0x46')]['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x39a2d3,null))[_0xbff0('0x22')](function(_0x1101c8){if(_0x1101c8){_0x8c1c8b=_0x1101c8;_0x427007['model']=_[_0xbff0('0x2a')](db[_0xbff0('0x53')][_0xbff0('0x28')]);_0x427007[_0xbff0('0x2b')]=_[_0xbff0('0x2a')](_0x390164[_0xbff0('0x2b')]);_0x427007[_0xbff0('0x36')]=_['intersection'](_0x427007['model'],_0x427007[_0xbff0('0x2b')]);_0x2b28d0[_0xbff0('0x2e')]=_[_0xbff0('0x2c')](_0x427007['model'],qs[_0xbff0('0x2d')](_0x390164[_0xbff0('0x2b')][_0xbff0('0x2d')]));_0x2b28d0['attributes']=_0x2b28d0[_0xbff0('0x2e')][_0xbff0('0x2f')]?_0x2b28d0[_0xbff0('0x2e')]:_0x427007[_0xbff0('0x29')];_0x2b28d0[_0xbff0('0x33')]=qs[_0xbff0('0x34')](_0x390164[_0xbff0('0x2b')][_0xbff0('0x34')]);_0x2b28d0[_0xbff0('0x35')]=qs[_0xbff0('0x36')](_[_0xbff0('0x37')](_0x390164[_0xbff0('0x2b')],_0x427007['filters']));if(_0x390164[_0xbff0('0x2b')][_0xbff0('0x3c')]){_0x2b28d0[_0xbff0('0x35')]=_[_0xbff0('0x3d')](_0x2b28d0[_0xbff0('0x35')],{'$or':_[_0xbff0('0x38')](_0x2b28d0[_0xbff0('0x2e')],function(_0x32cc36){var _0x27cae7={};_0x27cae7[_0x32cc36]={'$like':'%'+_0x390164['query']['filter']+'%'};return _0x27cae7;})});}_0x2b28d0=_[_0xbff0('0x3d')]({},_0x2b28d0,_0x390164[_0xbff0('0x3e')]);return _0x8c1c8b['getAllConditions'](_0x2b28d0);}})['then'](function(_0x22af40){if(_0x22af40){_0x1c61dc=_0x22af40[_0xbff0('0x2f')];if(!_0x390164[_0xbff0('0x2b')][_0xbff0('0x30')](_0xbff0('0x31'))){_0x2b28d0[_0xbff0('0x32')]=qs[_0xbff0('0x32')](_0x390164[_0xbff0('0x2b')][_0xbff0('0x32')]);_0x2b28d0[_0xbff0('0x1b')]=qs['offset'](_0x390164[_0xbff0('0x2b')]['offset']);}return _0x8c1c8b[_0xbff0('0x56')](_0x2b28d0);}})[_0xbff0('0x22')](function(_0x5de7fb){if(_0x5de7fb){return _0x5de7fb?{'count':_0x1c61dc,'rows':_0x5de7fb}:null;}})[_0xbff0('0x22')](respondWithResult(_0x39a2d3,null))[_0xbff0('0x44')](handleError(_0x39a2d3,null));};exports[_0xbff0('0x58')]=function(_0x4265f7,_0x4125d0,_0x26f181){var _0x5b06b5={};var _0x3f9a49={};var _0x17fafc;var _0x3f0322;return db[_0xbff0('0x47')][_0xbff0('0x57')]({'where':{'id':_0x4265f7['params']['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x4125d0,null))[_0xbff0('0x22')](function(_0x1d6009){if(_0x1d6009){_0x17fafc=_0x1d6009;_0x3f9a49[_0xbff0('0x29')]=_['keys'](db[_0xbff0('0x53')][_0xbff0('0x28')]);_0x3f9a49[_0xbff0('0x2b')]=_[_0xbff0('0x2a')](_0x4265f7['query']);_0x3f9a49[_0xbff0('0x36')]=_['intersection'](_0x3f9a49['model'],_0x3f9a49['query']);_0x5b06b5['attributes']=_[_0xbff0('0x2c')](_0x3f9a49['model'],qs[_0xbff0('0x2d')](_0x4265f7['query'][_0xbff0('0x2d')]));_0x5b06b5[_0xbff0('0x2e')]=_0x5b06b5[_0xbff0('0x2e')]['length']?_0x5b06b5['attributes']:_0x3f9a49[_0xbff0('0x29')];_0x5b06b5[_0xbff0('0x33')]=qs[_0xbff0('0x34')](_0x4265f7[_0xbff0('0x2b')][_0xbff0('0x34')]);_0x5b06b5[_0xbff0('0x35')]=qs[_0xbff0('0x36')](_[_0xbff0('0x37')](_0x4265f7[_0xbff0('0x2b')],_0x3f9a49[_0xbff0('0x36')]));if(_0x4265f7['query']['filter']){_0x5b06b5[_0xbff0('0x35')]=_['merge'](_0x5b06b5['where'],{'$or':_[_0xbff0('0x38')](_0x5b06b5['attributes'],function(_0x34e2bf){var _0x495e20={};_0x495e20[_0x34e2bf]={'$like':'%'+_0x4265f7[_0xbff0('0x2b')]['filter']+'%'};return _0x495e20;})});}_0x5b06b5=_[_0xbff0('0x3d')]({},_0x5b06b5,_0x4265f7[_0xbff0('0x3e')]);return _0x17fafc['getAnyConditions'](_0x5b06b5);}})[_0xbff0('0x22')](function(_0x46aa31){if(_0x46aa31){_0x3f0322=_0x46aa31['length'];if(!_0x4265f7[_0xbff0('0x2b')][_0xbff0('0x30')](_0xbff0('0x31'))){_0x5b06b5[_0xbff0('0x32')]=qs[_0xbff0('0x32')](_0x4265f7[_0xbff0('0x2b')][_0xbff0('0x32')]);_0x5b06b5['offset']=qs[_0xbff0('0x1b')](_0x4265f7[_0xbff0('0x2b')][_0xbff0('0x1b')]);}return _0x17fafc[_0xbff0('0x58')](_0x5b06b5);}})['then'](function(_0x2dfcd8){if(_0x2dfcd8){return _0x2dfcd8?{'count':_0x3f0322,'rows':_0x2dfcd8}:null;}})[_0xbff0('0x22')](respondWithResult(_0x4125d0,null))[_0xbff0('0x44')](handleError(_0x4125d0,null));};exports[_0xbff0('0x59')]=function(_0x2be95c,_0x2970ed,_0x537383){if(_0x2be95c[_0xbff0('0x49')]['id']){delete _0x2be95c[_0xbff0('0x49')]['id'];}return db[_0xbff0('0x47')]['find']({'where':{'id':_0x2be95c[_0xbff0('0x46')]['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x2970ed,null))[_0xbff0('0x22')](function(_0x504906){if(_0x504906){_0x2be95c[_0xbff0('0x49')][_0xbff0('0x5a')]=_0x504906['id'];return db['Action'][_0xbff0('0x48')](_0x2be95c[_0xbff0('0x49')]);}})[_0xbff0('0x22')](respondWithResult(_0x2970ed,null))[_0xbff0('0x44')](handleError(_0x2970ed,null));};exports[_0xbff0('0x5b')]=function(_0x4e089e,_0x5627bf,_0x79a8d3){var _0x2617d8={};var _0x344273={};var _0x3cb764;var _0x19da34;return db[_0xbff0('0x47')][_0xbff0('0x57')]({'where':{'id':_0x4e089e[_0xbff0('0x46')]['id']}})[_0xbff0('0x22')](handleEntityNotFound(_0x5627bf,null))[_0xbff0('0x22')](function(_0x51c588){if(_0x51c588){_0x3cb764=_0x51c588;_0x344273['model']=_[_0xbff0('0x2a')](db[_0xbff0('0x5c')][_0xbff0('0x28')]);_0x344273[_0xbff0('0x2b')]=_[_0xbff0('0x2a')](_0x4e089e[_0xbff0('0x2b')]);_0x344273[_0xbff0('0x36')]=_[_0xbff0('0x2c')](_0x344273['model'],_0x344273[_0xbff0('0x2b')]);_0x2617d8['attributes']=_['intersection'](_0x344273[_0xbff0('0x29')],qs['fields'](_0x4e089e[_0xbff0('0x2b')][_0xbff0('0x2d')]));_0x2617d8[_0xbff0('0x2e')]=_0x2617d8[_0xbff0('0x2e')][_0xbff0('0x2f')]?_0x2617d8[_0xbff0('0x2e')]:_0x344273[_0xbff0('0x29')];_0x2617d8[_0xbff0('0x33')]=qs[_0xbff0('0x34')](_0x4e089e[_0xbff0('0x2b')][_0xbff0('0x34')]);_0x2617d8[_0xbff0('0x35')]=qs[_0xbff0('0x36')](_['pick'](_0x4e089e['query'],_0x344273[_0xbff0('0x36')]));if(_0x4e089e['query'][_0xbff0('0x3c')]){_0x2617d8['where']=_[_0xbff0('0x3d')](_0x2617d8[_0xbff0('0x35')],{'$or':_[_0xbff0('0x38')](_0x2617d8[_0xbff0('0x2e')],function(_0xdd5f1a){var _0x24712d={};_0x24712d[_0xdd5f1a]={'$like':'%'+_0x4e089e['query'][_0xbff0('0x3c')]+'%'};return _0x24712d;})});}_0x2617d8=_[_0xbff0('0x3d')]({},_0x2617d8,_0x4e089e[_0xbff0('0x3e')]);return _0x3cb764[_0xbff0('0x5b')](_0x2617d8);}})['then'](function(_0x28ae27){if(_0x28ae27){_0x19da34=_0x28ae27[_0xbff0('0x2f')];if(!_0x4e089e['query'][_0xbff0('0x30')](_0xbff0('0x31'))){_0x2617d8['limit']=qs[_0xbff0('0x32')](_0x4e089e['query'][_0xbff0('0x32')]);_0x2617d8['offset']=qs[_0xbff0('0x1b')](_0x4e089e[_0xbff0('0x2b')][_0xbff0('0x1b')]);}return _0x3cb764[_0xbff0('0x5b')](_0x2617d8);}})[_0xbff0('0x22')](function(_0x289f03){if(_0x289f03){return _0x289f03?{'count':_0x19da34,'rows':_0x289f03}:null;}})['then'](respondWithResult(_0x5627bf,null))['catch'](handleError(_0x5627bf,null));};