Built motion from commit (unavailable).|2.5.18
[motion2.git] / server / api / condition / condition.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 _0xf07d=['update','then','destroy','end','stack','name','body','Condition','find','params','catch','html-pdf','eml-format','rimraf','request-promise','mustache','util','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../mysqldb','sendStatus','status','count','offset','limit','set','Content-Range','json','reject','save'];(function(_0x36d25e,_0x1a047d){var _0x4b95b8=function(_0x74da3){while(--_0x74da3){_0x36d25e['push'](_0x36d25e['shift']());}};_0x4b95b8(++_0x1a047d);}(_0xf07d,0x12a));var _0xdf07=function(_0x3d5181,_0xb85da0){_0x3d5181=_0x3d5181-0x0;var _0x403991=_0xf07d[_0x3d5181];return _0x403991;};'use strict';var pdf=require(_0xdf07('0x0'));var emlformat=require(_0xdf07('0x1'));var rimraf=require(_0xdf07('0x2'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xdf07('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xdf07('0x4'));var util=require(_0xdf07('0x5'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xdf07('0x6'));var squel=require(_0xdf07('0x7'));var crypto=require(_0xdf07('0x8'));var jsforce=require(_0xdf07('0x9'));var deskjs=require(_0xdf07('0xa'));var toCsv=require('to-csv');var querystring=require(_0xdf07('0xb'));var Papa=require(_0xdf07('0xc'));var Redis=require(_0xdf07('0xd'));var authService=require('../../components/auth/service');var qs=require(_0xdf07('0xe'));var as=require(_0xdf07('0xf'));var hardwareService=require(_0xdf07('0x10'));var logger=require(_0xdf07('0x11'))('api');var utils=require(_0xdf07('0x12'));var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0xdf07('0x13'))['db'];function respondWithStatusCode(_0x4818c6,_0x1d3d71){_0x1d3d71=_0x1d3d71||0xcc;return function(_0x100079){if(_0x100079){return _0x4818c6[_0xdf07('0x14')](_0x1d3d71);}return _0x4818c6['status'](_0x1d3d71)['end']();};}function respondWithResult(_0x5084ef,_0x22de19){_0x22de19=_0x22de19||0xc8;return function(_0x48ad68){if(_0x48ad68){return _0x5084ef[_0xdf07('0x15')](_0x22de19)['json'](_0x48ad68);}};}function respondWithFilteredResult(_0x9a6c01,_0xf9ddd9){return function(_0x2b7320){if(_0x2b7320){var _0x130e0b=_0x2b7320[_0xdf07('0x16')],_0x2da7d8=_0xf9ddd9[_0xdf07('0x17')],_0x13fb45=_0xf9ddd9[_0xdf07('0x17')]+_0xf9ddd9[_0xdf07('0x18')],_0x867a53;if(_0x13fb45>=_0x130e0b){_0x13fb45=_0x130e0b;_0x867a53=0xc8;}else{_0x867a53=0xce;}_0x9a6c01[_0xdf07('0x15')](_0x867a53);return _0x9a6c01[_0xdf07('0x19')](_0xdf07('0x1a'),_0x2da7d8+'-'+_0x13fb45+'/'+_0x130e0b)[_0xdf07('0x1b')](_0x2b7320);}return null;};}function patchUpdates(_0x5096e4){return function(_0x212780){try{jsonpatch['apply'](_0x212780,_0x5096e4,!![]);}catch(_0x1f3102){return BPromise[_0xdf07('0x1c')](_0x1f3102);}return _0x212780[_0xdf07('0x1d')]();};}function saveUpdates(_0x669da1,_0x27941f){return function(_0x3a92a9){if(_0x3a92a9){return _0x3a92a9[_0xdf07('0x1e')](_0x669da1)[_0xdf07('0x1f')](function(_0x2fd656){return _0x2fd656;});}return null;};}function removeEntity(_0x246d5d,_0xd52b60){return function(_0x367120){if(_0x367120){return _0x367120[_0xdf07('0x20')]()[_0xdf07('0x1f')](function(){_0x246d5d[_0xdf07('0x15')](0xcc)[_0xdf07('0x21')]();});}};}function handleEntityNotFound(_0x5bf89b,_0x4d8da5){return function(_0x47df48){if(!_0x47df48){_0x5bf89b['sendStatus'](0x194);}return _0x47df48;};}function handleError(_0x49f3c5,_0x2b3dff){_0x2b3dff=_0x2b3dff||0x1f4;return function(_0x14c4c6){logger['error'](_0x14c4c6[_0xdf07('0x22')]);if(_0x14c4c6[_0xdf07('0x23')]){delete _0x14c4c6[_0xdf07('0x23')];}_0x49f3c5[_0xdf07('0x15')](_0x2b3dff)['send'](_0x14c4c6);};}exports['update']=function(_0x7a6396,_0x4a885a){if(_0x7a6396[_0xdf07('0x24')]['id']){delete _0x7a6396[_0xdf07('0x24')]['id'];}return db[_0xdf07('0x25')][_0xdf07('0x26')]({'where':{'id':_0x7a6396[_0xdf07('0x27')]['id']}})[_0xdf07('0x1f')](handleEntityNotFound(_0x4a885a,null))[_0xdf07('0x1f')](saveUpdates(_0x7a6396['body'],null))[_0xdf07('0x1f')](respondWithResult(_0x4a885a,null))[_0xdf07('0x28')](handleError(_0x4a885a,null));};exports[_0xdf07('0x20')]=function(_0x597cd9,_0x647a44){return db[_0xdf07('0x25')][_0xdf07('0x26')]({'where':{'id':_0x597cd9[_0xdf07('0x27')]['id']}})['then'](handleEntityNotFound(_0x647a44,null))['then'](removeEntity(_0x647a44,null))[_0xdf07('0x28')](handleError(_0x647a44,null));};