95d356071b938459fcfb7ab163da58e4a5f04b45
[motion2.git] / server / api / action / action.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 _0x607c=['sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','json','offset','undefined','count','limit','Content-Range','apply','save','update','destroy','then','error','stack','name','send','body','Action','find','params','catch','zip-dir','request-promise','moment','bluebird','mustache','util'];(function(_0x26b090,_0x36eddf){var _0x39f64c=function(_0x5efac4){while(--_0x5efac4){_0x26b090['push'](_0x26b090['shift']());}};_0x39f64c(++_0x36eddf);}(_0x607c,0x84));var _0xc607=function(_0x36beb9,_0x50fb7f){_0x36beb9=_0x36beb9-0x0;var _0x112b4c=_0x607c[_0x36beb9];return _0x112b4c;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0xc607('0x0'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc607('0x1'));var moment=require(_0xc607('0x2'));var BPromise=require(_0xc607('0x3'));var Mustache=require(_0xc607('0x4'));var util=require(_0xc607('0x5'));var path=require('path');var sox=require(_0xc607('0x6'));var csv=require(_0xc607('0x7'));var ejs=require(_0xc607('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc607('0x9'));var squel=require(_0xc607('0xa'));var crypto=require(_0xc607('0xb'));var jsforce=require(_0xc607('0xc'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xc607('0xd'));var Papa=require(_0xc607('0xe'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xc607('0xf'));var as=require(_0xc607('0x10'));var hardwareService=require(_0xc607('0x11'));var logger=require(_0xc607('0x12'))(_0xc607('0x13'));var utils=require(_0xc607('0x14'));var config=require(_0xc607('0x15'));var licenseUtil=require('../../config/license/util');var db=require(_0xc607('0x16'))['db'];function respondWithStatusCode(_0x3d9b77,_0x3bb249){_0x3bb249=_0x3bb249||0xcc;return function(_0x1ef741){if(_0x1ef741){return _0x3d9b77[_0xc607('0x17')](_0x3bb249);}return _0x3d9b77['status'](_0x3bb249)[_0xc607('0x18')]();};}function respondWithResult(_0x4e2e20,_0x55103d){_0x55103d=_0x55103d||0xc8;return function(_0x524929){if(_0x524929){return _0x4e2e20[_0xc607('0x19')](_0x55103d)[_0xc607('0x1a')](_0x524929);}};}function respondWithFilteredResult(_0x43d783,_0x5a56de){return function(_0x55a986){if(_0x55a986){var _0x2c8dc4=typeof _0x5a56de[_0xc607('0x1b')]===_0xc607('0x1c')&&typeof _0x5a56de['limit']===_0xc607('0x1c');var _0x3809a0=_0x55a986[_0xc607('0x1d')];var _0x279364=_0x2c8dc4?0x0:_0x5a56de[_0xc607('0x1b')];var _0x4adb14=_0x2c8dc4?_0x55a986[_0xc607('0x1d')]:_0x5a56de['offset']+_0x5a56de[_0xc607('0x1e')];var _0x7bc2ce;if(_0x4adb14>=_0x3809a0){_0x4adb14=_0x3809a0;_0x7bc2ce=0xc8;}else{_0x7bc2ce=0xce;}_0x43d783[_0xc607('0x19')](_0x7bc2ce);return _0x43d783['set'](_0xc607('0x1f'),_0x279364+'-'+_0x4adb14+'/'+_0x3809a0)[_0xc607('0x1a')](_0x55a986);}return null;};}function patchUpdates(_0x295b11){return function(_0x88acb2){try{jsonpatch[_0xc607('0x20')](_0x88acb2,_0x295b11,!![]);}catch(_0xf22cc7){return BPromise['reject'](_0xf22cc7);}return _0x88acb2[_0xc607('0x21')]();};}function saveUpdates(_0x28fa2c,_0x312abc){return function(_0x2fedea){if(_0x2fedea){return _0x2fedea[_0xc607('0x22')](_0x28fa2c)['then'](function(_0x55c523){return _0x55c523;});}return null;};}function removeEntity(_0x1e978c,_0x2c2789){return function(_0x391d78){if(_0x391d78){return _0x391d78[_0xc607('0x23')]()[_0xc607('0x24')](function(){_0x1e978c['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x1b9448,_0x5288f1){return function(_0x18a07d){if(!_0x18a07d){_0x1b9448[_0xc607('0x17')](0x194);}return _0x18a07d;};}function handleError(_0x5fda36,_0x4e1afb){_0x4e1afb=_0x4e1afb||0x1f4;return function(_0x2e1af6){logger[_0xc607('0x25')](_0x2e1af6[_0xc607('0x26')]);if(_0x2e1af6[_0xc607('0x27')]){delete _0x2e1af6['name'];}_0x5fda36[_0xc607('0x19')](_0x4e1afb)[_0xc607('0x28')](_0x2e1af6);};}exports[_0xc607('0x22')]=function(_0x1f8ff8,_0x55f185){if(_0x1f8ff8[_0xc607('0x29')]['id']){delete _0x1f8ff8[_0xc607('0x29')]['id'];}return db[_0xc607('0x2a')][_0xc607('0x2b')]({'where':{'id':_0x1f8ff8[_0xc607('0x2c')]['id']}})[_0xc607('0x24')](handleEntityNotFound(_0x55f185,null))[_0xc607('0x24')](saveUpdates(_0x1f8ff8[_0xc607('0x29')],null))[_0xc607('0x24')](respondWithResult(_0x55f185,null))[_0xc607('0x2d')](handleError(_0x55f185,null));};exports['destroy']=function(_0x1c9243,_0x205dd4){return db[_0xc607('0x2a')][_0xc607('0x2b')]({'where':{'id':_0x1c9243['params']['id']}})[_0xc607('0x24')](handleEntityNotFound(_0x205dd4,null))['then'](removeEntity(_0x205dd4,null))[_0xc607('0x2d')](handleError(_0x205dd4,null));};