Built motion from commit (unavailable).|2.5.6
[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 _0xaff3=['VIRTUAL','merge','options','count','include','findAll','show','params','rawAttributes','keys','filtears','includeAll','find','catch','update','body','describe','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','to-csv','lodash','desk.js','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','limit','Content-Range','apply','reject','save','destroy','then','error','stack','name','send','CmHopperBlack','fieldName','key','model','map','query','filters','intersection','attributes','fields','length','hasOwnProperty','order','sort','where','pick','filter','type'];(function(_0x24b23a,_0xe7a71f){var _0x21eacf=function(_0x1c2f78){while(--_0x1c2f78){_0x24b23a['push'](_0x24b23a['shift']());}};_0x21eacf(++_0xe7a71f);}(_0xaff3,0xa3));var _0x3aff=function(_0x7fbf91,_0x255d32){_0x7fbf91=_0x7fbf91-0x0;var _0x3222f4=_0xaff3[_0x7fbf91];return _0x3222f4;};'use strict';var pdf=require(_0x3aff('0x0'));var emlformat=require(_0x3aff('0x1'));var rimraf=require(_0x3aff('0x2'));var zipdir=require(_0x3aff('0x3'));var jsonpatch=require(_0x3aff('0x4'));var rp=require(_0x3aff('0x5'));var moment=require(_0x3aff('0x6'));var BPromise=require(_0x3aff('0x7'));var Mustache=require(_0x3aff('0x8'));var util=require('util');var path=require(_0x3aff('0x9'));var sox=require('sox');var csv=require(_0x3aff('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x3aff('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0x3aff('0xc'));var toCsv=require(_0x3aff('0xa'));var querystring=require('querystring');var Papa=require(_0x3aff('0xd'));var Redis=require(_0x3aff('0xe'));var authService=require(_0x3aff('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x3aff('0x10'));var logger=require(_0x3aff('0x11'))(_0x3aff('0x12'));var utils=require('../../config/utils');var config=require(_0x3aff('0x13'));var licenseUtil=require(_0x3aff('0x14'));var db=require(_0x3aff('0x15'))['db'];function respondWithStatusCode(_0x34951e,_0x5b1a8a){_0x5b1a8a=_0x5b1a8a||0xcc;return function(_0x2586b2){if(_0x2586b2){return _0x34951e[_0x3aff('0x16')](_0x5b1a8a);}return _0x34951e[_0x3aff('0x17')](_0x5b1a8a)[_0x3aff('0x18')]();};}function respondWithResult(_0x5d6c06,_0x516a15){_0x516a15=_0x516a15||0xc8;return function(_0x415e0c){if(_0x415e0c){return _0x5d6c06[_0x3aff('0x17')](_0x516a15)[_0x3aff('0x19')](_0x415e0c);}};}function respondWithFilteredResult(_0x1d0f64,_0x35c60d){return function(_0x3fe7d4){if(_0x3fe7d4){var _0x402ff6=_0x3fe7d4['count'],_0x4e20d2=_0x35c60d['offset'],_0x551064=_0x35c60d[_0x3aff('0x1a')]+_0x35c60d[_0x3aff('0x1b')],_0x2f7752;if(_0x551064>=_0x402ff6){_0x551064=_0x402ff6;_0x2f7752=0xc8;}else{_0x2f7752=0xce;}_0x1d0f64['status'](_0x2f7752);return _0x1d0f64['set'](_0x3aff('0x1c'),_0x4e20d2+'-'+_0x551064+'/'+_0x402ff6)[_0x3aff('0x19')](_0x3fe7d4);}return null;};}function patchUpdates(_0x49c9aa){return function(_0x2f06e5){try{jsonpatch[_0x3aff('0x1d')](_0x2f06e5,_0x49c9aa,!![]);}catch(_0x1ed2aa){return BPromise[_0x3aff('0x1e')](_0x1ed2aa);}return _0x2f06e5[_0x3aff('0x1f')]();};}function saveUpdates(_0x4d40d0,_0x2c59ab){return function(_0x1dcfb3){if(_0x1dcfb3){return _0x1dcfb3['update'](_0x4d40d0)['then'](function(_0x5de53f){return _0x5de53f;});}return null;};}function removeEntity(_0x11d68c,_0x588195){return function(_0x4f9cf7){if(_0x4f9cf7){return _0x4f9cf7[_0x3aff('0x20')]()[_0x3aff('0x21')](function(){_0x11d68c[_0x3aff('0x17')](0xcc)[_0x3aff('0x18')]();});}};}function handleEntityNotFound(_0x19fd4d,_0xf1abe){return function(_0x3e8d8e){if(!_0x3e8d8e){_0x19fd4d[_0x3aff('0x16')](0x194);}return _0x3e8d8e;};}function handleError(_0x6b450a,_0x340fa2){_0x340fa2=_0x340fa2||0x1f4;return function(_0x159cd2){logger[_0x3aff('0x22')](_0x159cd2[_0x3aff('0x23')]);if(_0x159cd2[_0x3aff('0x24')]){delete _0x159cd2[_0x3aff('0x24')];}_0x6b450a[_0x3aff('0x17')](_0x340fa2)[_0x3aff('0x25')](_0x159cd2);};}exports['index']=function(_0x417268,_0x3b968b){var _0x181c54={},_0x4ab702={},_0x235719={'count':0x0,'rows':[]};var _0x5625e0=_['map'](db[_0x3aff('0x26')]['rawAttributes'],function(_0x4c3a9d){return{'name':_0x4c3a9d[_0x3aff('0x27')],'type':_0x4c3a9d['type'][_0x3aff('0x28')]};});_0x4ab702[_0x3aff('0x29')]=_[_0x3aff('0x2a')](_0x5625e0,_0x3aff('0x24'));_0x4ab702['query']=_['keys'](_0x417268[_0x3aff('0x2b')]);_0x4ab702[_0x3aff('0x2c')]=_[_0x3aff('0x2d')](_0x4ab702[_0x3aff('0x29')],_0x4ab702[_0x3aff('0x2b')]);_0x181c54[_0x3aff('0x2e')]=_[_0x3aff('0x2d')](_0x4ab702[_0x3aff('0x29')],qs[_0x3aff('0x2f')](_0x417268[_0x3aff('0x2b')][_0x3aff('0x2f')]));_0x181c54[_0x3aff('0x2e')]=_0x181c54[_0x3aff('0x2e')][_0x3aff('0x30')]?_0x181c54[_0x3aff('0x2e')]:_0x4ab702['model'];if(!_0x417268[_0x3aff('0x2b')][_0x3aff('0x31')]('nolimit')){_0x181c54['limit']=qs[_0x3aff('0x1b')](_0x417268[_0x3aff('0x2b')][_0x3aff('0x1b')]);_0x181c54['offset']=qs[_0x3aff('0x1a')](_0x417268[_0x3aff('0x2b')][_0x3aff('0x1a')]);}_0x181c54[_0x3aff('0x32')]=qs['sort'](_0x417268['query'][_0x3aff('0x33')]);_0x181c54[_0x3aff('0x34')]=qs['filters'](_[_0x3aff('0x35')](_0x417268[_0x3aff('0x2b')],_0x4ab702[_0x3aff('0x2c')]),_0x5625e0);if(_0x417268[_0x3aff('0x2b')][_0x3aff('0x36')]){_0x181c54['where']=_['merge'](_0x181c54['where'],{'$or':_[_0x3aff('0x2a')](_0x5625e0,function(_0x1b04cc){if(_0x1b04cc[_0x3aff('0x37')]!==_0x3aff('0x38')){var _0x5949fa={};_0x5949fa[_0x1b04cc[_0x3aff('0x24')]]={'$like':'%'+_0x417268[_0x3aff('0x2b')]['filter']+'%'};return _0x5949fa;}})});}_0x181c54=_[_0x3aff('0x39')]({},_0x181c54,_0x417268[_0x3aff('0x3a')]);var _0x142ef0={'where':_0x181c54[_0x3aff('0x34')]};return db['CmHopperBlack'][_0x3aff('0x3b')](_0x142ef0)[_0x3aff('0x21')](function(_0x1deab5){_0x235719['count']=_0x1deab5;if(_0x417268[_0x3aff('0x2b')]['includeAll']){_0x181c54[_0x3aff('0x3c')]=[{'all':!![]}];}return db[_0x3aff('0x26')][_0x3aff('0x3d')](_0x181c54);})[_0x3aff('0x21')](function(_0x2efc65){_0x235719['rows']=_0x2efc65;return _0x235719;})[_0x3aff('0x21')](respondWithFilteredResult(_0x3b968b,_0x181c54))['catch'](handleError(_0x3b968b,null));};exports[_0x3aff('0x3e')]=function(_0x1ac1ea,_0x2f3d12){var _0x12f4a1={'raw':!![],'where':{'id':_0x1ac1ea[_0x3aff('0x3f')]['id']}},_0x353213={};_0x353213[_0x3aff('0x29')]=_['keys'](db[_0x3aff('0x26')][_0x3aff('0x40')]);_0x353213[_0x3aff('0x2b')]=_[_0x3aff('0x41')](_0x1ac1ea[_0x3aff('0x2b')]);_0x353213[_0x3aff('0x42')]=_[_0x3aff('0x2d')](_0x353213[_0x3aff('0x29')],_0x353213[_0x3aff('0x2b')]);_0x12f4a1['attributes']=_[_0x3aff('0x2d')](_0x353213[_0x3aff('0x29')],qs[_0x3aff('0x2f')](_0x1ac1ea[_0x3aff('0x2b')][_0x3aff('0x2f')]));_0x12f4a1[_0x3aff('0x2e')]=_0x12f4a1[_0x3aff('0x2e')][_0x3aff('0x30')]?_0x12f4a1[_0x3aff('0x2e')]:_0x353213[_0x3aff('0x29')];if(_0x1ac1ea[_0x3aff('0x2b')][_0x3aff('0x43')]){_0x12f4a1[_0x3aff('0x3c')]=[{'all':!![]}];}_0x12f4a1=_[_0x3aff('0x39')]({},_0x12f4a1,_0x1ac1ea[_0x3aff('0x3a')]);return db['CmHopperBlack'][_0x3aff('0x44')](_0x12f4a1)['then'](handleEntityNotFound(_0x2f3d12,null))[_0x3aff('0x21')](respondWithResult(_0x2f3d12,null))[_0x3aff('0x45')](handleError(_0x2f3d12,null));};exports[_0x3aff('0x46')]=function(_0x1a27bd,_0x3ee4f9){if(_0x1a27bd['body']['id']){delete _0x1a27bd[_0x3aff('0x47')]['id'];}return db['CmHopperBlack'][_0x3aff('0x44')]({'where':{'id':_0x1a27bd['params']['id']}})['then'](handleEntityNotFound(_0x3ee4f9,null))[_0x3aff('0x21')](saveUpdates(_0x1a27bd['body'],null))['then'](respondWithResult(_0x3ee4f9,null))[_0x3aff('0x45')](handleError(_0x3ee4f9,null));};exports[_0x3aff('0x20')]=function(_0x3a1e5e,_0x15580e){return db[_0x3aff('0x26')][_0x3aff('0x44')]({'where':{'id':_0x3a1e5e['params']['id']}})[_0x3aff('0x21')](handleEntityNotFound(_0x15580e,null))[_0x3aff('0x21')](removeEntity(_0x15580e,null))[_0x3aff('0x45')](handleError(_0x15580e,null));};exports[_0x3aff('0x48')]=function(_0x142798,_0x31cef5){return db[_0x3aff('0x26')][_0x3aff('0x48')]()[_0x3aff('0x21')](respondWithResult(_0x31cef5,null))[_0x3aff('0x45')](handleError(_0x31cef5,null));};