be1c7a54fe2ec9ab52a614350dda8522224b98a2
[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 _0x4e9f=['json','limit','undefined','count','offset','set','Content-Range','reject','save','update','then','destroy','stack','name','send','body','Action','find','params','catch','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','path','sox','to-csv','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../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'];(function(_0x4afe4c,_0x540656){var _0x18f229=function(_0x3973ed){while(--_0x3973ed){_0x4afe4c['push'](_0x4afe4c['shift']());}};_0x18f229(++_0x540656);}(_0x4e9f,0x1ac));var _0xf4e9=function(_0x51b460,_0x52e6ba){_0x51b460=_0x51b460-0x0;var _0x14652c=_0x4e9f[_0x51b460];return _0x14652c;};'use strict';var emlformat=require(_0xf4e9('0x0'));var rimraf=require(_0xf4e9('0x1'));var zipdir=require(_0xf4e9('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xf4e9('0x3'));var moment=require(_0xf4e9('0x4'));var BPromise=require(_0xf4e9('0x5'));var Mustache=require(_0xf4e9('0x6'));var util=require('util');var path=require(_0xf4e9('0x7'));var sox=require(_0xf4e9('0x8'));var csv=require(_0xf4e9('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xf4e9('0xa'));var _=require(_0xf4e9('0xb'));var squel=require(_0xf4e9('0xc'));var crypto=require(_0xf4e9('0xd'));var jsforce=require(_0xf4e9('0xe'));var deskjs=require(_0xf4e9('0xf'));var toCsv=require(_0xf4e9('0x9'));var querystring=require(_0xf4e9('0x10'));var Papa=require('papaparse');var Redis=require(_0xf4e9('0x11'));var authService=require(_0xf4e9('0x12'));var qs=require(_0xf4e9('0x13'));var as=require(_0xf4e9('0x14'));var hardwareService=require(_0xf4e9('0x15'));var logger=require(_0xf4e9('0x16'))(_0xf4e9('0x17'));var utils=require(_0xf4e9('0x18'));var config=require(_0xf4e9('0x19'));var licenseUtil=require(_0xf4e9('0x1a'));var db=require(_0xf4e9('0x1b'))['db'];function respondWithStatusCode(_0x5ed80a,_0x11eb77){_0x11eb77=_0x11eb77||0xcc;return function(_0x593606){if(_0x593606){return _0x5ed80a[_0xf4e9('0x1c')](_0x11eb77);}return _0x5ed80a[_0xf4e9('0x1d')](_0x11eb77)[_0xf4e9('0x1e')]();};}function respondWithResult(_0x59e53d,_0x559c4f){_0x559c4f=_0x559c4f||0xc8;return function(_0x2271ab){if(_0x2271ab){return _0x59e53d[_0xf4e9('0x1d')](_0x559c4f)[_0xf4e9('0x1f')](_0x2271ab);}};}function respondWithFilteredResult(_0x61dc84,_0x363345){return function(_0x46fb65){if(_0x46fb65){var _0x4d1c54=typeof _0x363345['offset']==='undefined'&&typeof _0x363345[_0xf4e9('0x20')]===_0xf4e9('0x21');var _0x1db00e=_0x46fb65[_0xf4e9('0x22')];var _0x49c68e=_0x4d1c54?0x0:_0x363345['offset'];var _0x56ad13=_0x4d1c54?_0x46fb65[_0xf4e9('0x22')]:_0x363345[_0xf4e9('0x23')]+_0x363345[_0xf4e9('0x20')];var _0xd29f07;if(_0x56ad13>=_0x1db00e){_0x56ad13=_0x1db00e;_0xd29f07=0xc8;}else{_0xd29f07=0xce;}_0x61dc84[_0xf4e9('0x1d')](_0xd29f07);return _0x61dc84[_0xf4e9('0x24')](_0xf4e9('0x25'),_0x49c68e+'-'+_0x56ad13+'/'+_0x1db00e)[_0xf4e9('0x1f')](_0x46fb65);}return null;};}function patchUpdates(_0xdcabd7){return function(_0xdfbcc8){try{jsonpatch['apply'](_0xdfbcc8,_0xdcabd7,!![]);}catch(_0x55fbc9){return BPromise[_0xf4e9('0x26')](_0x55fbc9);}return _0xdfbcc8[_0xf4e9('0x27')]();};}function saveUpdates(_0x55a43a,_0x1a375a){return function(_0x2f5af4){if(_0x2f5af4){return _0x2f5af4[_0xf4e9('0x28')](_0x55a43a)[_0xf4e9('0x29')](function(_0x4b2b90){return _0x4b2b90;});}return null;};}function removeEntity(_0x333a41,_0x235109){return function(_0x5ec049){if(_0x5ec049){return _0x5ec049[_0xf4e9('0x2a')]()['then'](function(){_0x333a41[_0xf4e9('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x391064,_0x48c303){return function(_0x406f26){if(!_0x406f26){_0x391064['sendStatus'](0x194);}return _0x406f26;};}function handleError(_0x20ec65,_0x10e6ee){_0x10e6ee=_0x10e6ee||0x1f4;return function(_0x4f54c1){logger['error'](_0x4f54c1[_0xf4e9('0x2b')]);if(_0x4f54c1['name']){delete _0x4f54c1[_0xf4e9('0x2c')];}_0x20ec65[_0xf4e9('0x1d')](_0x10e6ee)[_0xf4e9('0x2d')](_0x4f54c1);};}exports[_0xf4e9('0x28')]=function(_0x33d28e,_0x1e2453){if(_0x33d28e[_0xf4e9('0x2e')]['id']){delete _0x33d28e[_0xf4e9('0x2e')]['id'];}return db[_0xf4e9('0x2f')][_0xf4e9('0x30')]({'where':{'id':_0x33d28e[_0xf4e9('0x31')]['id']}})['then'](handleEntityNotFound(_0x1e2453,null))[_0xf4e9('0x29')](saveUpdates(_0x33d28e[_0xf4e9('0x2e')],null))['then'](respondWithResult(_0x1e2453,null))[_0xf4e9('0x32')](handleError(_0x1e2453,null));};exports[_0xf4e9('0x2a')]=function(_0x34db21,_0xed943a){return db[_0xf4e9('0x2f')][_0xf4e9('0x30')]({'where':{'id':_0x34db21[_0xf4e9('0x31')]['id']}})[_0xf4e9('0x29')](handleEntityNotFound(_0xed943a,null))[_0xf4e9('0x29')](removeEntity(_0xed943a,null))['catch'](handleError(_0xed943a,null));};