Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatQueueReport / chatQueueReport.controller.js
index c6f14b1..af9abeb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-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
+var _0x61f1=['find','create','body','describe','rimraf','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','then','error','stack','name','send','index','ChatQueueReport','rawAttributes','fieldName','type','key','model','map','keys','query','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','VIRTUAL','merge','includeAll','include','findAll','catch','show','params'];(function(_0x424d98,_0xae5075){var _0xdad5cd=function(_0x227acd){while(--_0x227acd){_0x424d98['push'](_0x424d98['shift']());}};_0xdad5cd(++_0xae5075);}(_0x61f1,0x18a));var _0x161f=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0x61f1[_0x20a584];return _0x4b41a8;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x161f('0x0'));var zipdir=require('zip-dir');var jsonpatch=require(_0x161f('0x1'));var rp=require(_0x161f('0x2'));var moment=require(_0x161f('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x161f('0x4'));var path=require(_0x161f('0x5'));var sox=require('sox');var csv=require(_0x161f('0x6'));var ejs=require(_0x161f('0x7'));var fs=require('fs');var fs_extra=require(_0x161f('0x8'));var _=require(_0x161f('0x9'));var squel=require(_0x161f('0xa'));var crypto=require('crypto');var jsforce=require(_0x161f('0xb'));var deskjs=require(_0x161f('0xc'));var toCsv=require(_0x161f('0x6'));var querystring=require(_0x161f('0xd'));var Papa=require(_0x161f('0xe'));var Redis=require(_0x161f('0xf'));var authService=require(_0x161f('0x10'));var qs=require(_0x161f('0x11'));var as=require(_0x161f('0x12'));var hardwareService=require(_0x161f('0x13'));var logger=require(_0x161f('0x14'))('api');var utils=require(_0x161f('0x15'));var config=require(_0x161f('0x16'));var licenseUtil=require(_0x161f('0x17'));var db=require(_0x161f('0x18'))['db'];function respondWithStatusCode(_0x113346,_0x4b0917){_0x4b0917=_0x4b0917||0xcc;return function(_0x30b9fb){if(_0x30b9fb){return _0x113346[_0x161f('0x19')](_0x4b0917);}return _0x113346[_0x161f('0x1a')](_0x4b0917)[_0x161f('0x1b')]();};}function respondWithResult(_0x4b34db,_0xc6108b){_0xc6108b=_0xc6108b||0xc8;return function(_0x3a80c4){if(_0x3a80c4){return _0x4b34db[_0x161f('0x1a')](_0xc6108b)[_0x161f('0x1c')](_0x3a80c4);}};}function respondWithFilteredResult(_0x4470d9,_0x1ceffb){return function(_0x594742){if(_0x594742){var _0x486261=typeof _0x1ceffb[_0x161f('0x1d')]===_0x161f('0x1e')&&typeof _0x1ceffb[_0x161f('0x1f')]==='undefined';var _0x325d4c=_0x594742[_0x161f('0x20')];var _0x2cf920=_0x486261?0x0:_0x1ceffb['offset'];var _0x420818=_0x486261?_0x594742['count']:_0x1ceffb[_0x161f('0x1d')]+_0x1ceffb[_0x161f('0x1f')];var _0x10fd8e;if(_0x420818>=_0x325d4c){_0x420818=_0x325d4c;_0x10fd8e=0xc8;}else{_0x10fd8e=0xce;}_0x4470d9[_0x161f('0x1a')](_0x10fd8e);return _0x4470d9[_0x161f('0x21')](_0x161f('0x22'),_0x2cf920+'-'+_0x420818+'/'+_0x325d4c)[_0x161f('0x1c')](_0x594742);}return null;};}function patchUpdates(_0x3a3a61){return function(_0x1153ce){try{jsonpatch[_0x161f('0x23')](_0x1153ce,_0x3a3a61,!![]);}catch(_0xdba48d){return BPromise[_0x161f('0x24')](_0xdba48d);}return _0x1153ce[_0x161f('0x25')]();};}function saveUpdates(_0x5a92b8,_0x3ae0dc){return function(_0xc6fc5e){if(_0xc6fc5e){return _0xc6fc5e[_0x161f('0x26')](_0x5a92b8)['then'](function(_0x5966d6){return _0x5966d6;});}return null;};}function removeEntity(_0xca1a9f,_0xaf2a44){return function(_0x161d91){if(_0x161d91){return _0x161d91[_0x161f('0x27')]()[_0x161f('0x28')](function(){_0xca1a9f['status'](0xcc)[_0x161f('0x1b')]();});}};}function handleEntityNotFound(_0x2b501f,_0x2ad3d2){return function(_0x4c1cac){if(!_0x4c1cac){_0x2b501f[_0x161f('0x19')](0x194);}return _0x4c1cac;};}function handleError(_0x378423,_0xe900b0){_0xe900b0=_0xe900b0||0x1f4;return function(_0x413c75){logger[_0x161f('0x29')](_0x413c75[_0x161f('0x2a')]);if(_0x413c75['name']){delete _0x413c75[_0x161f('0x2b')];}_0x378423[_0x161f('0x1a')](_0xe900b0)[_0x161f('0x2c')](_0x413c75);};}exports[_0x161f('0x2d')]=function(_0x94935,_0xc3a866){var _0x589793={},_0x18e910={},_0x3c5717={'count':0x0,'rows':[]};var _0x264d09=_['map'](db[_0x161f('0x2e')][_0x161f('0x2f')],function(_0x151bf4){return{'name':_0x151bf4[_0x161f('0x30')],'type':_0x151bf4[_0x161f('0x31')][_0x161f('0x32')]};});_0x18e910[_0x161f('0x33')]=_[_0x161f('0x34')](_0x264d09,'name');_0x18e910['query']=_[_0x161f('0x35')](_0x94935[_0x161f('0x36')]);_0x18e910[_0x161f('0x37')]=_['intersection'](_0x18e910['model'],_0x18e910['query']);_0x589793[_0x161f('0x38')]=_[_0x161f('0x39')](_0x18e910['model'],qs[_0x161f('0x3a')](_0x94935[_0x161f('0x36')][_0x161f('0x3a')]));_0x589793[_0x161f('0x38')]=_0x589793['attributes'][_0x161f('0x3b')]?_0x589793['attributes']:_0x18e910[_0x161f('0x33')];if(!_0x94935[_0x161f('0x36')][_0x161f('0x3c')](_0x161f('0x3d'))){_0x589793[_0x161f('0x1f')]=qs[_0x161f('0x1f')](_0x94935[_0x161f('0x36')][_0x161f('0x1f')]);_0x589793[_0x161f('0x1d')]=qs[_0x161f('0x1d')](_0x94935['query'][_0x161f('0x1d')]);}_0x589793['order']=qs[_0x161f('0x3e')](_0x94935[_0x161f('0x36')]['sort']);_0x589793[_0x161f('0x3f')]=qs[_0x161f('0x37')](_[_0x161f('0x40')](_0x94935[_0x161f('0x36')],_0x18e910['filters']),_0x264d09);if(_0x94935[_0x161f('0x36')][_0x161f('0x41')]){_0x589793['where']=_['merge'](_0x589793['where'],{'$or':_[_0x161f('0x34')](_0x264d09,function(_0x1dc384){if(_0x1dc384['type']!==_0x161f('0x42')){var _0x4cdb1a={};_0x4cdb1a[_0x1dc384['name']]={'$like':'%'+_0x94935[_0x161f('0x36')][_0x161f('0x41')]+'%'};return _0x4cdb1a;}})});}_0x589793=_[_0x161f('0x43')]({},_0x589793,_0x94935['options']);var _0x779e5f={'where':_0x589793[_0x161f('0x3f')]};return db[_0x161f('0x2e')][_0x161f('0x20')](_0x779e5f)[_0x161f('0x28')](function(_0x44b437){_0x3c5717[_0x161f('0x20')]=_0x44b437;if(_0x94935[_0x161f('0x36')][_0x161f('0x44')]){_0x589793[_0x161f('0x45')]=[{'all':!![]}];}return db[_0x161f('0x2e')][_0x161f('0x46')](_0x589793);})[_0x161f('0x28')](function(_0x49a60b){_0x3c5717['rows']=_0x49a60b;return _0x3c5717;})[_0x161f('0x28')](respondWithFilteredResult(_0xc3a866,_0x589793))[_0x161f('0x47')](handleError(_0xc3a866,null));};exports[_0x161f('0x48')]=function(_0xbf283e,_0x51076d){var _0xebcfb1={'raw':!![],'where':{'id':_0xbf283e[_0x161f('0x49')]['id']}},_0x2972d3={};_0x2972d3[_0x161f('0x33')]=_[_0x161f('0x35')](db[_0x161f('0x2e')][_0x161f('0x2f')]);_0x2972d3['query']=_[_0x161f('0x35')](_0xbf283e[_0x161f('0x36')]);_0x2972d3['filters']=_['intersection'](_0x2972d3[_0x161f('0x33')],_0x2972d3['query']);_0xebcfb1[_0x161f('0x38')]=_[_0x161f('0x39')](_0x2972d3[_0x161f('0x33')],qs[_0x161f('0x3a')](_0xbf283e[_0x161f('0x36')][_0x161f('0x3a')]));_0xebcfb1[_0x161f('0x38')]=_0xebcfb1[_0x161f('0x38')]['length']?_0xebcfb1[_0x161f('0x38')]:_0x2972d3[_0x161f('0x33')];if(_0xbf283e[_0x161f('0x36')][_0x161f('0x44')]){_0xebcfb1[_0x161f('0x45')]=[{'all':!![]}];}_0xebcfb1=_[_0x161f('0x43')]({},_0xebcfb1,_0xbf283e['options']);return db[_0x161f('0x2e')][_0x161f('0x4a')](_0xebcfb1)[_0x161f('0x28')](handleEntityNotFound(_0x51076d,null))[_0x161f('0x28')](respondWithResult(_0x51076d,null))[_0x161f('0x47')](handleError(_0x51076d,null));};exports['create']=function(_0x5bbc82,_0x5d8ef8){return db['ChatQueueReport'][_0x161f('0x4b')](_0x5bbc82['body'],{})[_0x161f('0x28')](respondWithResult(_0x5d8ef8,0xc9))['catch'](handleError(_0x5d8ef8,null));};exports[_0x161f('0x26')]=function(_0x23c4ce,_0x913df3){if(_0x23c4ce['body']['id']){delete _0x23c4ce[_0x161f('0x4c')]['id'];}return db[_0x161f('0x2e')]['find']({'where':{'id':_0x23c4ce['params']['id']}})[_0x161f('0x28')](handleEntityNotFound(_0x913df3,null))['then'](saveUpdates(_0x23c4ce[_0x161f('0x4c')],null))['then'](respondWithResult(_0x913df3,null))[_0x161f('0x47')](handleError(_0x913df3,null));};exports[_0x161f('0x27')]=function(_0x165aff,_0x3f2ebb){return db[_0x161f('0x2e')][_0x161f('0x4a')]({'where':{'id':_0x165aff[_0x161f('0x49')]['id']}})[_0x161f('0x28')](handleEntityNotFound(_0x3f2ebb,null))[_0x161f('0x28')](removeEntity(_0x3f2ebb,null))[_0x161f('0x47')](handleError(_0x3f2ebb,null));};exports[_0x161f('0x4d')]=function(_0x67219b,_0x26623f){return db[_0x161f('0x2e')][_0x161f('0x4d')]()[_0x161f('0x28')](respondWithResult(_0x26623f,null))[_0x161f('0x47')](handleError(_0x26623f,null));};
\ No newline at end of file