Built motion from commit (unavailable).|2.4.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 _0xe6b0=['../../components/auth/service','../../components/parsers/advancedSearch','../../config/logger','api','../../config/utils','../../mysqldb','sendStatus','json','count','offset','status','Content-Range','apply','save','update','destroy','end','error','stack','name','body','find','params','then','catch','Condition','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','mustache','util','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','querystring'];(function(_0x5cf8d7,_0x2160e3){var _0x127110=function(_0x3bdd3c){while(--_0x3bdd3c){_0x5cf8d7['push'](_0x5cf8d7['shift']());}};_0x127110(++_0x2160e3);}(_0xe6b0,0x18b));var _0x0e6b=function(_0x3dd15e,_0x1f0015){_0x3dd15e=_0x3dd15e-0x0;var _0x231fd0=_0xe6b0[_0x3dd15e];return _0x231fd0;};'use strict';var pdf=require(_0x0e6b('0x0'));var emlformat=require(_0x0e6b('0x1'));var rimraf=require(_0x0e6b('0x2'));var zipdir=require(_0x0e6b('0x3'));var jsonpatch=require(_0x0e6b('0x4'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x0e6b('0x5'));var util=require(_0x0e6b('0x6'));var path=require('path');var sox=require(_0x0e6b('0x7'));var csv=require(_0x0e6b('0x8'));var ejs=require(_0x0e6b('0x9'));var fs=require('fs');var _=require(_0x0e6b('0xa'));var squel=require('squel');var crypto=require(_0x0e6b('0xb'));var jsforce=require(_0x0e6b('0xc'));var deskjs=require(_0x0e6b('0xd'));var toCsv=require(_0x0e6b('0x8'));var querystring=require(_0x0e6b('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0x0e6b('0xf'));var qs=require('../../components/parsers/qs');var as=require(_0x0e6b('0x10'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0e6b('0x11'))(_0x0e6b('0x12'));var utils=require(_0x0e6b('0x13'));var config=require('../../config/environment');var db=require(_0x0e6b('0x14'))['db'];function respondWithStatusCode(_0x3d566d,_0x21e4ef){_0x21e4ef=_0x21e4ef||0xcc;return function(_0x1b6497){if(_0x1b6497){return _0x3d566d[_0x0e6b('0x15')](_0x21e4ef);}return _0x3d566d['status'](_0x21e4ef)['end']();};}function respondWithResult(_0x428a85,_0x712bc1){_0x712bc1=_0x712bc1||0xc8;return function(_0x55fa6d){if(_0x55fa6d){return _0x428a85['status'](_0x712bc1)[_0x0e6b('0x16')](_0x55fa6d);}};}function respondWithFilteredResult(_0x5a52a0,_0x4f1736){return function(_0x4074be){if(_0x4074be){var _0x11fd9a=_0x4074be[_0x0e6b('0x17')],_0x1908e9=_0x4f1736[_0x0e6b('0x18')],_0x263d84=_0x4f1736['offset']+_0x4f1736['limit'],_0x38f44c;if(_0x263d84>=_0x11fd9a){_0x263d84=_0x11fd9a;_0x38f44c=0xc8;}else{_0x38f44c=0xce;}_0x5a52a0[_0x0e6b('0x19')](_0x38f44c);return _0x5a52a0['set'](_0x0e6b('0x1a'),_0x1908e9+'-'+_0x263d84+'/'+_0x11fd9a)['json'](_0x4074be);}return null;};}function patchUpdates(_0x4d24b8){return function(_0x193adb){try{jsonpatch[_0x0e6b('0x1b')](_0x193adb,_0x4d24b8,!![]);}catch(_0x14c8d7){return BPromise['reject'](_0x14c8d7);}return _0x193adb[_0x0e6b('0x1c')]();};}function saveUpdates(_0x46403c,_0xf72673){return function(_0x3e66c8){if(_0x3e66c8){return _0x3e66c8[_0x0e6b('0x1d')](_0x46403c)['then'](function(_0x5e4fab){return _0x5e4fab;});}return null;};}function removeEntity(_0x37a0fb,_0x2aa695){return function(_0x6f0662){if(_0x6f0662){return _0x6f0662[_0x0e6b('0x1e')]()['then'](function(){_0x37a0fb[_0x0e6b('0x19')](0xcc)[_0x0e6b('0x1f')]();});}};}function handleEntityNotFound(_0x455e40,_0x3f17dc){return function(_0x5e3d47){if(!_0x5e3d47){_0x455e40[_0x0e6b('0x15')](0x194);}return _0x5e3d47;};}function handleError(_0x2d6236,_0x1ac0be){_0x1ac0be=_0x1ac0be||0x1f4;return function(_0x528073){logger[_0x0e6b('0x20')](_0x528073[_0x0e6b('0x21')]);if(_0x528073['name']){delete _0x528073[_0x0e6b('0x22')];}_0x2d6236[_0x0e6b('0x19')](_0x1ac0be)['send'](_0x528073);};}exports[_0x0e6b('0x1d')]=function(_0x173cfc,_0x14ca08){if(_0x173cfc['body']['id']){delete _0x173cfc[_0x0e6b('0x23')]['id'];}return db['Condition'][_0x0e6b('0x24')]({'where':{'id':_0x173cfc[_0x0e6b('0x25')]['id']}})[_0x0e6b('0x26')](handleEntityNotFound(_0x14ca08,null))[_0x0e6b('0x26')](saveUpdates(_0x173cfc[_0x0e6b('0x23')],null))[_0x0e6b('0x26')](respondWithResult(_0x14ca08,null))[_0x0e6b('0x27')](handleError(_0x14ca08,null));};exports[_0x0e6b('0x1e')]=function(_0x5b56d6,_0x5c13dc){return db[_0x0e6b('0x28')][_0x0e6b('0x24')]({'where':{'id':_0x5b56d6[_0x0e6b('0x25')]['id']}})[_0x0e6b('0x26')](handleEntityNotFound(_0x5c13dc,null))[_0x0e6b('0x26')](removeEntity(_0x5c13dc,null))['catch'](handleError(_0x5c13dc,null));};