Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / chatQueueReport / chatQueueReport.controller.js
index 7181ce3..c6f14b1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x15f1=['include','options','find','body','describe','html-pdf','eml-format','rimraf','zip-dir','request-promise','moment','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','end','status','json','offset','limit','Content-Range','save','update','then','destroy','sendStatus','stack','name','send','index','map','ChatQueueReport','rawAttributes','fieldName','type','key','model','query','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','VIRTUAL','merge','count','findAll','rows','catch','show','params','keys','filters','includeAll'];(function(_0x332299,_0x247952){var _0x5f4d5b=function(_0x5398bb){while(--_0x5398bb){_0x332299['push'](_0x332299['shift']());}};_0x5f4d5b(++_0x247952);}(_0x15f1,0x190));var _0x115f=function(_0x16837f,_0x5bf229){_0x16837f=_0x16837f-0x0;var _0x9eccc9=_0x15f1[_0x16837f];return _0x9eccc9;};'use strict';var pdf=require(_0x115f('0x0'));var emlformat=require(_0x115f('0x1'));var rimraf=require(_0x115f('0x2'));var zipdir=require(_0x115f('0x3'));var jsonpatch=require('fast-json-patch');var rp=require(_0x115f('0x4'));var moment=require(_0x115f('0x5'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x115f('0x6'));var path=require(_0x115f('0x7'));var sox=require(_0x115f('0x8'));var csv=require(_0x115f('0x9'));var ejs=require(_0x115f('0xa'));var fs=require('fs');var _=require(_0x115f('0xb'));var squel=require(_0x115f('0xc'));var crypto=require(_0x115f('0xd'));var jsforce=require(_0x115f('0xe'));var deskjs=require(_0x115f('0xf'));var toCsv=require(_0x115f('0x9'));var querystring=require(_0x115f('0x10'));var Papa=require(_0x115f('0x11'));var Redis=require(_0x115f('0x12'));var authService=require(_0x115f('0x13'));var qs=require(_0x115f('0x14'));var as=require(_0x115f('0x15'));var hardwareService=require(_0x115f('0x16'));var logger=require(_0x115f('0x17'))(_0x115f('0x18'));var utils=require(_0x115f('0x19'));var config=require(_0x115f('0x1a'));var licenseUtil=require(_0x115f('0x1b'));var db=require(_0x115f('0x1c'))['db'];function respondWithStatusCode(_0x365fc1,_0x3c39e1){_0x3c39e1=_0x3c39e1||0xcc;return function(_0x54e5fd){if(_0x54e5fd){return _0x365fc1['sendStatus'](_0x3c39e1);}return _0x365fc1['status'](_0x3c39e1)[_0x115f('0x1d')]();};}function respondWithResult(_0x387856,_0x81c1ca){_0x81c1ca=_0x81c1ca||0xc8;return function(_0x54edce){if(_0x54edce){return _0x387856[_0x115f('0x1e')](_0x81c1ca)[_0x115f('0x1f')](_0x54edce);}};}function respondWithFilteredResult(_0x1c297b,_0x1ae501){return function(_0x5c0893){if(_0x5c0893){var _0x2daeeb=_0x5c0893['count'],_0x3f6702=_0x1ae501[_0x115f('0x20')],_0x436899=_0x1ae501[_0x115f('0x20')]+_0x1ae501[_0x115f('0x21')],_0x10be93;if(_0x436899>=_0x2daeeb){_0x436899=_0x2daeeb;_0x10be93=0xc8;}else{_0x10be93=0xce;}_0x1c297b[_0x115f('0x1e')](_0x10be93);return _0x1c297b['set'](_0x115f('0x22'),_0x3f6702+'-'+_0x436899+'/'+_0x2daeeb)[_0x115f('0x1f')](_0x5c0893);}return null;};}function patchUpdates(_0x1c4ce7){return function(_0x589593){try{jsonpatch['apply'](_0x589593,_0x1c4ce7,!![]);}catch(_0x2eae3a){return BPromise['reject'](_0x2eae3a);}return _0x589593[_0x115f('0x23')]();};}function saveUpdates(_0x151a18,_0x20be38){return function(_0x2aaf20){if(_0x2aaf20){return _0x2aaf20[_0x115f('0x24')](_0x151a18)[_0x115f('0x25')](function(_0x1bfb9c){return _0x1bfb9c;});}return null;};}function removeEntity(_0xa7896,_0x347e3c){return function(_0x2e0518){if(_0x2e0518){return _0x2e0518[_0x115f('0x26')]()[_0x115f('0x25')](function(){_0xa7896[_0x115f('0x1e')](0xcc)[_0x115f('0x1d')]();});}};}function handleEntityNotFound(_0x2e18e9,_0x31035e){return function(_0x4b09f5){if(!_0x4b09f5){_0x2e18e9[_0x115f('0x27')](0x194);}return _0x4b09f5;};}function handleError(_0x2965e2,_0x229147){_0x229147=_0x229147||0x1f4;return function(_0x2ffd0e){logger['error'](_0x2ffd0e[_0x115f('0x28')]);if(_0x2ffd0e[_0x115f('0x29')]){delete _0x2ffd0e[_0x115f('0x29')];}_0x2965e2['status'](_0x229147)[_0x115f('0x2a')](_0x2ffd0e);};}exports[_0x115f('0x2b')]=function(_0x4c75f6,_0x3c0bf1){var _0x17dfed={},_0x3f2354={},_0x1ee2b5={'count':0x0,'rows':[]};var _0x42a119=_[_0x115f('0x2c')](db[_0x115f('0x2d')][_0x115f('0x2e')],function(_0x43fd23){return{'name':_0x43fd23[_0x115f('0x2f')],'type':_0x43fd23[_0x115f('0x30')][_0x115f('0x31')]};});_0x3f2354[_0x115f('0x32')]=_[_0x115f('0x2c')](_0x42a119,_0x115f('0x29'));_0x3f2354[_0x115f('0x33')]=_['keys'](_0x4c75f6[_0x115f('0x33')]);_0x3f2354['filters']=_[_0x115f('0x34')](_0x3f2354['model'],_0x3f2354[_0x115f('0x33')]);_0x17dfed['attributes']=_[_0x115f('0x34')](_0x3f2354[_0x115f('0x32')],qs['fields'](_0x4c75f6['query'][_0x115f('0x35')]));_0x17dfed[_0x115f('0x36')]=_0x17dfed['attributes'][_0x115f('0x37')]?_0x17dfed['attributes']:_0x3f2354[_0x115f('0x32')];if(!_0x4c75f6[_0x115f('0x33')][_0x115f('0x38')](_0x115f('0x39'))){_0x17dfed[_0x115f('0x21')]=qs[_0x115f('0x21')](_0x4c75f6['query'][_0x115f('0x21')]);_0x17dfed[_0x115f('0x20')]=qs[_0x115f('0x20')](_0x4c75f6['query'][_0x115f('0x20')]);}_0x17dfed[_0x115f('0x3a')]=qs[_0x115f('0x3b')](_0x4c75f6[_0x115f('0x33')]['sort']);_0x17dfed[_0x115f('0x3c')]=qs['filters'](_[_0x115f('0x3d')](_0x4c75f6[_0x115f('0x33')],_0x3f2354['filters']),_0x42a119);if(_0x4c75f6[_0x115f('0x33')][_0x115f('0x3e')]){_0x17dfed[_0x115f('0x3c')]=_['merge'](_0x17dfed[_0x115f('0x3c')],{'$or':_[_0x115f('0x2c')](_0x42a119,function(_0x3d7ed7){if(_0x3d7ed7['type']!==_0x115f('0x3f')){var _0x16cc8b={};_0x16cc8b[_0x3d7ed7['name']]={'$like':'%'+_0x4c75f6[_0x115f('0x33')]['filter']+'%'};return _0x16cc8b;}})});}_0x17dfed=_[_0x115f('0x40')]({},_0x17dfed,_0x4c75f6['options']);var _0x3895ee={'where':_0x17dfed[_0x115f('0x3c')]};return db[_0x115f('0x2d')][_0x115f('0x41')](_0x3895ee)['then'](function(_0x53cba8){_0x1ee2b5[_0x115f('0x41')]=_0x53cba8;if(_0x4c75f6['query']['includeAll']){_0x17dfed['include']=[{'all':!![]}];}return db[_0x115f('0x2d')][_0x115f('0x42')](_0x17dfed);})['then'](function(_0x55e6fa){_0x1ee2b5[_0x115f('0x43')]=_0x55e6fa;return _0x1ee2b5;})[_0x115f('0x25')](respondWithFilteredResult(_0x3c0bf1,_0x17dfed))[_0x115f('0x44')](handleError(_0x3c0bf1,null));};exports[_0x115f('0x45')]=function(_0x44689c,_0xafb744){var _0x1ef71d={'raw':!![],'where':{'id':_0x44689c[_0x115f('0x46')]['id']}},_0x3e7cb4={};_0x3e7cb4[_0x115f('0x32')]=_[_0x115f('0x47')](db['ChatQueueReport'][_0x115f('0x2e')]);_0x3e7cb4[_0x115f('0x33')]=_['keys'](_0x44689c['query']);_0x3e7cb4[_0x115f('0x48')]=_[_0x115f('0x34')](_0x3e7cb4['model'],_0x3e7cb4[_0x115f('0x33')]);_0x1ef71d['attributes']=_[_0x115f('0x34')](_0x3e7cb4[_0x115f('0x32')],qs['fields'](_0x44689c[_0x115f('0x33')][_0x115f('0x35')]));_0x1ef71d['attributes']=_0x1ef71d[_0x115f('0x36')]['length']?_0x1ef71d[_0x115f('0x36')]:_0x3e7cb4[_0x115f('0x32')];if(_0x44689c[_0x115f('0x33')][_0x115f('0x49')]){_0x1ef71d[_0x115f('0x4a')]=[{'all':!![]}];}_0x1ef71d=_[_0x115f('0x40')]({},_0x1ef71d,_0x44689c[_0x115f('0x4b')]);return db[_0x115f('0x2d')][_0x115f('0x4c')](_0x1ef71d)[_0x115f('0x25')](handleEntityNotFound(_0xafb744,null))['then'](respondWithResult(_0xafb744,null))[_0x115f('0x44')](handleError(_0xafb744,null));};exports['create']=function(_0x6aaae6,_0x17d3ca){return db[_0x115f('0x2d')]['create'](_0x6aaae6[_0x115f('0x4d')],{})[_0x115f('0x25')](respondWithResult(_0x17d3ca,0xc9))[_0x115f('0x44')](handleError(_0x17d3ca,null));};exports['update']=function(_0x524a5b,_0x40c14b){if(_0x524a5b[_0x115f('0x4d')]['id']){delete _0x524a5b[_0x115f('0x4d')]['id'];}return db[_0x115f('0x2d')]['find']({'where':{'id':_0x524a5b[_0x115f('0x46')]['id']}})['then'](handleEntityNotFound(_0x40c14b,null))[_0x115f('0x25')](saveUpdates(_0x524a5b[_0x115f('0x4d')],null))[_0x115f('0x25')](respondWithResult(_0x40c14b,null))[_0x115f('0x44')](handleError(_0x40c14b,null));};exports[_0x115f('0x26')]=function(_0x431b13,_0x47b41c){return db[_0x115f('0x2d')]['find']({'where':{'id':_0x431b13[_0x115f('0x46')]['id']}})[_0x115f('0x25')](handleEntityNotFound(_0x47b41c,null))[_0x115f('0x25')](removeEntity(_0x47b41c,null))[_0x115f('0x44')](handleError(_0x47b41c,null));};exports[_0x115f('0x4e')]=function(_0x279843,_0x502303){return db[_0x115f('0x2d')]['describe']()[_0x115f('0x25')](respondWithResult(_0x502303,null))[_0x115f('0x44')](handleError(_0x502303,null));};
\ No newline at end of file
+var _0xc14a=['length','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','options','includeAll','include','ChatQueueReport','findAll','rows','show','params','find','catch','create','body','update','describe','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','path','to-csv','ejs','fs-extra','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','sendStatus','end','json','offset','undefined','limit','count','status','set','Content-Range','reject','then','destroy','error','stack','name','rawAttributes','fieldName','type','key','map','query','keys','filters','model','attributes','intersection','fields'];(function(_0x423786,_0x324952){var _0x64f04f=function(_0x30f3e7){while(--_0x30f3e7){_0x423786['push'](_0x423786['shift']());}};_0x64f04f(++_0x324952);}(_0xc14a,0xa9));var _0xac14=function(_0x3947c9,_0x4d6c97){_0x3947c9=_0x3947c9-0x0;var _0x2e7871=_0xc14a[_0x3947c9];return _0x2e7871;};'use strict';var emlformat=require(_0xac14('0x0'));var rimraf=require(_0xac14('0x1'));var zipdir=require(_0xac14('0x2'));var jsonpatch=require(_0xac14('0x3'));var rp=require(_0xac14('0x4'));var moment=require('moment');var BPromise=require(_0xac14('0x5'));var Mustache=require(_0xac14('0x6'));var util=require('util');var path=require(_0xac14('0x7'));var sox=require('sox');var csv=require(_0xac14('0x8'));var ejs=require(_0xac14('0x9'));var fs=require('fs');var fs_extra=require(_0xac14('0xa'));var _=require('lodash');var squel=require(_0xac14('0xb'));var crypto=require(_0xac14('0xc'));var jsforce=require(_0xac14('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xac14('0x8'));var querystring=require(_0xac14('0xe'));var Papa=require(_0xac14('0xf'));var Redis=require(_0xac14('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xac14('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xac14('0x12'));var logger=require(_0xac14('0x13'))('api');var utils=require('../../config/utils');var config=require(_0xac14('0x14'));var licenseUtil=require(_0xac14('0x15'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x11d522,_0x394952){_0x394952=_0x394952||0xcc;return function(_0x5920f7){if(_0x5920f7){return _0x11d522[_0xac14('0x16')](_0x394952);}return _0x11d522['status'](_0x394952)[_0xac14('0x17')]();};}function respondWithResult(_0x3a171d,_0x44e80d){_0x44e80d=_0x44e80d||0xc8;return function(_0x5a80ed){if(_0x5a80ed){return _0x3a171d['status'](_0x44e80d)[_0xac14('0x18')](_0x5a80ed);}};}function respondWithFilteredResult(_0x5c00df,_0xe50537){return function(_0x497be2){if(_0x497be2){var _0x270284=typeof _0xe50537[_0xac14('0x19')]===_0xac14('0x1a')&&typeof _0xe50537[_0xac14('0x1b')]===_0xac14('0x1a');var _0x4d7f22=_0x497be2[_0xac14('0x1c')];var _0x219ee6=_0x270284?0x0:_0xe50537[_0xac14('0x19')];var _0x1682b1=_0x270284?_0x497be2[_0xac14('0x1c')]:_0xe50537[_0xac14('0x19')]+_0xe50537[_0xac14('0x1b')];var _0x572d08;if(_0x1682b1>=_0x4d7f22){_0x1682b1=_0x4d7f22;_0x572d08=0xc8;}else{_0x572d08=0xce;}_0x5c00df[_0xac14('0x1d')](_0x572d08);return _0x5c00df[_0xac14('0x1e')](_0xac14('0x1f'),_0x219ee6+'-'+_0x1682b1+'/'+_0x4d7f22)[_0xac14('0x18')](_0x497be2);}return null;};}function patchUpdates(_0x14b2a0){return function(_0x52d9d2){try{jsonpatch['apply'](_0x52d9d2,_0x14b2a0,!![]);}catch(_0x1cbb67){return BPromise[_0xac14('0x20')](_0x1cbb67);}return _0x52d9d2['save']();};}function saveUpdates(_0x44a533,_0x492f37){return function(_0x528406){if(_0x528406){return _0x528406['update'](_0x44a533)[_0xac14('0x21')](function(_0x4c6580){return _0x4c6580;});}return null;};}function removeEntity(_0x1b863e,_0x8e5979){return function(_0x272b46){if(_0x272b46){return _0x272b46[_0xac14('0x22')]()['then'](function(){_0x1b863e[_0xac14('0x1d')](0xcc)['end']();});}};}function handleEntityNotFound(_0x186a10,_0xa2c069){return function(_0x536eb3){if(!_0x536eb3){_0x186a10[_0xac14('0x16')](0x194);}return _0x536eb3;};}function handleError(_0x34f641,_0x3d2eeb){_0x3d2eeb=_0x3d2eeb||0x1f4;return function(_0x1c581b){logger[_0xac14('0x23')](_0x1c581b[_0xac14('0x24')]);if(_0x1c581b['name']){delete _0x1c581b[_0xac14('0x25')];}_0x34f641['status'](_0x3d2eeb)['send'](_0x1c581b);};}exports['index']=function(_0x23a5b3,_0x25b07e){var _0x2f6914={},_0x53584e={},_0x4b72e0={'count':0x0,'rows':[]};var _0x506837=_['map'](db['ChatQueueReport'][_0xac14('0x26')],function(_0x568024){return{'name':_0x568024[_0xac14('0x27')],'type':_0x568024[_0xac14('0x28')][_0xac14('0x29')]};});_0x53584e['model']=_[_0xac14('0x2a')](_0x506837,'name');_0x53584e[_0xac14('0x2b')]=_[_0xac14('0x2c')](_0x23a5b3[_0xac14('0x2b')]);_0x53584e[_0xac14('0x2d')]=_['intersection'](_0x53584e[_0xac14('0x2e')],_0x53584e[_0xac14('0x2b')]);_0x2f6914[_0xac14('0x2f')]=_[_0xac14('0x30')](_0x53584e[_0xac14('0x2e')],qs[_0xac14('0x31')](_0x23a5b3['query']['fields']));_0x2f6914['attributes']=_0x2f6914[_0xac14('0x2f')][_0xac14('0x32')]?_0x2f6914[_0xac14('0x2f')]:_0x53584e[_0xac14('0x2e')];if(!_0x23a5b3['query'][_0xac14('0x33')](_0xac14('0x34'))){_0x2f6914[_0xac14('0x1b')]=qs['limit'](_0x23a5b3[_0xac14('0x2b')][_0xac14('0x1b')]);_0x2f6914['offset']=qs['offset'](_0x23a5b3['query'][_0xac14('0x19')]);}_0x2f6914[_0xac14('0x35')]=qs[_0xac14('0x36')](_0x23a5b3[_0xac14('0x2b')][_0xac14('0x36')]);_0x2f6914[_0xac14('0x37')]=qs[_0xac14('0x2d')](_[_0xac14('0x38')](_0x23a5b3['query'],_0x53584e[_0xac14('0x2d')]),_0x506837);if(_0x23a5b3[_0xac14('0x2b')]['filter']){_0x2f6914[_0xac14('0x37')]=_[_0xac14('0x39')](_0x2f6914[_0xac14('0x37')],{'$or':_[_0xac14('0x2a')](_0x506837,function(_0x561a70){if(_0x561a70[_0xac14('0x28')]!==_0xac14('0x3a')){var _0x296644={};_0x296644[_0x561a70[_0xac14('0x25')]]={'$like':'%'+_0x23a5b3[_0xac14('0x2b')]['filter']+'%'};return _0x296644;}})});}_0x2f6914=_[_0xac14('0x39')]({},_0x2f6914,_0x23a5b3[_0xac14('0x3b')]);var _0x116a5a={'where':_0x2f6914[_0xac14('0x37')]};return db['ChatQueueReport'][_0xac14('0x1c')](_0x116a5a)['then'](function(_0x35f359){_0x4b72e0[_0xac14('0x1c')]=_0x35f359;if(_0x23a5b3[_0xac14('0x2b')][_0xac14('0x3c')]){_0x2f6914[_0xac14('0x3d')]=[{'all':!![]}];}return db[_0xac14('0x3e')][_0xac14('0x3f')](_0x2f6914);})['then'](function(_0x375712){_0x4b72e0[_0xac14('0x40')]=_0x375712;return _0x4b72e0;})[_0xac14('0x21')](respondWithFilteredResult(_0x25b07e,_0x2f6914))['catch'](handleError(_0x25b07e,null));};exports[_0xac14('0x41')]=function(_0x46b7ea,_0x515b58){var _0x160621={'raw':!![],'where':{'id':_0x46b7ea[_0xac14('0x42')]['id']}},_0x34932e={};_0x34932e[_0xac14('0x2e')]=_['keys'](db[_0xac14('0x3e')][_0xac14('0x26')]);_0x34932e[_0xac14('0x2b')]=_[_0xac14('0x2c')](_0x46b7ea['query']);_0x34932e['filters']=_[_0xac14('0x30')](_0x34932e[_0xac14('0x2e')],_0x34932e[_0xac14('0x2b')]);_0x160621[_0xac14('0x2f')]=_[_0xac14('0x30')](_0x34932e['model'],qs[_0xac14('0x31')](_0x46b7ea[_0xac14('0x2b')]['fields']));_0x160621[_0xac14('0x2f')]=_0x160621[_0xac14('0x2f')]['length']?_0x160621[_0xac14('0x2f')]:_0x34932e['model'];if(_0x46b7ea[_0xac14('0x2b')][_0xac14('0x3c')]){_0x160621[_0xac14('0x3d')]=[{'all':!![]}];}_0x160621=_[_0xac14('0x39')]({},_0x160621,_0x46b7ea[_0xac14('0x3b')]);return db[_0xac14('0x3e')][_0xac14('0x43')](_0x160621)[_0xac14('0x21')](handleEntityNotFound(_0x515b58,null))[_0xac14('0x21')](respondWithResult(_0x515b58,null))[_0xac14('0x44')](handleError(_0x515b58,null));};exports[_0xac14('0x45')]=function(_0x43d34e,_0x1ba97c){return db['ChatQueueReport'][_0xac14('0x45')](_0x43d34e[_0xac14('0x46')],{})[_0xac14('0x21')](respondWithResult(_0x1ba97c,0xc9))[_0xac14('0x44')](handleError(_0x1ba97c,null));};exports[_0xac14('0x47')]=function(_0x19b9a2,_0x24764b){if(_0x19b9a2[_0xac14('0x46')]['id']){delete _0x19b9a2[_0xac14('0x46')]['id'];}return db['ChatQueueReport']['find']({'where':{'id':_0x19b9a2[_0xac14('0x42')]['id']}})[_0xac14('0x21')](handleEntityNotFound(_0x24764b,null))[_0xac14('0x21')](saveUpdates(_0x19b9a2['body'],null))[_0xac14('0x21')](respondWithResult(_0x24764b,null))[_0xac14('0x44')](handleError(_0x24764b,null));};exports[_0xac14('0x22')]=function(_0x5d817a,_0x33b158){return db[_0xac14('0x3e')]['find']({'where':{'id':_0x5d817a[_0xac14('0x42')]['id']}})[_0xac14('0x21')](handleEntityNotFound(_0x33b158,null))[_0xac14('0x21')](removeEntity(_0x33b158,null))['catch'](handleError(_0x33b158,null));};exports[_0xac14('0x48')]=function(_0xa6acb3,_0x3e94b6){return db[_0xac14('0x3e')][_0xac14('0x48')]()[_0xac14('0x21')](respondWithResult(_0x3e94b6,null))[_0xac14('0x44')](handleError(_0x3e94b6,null));};
\ No newline at end of file