Built motion from commit (unavailable).|2.5.31
[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 _0xbf44=['sendStatus','error','stack','name','send','merge','body','contact','message','agent','account','Condition','find','params','destroy','catch','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','api','../../config/license/util','../../mysqldb','status','end','offset','undefined','limit','count','Content-Range','json','apply','save','then'];(function(_0x89a001,_0x3a9a8c){var _0x5f3ec2=function(_0x3e849b){while(--_0x3e849b){_0x89a001['push'](_0x89a001['shift']());}};_0x5f3ec2(++_0x3a9a8c);}(_0xbf44,0xa0));var _0x4bf4=function(_0x29ee0a,_0x2e019b){_0x29ee0a=_0x29ee0a-0x0;var _0x54efbf=_0xbf44[_0x29ee0a];return _0x54efbf;};'use strict';var emlformat=require(_0x4bf4('0x0'));var rimraf=require(_0x4bf4('0x1'));var zipdir=require(_0x4bf4('0x2'));var jsonpatch=require(_0x4bf4('0x3'));var rp=require('request-promise');var moment=require(_0x4bf4('0x4'));var BPromise=require(_0x4bf4('0x5'));var Mustache=require('mustache');var util=require('util');var path=require('path');var sox=require(_0x4bf4('0x6'));var csv=require(_0x4bf4('0x7'));var ejs=require(_0x4bf4('0x8'));var fs=require('fs');var fs_extra=require(_0x4bf4('0x9'));var _=require(_0x4bf4('0xa'));var squel=require(_0x4bf4('0xb'));var crypto=require('crypto');var jsforce=require(_0x4bf4('0xc'));var deskjs=require(_0x4bf4('0xd'));var toCsv=require(_0x4bf4('0x7'));var querystring=require('querystring');var Papa=require(_0x4bf4('0xe'));var Redis=require(_0x4bf4('0xf'));var authService=require(_0x4bf4('0x10'));var qs=require(_0x4bf4('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0x4bf4('0x12'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0x4bf4('0x13'));var db=require(_0x4bf4('0x14'))['db'];function respondWithStatusCode(_0x5db4a3,_0x1fbaf7){_0x1fbaf7=_0x1fbaf7||0xcc;return function(_0xe283ae){if(_0xe283ae){return _0x5db4a3['sendStatus'](_0x1fbaf7);}return _0x5db4a3[_0x4bf4('0x15')](_0x1fbaf7)[_0x4bf4('0x16')]();};}function respondWithResult(_0x1f94a2,_0x12bf07){_0x12bf07=_0x12bf07||0xc8;return function(_0x8419ff){if(_0x8419ff){return _0x1f94a2[_0x4bf4('0x15')](_0x12bf07)['json'](_0x8419ff);}};}function respondWithFilteredResult(_0x27f8a4,_0x3404fa){return function(_0x3d7d6a){if(_0x3d7d6a){var _0x4e9c31=typeof _0x3404fa[_0x4bf4('0x17')]===_0x4bf4('0x18')&&typeof _0x3404fa[_0x4bf4('0x19')]===_0x4bf4('0x18');var _0x4f6319=_0x3d7d6a['count'];var _0x1cc14d=_0x4e9c31?0x0:_0x3404fa[_0x4bf4('0x17')];var _0x233e43=_0x4e9c31?_0x3d7d6a[_0x4bf4('0x1a')]:_0x3404fa[_0x4bf4('0x17')]+_0x3404fa['limit'];var _0x1c5ed8;if(_0x233e43>=_0x4f6319){_0x233e43=_0x4f6319;_0x1c5ed8=0xc8;}else{_0x1c5ed8=0xce;}_0x27f8a4[_0x4bf4('0x15')](_0x1c5ed8);return _0x27f8a4['set'](_0x4bf4('0x1b'),_0x1cc14d+'-'+_0x233e43+'/'+_0x4f6319)[_0x4bf4('0x1c')](_0x3d7d6a);}return null;};}function patchUpdates(_0xc39df2){return function(_0x2df888){try{jsonpatch[_0x4bf4('0x1d')](_0x2df888,_0xc39df2,!![]);}catch(_0x18bcb4){return BPromise['reject'](_0x18bcb4);}return _0x2df888[_0x4bf4('0x1e')]();};}function saveUpdates(_0x36972d,_0x593718){return function(_0x40b3e8){if(_0x40b3e8){return _0x40b3e8['update'](_0x36972d)[_0x4bf4('0x1f')](function(_0x4f0b8d){return _0x4f0b8d;});}return null;};}function removeEntity(_0x4aa129,_0x3d0cee){return function(_0x86d77f){if(_0x86d77f){return _0x86d77f['destroy']()[_0x4bf4('0x1f')](function(){_0x4aa129['status'](0xcc)[_0x4bf4('0x16')]();});}};}function handleEntityNotFound(_0x51fa77,_0x1a9bb7){return function(_0x9d0fb1){if(!_0x9d0fb1){_0x51fa77[_0x4bf4('0x20')](0x194);}return _0x9d0fb1;};}function handleError(_0x2ffc0e,_0x403670){_0x403670=_0x403670||0x1f4;return function(_0x13b45e){logger[_0x4bf4('0x21')](_0x13b45e[_0x4bf4('0x22')]);if(_0x13b45e[_0x4bf4('0x23')]){delete _0x13b45e[_0x4bf4('0x23')];}_0x2ffc0e[_0x4bf4('0x15')](_0x403670)[_0x4bf4('0x24')](_0x13b45e);};}function getMustacheRender(_0x48a2c0,_0x8584b5){return Mustache['render'](_0x48a2c0,_[_0x4bf4('0x25')](_0x8584b5[_0x4bf4('0x26')],{'contact':_0x8584b5[_0x4bf4('0x27')],'message':_0x8584b5[_0x4bf4('0x28')],'agent':_0x8584b5[_0x4bf4('0x29')],'interaction':_0x8584b5['interaction'],'account':_0x8584b5[_0x4bf4('0x2a')]}))||'';}exports['update']=function(_0x1d31a5,_0x2508ef){if(_0x1d31a5[_0x4bf4('0x26')]['id']){delete _0x1d31a5[_0x4bf4('0x26')]['id'];}return db[_0x4bf4('0x2b')][_0x4bf4('0x2c')]({'where':{'id':_0x1d31a5[_0x4bf4('0x2d')]['id']}})[_0x4bf4('0x1f')](handleEntityNotFound(_0x2508ef,null))[_0x4bf4('0x1f')](saveUpdates(_0x1d31a5[_0x4bf4('0x26')],null))[_0x4bf4('0x1f')](respondWithResult(_0x2508ef,null))['catch'](handleError(_0x2508ef,null));};exports[_0x4bf4('0x2e')]=function(_0x33aa1f,_0x1bdc42){return db[_0x4bf4('0x2b')][_0x4bf4('0x2c')]({'where':{'id':_0x33aa1f[_0x4bf4('0x2d')]['id']}})['then'](handleEntityNotFound(_0x1bdc42,null))[_0x4bf4('0x1f')](removeEntity(_0x1bdc42,null))[_0x4bf4('0x2f')](handleError(_0x1bdc42,null));};