Built motion from commit (unavailable).|2.5.22
[motion2.git] / server / api / cmHopperBlack / cmHopperBlack.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 _0xce8a=['keys','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filters','filter','merge','type','options','includeAll','include','rows','catch','show','params','find','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','util','path','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','error','stack','name','index','map','CmHopperBlack','rawAttributes','fieldName','model','query'];(function(_0x163040,_0x38a58c){var _0x364667=function(_0x3b104f){while(--_0x3b104f){_0x163040['push'](_0x163040['shift']());}};_0x364667(++_0x38a58c);}(_0xce8a,0x13b));var _0xace8=function(_0x3ebda0,_0x52ed01){_0x3ebda0=_0x3ebda0-0x0;var _0x29828b=_0xce8a[_0x3ebda0];return _0x29828b;};'use strict';var pdf=require(_0xace8('0x0'));var emlformat=require(_0xace8('0x1'));var rimraf=require(_0xace8('0x2'));var zipdir=require(_0xace8('0x3'));var jsonpatch=require(_0xace8('0x4'));var rp=require(_0xace8('0x5'));var moment=require(_0xace8('0x6'));var BPromise=require(_0xace8('0x7'));var Mustache=require('mustache');var util=require(_0xace8('0x8'));var path=require(_0xace8('0x9'));var sox=require('sox');var csv=require(_0xace8('0xa'));var ejs=require(_0xace8('0xb'));var fs=require('fs');var _=require(_0xace8('0xc'));var squel=require(_0xace8('0xd'));var crypto=require(_0xace8('0xe'));var jsforce=require(_0xace8('0xf'));var deskjs=require(_0xace8('0x10'));var toCsv=require(_0xace8('0xa'));var querystring=require(_0xace8('0x11'));var Papa=require(_0xace8('0x12'));var Redis=require('ioredis');var authService=require(_0xace8('0x13'));var qs=require(_0xace8('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')(_0xace8('0x15'));var utils=require(_0xace8('0x16'));var config=require('../../config/environment');var licenseUtil=require(_0xace8('0x17'));var db=require(_0xace8('0x18'))['db'];function respondWithStatusCode(_0x19d4c9,_0x3e75e4){_0x3e75e4=_0x3e75e4||0xcc;return function(_0x3f5019){if(_0x3f5019){return _0x19d4c9[_0xace8('0x19')](_0x3e75e4);}return _0x19d4c9[_0xace8('0x1a')](_0x3e75e4)[_0xace8('0x1b')]();};}function respondWithResult(_0x48731a,_0x50bea5){_0x50bea5=_0x50bea5||0xc8;return function(_0x5f271a){if(_0x5f271a){return _0x48731a[_0xace8('0x1a')](_0x50bea5)[_0xace8('0x1c')](_0x5f271a);}};}function respondWithFilteredResult(_0x3fdc7b,_0x55bc40){return function(_0x1e3b42){if(_0x1e3b42){var _0x514e45=_0x1e3b42[_0xace8('0x1d')],_0x313907=_0x55bc40[_0xace8('0x1e')],_0x12ae32=_0x55bc40[_0xace8('0x1e')]+_0x55bc40[_0xace8('0x1f')],_0x563ca2;if(_0x12ae32>=_0x514e45){_0x12ae32=_0x514e45;_0x563ca2=0xc8;}else{_0x563ca2=0xce;}_0x3fdc7b[_0xace8('0x1a')](_0x563ca2);return _0x3fdc7b[_0xace8('0x20')](_0xace8('0x21'),_0x313907+'-'+_0x12ae32+'/'+_0x514e45)[_0xace8('0x1c')](_0x1e3b42);}return null;};}function patchUpdates(_0xb4f063){return function(_0x48e54d){try{jsonpatch[_0xace8('0x22')](_0x48e54d,_0xb4f063,!![]);}catch(_0x506899){return BPromise[_0xace8('0x23')](_0x506899);}return _0x48e54d[_0xace8('0x24')]();};}function saveUpdates(_0x3d9689,_0x57a530){return function(_0x3b65c0){if(_0x3b65c0){return _0x3b65c0[_0xace8('0x25')](_0x3d9689)[_0xace8('0x26')](function(_0x5977a0){return _0x5977a0;});}return null;};}function removeEntity(_0x1a3656,_0x1d44db){return function(_0x442e13){if(_0x442e13){return _0x442e13[_0xace8('0x27')]()['then'](function(){_0x1a3656[_0xace8('0x1a')](0xcc)['end']();});}};}function handleEntityNotFound(_0x2fb500,_0x13c12c){return function(_0x44c65a){if(!_0x44c65a){_0x2fb500[_0xace8('0x19')](0x194);}return _0x44c65a;};}function handleError(_0x25c855,_0x3ee3b7){_0x3ee3b7=_0x3ee3b7||0x1f4;return function(_0x29ed17){logger[_0xace8('0x28')](_0x29ed17[_0xace8('0x29')]);if(_0x29ed17[_0xace8('0x2a')]){delete _0x29ed17[_0xace8('0x2a')];}_0x25c855[_0xace8('0x1a')](_0x3ee3b7)['send'](_0x29ed17);};}exports[_0xace8('0x2b')]=function(_0x544c5b,_0x354d73){var _0x100d7e={},_0x28849d={},_0x280cf8={'count':0x0,'rows':[]};var _0x4a1302=_[_0xace8('0x2c')](db[_0xace8('0x2d')][_0xace8('0x2e')],function(_0x261ea7){return{'name':_0x261ea7[_0xace8('0x2f')],'type':_0x261ea7['type']['key']};});_0x28849d[_0xace8('0x30')]=_['map'](_0x4a1302,_0xace8('0x2a'));_0x28849d[_0xace8('0x31')]=_[_0xace8('0x32')](_0x544c5b[_0xace8('0x31')]);_0x28849d['filters']=_[_0xace8('0x33')](_0x28849d[_0xace8('0x30')],_0x28849d[_0xace8('0x31')]);_0x100d7e[_0xace8('0x34')]=_['intersection'](_0x28849d[_0xace8('0x30')],qs[_0xace8('0x35')](_0x544c5b[_0xace8('0x31')]['fields']));_0x100d7e[_0xace8('0x34')]=_0x100d7e[_0xace8('0x34')][_0xace8('0x36')]?_0x100d7e[_0xace8('0x34')]:_0x28849d[_0xace8('0x30')];if(!_0x544c5b[_0xace8('0x31')][_0xace8('0x37')]('nolimit')){_0x100d7e[_0xace8('0x1f')]=qs['limit'](_0x544c5b[_0xace8('0x31')]['limit']);_0x100d7e[_0xace8('0x1e')]=qs['offset'](_0x544c5b[_0xace8('0x31')][_0xace8('0x1e')]);}_0x100d7e[_0xace8('0x38')]=qs[_0xace8('0x39')](_0x544c5b[_0xace8('0x31')][_0xace8('0x39')]);_0x100d7e[_0xace8('0x3a')]=qs['filters'](_[_0xace8('0x3b')](_0x544c5b[_0xace8('0x31')],_0x28849d[_0xace8('0x3c')]),_0x4a1302);if(_0x544c5b['query'][_0xace8('0x3d')]){_0x100d7e['where']=_[_0xace8('0x3e')](_0x100d7e[_0xace8('0x3a')],{'$or':_['map'](_0x4a1302,function(_0x293d68){if(_0x293d68[_0xace8('0x3f')]!=='VIRTUAL'){var _0x14ec6b={};_0x14ec6b[_0x293d68[_0xace8('0x2a')]]={'$like':'%'+_0x544c5b[_0xace8('0x31')][_0xace8('0x3d')]+'%'};return _0x14ec6b;}})});}_0x100d7e=_['merge']({},_0x100d7e,_0x544c5b[_0xace8('0x40')]);var _0x3c4f39={'where':_0x100d7e['where']};return db['CmHopperBlack'][_0xace8('0x1d')](_0x3c4f39)[_0xace8('0x26')](function(_0x59cc25){_0x280cf8[_0xace8('0x1d')]=_0x59cc25;if(_0x544c5b[_0xace8('0x31')][_0xace8('0x41')]){_0x100d7e[_0xace8('0x42')]=[{'all':!![]}];}return db['CmHopperBlack']['findAll'](_0x100d7e);})[_0xace8('0x26')](function(_0x4a6624){_0x280cf8[_0xace8('0x43')]=_0x4a6624;return _0x280cf8;})['then'](respondWithFilteredResult(_0x354d73,_0x100d7e))[_0xace8('0x44')](handleError(_0x354d73,null));};exports[_0xace8('0x45')]=function(_0x3068d9,_0xe8a8f){var _0x32bc1d={'raw':!![],'where':{'id':_0x3068d9[_0xace8('0x46')]['id']}},_0x44fa8f={};_0x44fa8f[_0xace8('0x30')]=_[_0xace8('0x32')](db['CmHopperBlack'][_0xace8('0x2e')]);_0x44fa8f['query']=_['keys'](_0x3068d9[_0xace8('0x31')]);_0x44fa8f[_0xace8('0x3c')]=_[_0xace8('0x33')](_0x44fa8f[_0xace8('0x30')],_0x44fa8f[_0xace8('0x31')]);_0x32bc1d[_0xace8('0x34')]=_[_0xace8('0x33')](_0x44fa8f[_0xace8('0x30')],qs[_0xace8('0x35')](_0x3068d9['query'][_0xace8('0x35')]));_0x32bc1d[_0xace8('0x34')]=_0x32bc1d['attributes'][_0xace8('0x36')]?_0x32bc1d[_0xace8('0x34')]:_0x44fa8f['model'];if(_0x3068d9['query']['includeAll']){_0x32bc1d[_0xace8('0x42')]=[{'all':!![]}];}_0x32bc1d=_[_0xace8('0x3e')]({},_0x32bc1d,_0x3068d9[_0xace8('0x40')]);return db['CmHopperBlack'][_0xace8('0x47')](_0x32bc1d)[_0xace8('0x26')](handleEntityNotFound(_0xe8a8f,null))[_0xace8('0x26')](respondWithResult(_0xe8a8f,null))[_0xace8('0x44')](handleError(_0xe8a8f,null));};exports[_0xace8('0x25')]=function(_0x13d1b2,_0x38e2b5){if(_0x13d1b2['body']['id']){delete _0x13d1b2['body']['id'];}return db[_0xace8('0x2d')][_0xace8('0x47')]({'where':{'id':_0x13d1b2[_0xace8('0x46')]['id']}})[_0xace8('0x26')](handleEntityNotFound(_0x38e2b5,null))[_0xace8('0x26')](saveUpdates(_0x13d1b2['body'],null))['then'](respondWithResult(_0x38e2b5,null))[_0xace8('0x44')](handleError(_0x38e2b5,null));};exports[_0xace8('0x27')]=function(_0x175045,_0x3158a2){return db[_0xace8('0x2d')][_0xace8('0x47')]({'where':{'id':_0x175045['params']['id']}})[_0xace8('0x26')](handleEntityNotFound(_0x3158a2,null))['then'](removeEntity(_0x3158a2,null))[_0xace8('0x44')](handleError(_0x3158a2,null));};exports['describe']=function(_0x5614f7,_0x469705){return db[_0xace8('0x2d')][_0xace8('0x48')]()[_0xace8('0x26')](respondWithResult(_0x469705,null))[_0xace8('0x44')](handleError(_0x469705,null));};