Built motion from commit (unavailable).|2.4.18
[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 _0xa009=['update','destroy','then','end','error','stack','name','send','body','Action','find','catch','eml-format','zip-dir','request-promise','moment','mustache','util','path','sox','to-csv','ejs','squel','crypto','jsforce','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','json','count','offset','limit','apply','reject','save'];(function(_0x3a7e76,_0x378760){var _0x2cc4b7=function(_0x26e30c){while(--_0x26e30c){_0x3a7e76['push'](_0x3a7e76['shift']());}};_0x2cc4b7(++_0x378760);}(_0xa009,0x8d));var _0x9a00=function(_0x929c7e,_0x38c4cc){_0x929c7e=_0x929c7e-0x0;var _0x5de099=_0xa009[_0x929c7e];return _0x5de099;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x9a00('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x9a00('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0x9a00('0x2'));var moment=require(_0x9a00('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x9a00('0x4'));var util=require(_0x9a00('0x5'));var path=require(_0x9a00('0x6'));var sox=require(_0x9a00('0x7'));var csv=require(_0x9a00('0x8'));var ejs=require(_0x9a00('0x9'));var fs=require('fs');var _=require('lodash');var squel=require(_0x9a00('0xa'));var crypto=require(_0x9a00('0xb'));var jsforce=require(_0x9a00('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x9a00('0x8'));var querystring=require('querystring');var Papa=require(_0x9a00('0xd'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x9a00('0xe'));var as=require(_0x9a00('0xf'));var hardwareService=require(_0x9a00('0x10'));var logger=require(_0x9a00('0x11'))(_0x9a00('0x12'));var utils=require(_0x9a00('0x13'));var config=require(_0x9a00('0x14'));var db=require(_0x9a00('0x15'))['db'];function respondWithStatusCode(_0x30f6f9,_0x27fa8f){_0x27fa8f=_0x27fa8f||0xcc;return function(_0x72dae4){if(_0x72dae4){return _0x30f6f9[_0x9a00('0x16')](_0x27fa8f);}return _0x30f6f9[_0x9a00('0x17')](_0x27fa8f)['end']();};}function respondWithResult(_0xd4b39c,_0x5e1eab){_0x5e1eab=_0x5e1eab||0xc8;return function(_0x5c54c3){if(_0x5c54c3){return _0xd4b39c['status'](_0x5e1eab)[_0x9a00('0x18')](_0x5c54c3);}};}function respondWithFilteredResult(_0x4886a3,_0x3ab4fb){return function(_0x4fe23a){if(_0x4fe23a){var _0x3037f4=_0x4fe23a[_0x9a00('0x19')],_0x76d6ac=_0x3ab4fb['offset'],_0x347754=_0x3ab4fb[_0x9a00('0x1a')]+_0x3ab4fb[_0x9a00('0x1b')],_0x5a84b0;if(_0x347754>=_0x3037f4){_0x347754=_0x3037f4;_0x5a84b0=0xc8;}else{_0x5a84b0=0xce;}_0x4886a3['status'](_0x5a84b0);return _0x4886a3['set']('Content-Range',_0x76d6ac+'-'+_0x347754+'/'+_0x3037f4)['json'](_0x4fe23a);}return null;};}function patchUpdates(_0x1673f8){return function(_0x486b55){try{jsonpatch[_0x9a00('0x1c')](_0x486b55,_0x1673f8,!![]);}catch(_0x39cc56){return BPromise[_0x9a00('0x1d')](_0x39cc56);}return _0x486b55[_0x9a00('0x1e')]();};}function saveUpdates(_0x478d0a,_0x23eec7){return function(_0xdb7bdd){if(_0xdb7bdd){return _0xdb7bdd[_0x9a00('0x1f')](_0x478d0a)['then'](function(_0x1eddf3){return _0x1eddf3;});}return null;};}function removeEntity(_0x22fa2e,_0x3e1368){return function(_0x2c9267){if(_0x2c9267){return _0x2c9267[_0x9a00('0x20')]()[_0x9a00('0x21')](function(){_0x22fa2e[_0x9a00('0x17')](0xcc)[_0x9a00('0x22')]();});}};}function handleEntityNotFound(_0x40854f,_0x251d0e){return function(_0x320762){if(!_0x320762){_0x40854f[_0x9a00('0x16')](0x194);}return _0x320762;};}function handleError(_0x131222,_0x33bc35){_0x33bc35=_0x33bc35||0x1f4;return function(_0x45e2d2){logger[_0x9a00('0x23')](_0x45e2d2[_0x9a00('0x24')]);if(_0x45e2d2[_0x9a00('0x25')]){delete _0x45e2d2['name'];}_0x131222['status'](_0x33bc35)[_0x9a00('0x26')](_0x45e2d2);};}exports[_0x9a00('0x1f')]=function(_0x1e4f3c,_0x4d33b9){if(_0x1e4f3c[_0x9a00('0x27')]['id']){delete _0x1e4f3c[_0x9a00('0x27')]['id'];}return db[_0x9a00('0x28')][_0x9a00('0x29')]({'where':{'id':_0x1e4f3c['params']['id']}})[_0x9a00('0x21')](handleEntityNotFound(_0x4d33b9,null))[_0x9a00('0x21')](saveUpdates(_0x1e4f3c[_0x9a00('0x27')],null))['then'](respondWithResult(_0x4d33b9,null))[_0x9a00('0x2a')](handleError(_0x4d33b9,null));};exports[_0x9a00('0x20')]=function(_0x4d4787,_0x4cfb6d){return db['Action']['find']({'where':{'id':_0x4d4787['params']['id']}})[_0x9a00('0x21')](handleEntityNotFound(_0x4cfb6d,null))[_0x9a00('0x21')](removeEntity(_0x4cfb6d,null))[_0x9a00('0x2a')](handleError(_0x4cfb6d,null));};