Built motion from commit (unavailable).|2.6.0
[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 _0x9f1b=['squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','apply','reject','save','update','destroy','then','error','stack','send','body','find','params','catch','Action','rimraf','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','lodash'];(function(_0x36433c,_0x4fcfe5){var _0x1aa57d=function(_0x1cb56d){while(--_0x1cb56d){_0x36433c['push'](_0x36433c['shift']());}};_0x1aa57d(++_0x4fcfe5);}(_0x9f1b,0xbd));var _0xb9f1=function(_0x49543f,_0x30772d){_0x49543f=_0x49543f-0x0;var _0x228073=_0x9f1b[_0x49543f];return _0x228073;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xb9f1('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0xb9f1('0x1'));var rp=require(_0xb9f1('0x2'));var moment=require('moment');var BPromise=require(_0xb9f1('0x3'));var Mustache=require(_0xb9f1('0x4'));var util=require(_0xb9f1('0x5'));var path=require(_0xb9f1('0x6'));var sox=require(_0xb9f1('0x7'));var csv=require(_0xb9f1('0x8'));var ejs=require(_0xb9f1('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xb9f1('0xa'));var squel=require(_0xb9f1('0xb'));var crypto=require(_0xb9f1('0xc'));var jsforce=require(_0xb9f1('0xd'));var deskjs=require(_0xb9f1('0xe'));var toCsv=require(_0xb9f1('0x8'));var querystring=require(_0xb9f1('0xf'));var Papa=require(_0xb9f1('0x10'));var Redis=require('ioredis');var authService=require(_0xb9f1('0x11'));var qs=require(_0xb9f1('0x12'));var as=require(_0xb9f1('0x13'));var hardwareService=require(_0xb9f1('0x14'));var logger=require(_0xb9f1('0x15'))(_0xb9f1('0x16'));var utils=require(_0xb9f1('0x17'));var config=require(_0xb9f1('0x18'));var licenseUtil=require(_0xb9f1('0x19'));var db=require(_0xb9f1('0x1a'))['db'];function respondWithStatusCode(_0x2206dd,_0x53f617){_0x53f617=_0x53f617||0xcc;return function(_0x86c04){if(_0x86c04){return _0x2206dd[_0xb9f1('0x1b')](_0x53f617);}return _0x2206dd[_0xb9f1('0x1c')](_0x53f617)[_0xb9f1('0x1d')]();};}function respondWithResult(_0xf54090,_0x4960b4){_0x4960b4=_0x4960b4||0xc8;return function(_0x350add){if(_0x350add){return _0xf54090['status'](_0x4960b4)[_0xb9f1('0x1e')](_0x350add);}};}function respondWithFilteredResult(_0x54edaa,_0xfbf69b){return function(_0x3078a5){if(_0x3078a5){var _0x25e2df=typeof _0xfbf69b['offset']===_0xb9f1('0x1f')&&typeof _0xfbf69b[_0xb9f1('0x20')]==='undefined';var _0x53e6e6=_0x3078a5[_0xb9f1('0x21')];var _0x5b29d8=_0x25e2df?0x0:_0xfbf69b[_0xb9f1('0x22')];var _0x28936c=_0x25e2df?_0x3078a5[_0xb9f1('0x21')]:_0xfbf69b['offset']+_0xfbf69b[_0xb9f1('0x20')];var _0x1f1b73;if(_0x28936c>=_0x53e6e6){_0x28936c=_0x53e6e6;_0x1f1b73=0xc8;}else{_0x1f1b73=0xce;}_0x54edaa[_0xb9f1('0x1c')](_0x1f1b73);return _0x54edaa[_0xb9f1('0x23')]('Content-Range',_0x5b29d8+'-'+_0x28936c+'/'+_0x53e6e6)[_0xb9f1('0x1e')](_0x3078a5);}return null;};}function patchUpdates(_0xf06cf0){return function(_0x2db88b){try{jsonpatch[_0xb9f1('0x24')](_0x2db88b,_0xf06cf0,!![]);}catch(_0x2bb540){return BPromise[_0xb9f1('0x25')](_0x2bb540);}return _0x2db88b[_0xb9f1('0x26')]();};}function saveUpdates(_0x4646a0,_0x59b0a0){return function(_0x158dc3){if(_0x158dc3){return _0x158dc3[_0xb9f1('0x27')](_0x4646a0)['then'](function(_0x197b4c){return _0x197b4c;});}return null;};}function removeEntity(_0x21ad00,_0x4e9935){return function(_0x422f80){if(_0x422f80){return _0x422f80[_0xb9f1('0x28')]()[_0xb9f1('0x29')](function(){_0x21ad00['status'](0xcc)[_0xb9f1('0x1d')]();});}};}function handleEntityNotFound(_0x1c0c9d,_0x5bbd52){return function(_0x231ad4){if(!_0x231ad4){_0x1c0c9d['sendStatus'](0x194);}return _0x231ad4;};}function handleError(_0x5e88d3,_0x18d283){_0x18d283=_0x18d283||0x1f4;return function(_0x5793dc){logger[_0xb9f1('0x2a')](_0x5793dc[_0xb9f1('0x2b')]);if(_0x5793dc['name']){delete _0x5793dc['name'];}_0x5e88d3[_0xb9f1('0x1c')](_0x18d283)[_0xb9f1('0x2c')](_0x5793dc);};}exports[_0xb9f1('0x27')]=function(_0x89ad8d,_0x2313bf){if(_0x89ad8d[_0xb9f1('0x2d')]['id']){delete _0x89ad8d[_0xb9f1('0x2d')]['id'];}return db['Action'][_0xb9f1('0x2e')]({'where':{'id':_0x89ad8d[_0xb9f1('0x2f')]['id']}})[_0xb9f1('0x29')](handleEntityNotFound(_0x2313bf,null))[_0xb9f1('0x29')](saveUpdates(_0x89ad8d[_0xb9f1('0x2d')],null))[_0xb9f1('0x29')](respondWithResult(_0x2313bf,null))[_0xb9f1('0x30')](handleError(_0x2313bf,null));};exports[_0xb9f1('0x28')]=function(_0x46e274,_0x1f3d37){return db[_0xb9f1('0x31')][_0xb9f1('0x2e')]({'where':{'id':_0x46e274['params']['id']}})[_0xb9f1('0x29')](handleEntityNotFound(_0x1f3d37,null))[_0xb9f1('0x29')](removeEntity(_0x1f3d37,null))[_0xb9f1('0x30')](handleError(_0x1f3d37,null));};