0e0cadacbbcb558d17d9d4030a7161e52e1d4e22
[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 _0xf485=['getActions','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','then','destroy','Triggers','UserProfileResource','error','stack','name','index','map','fieldName','query','keys','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','type','Trigger','includeAll','findAll','rows','catch','show','params','rawAttributes','include','options','find','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','get','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','TriggerAllId','Condition','addAnyCondition','TriggerAnyId','findOne','getAllConditions','getAnyConditions','TriggerId','Action'];(function(_0x12d6de,_0xccc040){var _0x32923b=function(_0x1b150f){while(--_0x1b150f){_0x12d6de['push'](_0x12d6de['shift']());}};_0x32923b(++_0xccc040);}(_0xf485,0x1e1));var _0x5f48=function(_0x35d940,_0x43bf93){_0x35d940=_0x35d940-0x0;var _0x7bf56c=_0xf485[_0x35d940];return _0x7bf56c;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x5f48('0x0'));var zipdir=require(_0x5f48('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5f48('0x2'));var moment=require(_0x5f48('0x3'));var BPromise=require(_0x5f48('0x4'));var Mustache=require(_0x5f48('0x5'));var util=require(_0x5f48('0x6'));var path=require(_0x5f48('0x7'));var sox=require(_0x5f48('0x8'));var csv=require(_0x5f48('0x9'));var ejs=require(_0x5f48('0xa'));var fs=require('fs');var fs_extra=require(_0x5f48('0xb'));var _=require(_0x5f48('0xc'));var squel=require(_0x5f48('0xd'));var crypto=require('crypto');var jsforce=require(_0x5f48('0xe'));var deskjs=require(_0x5f48('0xf'));var toCsv=require(_0x5f48('0x9'));var querystring=require(_0x5f48('0x10'));var Papa=require('papaparse');var Redis=require(_0x5f48('0x11'));var authService=require(_0x5f48('0x12'));var qs=require(_0x5f48('0x13'));var as=require(_0x5f48('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x5f48('0x15'))(_0x5f48('0x16'));var utils=require(_0x5f48('0x17'));var config=require(_0x5f48('0x18'));var licenseUtil=require(_0x5f48('0x19'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x44c500,_0x3af296){_0x3af296=_0x3af296||0xcc;return function(_0x34ec95){if(_0x34ec95){return _0x44c500[_0x5f48('0x1a')](_0x3af296);}return _0x44c500['status'](_0x3af296)[_0x5f48('0x1b')]();};}function respondWithResult(_0x480def,_0x14e58a){_0x14e58a=_0x14e58a||0xc8;return function(_0x1cd991){if(_0x1cd991){return _0x480def[_0x5f48('0x1c')](_0x14e58a)[_0x5f48('0x1d')](_0x1cd991);}};}function respondWithFilteredResult(_0x5d39da,_0x208bf3){return function(_0x5b20a1){if(_0x5b20a1){var _0x4cf1b7=typeof _0x208bf3[_0x5f48('0x1e')]===_0x5f48('0x1f')&&typeof _0x208bf3[_0x5f48('0x20')]==='undefined';var _0x3314f1=_0x5b20a1[_0x5f48('0x21')];var _0xe5fde8=_0x4cf1b7?0x0:_0x208bf3['offset'];var _0x9b42b3=_0x4cf1b7?_0x5b20a1[_0x5f48('0x21')]:_0x208bf3[_0x5f48('0x1e')]+_0x208bf3[_0x5f48('0x20')];var _0x2b39d5;if(_0x9b42b3>=_0x3314f1){_0x9b42b3=_0x3314f1;_0x2b39d5=0xc8;}else{_0x2b39d5=0xce;}_0x5d39da[_0x5f48('0x1c')](_0x2b39d5);return _0x5d39da[_0x5f48('0x22')](_0x5f48('0x23'),_0xe5fde8+'-'+_0x9b42b3+'/'+_0x3314f1)[_0x5f48('0x1d')](_0x5b20a1);}return null;};}function patchUpdates(_0x6a71dd){return function(_0x3bcac8){try{jsonpatch[_0x5f48('0x24')](_0x3bcac8,_0x6a71dd,!![]);}catch(_0x371a5b){return BPromise[_0x5f48('0x25')](_0x371a5b);}return _0x3bcac8[_0x5f48('0x26')]();};}function saveUpdates(_0x2134cf,_0x4d9aee){return function(_0x475125){if(_0x475125){return _0x475125['update'](_0x2134cf)[_0x5f48('0x27')](function(_0x1e5c7b){return _0x1e5c7b;});}return null;};}function removeEntity(_0x4acdb2,_0x3a59ac){return function(_0xe8e1e5){if(_0xe8e1e5){return _0xe8e1e5[_0x5f48('0x28')]()[_0x5f48('0x27')](function(){var _0x2e053a=_0xe8e1e5['get']({'plain':!![]});var _0x1c77be=_0x5f48('0x29');return db[_0x5f48('0x2a')][_0x5f48('0x28')]({'where':{'type':_0x1c77be,'resourceId':_0x2e053a['id']}})[_0x5f48('0x27')](function(){return _0xe8e1e5;});})[_0x5f48('0x27')](function(){_0x4acdb2[_0x5f48('0x1c')](0xcc)[_0x5f48('0x1b')]();});}};}function handleEntityNotFound(_0xa683c4,_0x1d08b3){return function(_0xe816bb){if(!_0xe816bb){_0xa683c4[_0x5f48('0x1a')](0x194);}return _0xe816bb;};}function handleError(_0x1ae6ac,_0x3c8586){_0x3c8586=_0x3c8586||0x1f4;return function(_0x1efc0d){logger[_0x5f48('0x2b')](_0x1efc0d[_0x5f48('0x2c')]);if(_0x1efc0d[_0x5f48('0x2d')]){delete _0x1efc0d[_0x5f48('0x2d')];}_0x1ae6ac[_0x5f48('0x1c')](_0x3c8586)['send'](_0x1efc0d);};}exports[_0x5f48('0x2e')]=function(_0xe0b060,_0x57dedd){var _0x4ada7a={},_0x205e6b={},_0x5caa34={'count':0x0,'rows':[]};var _0x54d553=_[_0x5f48('0x2f')](db['Trigger']['rawAttributes'],function(_0x32373c){return{'name':_0x32373c[_0x5f48('0x30')],'type':_0x32373c['type']['key']};});_0x205e6b['model']=_[_0x5f48('0x2f')](_0x54d553,_0x5f48('0x2d'));_0x205e6b[_0x5f48('0x31')]=_[_0x5f48('0x32')](_0xe0b060[_0x5f48('0x31')]);_0x205e6b['filters']=_[_0x5f48('0x33')](_0x205e6b[_0x5f48('0x34')],_0x205e6b[_0x5f48('0x31')]);_0x4ada7a[_0x5f48('0x35')]=_[_0x5f48('0x33')](_0x205e6b['model'],qs[_0x5f48('0x36')](_0xe0b060[_0x5f48('0x31')][_0x5f48('0x36')]));_0x4ada7a[_0x5f48('0x35')]=_0x4ada7a['attributes'][_0x5f48('0x37')]?_0x4ada7a[_0x5f48('0x35')]:_0x205e6b['model'];if(!_0xe0b060[_0x5f48('0x31')][_0x5f48('0x38')](_0x5f48('0x39'))){_0x4ada7a['limit']=qs[_0x5f48('0x20')](_0xe0b060[_0x5f48('0x31')][_0x5f48('0x20')]);_0x4ada7a['offset']=qs['offset'](_0xe0b060[_0x5f48('0x31')][_0x5f48('0x1e')]);}_0x4ada7a[_0x5f48('0x3a')]=qs[_0x5f48('0x3b')](_0xe0b060[_0x5f48('0x31')][_0x5f48('0x3b')]);_0x4ada7a[_0x5f48('0x3c')]=qs[_0x5f48('0x3d')](_[_0x5f48('0x3e')](_0xe0b060[_0x5f48('0x31')],_0x205e6b['filters']),_0x54d553);if(_0xe0b060[_0x5f48('0x31')][_0x5f48('0x3f')]){_0x4ada7a[_0x5f48('0x3c')]=_[_0x5f48('0x40')](_0x4ada7a[_0x5f48('0x3c')],{'$or':_[_0x5f48('0x2f')](_0x54d553,function(_0x310bca){if(_0x310bca[_0x5f48('0x41')]!=='VIRTUAL'){var _0x28c486={};_0x28c486[_0x310bca['name']]={'$like':'%'+_0xe0b060[_0x5f48('0x31')]['filter']+'%'};return _0x28c486;}})});}_0x4ada7a=_['merge']({},_0x4ada7a,_0xe0b060['options']);var _0x53e53e={'where':_0x4ada7a[_0x5f48('0x3c')]};return db[_0x5f48('0x42')][_0x5f48('0x21')](_0x53e53e)[_0x5f48('0x27')](function(_0x11e112){_0x5caa34['count']=_0x11e112;if(_0xe0b060[_0x5f48('0x31')][_0x5f48('0x43')]){_0x4ada7a['include']=[{'all':!![]}];}return db[_0x5f48('0x42')][_0x5f48('0x44')](_0x4ada7a);})[_0x5f48('0x27')](function(_0x56c0fe){_0x5caa34[_0x5f48('0x45')]=_0x56c0fe;return _0x5caa34;})['then'](respondWithFilteredResult(_0x57dedd,_0x4ada7a))[_0x5f48('0x46')](handleError(_0x57dedd,null));};exports[_0x5f48('0x47')]=function(_0x45fdf2,_0x2c17e3){var _0x5260f1={'raw':![],'where':{'id':_0x45fdf2[_0x5f48('0x48')]['id']}},_0x49885e={};_0x49885e[_0x5f48('0x34')]=_[_0x5f48('0x32')](db[_0x5f48('0x42')][_0x5f48('0x49')]);_0x49885e[_0x5f48('0x31')]=_['keys'](_0x45fdf2[_0x5f48('0x31')]);_0x49885e[_0x5f48('0x3d')]=_[_0x5f48('0x33')](_0x49885e['model'],_0x49885e[_0x5f48('0x31')]);_0x5260f1[_0x5f48('0x35')]=_['intersection'](_0x49885e[_0x5f48('0x34')],qs[_0x5f48('0x36')](_0x45fdf2[_0x5f48('0x31')][_0x5f48('0x36')]));_0x5260f1[_0x5f48('0x35')]=_0x5260f1[_0x5f48('0x35')]['length']?_0x5260f1[_0x5f48('0x35')]:_0x49885e['model'];if(_0x45fdf2[_0x5f48('0x31')][_0x5f48('0x43')]){_0x5260f1[_0x5f48('0x4a')]=[{'all':!![]}];}_0x5260f1=_[_0x5f48('0x40')]({},_0x5260f1,_0x45fdf2[_0x5f48('0x4b')]);return db['Trigger'][_0x5f48('0x4c')](_0x5260f1)['then'](handleEntityNotFound(_0x2c17e3,null))[_0x5f48('0x27')](respondWithResult(_0x2c17e3,null))[_0x5f48('0x46')](handleError(_0x2c17e3,null));};exports[_0x5f48('0x4d')]=function(_0x216060,_0x29ffe5){return db[_0x5f48('0x42')][_0x5f48('0x4d')](_0x216060['body'],{})[_0x5f48('0x27')](function(_0x2fdb3c){var _0x24c033=_0x216060['user']['get']({'plain':!![]});if(!_0x24c033)throw new Error(_0x5f48('0x4e'));if(_0x24c033[_0x5f48('0x4f')]===_0x5f48('0x50')){var _0x2f7ceb=_0x2fdb3c[_0x5f48('0x51')]({'plain':!![]});var _0x988ef4='Triggers';return db['UserProfileSection'][_0x5f48('0x4c')]({'where':{'name':_0x988ef4,'userProfileId':_0x24c033['userProfileId']},'raw':!![]})[_0x5f48('0x27')](function(_0x4f5a2f){if(_0x4f5a2f&&_0x4f5a2f[_0x5f48('0x52')]===0x0){return db[_0x5f48('0x2a')][_0x5f48('0x4d')]({'name':_0x2f7ceb[_0x5f48('0x2d')],'resourceId':_0x2f7ceb['id'],'type':_0x4f5a2f[_0x5f48('0x2d')],'sectionId':_0x4f5a2f['id']},{})[_0x5f48('0x27')](function(){return _0x2fdb3c;});}else{return _0x2fdb3c;}})[_0x5f48('0x46')](function(_0x14b5d3){logger[_0x5f48('0x2b')](_0x5f48('0x53'),_0x14b5d3);throw _0x14b5d3;});}return _0x2fdb3c;})['then'](respondWithResult(_0x29ffe5,0xc9))['catch'](handleError(_0x29ffe5,null));};exports[_0x5f48('0x54')]=function(_0x5f35e8,_0x93a662){if(_0x5f35e8[_0x5f48('0x55')]['id']){delete _0x5f35e8[_0x5f48('0x55')]['id'];}return db[_0x5f48('0x42')]['find']({'where':{'id':_0x5f35e8[_0x5f48('0x48')]['id']}})['then'](handleEntityNotFound(_0x93a662,null))[_0x5f48('0x27')](saveUpdates(_0x5f35e8['body'],null))[_0x5f48('0x27')](respondWithResult(_0x93a662,null))[_0x5f48('0x46')](handleError(_0x93a662,null));};exports[_0x5f48('0x28')]=function(_0x44a085,_0x588041){return db[_0x5f48('0x42')][_0x5f48('0x4c')]({'where':{'id':_0x44a085[_0x5f48('0x48')]['id']}})[_0x5f48('0x27')](handleEntityNotFound(_0x588041,null))['then'](removeEntity(_0x588041,null))[_0x5f48('0x46')](handleError(_0x588041,null));};exports['addAllCondition']=function(_0x5e3e,_0x2fd6ce,_0x3bf215){if(_0x5e3e['body']['id']){delete _0x5e3e[_0x5f48('0x55')]['id'];}return db['Trigger'][_0x5f48('0x4c')]({'where':{'id':_0x5e3e['params']['id']}})['then'](handleEntityNotFound(_0x2fd6ce,null))[_0x5f48('0x27')](function(_0x41a9b8){if(_0x41a9b8){_0x5e3e[_0x5f48('0x55')][_0x5f48('0x56')]=_0x41a9b8['id'];return db[_0x5f48('0x57')][_0x5f48('0x4d')](_0x5e3e['body']);}})[_0x5f48('0x27')](respondWithResult(_0x2fd6ce,null))[_0x5f48('0x46')](handleError(_0x2fd6ce,null));};exports[_0x5f48('0x58')]=function(_0x599b6b,_0x1f6a2c,_0x3445dc){if(_0x599b6b[_0x5f48('0x55')]['id']){delete _0x599b6b[_0x5f48('0x55')]['id'];}return db[_0x5f48('0x42')][_0x5f48('0x4c')]({'where':{'id':_0x599b6b[_0x5f48('0x48')]['id']}})[_0x5f48('0x27')](handleEntityNotFound(_0x1f6a2c,null))['then'](function(_0x456a83){if(_0x456a83){_0x599b6b[_0x5f48('0x55')][_0x5f48('0x59')]=_0x456a83['id'];return db[_0x5f48('0x57')]['create'](_0x599b6b[_0x5f48('0x55')]);}})[_0x5f48('0x27')](respondWithResult(_0x1f6a2c,null))[_0x5f48('0x46')](handleError(_0x1f6a2c,null));};exports['getAllConditions']=function(_0x50b6dc,_0x34b28d,_0x440e7a){var _0x1db09e={};var _0x55955c={};var _0xb4e2f7;var _0x434230;return db[_0x5f48('0x42')][_0x5f48('0x5a')]({'where':{'id':_0x50b6dc[_0x5f48('0x48')]['id']}})['then'](handleEntityNotFound(_0x34b28d,null))[_0x5f48('0x27')](function(_0xc5944){if(_0xc5944){_0xb4e2f7=_0xc5944;_0x55955c[_0x5f48('0x34')]=_[_0x5f48('0x32')](db['Condition']['rawAttributes']);_0x55955c['query']=_[_0x5f48('0x32')](_0x50b6dc['query']);_0x55955c[_0x5f48('0x3d')]=_[_0x5f48('0x33')](_0x55955c[_0x5f48('0x34')],_0x55955c[_0x5f48('0x31')]);_0x1db09e[_0x5f48('0x35')]=_[_0x5f48('0x33')](_0x55955c[_0x5f48('0x34')],qs[_0x5f48('0x36')](_0x50b6dc[_0x5f48('0x31')][_0x5f48('0x36')]));_0x1db09e[_0x5f48('0x35')]=_0x1db09e[_0x5f48('0x35')]['length']?_0x1db09e[_0x5f48('0x35')]:_0x55955c[_0x5f48('0x34')];_0x1db09e[_0x5f48('0x3a')]=qs[_0x5f48('0x3b')](_0x50b6dc[_0x5f48('0x31')]['sort']);_0x1db09e[_0x5f48('0x3c')]=qs[_0x5f48('0x3d')](_[_0x5f48('0x3e')](_0x50b6dc[_0x5f48('0x31')],_0x55955c[_0x5f48('0x3d')]));if(_0x50b6dc[_0x5f48('0x31')][_0x5f48('0x3f')]){_0x1db09e[_0x5f48('0x3c')]=_[_0x5f48('0x40')](_0x1db09e[_0x5f48('0x3c')],{'$or':_[_0x5f48('0x2f')](_0x1db09e[_0x5f48('0x35')],function(_0x5f2c6d){var _0xd42dba={};_0xd42dba[_0x5f2c6d]={'$like':'%'+_0x50b6dc[_0x5f48('0x31')][_0x5f48('0x3f')]+'%'};return _0xd42dba;})});}_0x1db09e=_[_0x5f48('0x40')]({},_0x1db09e,_0x50b6dc[_0x5f48('0x4b')]);return _0xb4e2f7[_0x5f48('0x5b')](_0x1db09e);}})[_0x5f48('0x27')](function(_0x265578){if(_0x265578){_0x434230=_0x265578[_0x5f48('0x37')];if(!_0x50b6dc[_0x5f48('0x31')]['hasOwnProperty'](_0x5f48('0x39'))){_0x1db09e['limit']=qs[_0x5f48('0x20')](_0x50b6dc[_0x5f48('0x31')]['limit']);_0x1db09e[_0x5f48('0x1e')]=qs[_0x5f48('0x1e')](_0x50b6dc[_0x5f48('0x31')][_0x5f48('0x1e')]);}return _0xb4e2f7[_0x5f48('0x5b')](_0x1db09e);}})[_0x5f48('0x27')](function(_0x3aa5e3){if(_0x3aa5e3){return _0x3aa5e3?{'count':_0x434230,'rows':_0x3aa5e3}:null;}})[_0x5f48('0x27')](respondWithResult(_0x34b28d,null))['catch'](handleError(_0x34b28d,null));};exports[_0x5f48('0x5c')]=function(_0x26d068,_0x3ece7a,_0x2cb814){var _0x3ddd8e={};var _0x40681b={};var _0x4536e6;var _0x512c0a;return db[_0x5f48('0x42')][_0x5f48('0x5a')]({'where':{'id':_0x26d068['params']['id']}})[_0x5f48('0x27')](handleEntityNotFound(_0x3ece7a,null))[_0x5f48('0x27')](function(_0x2e2b9f){if(_0x2e2b9f){_0x4536e6=_0x2e2b9f;_0x40681b[_0x5f48('0x34')]=_[_0x5f48('0x32')](db[_0x5f48('0x57')][_0x5f48('0x49')]);_0x40681b[_0x5f48('0x31')]=_['keys'](_0x26d068[_0x5f48('0x31')]);_0x40681b[_0x5f48('0x3d')]=_[_0x5f48('0x33')](_0x40681b[_0x5f48('0x34')],_0x40681b[_0x5f48('0x31')]);_0x3ddd8e[_0x5f48('0x35')]=_[_0x5f48('0x33')](_0x40681b['model'],qs[_0x5f48('0x36')](_0x26d068[_0x5f48('0x31')][_0x5f48('0x36')]));_0x3ddd8e[_0x5f48('0x35')]=_0x3ddd8e['attributes'][_0x5f48('0x37')]?_0x3ddd8e[_0x5f48('0x35')]:_0x40681b['model'];_0x3ddd8e[_0x5f48('0x3a')]=qs[_0x5f48('0x3b')](_0x26d068['query']['sort']);_0x3ddd8e[_0x5f48('0x3c')]=qs[_0x5f48('0x3d')](_[_0x5f48('0x3e')](_0x26d068[_0x5f48('0x31')],_0x40681b['filters']));if(_0x26d068[_0x5f48('0x31')][_0x5f48('0x3f')]){_0x3ddd8e[_0x5f48('0x3c')]=_[_0x5f48('0x40')](_0x3ddd8e[_0x5f48('0x3c')],{'$or':_[_0x5f48('0x2f')](_0x3ddd8e['attributes'],function(_0x3fd369){var _0x4cecf2={};_0x4cecf2[_0x3fd369]={'$like':'%'+_0x26d068['query']['filter']+'%'};return _0x4cecf2;})});}_0x3ddd8e=_[_0x5f48('0x40')]({},_0x3ddd8e,_0x26d068[_0x5f48('0x4b')]);return _0x4536e6[_0x5f48('0x5c')](_0x3ddd8e);}})[_0x5f48('0x27')](function(_0x504e1d){if(_0x504e1d){_0x512c0a=_0x504e1d[_0x5f48('0x37')];if(!_0x26d068['query'][_0x5f48('0x38')](_0x5f48('0x39'))){_0x3ddd8e[_0x5f48('0x20')]=qs[_0x5f48('0x20')](_0x26d068['query']['limit']);_0x3ddd8e[_0x5f48('0x1e')]=qs['offset'](_0x26d068[_0x5f48('0x31')][_0x5f48('0x1e')]);}return _0x4536e6['getAnyConditions'](_0x3ddd8e);}})[_0x5f48('0x27')](function(_0x5578c6){if(_0x5578c6){return _0x5578c6?{'count':_0x512c0a,'rows':_0x5578c6}:null;}})[_0x5f48('0x27')](respondWithResult(_0x3ece7a,null))[_0x5f48('0x46')](handleError(_0x3ece7a,null));};exports['addAction']=function(_0x5bf785,_0x27b615,_0x2f0f21){if(_0x5bf785[_0x5f48('0x55')]['id']){delete _0x5bf785[_0x5f48('0x55')]['id'];}return db[_0x5f48('0x42')][_0x5f48('0x4c')]({'where':{'id':_0x5bf785[_0x5f48('0x48')]['id']}})[_0x5f48('0x27')](handleEntityNotFound(_0x27b615,null))[_0x5f48('0x27')](function(_0xec4fad){if(_0xec4fad){_0x5bf785[_0x5f48('0x55')][_0x5f48('0x5d')]=_0xec4fad['id'];return db[_0x5f48('0x5e')][_0x5f48('0x4d')](_0x5bf785[_0x5f48('0x55')]);}})[_0x5f48('0x27')](respondWithResult(_0x27b615,null))[_0x5f48('0x46')](handleError(_0x27b615,null));};exports[_0x5f48('0x5f')]=function(_0x2dcfdd,_0x2afa6b,_0x3e0a76){var _0x43ce9c={};var _0x24368e={};var _0x57d721;var _0x24dda6;return db[_0x5f48('0x42')][_0x5f48('0x5a')]({'where':{'id':_0x2dcfdd[_0x5f48('0x48')]['id']}})[_0x5f48('0x27')](handleEntityNotFound(_0x2afa6b,null))[_0x5f48('0x27')](function(_0x1c9a95){if(_0x1c9a95){_0x57d721=_0x1c9a95;_0x24368e[_0x5f48('0x34')]=_['keys'](db['Action'][_0x5f48('0x49')]);_0x24368e[_0x5f48('0x31')]=_[_0x5f48('0x32')](_0x2dcfdd[_0x5f48('0x31')]);_0x24368e['filters']=_[_0x5f48('0x33')](_0x24368e['model'],_0x24368e[_0x5f48('0x31')]);_0x43ce9c['attributes']=_[_0x5f48('0x33')](_0x24368e['model'],qs['fields'](_0x2dcfdd[_0x5f48('0x31')][_0x5f48('0x36')]));_0x43ce9c[_0x5f48('0x35')]=_0x43ce9c['attributes'][_0x5f48('0x37')]?_0x43ce9c[_0x5f48('0x35')]:_0x24368e[_0x5f48('0x34')];_0x43ce9c['order']=qs[_0x5f48('0x3b')](_0x2dcfdd[_0x5f48('0x31')][_0x5f48('0x3b')]);_0x43ce9c[_0x5f48('0x3c')]=qs[_0x5f48('0x3d')](_[_0x5f48('0x3e')](_0x2dcfdd[_0x5f48('0x31')],_0x24368e['filters']));if(_0x2dcfdd['query']['filter']){_0x43ce9c[_0x5f48('0x3c')]=_['merge'](_0x43ce9c[_0x5f48('0x3c')],{'$or':_[_0x5f48('0x2f')](_0x43ce9c[_0x5f48('0x35')],function(_0x57b0a1){var _0x693f38={};_0x693f38[_0x57b0a1]={'$like':'%'+_0x2dcfdd[_0x5f48('0x31')][_0x5f48('0x3f')]+'%'};return _0x693f38;})});}_0x43ce9c=_['merge']({},_0x43ce9c,_0x2dcfdd['options']);return _0x57d721[_0x5f48('0x5f')](_0x43ce9c);}})[_0x5f48('0x27')](function(_0x33d3cd){if(_0x33d3cd){_0x24dda6=_0x33d3cd['length'];if(!_0x2dcfdd[_0x5f48('0x31')][_0x5f48('0x38')](_0x5f48('0x39'))){_0x43ce9c['limit']=qs['limit'](_0x2dcfdd[_0x5f48('0x31')]['limit']);_0x43ce9c[_0x5f48('0x1e')]=qs[_0x5f48('0x1e')](_0x2dcfdd[_0x5f48('0x31')][_0x5f48('0x1e')]);}return _0x57d721['getActions'](_0x43ce9c);}})[_0x5f48('0x27')](function(_0x37dfde){if(_0x37dfde){return _0x37dfde?{'count':_0x24dda6,'rows':_0x37dfde}:null;}})['then'](respondWithResult(_0x2afa6b,null))[_0x5f48('0x46')](handleError(_0x2afa6b,null));};