ff73626f4cbe9fa07bd174d8e83ed97107772eca
[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 _0xee3e=['sox','to-csv','ejs','fs-extra','lodash','squel','crypto','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','sendStatus','end','status','json','undefined','limit','count','offset','Content-Range','apply','reject','save','then','destroy','error','stack','name','send','body','find','params','Action','catch','eml-format','rimraf','zip-dir','fast-json-patch','moment','path'];(function(_0x1c2a50,_0x6395f9){var _0x1c0929=function(_0x5c1180){while(--_0x5c1180){_0x1c2a50['push'](_0x1c2a50['shift']());}};_0x1c0929(++_0x6395f9);}(_0xee3e,0x1aa));var _0xeee3=function(_0x4b0893,_0x22d275){_0x4b0893=_0x4b0893-0x0;var _0x1a1637=_0xee3e[_0x4b0893];return _0x1a1637;};'use strict';var emlformat=require(_0xeee3('0x0'));var rimraf=require(_0xeee3('0x1'));var zipdir=require(_0xeee3('0x2'));var jsonpatch=require(_0xeee3('0x3'));var rp=require('request-promise');var moment=require(_0xeee3('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0xeee3('0x5'));var sox=require(_0xeee3('0x6'));var csv=require(_0xeee3('0x7'));var ejs=require(_0xeee3('0x8'));var fs=require('fs');var fs_extra=require(_0xeee3('0x9'));var _=require(_0xeee3('0xa'));var squel=require(_0xeee3('0xb'));var crypto=require(_0xeee3('0xc'));var jsforce=require('jsforce');var deskjs=require(_0xeee3('0xd'));var toCsv=require(_0xeee3('0x7'));var querystring=require(_0xeee3('0xe'));var Papa=require(_0xeee3('0xf'));var Redis=require(_0xeee3('0x10'));var authService=require(_0xeee3('0x11'));var qs=require(_0xeee3('0x12'));var as=require(_0xeee3('0x13'));var hardwareService=require(_0xeee3('0x14'));var logger=require(_0xeee3('0x15'))('api');var utils=require(_0xeee3('0x16'));var config=require(_0xeee3('0x17'));var licenseUtil=require(_0xeee3('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5e3ad9,_0x301fc7){_0x301fc7=_0x301fc7||0xcc;return function(_0x560b47){if(_0x560b47){return _0x5e3ad9[_0xeee3('0x19')](_0x301fc7);}return _0x5e3ad9['status'](_0x301fc7)[_0xeee3('0x1a')]();};}function respondWithResult(_0x276dd8,_0x5d2d8c){_0x5d2d8c=_0x5d2d8c||0xc8;return function(_0x49ae40){if(_0x49ae40){return _0x276dd8[_0xeee3('0x1b')](_0x5d2d8c)[_0xeee3('0x1c')](_0x49ae40);}};}function respondWithFilteredResult(_0x1a777d,_0x42cd15){return function(_0x2f9a3a){if(_0x2f9a3a){var _0x3260bf=typeof _0x42cd15['offset']===_0xeee3('0x1d')&&typeof _0x42cd15[_0xeee3('0x1e')]==='undefined';var _0x1da5a4=_0x2f9a3a[_0xeee3('0x1f')];var _0x2a6e06=_0x3260bf?0x0:_0x42cd15[_0xeee3('0x20')];var _0x129d14=_0x3260bf?_0x2f9a3a[_0xeee3('0x1f')]:_0x42cd15['offset']+_0x42cd15[_0xeee3('0x1e')];var _0x23169f;if(_0x129d14>=_0x1da5a4){_0x129d14=_0x1da5a4;_0x23169f=0xc8;}else{_0x23169f=0xce;}_0x1a777d[_0xeee3('0x1b')](_0x23169f);return _0x1a777d['set'](_0xeee3('0x21'),_0x2a6e06+'-'+_0x129d14+'/'+_0x1da5a4)[_0xeee3('0x1c')](_0x2f9a3a);}return null;};}function patchUpdates(_0x42c74e){return function(_0x4de8e3){try{jsonpatch[_0xeee3('0x22')](_0x4de8e3,_0x42c74e,!![]);}catch(_0x267bad){return BPromise[_0xeee3('0x23')](_0x267bad);}return _0x4de8e3[_0xeee3('0x24')]();};}function saveUpdates(_0xc25a4c,_0x48a3a5){return function(_0x3c3226){if(_0x3c3226){return _0x3c3226['update'](_0xc25a4c)[_0xeee3('0x25')](function(_0x32b82e){return _0x32b82e;});}return null;};}function removeEntity(_0x4f9d4a,_0x482e30){return function(_0xac72c0){if(_0xac72c0){return _0xac72c0[_0xeee3('0x26')]()['then'](function(){_0x4f9d4a['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x161a39,_0x17a561){return function(_0x4a4079){if(!_0x4a4079){_0x161a39[_0xeee3('0x19')](0x194);}return _0x4a4079;};}function handleError(_0x5725b9,_0x33f4a8){_0x33f4a8=_0x33f4a8||0x1f4;return function(_0x13cad2){logger[_0xeee3('0x27')](_0x13cad2[_0xeee3('0x28')]);if(_0x13cad2[_0xeee3('0x29')]){delete _0x13cad2[_0xeee3('0x29')];}_0x5725b9['status'](_0x33f4a8)[_0xeee3('0x2a')](_0x13cad2);};}exports['update']=function(_0x4f3c62,_0xc925f6){if(_0x4f3c62[_0xeee3('0x2b')]['id']){delete _0x4f3c62['body']['id'];}return db['Action'][_0xeee3('0x2c')]({'where':{'id':_0x4f3c62[_0xeee3('0x2d')]['id']}})[_0xeee3('0x25')](handleEntityNotFound(_0xc925f6,null))[_0xeee3('0x25')](saveUpdates(_0x4f3c62[_0xeee3('0x2b')],null))[_0xeee3('0x25')](respondWithResult(_0xc925f6,null))['catch'](handleError(_0xc925f6,null));};exports['destroy']=function(_0x52d5e0,_0x3c6646){return db[_0xeee3('0x2e')][_0xeee3('0x2c')]({'where':{'id':_0x52d5e0['params']['id']}})[_0xeee3('0x25')](handleEntityNotFound(_0x3c6646,null))[_0xeee3('0x25')](removeEntity(_0x3c6646,null))[_0xeee3('0x2f')](handleError(_0x3c6646,null));};