Built motion from commit (unavailable).|2.5.11
[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 _0xa46e=['status','json','count','limit','apply','reject','save','then','destroy','end','error','stack','send','body','Action','find','params','catch','html-pdf','eml-format','zip-dir','fast-json-patch','request-promise','bluebird','util','sox','ejs','lodash','crypto','jsforce','desk.js','to-csv','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb'];(function(_0x3dad57,_0x1dd8b3){var _0x47a6b5=function(_0x6e545d){while(--_0x6e545d){_0x3dad57['push'](_0x3dad57['shift']());}};_0x47a6b5(++_0x1dd8b3);}(_0xa46e,0x8a));var _0xea46=function(_0x3ff085,_0x27c92e){_0x3ff085=_0x3ff085-0x0;var _0x2b68c3=_0xa46e[_0x3ff085];return _0x2b68c3;};'use strict';var pdf=require(_0xea46('0x0'));var emlformat=require(_0xea46('0x1'));var rimraf=require('rimraf');var zipdir=require(_0xea46('0x2'));var jsonpatch=require(_0xea46('0x3'));var rp=require(_0xea46('0x4'));var moment=require('moment');var BPromise=require(_0xea46('0x5'));var Mustache=require('mustache');var util=require(_0xea46('0x6'));var path=require('path');var sox=require(_0xea46('0x7'));var csv=require('to-csv');var ejs=require(_0xea46('0x8'));var fs=require('fs');var _=require(_0xea46('0x9'));var squel=require('squel');var crypto=require(_0xea46('0xa'));var jsforce=require(_0xea46('0xb'));var deskjs=require(_0xea46('0xc'));var toCsv=require(_0xea46('0xd'));var querystring=require(_0xea46('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xea46('0xf'));var as=require(_0xea46('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0xea46('0x11'))(_0xea46('0x12'));var utils=require(_0xea46('0x13'));var config=require('../../config/environment');var licenseUtil=require(_0xea46('0x14'));var db=require(_0xea46('0x15'))['db'];function respondWithStatusCode(_0x4e10f3,_0x13390c){_0x13390c=_0x13390c||0xcc;return function(_0x1a4fe2){if(_0x1a4fe2){return _0x4e10f3['sendStatus'](_0x13390c);}return _0x4e10f3[_0xea46('0x16')](_0x13390c)['end']();};}function respondWithResult(_0x3024af,_0x42c328){_0x42c328=_0x42c328||0xc8;return function(_0x6c4bc4){if(_0x6c4bc4){return _0x3024af[_0xea46('0x16')](_0x42c328)[_0xea46('0x17')](_0x6c4bc4);}};}function respondWithFilteredResult(_0x2ef436,_0x81ee45){return function(_0x20a79c){if(_0x20a79c){var _0x176ad2=_0x20a79c[_0xea46('0x18')],_0x59e1ea=_0x81ee45['offset'],_0x2fa2f9=_0x81ee45['offset']+_0x81ee45[_0xea46('0x19')],_0xbf225e;if(_0x2fa2f9>=_0x176ad2){_0x2fa2f9=_0x176ad2;_0xbf225e=0xc8;}else{_0xbf225e=0xce;}_0x2ef436[_0xea46('0x16')](_0xbf225e);return _0x2ef436['set']('Content-Range',_0x59e1ea+'-'+_0x2fa2f9+'/'+_0x176ad2)[_0xea46('0x17')](_0x20a79c);}return null;};}function patchUpdates(_0x9b7d04){return function(_0x4ff93d){try{jsonpatch[_0xea46('0x1a')](_0x4ff93d,_0x9b7d04,!![]);}catch(_0x16ae38){return BPromise[_0xea46('0x1b')](_0x16ae38);}return _0x4ff93d[_0xea46('0x1c')]();};}function saveUpdates(_0x53b8db,_0x2b6491){return function(_0x4e220f){if(_0x4e220f){return _0x4e220f['update'](_0x53b8db)[_0xea46('0x1d')](function(_0x59e431){return _0x59e431;});}return null;};}function removeEntity(_0x4cc673,_0x5064d8){return function(_0x3b25fe){if(_0x3b25fe){return _0x3b25fe[_0xea46('0x1e')]()[_0xea46('0x1d')](function(){_0x4cc673['status'](0xcc)[_0xea46('0x1f')]();});}};}function handleEntityNotFound(_0x59b10d,_0x12e688){return function(_0x2008b0){if(!_0x2008b0){_0x59b10d['sendStatus'](0x194);}return _0x2008b0;};}function handleError(_0xac33c3,_0x5480eb){_0x5480eb=_0x5480eb||0x1f4;return function(_0x2b3a8f){logger[_0xea46('0x20')](_0x2b3a8f[_0xea46('0x21')]);if(_0x2b3a8f['name']){delete _0x2b3a8f['name'];}_0xac33c3[_0xea46('0x16')](_0x5480eb)[_0xea46('0x22')](_0x2b3a8f);};}exports['update']=function(_0x3b3928,_0x4999b0){if(_0x3b3928[_0xea46('0x23')]['id']){delete _0x3b3928['body']['id'];}return db[_0xea46('0x24')][_0xea46('0x25')]({'where':{'id':_0x3b3928[_0xea46('0x26')]['id']}})[_0xea46('0x1d')](handleEntityNotFound(_0x4999b0,null))[_0xea46('0x1d')](saveUpdates(_0x3b3928[_0xea46('0x23')],null))['then'](respondWithResult(_0x4999b0,null))[_0xea46('0x27')](handleError(_0x4999b0,null));};exports[_0xea46('0x1e')]=function(_0x200e10,_0x5e0e35){return db[_0xea46('0x24')][_0xea46('0x25')]({'where':{'id':_0x200e10[_0xea46('0x26')]['id']}})['then'](handleEntityNotFound(_0x5e0e35,null))['then'](removeEntity(_0x5e0e35,null))['catch'](handleError(_0x5e0e35,null));};