Built motion from commit e1760111.|2.6.18
[motion2.git] / server / api / voiceQueuesLog / voiceQueuesLog.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 _0x8c7c=['length','hasOwnProperty','sort','filters','filter','where','merge','type','VIRTUAL','options','includeAll','findAll','rows','catch','show','params','include','create','body','find','destroy','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','end','status','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','sendStatus','error','stack','name','index','map','VoiceQueuesLog','fieldName','key','model','keys','query','intersection','attributes','fields'];(function(_0x264511,_0x53a490){var _0xbeffdc=function(_0x2dcb95){while(--_0x2dcb95){_0x264511['push'](_0x264511['shift']());}};_0xbeffdc(++_0x53a490);}(_0x8c7c,0x139));var _0xc8c7=function(_0x502c7d,_0x2f1285){_0x502c7d=_0x502c7d-0x0;var _0x30b7ed=_0x8c7c[_0x502c7d];return _0x30b7ed;};'use strict';var emlformat=require(_0xc8c7('0x0'));var rimraf=require(_0xc8c7('0x1'));var zipdir=require(_0xc8c7('0x2'));var jsonpatch=require(_0xc8c7('0x3'));var rp=require(_0xc8c7('0x4'));var moment=require('moment');var BPromise=require(_0xc8c7('0x5'));var Mustache=require(_0xc8c7('0x6'));var util=require(_0xc8c7('0x7'));var path=require(_0xc8c7('0x8'));var sox=require(_0xc8c7('0x9'));var csv=require(_0xc8c7('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require('lodash');var squel=require(_0xc8c7('0xb'));var crypto=require(_0xc8c7('0xc'));var jsforce=require(_0xc8c7('0xd'));var deskjs=require(_0xc8c7('0xe'));var toCsv=require(_0xc8c7('0xa'));var querystring=require(_0xc8c7('0xf'));var Papa=require(_0xc8c7('0x10'));var Redis=require(_0xc8c7('0x11'));var authService=require('../../components/auth/service');var qs=require(_0xc8c7('0x12'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xc8c7('0x13'));var logger=require(_0xc8c7('0x14'))('api');var utils=require('../../config/utils');var config=require(_0xc8c7('0x15'));var licenseUtil=require(_0xc8c7('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x47e35c,_0xe57678){_0xe57678=_0xe57678||0xcc;return function(_0x7ab9e8){if(_0x7ab9e8){return _0x47e35c['sendStatus'](_0xe57678);}return _0x47e35c['status'](_0xe57678)[_0xc8c7('0x17')]();};}function respondWithResult(_0x16851a,_0x151915){_0x151915=_0x151915||0xc8;return function(_0x3fbc50){if(_0x3fbc50){return _0x16851a[_0xc8c7('0x18')](_0x151915)[_0xc8c7('0x19')](_0x3fbc50);}};}function respondWithFilteredResult(_0x428088,_0x8233e6){return function(_0x1b6d91){if(_0x1b6d91){var _0x3ca41c=typeof _0x8233e6[_0xc8c7('0x1a')]===_0xc8c7('0x1b')&&typeof _0x8233e6['limit']===_0xc8c7('0x1b');var _0x30a5e9=_0x1b6d91[_0xc8c7('0x1c')];var _0x2412a6=_0x3ca41c?0x0:_0x8233e6[_0xc8c7('0x1a')];var _0x1878aa=_0x3ca41c?_0x1b6d91[_0xc8c7('0x1c')]:_0x8233e6[_0xc8c7('0x1a')]+_0x8233e6[_0xc8c7('0x1d')];var _0x3dead2;if(_0x1878aa>=_0x30a5e9){_0x1878aa=_0x30a5e9;_0x3dead2=0xc8;}else{_0x3dead2=0xce;}_0x428088[_0xc8c7('0x18')](_0x3dead2);return _0x428088[_0xc8c7('0x1e')](_0xc8c7('0x1f'),_0x2412a6+'-'+_0x1878aa+'/'+_0x30a5e9)[_0xc8c7('0x19')](_0x1b6d91);}return null;};}function patchUpdates(_0x3432e1){return function(_0x47f6b0){try{jsonpatch[_0xc8c7('0x20')](_0x47f6b0,_0x3432e1,!![]);}catch(_0x190149){return BPromise[_0xc8c7('0x21')](_0x190149);}return _0x47f6b0[_0xc8c7('0x22')]();};}function saveUpdates(_0xa6ef3a,_0x46dcfa){return function(_0x544ef6){if(_0x544ef6){return _0x544ef6[_0xc8c7('0x23')](_0xa6ef3a)[_0xc8c7('0x24')](function(_0x1b1d16){return _0x1b1d16;});}return null;};}function removeEntity(_0x206223,_0x263612){return function(_0xe994f0){if(_0xe994f0){return _0xe994f0['destroy']()['then'](function(){_0x206223[_0xc8c7('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x450f6c,_0x31ed9f){return function(_0x350e68){if(!_0x350e68){_0x450f6c[_0xc8c7('0x25')](0x194);}return _0x350e68;};}function handleError(_0x30739e,_0x58754f){_0x58754f=_0x58754f||0x1f4;return function(_0x12c04a){logger[_0xc8c7('0x26')](_0x12c04a[_0xc8c7('0x27')]);if(_0x12c04a[_0xc8c7('0x28')]){delete _0x12c04a[_0xc8c7('0x28')];}_0x30739e['status'](_0x58754f)['send'](_0x12c04a);};}exports[_0xc8c7('0x29')]=function(_0x3d208b,_0x571cc0){var _0x2f9425={},_0x3a13b7={},_0x13443={'count':0x0,'rows':[]};var _0x526530=_[_0xc8c7('0x2a')](db[_0xc8c7('0x2b')]['rawAttributes'],function(_0x2d16b3){return{'name':_0x2d16b3[_0xc8c7('0x2c')],'type':_0x2d16b3['type'][_0xc8c7('0x2d')]};});_0x3a13b7[_0xc8c7('0x2e')]=_['map'](_0x526530,'name');_0x3a13b7['query']=_[_0xc8c7('0x2f')](_0x3d208b[_0xc8c7('0x30')]);_0x3a13b7['filters']=_[_0xc8c7('0x31')](_0x3a13b7[_0xc8c7('0x2e')],_0x3a13b7[_0xc8c7('0x30')]);_0x2f9425[_0xc8c7('0x32')]=_[_0xc8c7('0x31')](_0x3a13b7['model'],qs['fields'](_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x33')]));_0x2f9425[_0xc8c7('0x32')]=_0x2f9425[_0xc8c7('0x32')][_0xc8c7('0x34')]?_0x2f9425[_0xc8c7('0x32')]:_0x3a13b7['model'];if(!_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x35')]('nolimit')){_0x2f9425[_0xc8c7('0x1d')]=qs[_0xc8c7('0x1d')](_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x1d')]);_0x2f9425[_0xc8c7('0x1a')]=qs['offset'](_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x1a')]);}_0x2f9425['order']=qs['sort'](_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x36')]);_0x2f9425['where']=qs['filters'](_['pick'](_0x3d208b['query'],_0x3a13b7[_0xc8c7('0x37')]),_0x526530);if(_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x38')]){_0x2f9425[_0xc8c7('0x39')]=_[_0xc8c7('0x3a')](_0x2f9425[_0xc8c7('0x39')],{'$or':_[_0xc8c7('0x2a')](_0x526530,function(_0x473697){if(_0x473697[_0xc8c7('0x3b')]!==_0xc8c7('0x3c')){var _0x33b8a9={};_0x33b8a9[_0x473697['name']]={'$like':'%'+_0x3d208b[_0xc8c7('0x30')][_0xc8c7('0x38')]+'%'};return _0x33b8a9;}})});}_0x2f9425=_[_0xc8c7('0x3a')]({},_0x2f9425,_0x3d208b[_0xc8c7('0x3d')]);var _0x1d7732={'where':_0x2f9425[_0xc8c7('0x39')]};return db['VoiceQueuesLog'][_0xc8c7('0x1c')](_0x1d7732)['then'](function(_0x3f46cf){_0x13443[_0xc8c7('0x1c')]=_0x3f46cf;if(_0x3d208b['query'][_0xc8c7('0x3e')]){_0x2f9425['include']=[{'all':!![]}];}return db['VoiceQueuesLog'][_0xc8c7('0x3f')](_0x2f9425);})[_0xc8c7('0x24')](function(_0x5c81eb){_0x13443[_0xc8c7('0x40')]=_0x5c81eb;return _0x13443;})['then'](respondWithFilteredResult(_0x571cc0,_0x2f9425))[_0xc8c7('0x41')](handleError(_0x571cc0,null));};exports[_0xc8c7('0x42')]=function(_0x20d7b3,_0x4eb660){var _0x209e3e={'raw':!![],'where':{'id':_0x20d7b3[_0xc8c7('0x43')]['id']}},_0x19201a={};_0x19201a[_0xc8c7('0x2e')]=_[_0xc8c7('0x2f')](db[_0xc8c7('0x2b')]['rawAttributes']);_0x19201a[_0xc8c7('0x30')]=_[_0xc8c7('0x2f')](_0x20d7b3['query']);_0x19201a[_0xc8c7('0x37')]=_['intersection'](_0x19201a[_0xc8c7('0x2e')],_0x19201a[_0xc8c7('0x30')]);_0x209e3e[_0xc8c7('0x32')]=_[_0xc8c7('0x31')](_0x19201a[_0xc8c7('0x2e')],qs[_0xc8c7('0x33')](_0x20d7b3[_0xc8c7('0x30')][_0xc8c7('0x33')]));_0x209e3e[_0xc8c7('0x32')]=_0x209e3e[_0xc8c7('0x32')][_0xc8c7('0x34')]?_0x209e3e[_0xc8c7('0x32')]:_0x19201a[_0xc8c7('0x2e')];if(_0x20d7b3[_0xc8c7('0x30')][_0xc8c7('0x3e')]){_0x209e3e[_0xc8c7('0x44')]=[{'all':!![]}];}_0x209e3e=_[_0xc8c7('0x3a')]({},_0x209e3e,_0x20d7b3['options']);return db['VoiceQueuesLog']['find'](_0x209e3e)['then'](handleEntityNotFound(_0x4eb660,null))[_0xc8c7('0x24')](respondWithResult(_0x4eb660,null))[_0xc8c7('0x41')](handleError(_0x4eb660,null));};exports[_0xc8c7('0x45')]=function(_0x5119e5,_0x121f73){return db['VoiceQueuesLog'][_0xc8c7('0x45')](_0x5119e5[_0xc8c7('0x46')],{})['then'](respondWithResult(_0x121f73,0xc9))['catch'](handleError(_0x121f73,null));};exports[_0xc8c7('0x23')]=function(_0x6f332e,_0x545ed5){if(_0x6f332e[_0xc8c7('0x46')]['id']){delete _0x6f332e[_0xc8c7('0x46')]['id'];}return db[_0xc8c7('0x2b')][_0xc8c7('0x47')]({'where':{'id':_0x6f332e[_0xc8c7('0x43')]['id']}})[_0xc8c7('0x24')](handleEntityNotFound(_0x545ed5,null))[_0xc8c7('0x24')](saveUpdates(_0x6f332e['body'],null))[_0xc8c7('0x24')](respondWithResult(_0x545ed5,null))['catch'](handleError(_0x545ed5,null));};exports[_0xc8c7('0x48')]=function(_0x3d87d6,_0x5b50f1){return db[_0xc8c7('0x2b')][_0xc8c7('0x47')]({'where':{'id':_0x3d87d6[_0xc8c7('0x43')]['id']}})['then'](handleEntityNotFound(_0x5b50f1,null))[_0xc8c7('0x24')](removeEntity(_0x5b50f1,null))[_0xc8c7('0x41')](handleError(_0x5b50f1,null));};