Built motion from commit (unavailable).|2.5.31
[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 _0x0bf7=['where','options','include','rows','catch','show','includeAll','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addAllCondition','TriggerAllId','Condition','addAnyCondition','TriggerAnyId','getAllConditions','findOne','order','pick','getAnyConditions','addAction','TriggerId','Action','getActions','eml-format','zip-dir','request-promise','bluebird','util','path','sox','to-csv','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','limit','count','set','apply','save','update','then','destroy','get','Triggers','UserProfileResource','end','error','stack','name','send','render','merge','body','contact','message','agent','interaction','account','index','Trigger','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','length','attributes','hasOwnProperty','nolimit','sort','filter'];(function(_0x4715d2,_0x3371b2){var _0x141811=function(_0x520bc6){while(--_0x520bc6){_0x4715d2['push'](_0x4715d2['shift']());}};_0x141811(++_0x3371b2);}(_0x0bf7,0xea));var _0x70bf=function(_0x5f0e7a,_0x2d9474){_0x5f0e7a=_0x5f0e7a-0x0;var _0x47e9ea=_0x0bf7[_0x5f0e7a];return _0x47e9ea;};'use strict';var emlformat=require(_0x70bf('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x70bf('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x70bf('0x2'));var moment=require('moment');var BPromise=require(_0x70bf('0x3'));var Mustache=require('mustache');var util=require(_0x70bf('0x4'));var path=require(_0x70bf('0x5'));var sox=require(_0x70bf('0x6'));var csv=require(_0x70bf('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x70bf('0x8'));var squel=require(_0x70bf('0x9'));var crypto=require(_0x70bf('0xa'));var jsforce=require(_0x70bf('0xb'));var deskjs=require(_0x70bf('0xc'));var toCsv=require('to-csv');var querystring=require(_0x70bf('0xd'));var Papa=require(_0x70bf('0xe'));var Redis=require(_0x70bf('0xf'));var authService=require(_0x70bf('0x10'));var qs=require(_0x70bf('0x11'));var as=require(_0x70bf('0x12'));var hardwareService=require(_0x70bf('0x13'));var logger=require(_0x70bf('0x14'))(_0x70bf('0x15'));var utils=require('../../config/utils');var config=require(_0x70bf('0x16'));var licenseUtil=require(_0x70bf('0x17'));var db=require(_0x70bf('0x18'))['db'];function respondWithStatusCode(_0x8b3205,_0x5c4a65){_0x5c4a65=_0x5c4a65||0xcc;return function(_0x4e9316){if(_0x4e9316){return _0x8b3205[_0x70bf('0x19')](_0x5c4a65);}return _0x8b3205[_0x70bf('0x1a')](_0x5c4a65)['end']();};}function respondWithResult(_0x45c79a,_0x476bc7){_0x476bc7=_0x476bc7||0xc8;return function(_0x4be9e2){if(_0x4be9e2){return _0x45c79a['status'](_0x476bc7)[_0x70bf('0x1b')](_0x4be9e2);}};}function respondWithFilteredResult(_0x3fadb8,_0x753d17){return function(_0x18abe0){if(_0x18abe0){var _0x2ffe41=typeof _0x753d17[_0x70bf('0x1c')]==='undefined'&&typeof _0x753d17[_0x70bf('0x1d')]==='undefined';var _0x220724=_0x18abe0[_0x70bf('0x1e')];var _0x94fdba=_0x2ffe41?0x0:_0x753d17[_0x70bf('0x1c')];var _0x3e63bc=_0x2ffe41?_0x18abe0[_0x70bf('0x1e')]:_0x753d17['offset']+_0x753d17['limit'];var _0x1618f6;if(_0x3e63bc>=_0x220724){_0x3e63bc=_0x220724;_0x1618f6=0xc8;}else{_0x1618f6=0xce;}_0x3fadb8[_0x70bf('0x1a')](_0x1618f6);return _0x3fadb8[_0x70bf('0x1f')]('Content-Range',_0x94fdba+'-'+_0x3e63bc+'/'+_0x220724)[_0x70bf('0x1b')](_0x18abe0);}return null;};}function patchUpdates(_0x1d7714){return function(_0x30c6a8){try{jsonpatch[_0x70bf('0x20')](_0x30c6a8,_0x1d7714,!![]);}catch(_0x12ce64){return BPromise['reject'](_0x12ce64);}return _0x30c6a8[_0x70bf('0x21')]();};}function saveUpdates(_0x2a7333,_0x49a9fb){return function(_0x20b8c9){if(_0x20b8c9){return _0x20b8c9[_0x70bf('0x22')](_0x2a7333)[_0x70bf('0x23')](function(_0x5874fe){return _0x5874fe;});}return null;};}function removeEntity(_0x59521f,_0xbe22b1){return function(_0x265fd8){if(_0x265fd8){return _0x265fd8[_0x70bf('0x24')]()['then'](function(){var _0x4f49f6=_0x265fd8[_0x70bf('0x25')]({'plain':!![]});var _0x1bfeca=_0x70bf('0x26');return db[_0x70bf('0x27')][_0x70bf('0x24')]({'where':{'type':_0x1bfeca,'resourceId':_0x4f49f6['id']}})[_0x70bf('0x23')](function(){return _0x265fd8;});})[_0x70bf('0x23')](function(){_0x59521f[_0x70bf('0x1a')](0xcc)[_0x70bf('0x28')]();});}};}function handleEntityNotFound(_0x143302,_0x3ac055){return function(_0x4fd4d4){if(!_0x4fd4d4){_0x143302[_0x70bf('0x19')](0x194);}return _0x4fd4d4;};}function handleError(_0x4a7d50,_0x39a948){_0x39a948=_0x39a948||0x1f4;return function(_0x13318a){logger[_0x70bf('0x29')](_0x13318a[_0x70bf('0x2a')]);if(_0x13318a[_0x70bf('0x2b')]){delete _0x13318a[_0x70bf('0x2b')];}_0x4a7d50[_0x70bf('0x1a')](_0x39a948)[_0x70bf('0x2c')](_0x13318a);};}function getMustacheRender(_0x500fa9,_0x2e0218){return Mustache[_0x70bf('0x2d')](_0x500fa9,_[_0x70bf('0x2e')](_0x2e0218[_0x70bf('0x2f')],{'contact':_0x2e0218[_0x70bf('0x30')],'message':_0x2e0218[_0x70bf('0x31')],'agent':_0x2e0218[_0x70bf('0x32')],'interaction':_0x2e0218[_0x70bf('0x33')],'account':_0x2e0218[_0x70bf('0x34')]}))||'';}exports[_0x70bf('0x35')]=function(_0x28bf8b,_0x455a54){var _0x335a9e={},_0x1bdb73={},_0x5118fc={'count':0x0,'rows':[]};var _0x5ba575=_['map'](db[_0x70bf('0x36')][_0x70bf('0x37')],function(_0x243c19){return{'name':_0x243c19[_0x70bf('0x38')],'type':_0x243c19[_0x70bf('0x39')][_0x70bf('0x3a')]};});_0x1bdb73[_0x70bf('0x3b')]=_[_0x70bf('0x3c')](_0x5ba575,'name');_0x1bdb73[_0x70bf('0x3d')]=_[_0x70bf('0x3e')](_0x28bf8b[_0x70bf('0x3d')]);_0x1bdb73[_0x70bf('0x3f')]=_[_0x70bf('0x40')](_0x1bdb73['model'],_0x1bdb73['query']);_0x335a9e['attributes']=_[_0x70bf('0x40')](_0x1bdb73['model'],qs[_0x70bf('0x41')](_0x28bf8b[_0x70bf('0x3d')][_0x70bf('0x41')]));_0x335a9e['attributes']=_0x335a9e['attributes'][_0x70bf('0x42')]?_0x335a9e[_0x70bf('0x43')]:_0x1bdb73[_0x70bf('0x3b')];if(!_0x28bf8b['query'][_0x70bf('0x44')](_0x70bf('0x45'))){_0x335a9e['limit']=qs[_0x70bf('0x1d')](_0x28bf8b[_0x70bf('0x3d')][_0x70bf('0x1d')]);_0x335a9e[_0x70bf('0x1c')]=qs[_0x70bf('0x1c')](_0x28bf8b[_0x70bf('0x3d')][_0x70bf('0x1c')]);}_0x335a9e['order']=qs[_0x70bf('0x46')](_0x28bf8b[_0x70bf('0x3d')][_0x70bf('0x46')]);_0x335a9e['where']=qs[_0x70bf('0x3f')](_['pick'](_0x28bf8b[_0x70bf('0x3d')],_0x1bdb73[_0x70bf('0x3f')]),_0x5ba575);if(_0x28bf8b[_0x70bf('0x3d')][_0x70bf('0x47')]){_0x335a9e[_0x70bf('0x48')]=_[_0x70bf('0x2e')](_0x335a9e[_0x70bf('0x48')],{'$or':_[_0x70bf('0x3c')](_0x5ba575,function(_0x3bd9fb){if(_0x3bd9fb['type']!=='VIRTUAL'){var _0x3e8229={};_0x3e8229[_0x3bd9fb[_0x70bf('0x2b')]]={'$like':'%'+_0x28bf8b[_0x70bf('0x3d')][_0x70bf('0x47')]+'%'};return _0x3e8229;}})});}_0x335a9e=_[_0x70bf('0x2e')]({},_0x335a9e,_0x28bf8b[_0x70bf('0x49')]);var _0x3a11c5={'where':_0x335a9e[_0x70bf('0x48')]};return db[_0x70bf('0x36')][_0x70bf('0x1e')](_0x3a11c5)[_0x70bf('0x23')](function(_0x463c61){_0x5118fc[_0x70bf('0x1e')]=_0x463c61;if(_0x28bf8b[_0x70bf('0x3d')]['includeAll']){_0x335a9e[_0x70bf('0x4a')]=[{'all':!![]}];}return db[_0x70bf('0x36')]['findAll'](_0x335a9e);})[_0x70bf('0x23')](function(_0x49fd3a){_0x5118fc[_0x70bf('0x4b')]=_0x49fd3a;return _0x5118fc;})[_0x70bf('0x23')](respondWithFilteredResult(_0x455a54,_0x335a9e))[_0x70bf('0x4c')](handleError(_0x455a54,null));};exports[_0x70bf('0x4d')]=function(_0x4abc76,_0x363a33){var _0x57984f={'raw':![],'where':{'id':_0x4abc76['params']['id']}},_0x1b7810={};_0x1b7810[_0x70bf('0x3b')]=_[_0x70bf('0x3e')](db[_0x70bf('0x36')]['rawAttributes']);_0x1b7810[_0x70bf('0x3d')]=_[_0x70bf('0x3e')](_0x4abc76[_0x70bf('0x3d')]);_0x1b7810['filters']=_[_0x70bf('0x40')](_0x1b7810[_0x70bf('0x3b')],_0x1b7810[_0x70bf('0x3d')]);_0x57984f['attributes']=_[_0x70bf('0x40')](_0x1b7810[_0x70bf('0x3b')],qs['fields'](_0x4abc76[_0x70bf('0x3d')][_0x70bf('0x41')]));_0x57984f[_0x70bf('0x43')]=_0x57984f[_0x70bf('0x43')][_0x70bf('0x42')]?_0x57984f[_0x70bf('0x43')]:_0x1b7810[_0x70bf('0x3b')];if(_0x4abc76[_0x70bf('0x3d')][_0x70bf('0x4e')]){_0x57984f[_0x70bf('0x4a')]=[{'all':!![]}];}_0x57984f=_[_0x70bf('0x2e')]({},_0x57984f,_0x4abc76[_0x70bf('0x49')]);return db['Trigger'][_0x70bf('0x4f')](_0x57984f)[_0x70bf('0x23')](handleEntityNotFound(_0x363a33,null))[_0x70bf('0x23')](respondWithResult(_0x363a33,null))[_0x70bf('0x4c')](handleError(_0x363a33,null));};exports[_0x70bf('0x50')]=function(_0x401286,_0xf13c78){return db['Trigger'][_0x70bf('0x50')](_0x401286[_0x70bf('0x2f')],{})[_0x70bf('0x23')](function(_0x106536){var _0x1d62d3=_0x401286[_0x70bf('0x51')]['get']({'plain':!![]});if(!_0x1d62d3)throw new Error(_0x70bf('0x52'));if(_0x1d62d3[_0x70bf('0x53')]===_0x70bf('0x51')){var _0x5389f4=_0x106536[_0x70bf('0x25')]({'plain':!![]});var _0x2a0838=_0x70bf('0x26');return db[_0x70bf('0x54')][_0x70bf('0x4f')]({'where':{'name':_0x2a0838,'userProfileId':_0x1d62d3['userProfileId']},'raw':!![]})[_0x70bf('0x23')](function(_0x2ee79d){if(_0x2ee79d&&_0x2ee79d[_0x70bf('0x55')]===0x0){return db[_0x70bf('0x27')][_0x70bf('0x50')]({'name':_0x5389f4[_0x70bf('0x2b')],'resourceId':_0x5389f4['id'],'type':_0x2ee79d[_0x70bf('0x2b')],'sectionId':_0x2ee79d['id']},{})[_0x70bf('0x23')](function(){return _0x106536;});}else{return _0x106536;}})[_0x70bf('0x4c')](function(_0x573e1f){logger[_0x70bf('0x29')](_0x70bf('0x56'),_0x573e1f);throw _0x573e1f;});}return _0x106536;})[_0x70bf('0x23')](respondWithResult(_0xf13c78,0xc9))['catch'](handleError(_0xf13c78,null));};exports[_0x70bf('0x22')]=function(_0x43a407,_0x454e98){if(_0x43a407[_0x70bf('0x2f')]['id']){delete _0x43a407[_0x70bf('0x2f')]['id'];}return db[_0x70bf('0x36')][_0x70bf('0x4f')]({'where':{'id':_0x43a407['params']['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x454e98,null))[_0x70bf('0x23')](saveUpdates(_0x43a407['body'],null))[_0x70bf('0x23')](respondWithResult(_0x454e98,null))['catch'](handleError(_0x454e98,null));};exports['destroy']=function(_0x3f67e2,_0x4d8169){return db[_0x70bf('0x36')][_0x70bf('0x4f')]({'where':{'id':_0x3f67e2[_0x70bf('0x57')]['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x4d8169,null))[_0x70bf('0x23')](removeEntity(_0x4d8169,null))[_0x70bf('0x4c')](handleError(_0x4d8169,null));};exports[_0x70bf('0x58')]=function(_0x3da9b6,_0x5e7d39,_0x29975a){if(_0x3da9b6[_0x70bf('0x2f')]['id']){delete _0x3da9b6['body']['id'];}return db[_0x70bf('0x36')][_0x70bf('0x4f')]({'where':{'id':_0x3da9b6[_0x70bf('0x57')]['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x5e7d39,null))['then'](function(_0x5b8128){if(_0x5b8128){_0x3da9b6['body'][_0x70bf('0x59')]=_0x5b8128['id'];return db[_0x70bf('0x5a')][_0x70bf('0x50')](_0x3da9b6[_0x70bf('0x2f')]);}})['then'](respondWithResult(_0x5e7d39,null))['catch'](handleError(_0x5e7d39,null));};exports[_0x70bf('0x5b')]=function(_0x1a504,_0x116031,_0x5df20d){if(_0x1a504[_0x70bf('0x2f')]['id']){delete _0x1a504['body']['id'];}return db['Trigger'][_0x70bf('0x4f')]({'where':{'id':_0x1a504[_0x70bf('0x57')]['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x116031,null))[_0x70bf('0x23')](function(_0x572de6){if(_0x572de6){_0x1a504[_0x70bf('0x2f')][_0x70bf('0x5c')]=_0x572de6['id'];return db['Condition'][_0x70bf('0x50')](_0x1a504[_0x70bf('0x2f')]);}})['then'](respondWithResult(_0x116031,null))[_0x70bf('0x4c')](handleError(_0x116031,null));};exports[_0x70bf('0x5d')]=function(_0x5e42a8,_0x5a48dd,_0x104562){var _0x577452={};var _0x44e179={};var _0x6149d4;var _0x4cc2c0;return db[_0x70bf('0x36')][_0x70bf('0x5e')]({'where':{'id':_0x5e42a8['params']['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x5a48dd,null))[_0x70bf('0x23')](function(_0x5022f3){if(_0x5022f3){_0x6149d4=_0x5022f3;_0x44e179[_0x70bf('0x3b')]=_['keys'](db[_0x70bf('0x5a')][_0x70bf('0x37')]);_0x44e179['query']=_[_0x70bf('0x3e')](_0x5e42a8[_0x70bf('0x3d')]);_0x44e179[_0x70bf('0x3f')]=_[_0x70bf('0x40')](_0x44e179[_0x70bf('0x3b')],_0x44e179[_0x70bf('0x3d')]);_0x577452['attributes']=_[_0x70bf('0x40')](_0x44e179[_0x70bf('0x3b')],qs['fields'](_0x5e42a8[_0x70bf('0x3d')][_0x70bf('0x41')]));_0x577452[_0x70bf('0x43')]=_0x577452[_0x70bf('0x43')]['length']?_0x577452['attributes']:_0x44e179[_0x70bf('0x3b')];_0x577452[_0x70bf('0x5f')]=qs['sort'](_0x5e42a8[_0x70bf('0x3d')]['sort']);_0x577452[_0x70bf('0x48')]=qs[_0x70bf('0x3f')](_[_0x70bf('0x60')](_0x5e42a8[_0x70bf('0x3d')],_0x44e179[_0x70bf('0x3f')]));if(_0x5e42a8[_0x70bf('0x3d')][_0x70bf('0x47')]){_0x577452[_0x70bf('0x48')]=_[_0x70bf('0x2e')](_0x577452['where'],{'$or':_['map'](_0x577452['attributes'],function(_0x58db54){var _0x473e18={};_0x473e18[_0x58db54]={'$like':'%'+_0x5e42a8[_0x70bf('0x3d')][_0x70bf('0x47')]+'%'};return _0x473e18;})});}_0x577452=_[_0x70bf('0x2e')]({},_0x577452,_0x5e42a8[_0x70bf('0x49')]);return _0x6149d4[_0x70bf('0x5d')](_0x577452);}})['then'](function(_0x48d873){if(_0x48d873){_0x4cc2c0=_0x48d873[_0x70bf('0x42')];if(!_0x5e42a8[_0x70bf('0x3d')]['hasOwnProperty'](_0x70bf('0x45'))){_0x577452['limit']=qs[_0x70bf('0x1d')](_0x5e42a8['query']['limit']);_0x577452['offset']=qs[_0x70bf('0x1c')](_0x5e42a8[_0x70bf('0x3d')]['offset']);}return _0x6149d4[_0x70bf('0x5d')](_0x577452);}})[_0x70bf('0x23')](function(_0x3a5127){if(_0x3a5127){return _0x3a5127?{'count':_0x4cc2c0,'rows':_0x3a5127}:null;}})[_0x70bf('0x23')](respondWithResult(_0x5a48dd,null))[_0x70bf('0x4c')](handleError(_0x5a48dd,null));};exports[_0x70bf('0x61')]=function(_0x157308,_0x29df3b,_0x24d345){var _0x2325ea={};var _0x4c7160={};var _0x23619f;var _0x449a35;return db[_0x70bf('0x36')][_0x70bf('0x5e')]({'where':{'id':_0x157308[_0x70bf('0x57')]['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x29df3b,null))['then'](function(_0x335785){if(_0x335785){_0x23619f=_0x335785;_0x4c7160[_0x70bf('0x3b')]=_[_0x70bf('0x3e')](db[_0x70bf('0x5a')][_0x70bf('0x37')]);_0x4c7160[_0x70bf('0x3d')]=_[_0x70bf('0x3e')](_0x157308['query']);_0x4c7160[_0x70bf('0x3f')]=_[_0x70bf('0x40')](_0x4c7160[_0x70bf('0x3b')],_0x4c7160[_0x70bf('0x3d')]);_0x2325ea[_0x70bf('0x43')]=_[_0x70bf('0x40')](_0x4c7160[_0x70bf('0x3b')],qs[_0x70bf('0x41')](_0x157308['query']['fields']));_0x2325ea['attributes']=_0x2325ea[_0x70bf('0x43')][_0x70bf('0x42')]?_0x2325ea[_0x70bf('0x43')]:_0x4c7160[_0x70bf('0x3b')];_0x2325ea[_0x70bf('0x5f')]=qs['sort'](_0x157308[_0x70bf('0x3d')][_0x70bf('0x46')]);_0x2325ea[_0x70bf('0x48')]=qs['filters'](_[_0x70bf('0x60')](_0x157308[_0x70bf('0x3d')],_0x4c7160[_0x70bf('0x3f')]));if(_0x157308[_0x70bf('0x3d')][_0x70bf('0x47')]){_0x2325ea['where']=_[_0x70bf('0x2e')](_0x2325ea[_0x70bf('0x48')],{'$or':_[_0x70bf('0x3c')](_0x2325ea[_0x70bf('0x43')],function(_0x2f44ac){var _0xdc82be={};_0xdc82be[_0x2f44ac]={'$like':'%'+_0x157308[_0x70bf('0x3d')][_0x70bf('0x47')]+'%'};return _0xdc82be;})});}_0x2325ea=_[_0x70bf('0x2e')]({},_0x2325ea,_0x157308['options']);return _0x23619f[_0x70bf('0x61')](_0x2325ea);}})[_0x70bf('0x23')](function(_0x33a377){if(_0x33a377){_0x449a35=_0x33a377[_0x70bf('0x42')];if(!_0x157308[_0x70bf('0x3d')][_0x70bf('0x44')](_0x70bf('0x45'))){_0x2325ea['limit']=qs['limit'](_0x157308[_0x70bf('0x3d')][_0x70bf('0x1d')]);_0x2325ea[_0x70bf('0x1c')]=qs[_0x70bf('0x1c')](_0x157308[_0x70bf('0x3d')][_0x70bf('0x1c')]);}return _0x23619f[_0x70bf('0x61')](_0x2325ea);}})[_0x70bf('0x23')](function(_0x162203){if(_0x162203){return _0x162203?{'count':_0x449a35,'rows':_0x162203}:null;}})[_0x70bf('0x23')](respondWithResult(_0x29df3b,null))[_0x70bf('0x4c')](handleError(_0x29df3b,null));};exports[_0x70bf('0x62')]=function(_0xdf10df,_0x1f5ee5,_0x522397){if(_0xdf10df[_0x70bf('0x2f')]['id']){delete _0xdf10df[_0x70bf('0x2f')]['id'];}return db[_0x70bf('0x36')][_0x70bf('0x4f')]({'where':{'id':_0xdf10df[_0x70bf('0x57')]['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x1f5ee5,null))[_0x70bf('0x23')](function(_0x5da91a){if(_0x5da91a){_0xdf10df[_0x70bf('0x2f')][_0x70bf('0x63')]=_0x5da91a['id'];return db[_0x70bf('0x64')]['create'](_0xdf10df[_0x70bf('0x2f')]);}})[_0x70bf('0x23')](respondWithResult(_0x1f5ee5,null))[_0x70bf('0x4c')](handleError(_0x1f5ee5,null));};exports['getActions']=function(_0x511175,_0x1e90a7,_0x4647ed){var _0x2705a0={};var _0x5996aa={};var _0x4086f5;var _0x31e1df;return db[_0x70bf('0x36')][_0x70bf('0x5e')]({'where':{'id':_0x511175[_0x70bf('0x57')]['id']}})[_0x70bf('0x23')](handleEntityNotFound(_0x1e90a7,null))[_0x70bf('0x23')](function(_0x18d21a){if(_0x18d21a){_0x4086f5=_0x18d21a;_0x5996aa[_0x70bf('0x3b')]=_[_0x70bf('0x3e')](db[_0x70bf('0x64')][_0x70bf('0x37')]);_0x5996aa[_0x70bf('0x3d')]=_[_0x70bf('0x3e')](_0x511175[_0x70bf('0x3d')]);_0x5996aa['filters']=_['intersection'](_0x5996aa[_0x70bf('0x3b')],_0x5996aa[_0x70bf('0x3d')]);_0x2705a0[_0x70bf('0x43')]=_[_0x70bf('0x40')](_0x5996aa[_0x70bf('0x3b')],qs[_0x70bf('0x41')](_0x511175[_0x70bf('0x3d')]['fields']));_0x2705a0['attributes']=_0x2705a0['attributes']['length']?_0x2705a0[_0x70bf('0x43')]:_0x5996aa['model'];_0x2705a0[_0x70bf('0x5f')]=qs[_0x70bf('0x46')](_0x511175['query'][_0x70bf('0x46')]);_0x2705a0['where']=qs[_0x70bf('0x3f')](_['pick'](_0x511175[_0x70bf('0x3d')],_0x5996aa['filters']));if(_0x511175[_0x70bf('0x3d')][_0x70bf('0x47')]){_0x2705a0[_0x70bf('0x48')]=_['merge'](_0x2705a0[_0x70bf('0x48')],{'$or':_['map'](_0x2705a0[_0x70bf('0x43')],function(_0x138f91){var _0xabcb59={};_0xabcb59[_0x138f91]={'$like':'%'+_0x511175[_0x70bf('0x3d')]['filter']+'%'};return _0xabcb59;})});}_0x2705a0=_[_0x70bf('0x2e')]({},_0x2705a0,_0x511175[_0x70bf('0x49')]);return _0x4086f5[_0x70bf('0x65')](_0x2705a0);}})[_0x70bf('0x23')](function(_0x269e52){if(_0x269e52){_0x31e1df=_0x269e52[_0x70bf('0x42')];if(!_0x511175['query'][_0x70bf('0x44')](_0x70bf('0x45'))){_0x2705a0[_0x70bf('0x1d')]=qs[_0x70bf('0x1d')](_0x511175['query'][_0x70bf('0x1d')]);_0x2705a0[_0x70bf('0x1c')]=qs['offset'](_0x511175['query'][_0x70bf('0x1c')]);}return _0x4086f5[_0x70bf('0x65')](_0x2705a0);}})[_0x70bf('0x23')](function(_0x1b11a6){if(_0x1b11a6){return _0x1b11a6?{'count':_0x31e1df,'rows':_0x1b11a6}:null;}})[_0x70bf('0x23')](respondWithResult(_0x1e90a7,null))[_0x70bf('0x4c')](handleError(_0x1e90a7,null));};