08406d37ba996819c26b6864c53b5c481f4c5c9b
[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 _0xb3c8=['papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','count','set','apply','reject','save','update','destroy','then','name','send','body','Action','find','params','catch','eml-format','zip-dir','request-promise','moment','mustache','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring'];(function(_0x352e09,_0x37a7da){var _0x1b7094=function(_0x561074){while(--_0x561074){_0x352e09['push'](_0x352e09['shift']());}};_0x1b7094(++_0x37a7da);}(_0xb3c8,0x13a));var _0x8b3c=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0xb3c8[_0x19e35c];return _0x3e1fe8;};'use strict';var emlformat=require(_0x8b3c('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x8b3c('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x8b3c('0x2'));var moment=require(_0x8b3c('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x8b3c('0x4'));var util=require(_0x8b3c('0x5'));var path=require(_0x8b3c('0x6'));var sox=require('sox');var csv=require(_0x8b3c('0x7'));var ejs=require(_0x8b3c('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x8b3c('0x9'));var squel=require(_0x8b3c('0xa'));var crypto=require(_0x8b3c('0xb'));var jsforce=require(_0x8b3c('0xc'));var deskjs=require(_0x8b3c('0xd'));var toCsv=require(_0x8b3c('0x7'));var querystring=require(_0x8b3c('0xe'));var Papa=require(_0x8b3c('0xf'));var Redis=require(_0x8b3c('0x10'));var authService=require(_0x8b3c('0x11'));var qs=require(_0x8b3c('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x8b3c('0x13'));var logger=require(_0x8b3c('0x14'))(_0x8b3c('0x15'));var utils=require(_0x8b3c('0x16'));var config=require(_0x8b3c('0x17'));var licenseUtil=require(_0x8b3c('0x18'));var db=require(_0x8b3c('0x19'))['db'];function respondWithStatusCode(_0x9a6637,_0x2fd8ba){_0x2fd8ba=_0x2fd8ba||0xcc;return function(_0x146e8e){if(_0x146e8e){return _0x9a6637[_0x8b3c('0x1a')](_0x2fd8ba);}return _0x9a6637[_0x8b3c('0x1b')](_0x2fd8ba)[_0x8b3c('0x1c')]();};}function respondWithResult(_0x432daf,_0x52e0be){_0x52e0be=_0x52e0be||0xc8;return function(_0x7180c9){if(_0x7180c9){return _0x432daf[_0x8b3c('0x1b')](_0x52e0be)[_0x8b3c('0x1d')](_0x7180c9);}};}function respondWithFilteredResult(_0x36e94b,_0x3bb2e5){return function(_0x5b7b19){if(_0x5b7b19){var _0x4ab435=typeof _0x3bb2e5[_0x8b3c('0x1e')]==='undefined'&&typeof _0x3bb2e5[_0x8b3c('0x1f')]==='undefined';var _0x302e40=_0x5b7b19[_0x8b3c('0x20')];var _0x145c61=_0x4ab435?0x0:_0x3bb2e5[_0x8b3c('0x1e')];var _0x5215c9=_0x4ab435?_0x5b7b19[_0x8b3c('0x20')]:_0x3bb2e5['offset']+_0x3bb2e5['limit'];var _0x21c201;if(_0x5215c9>=_0x302e40){_0x5215c9=_0x302e40;_0x21c201=0xc8;}else{_0x21c201=0xce;}_0x36e94b[_0x8b3c('0x1b')](_0x21c201);return _0x36e94b[_0x8b3c('0x21')]('Content-Range',_0x145c61+'-'+_0x5215c9+'/'+_0x302e40)[_0x8b3c('0x1d')](_0x5b7b19);}return null;};}function patchUpdates(_0x118188){return function(_0x30d760){try{jsonpatch[_0x8b3c('0x22')](_0x30d760,_0x118188,!![]);}catch(_0x3e276f){return BPromise[_0x8b3c('0x23')](_0x3e276f);}return _0x30d760[_0x8b3c('0x24')]();};}function saveUpdates(_0x20881c,_0x6ec134){return function(_0x4423be){if(_0x4423be){return _0x4423be[_0x8b3c('0x25')](_0x20881c)['then'](function(_0x230c44){return _0x230c44;});}return null;};}function removeEntity(_0x2b8e0d,_0x1b4570){return function(_0x7221a1){if(_0x7221a1){return _0x7221a1[_0x8b3c('0x26')]()[_0x8b3c('0x27')](function(){_0x2b8e0d[_0x8b3c('0x1b')](0xcc)[_0x8b3c('0x1c')]();});}};}function handleEntityNotFound(_0x402267,_0x30f87f){return function(_0x2bfb9b){if(!_0x2bfb9b){_0x402267[_0x8b3c('0x1a')](0x194);}return _0x2bfb9b;};}function handleError(_0x36e11e,_0x13822e){_0x13822e=_0x13822e||0x1f4;return function(_0x4c6b61){logger['error'](_0x4c6b61['stack']);if(_0x4c6b61[_0x8b3c('0x28')]){delete _0x4c6b61[_0x8b3c('0x28')];}_0x36e11e['status'](_0x13822e)[_0x8b3c('0x29')](_0x4c6b61);};}exports[_0x8b3c('0x25')]=function(_0x228cb5,_0x27a133){if(_0x228cb5[_0x8b3c('0x2a')]['id']){delete _0x228cb5[_0x8b3c('0x2a')]['id'];}return db[_0x8b3c('0x2b')][_0x8b3c('0x2c')]({'where':{'id':_0x228cb5[_0x8b3c('0x2d')]['id']}})[_0x8b3c('0x27')](handleEntityNotFound(_0x27a133,null))['then'](saveUpdates(_0x228cb5[_0x8b3c('0x2a')],null))[_0x8b3c('0x27')](respondWithResult(_0x27a133,null))[_0x8b3c('0x2e')](handleError(_0x27a133,null));};exports[_0x8b3c('0x26')]=function(_0x44e088,_0x1932b8){return db[_0x8b3c('0x2b')][_0x8b3c('0x2c')]({'where':{'id':_0x44e088[_0x8b3c('0x2d')]['id']}})[_0x8b3c('0x27')](handleEntityNotFound(_0x1932b8,null))[_0x8b3c('0x27')](removeEntity(_0x1932b8,null))['catch'](handleError(_0x1932b8,null));};