d179da5a78fcf5a0d21ba692d7016635d76930b4
[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 _0xd1f9=['lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','count','offset','limit','set','apply','save','then','destroy','end','error','name','send','update','body','Action','find','params','catch','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs'];(function(_0x36b22c,_0x57f816){var _0x254697=function(_0x5277f7){while(--_0x5277f7){_0x36b22c['push'](_0x36b22c['shift']());}};_0x254697(++_0x57f816);}(_0xd1f9,0x88));var _0x9d1f=function(_0x390a19,_0x5dd137){_0x390a19=_0x390a19-0x0;var _0x5d8230=_0xd1f9[_0x390a19];return _0x5d8230;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0x9d1f('0x0'));var zipdir=require(_0x9d1f('0x1'));var jsonpatch=require(_0x9d1f('0x2'));var rp=require(_0x9d1f('0x3'));var moment=require(_0x9d1f('0x4'));var BPromise=require(_0x9d1f('0x5'));var Mustache=require(_0x9d1f('0x6'));var util=require(_0x9d1f('0x7'));var path=require(_0x9d1f('0x8'));var sox=require('sox');var csv=require(_0x9d1f('0x9'));var ejs=require(_0x9d1f('0xa'));var fs=require('fs');var _=require(_0x9d1f('0xb'));var squel=require(_0x9d1f('0xc'));var crypto=require(_0x9d1f('0xd'));var jsforce=require(_0x9d1f('0xe'));var deskjs=require(_0x9d1f('0xf'));var toCsv=require(_0x9d1f('0x9'));var querystring=require(_0x9d1f('0x10'));var Papa=require(_0x9d1f('0x11'));var Redis=require(_0x9d1f('0x12'));var authService=require(_0x9d1f('0x13'));var qs=require(_0x9d1f('0x14'));var as=require(_0x9d1f('0x15'));var hardwareService=require(_0x9d1f('0x16'));var logger=require(_0x9d1f('0x17'))(_0x9d1f('0x18'));var utils=require(_0x9d1f('0x19'));var config=require(_0x9d1f('0x1a'));var licenseUtil=require('../../config/license/util');var db=require(_0x9d1f('0x1b'))['db'];function respondWithStatusCode(_0x15a999,_0x7edbfa){_0x7edbfa=_0x7edbfa||0xcc;return function(_0x5a4d43){if(_0x5a4d43){return _0x15a999[_0x9d1f('0x1c')](_0x7edbfa);}return _0x15a999['status'](_0x7edbfa)['end']();};}function respondWithResult(_0x71e9c9,_0x38395d){_0x38395d=_0x38395d||0xc8;return function(_0x25c0b0){if(_0x25c0b0){return _0x71e9c9[_0x9d1f('0x1d')](_0x38395d)[_0x9d1f('0x1e')](_0x25c0b0);}};}function respondWithFilteredResult(_0x40a87f,_0x9f8cfc){return function(_0x2488a3){if(_0x2488a3){var _0x24cd8a=_0x2488a3[_0x9d1f('0x1f')],_0x45a870=_0x9f8cfc['offset'],_0x1f9338=_0x9f8cfc[_0x9d1f('0x20')]+_0x9f8cfc[_0x9d1f('0x21')],_0x1dd0bd;if(_0x1f9338>=_0x24cd8a){_0x1f9338=_0x24cd8a;_0x1dd0bd=0xc8;}else{_0x1dd0bd=0xce;}_0x40a87f['status'](_0x1dd0bd);return _0x40a87f[_0x9d1f('0x22')]('Content-Range',_0x45a870+'-'+_0x1f9338+'/'+_0x24cd8a)['json'](_0x2488a3);}return null;};}function patchUpdates(_0x585850){return function(_0x2d39f3){try{jsonpatch[_0x9d1f('0x23')](_0x2d39f3,_0x585850,!![]);}catch(_0x380a14){return BPromise['reject'](_0x380a14);}return _0x2d39f3[_0x9d1f('0x24')]();};}function saveUpdates(_0x4cfcf5,_0x1c0280){return function(_0x4c1ec2){if(_0x4c1ec2){return _0x4c1ec2['update'](_0x4cfcf5)[_0x9d1f('0x25')](function(_0x31444a){return _0x31444a;});}return null;};}function removeEntity(_0x35a80d,_0x2d861b){return function(_0x44ef15){if(_0x44ef15){return _0x44ef15[_0x9d1f('0x26')]()[_0x9d1f('0x25')](function(){_0x35a80d[_0x9d1f('0x1d')](0xcc)[_0x9d1f('0x27')]();});}};}function handleEntityNotFound(_0xc05aa,_0x1ab0f4){return function(_0x426c31){if(!_0x426c31){_0xc05aa[_0x9d1f('0x1c')](0x194);}return _0x426c31;};}function handleError(_0xfb5358,_0x515404){_0x515404=_0x515404||0x1f4;return function(_0x2b234d){logger[_0x9d1f('0x28')](_0x2b234d['stack']);if(_0x2b234d['name']){delete _0x2b234d[_0x9d1f('0x29')];}_0xfb5358[_0x9d1f('0x1d')](_0x515404)[_0x9d1f('0x2a')](_0x2b234d);};}exports[_0x9d1f('0x2b')]=function(_0x1aeaf3,_0x55f7de){if(_0x1aeaf3['body']['id']){delete _0x1aeaf3[_0x9d1f('0x2c')]['id'];}return db[_0x9d1f('0x2d')][_0x9d1f('0x2e')]({'where':{'id':_0x1aeaf3[_0x9d1f('0x2f')]['id']}})[_0x9d1f('0x25')](handleEntityNotFound(_0x55f7de,null))[_0x9d1f('0x25')](saveUpdates(_0x1aeaf3['body'],null))[_0x9d1f('0x25')](respondWithResult(_0x55f7de,null))['catch'](handleError(_0x55f7de,null));};exports[_0x9d1f('0x26')]=function(_0x2e187b,_0x18a937){return db[_0x9d1f('0x2d')][_0x9d1f('0x2e')]({'where':{'id':_0x2e187b['params']['id']}})[_0x9d1f('0x25')](handleEntityNotFound(_0x18a937,null))[_0x9d1f('0x25')](removeEntity(_0x18a937,null))[_0x9d1f('0x30')](handleError(_0x18a937,null));};