Built motion from commit (unavailable).|2.5.22
[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 _0xe08b=['mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','count','offset','limit','set','Content-Range','reject','update','destroy','then','error','stack','name','body','Action','params','find','catch','html-pdf','rimraf','zip-dir','request-promise','moment','bluebird'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xe08b,0x10e));var _0xbe08=function(_0x4bc65f,_0x39ec43){_0x4bc65f=_0x4bc65f-0x0;var _0x44f85f=_0xe08b[_0x4bc65f];return _0x44f85f;};'use strict';var pdf=require(_0xbe08('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xbe08('0x1'));var zipdir=require(_0xbe08('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xbe08('0x3'));var moment=require(_0xbe08('0x4'));var BPromise=require(_0xbe08('0x5'));var Mustache=require(_0xbe08('0x6'));var util=require(_0xbe08('0x7'));var path=require(_0xbe08('0x8'));var sox=require(_0xbe08('0x9'));var csv=require(_0xbe08('0xa'));var ejs=require(_0xbe08('0xb'));var fs=require('fs');var _=require(_0xbe08('0xc'));var squel=require(_0xbe08('0xd'));var crypto=require(_0xbe08('0xe'));var jsforce=require(_0xbe08('0xf'));var deskjs=require('desk.js');var toCsv=require(_0xbe08('0xa'));var querystring=require(_0xbe08('0x10'));var Papa=require('papaparse');var Redis=require(_0xbe08('0x11'));var authService=require(_0xbe08('0x12'));var qs=require('../../components/parsers/qs');var as=require(_0xbe08('0x13'));var hardwareService=require(_0xbe08('0x14'));var logger=require('../../config/logger')(_0xbe08('0x15'));var utils=require(_0xbe08('0x16'));var config=require(_0xbe08('0x17'));var licenseUtil=require(_0xbe08('0x18'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x42ab71,_0x49410b){_0x49410b=_0x49410b||0xcc;return function(_0x18ee13){if(_0x18ee13){return _0x42ab71[_0xbe08('0x19')](_0x49410b);}return _0x42ab71[_0xbe08('0x1a')](_0x49410b)[_0xbe08('0x1b')]();};}function respondWithResult(_0xe1dafa,_0x3050f1){_0x3050f1=_0x3050f1||0xc8;return function(_0x434646){if(_0x434646){return _0xe1dafa[_0xbe08('0x1a')](_0x3050f1)[_0xbe08('0x1c')](_0x434646);}};}function respondWithFilteredResult(_0x191f51,_0x457129){return function(_0x2b0901){if(_0x2b0901){var _0x122f44=_0x2b0901[_0xbe08('0x1d')],_0x1f4269=_0x457129[_0xbe08('0x1e')],_0x337787=_0x457129['offset']+_0x457129[_0xbe08('0x1f')],_0x40b190;if(_0x337787>=_0x122f44){_0x337787=_0x122f44;_0x40b190=0xc8;}else{_0x40b190=0xce;}_0x191f51[_0xbe08('0x1a')](_0x40b190);return _0x191f51[_0xbe08('0x20')](_0xbe08('0x21'),_0x1f4269+'-'+_0x337787+'/'+_0x122f44)[_0xbe08('0x1c')](_0x2b0901);}return null;};}function patchUpdates(_0x1393ac){return function(_0x1f9808){try{jsonpatch['apply'](_0x1f9808,_0x1393ac,!![]);}catch(_0x16e8b4){return BPromise[_0xbe08('0x22')](_0x16e8b4);}return _0x1f9808['save']();};}function saveUpdates(_0x5ab5f5,_0x439a78){return function(_0xbbd202){if(_0xbbd202){return _0xbbd202[_0xbe08('0x23')](_0x5ab5f5)['then'](function(_0x31a075){return _0x31a075;});}return null;};}function removeEntity(_0x25ce24,_0x42143c){return function(_0x45697b){if(_0x45697b){return _0x45697b[_0xbe08('0x24')]()[_0xbe08('0x25')](function(){_0x25ce24[_0xbe08('0x1a')](0xcc)[_0xbe08('0x1b')]();});}};}function handleEntityNotFound(_0x2d6493,_0x493d13){return function(_0x34421d){if(!_0x34421d){_0x2d6493[_0xbe08('0x19')](0x194);}return _0x34421d;};}function handleError(_0x1fcbe5,_0x1a348e){_0x1a348e=_0x1a348e||0x1f4;return function(_0x3310be){logger[_0xbe08('0x26')](_0x3310be[_0xbe08('0x27')]);if(_0x3310be[_0xbe08('0x28')]){delete _0x3310be[_0xbe08('0x28')];}_0x1fcbe5[_0xbe08('0x1a')](_0x1a348e)['send'](_0x3310be);};}exports[_0xbe08('0x23')]=function(_0x23100b,_0x27ed43){if(_0x23100b[_0xbe08('0x29')]['id']){delete _0x23100b[_0xbe08('0x29')]['id'];}return db[_0xbe08('0x2a')]['find']({'where':{'id':_0x23100b[_0xbe08('0x2b')]['id']}})[_0xbe08('0x25')](handleEntityNotFound(_0x27ed43,null))[_0xbe08('0x25')](saveUpdates(_0x23100b[_0xbe08('0x29')],null))[_0xbe08('0x25')](respondWithResult(_0x27ed43,null))['catch'](handleError(_0x27ed43,null));};exports[_0xbe08('0x24')]=function(_0x35346a,_0x43a7fc){return db['Action'][_0xbe08('0x2c')]({'where':{'id':_0x35346a[_0xbe08('0x2b')]['id']}})['then'](handleEntityNotFound(_0x43a7fc,null))[_0xbe08('0x25')](removeEntity(_0x43a7fc,null))[_0xbe08('0x2d')](handleError(_0x43a7fc,null));};