Built motion from commit 43538d75.|2.5.35
[motion2.git] / server / api / chatQueueReport / chatQueueReport.controller.js
index be6e35f..c6f14b1 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x661f=['crypto','desk.js','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','count','offset','limit','set','apply','reject','save','update','then','destroy','error','stack','name','send','index','map','rawAttributes','type','key','model','keys','query','filters','intersection','attributes','fields','length','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','ChatQueueReport','includeAll','include','findAll','rows','catch','show','params','options','find','create','body','describe','html-pdf','eml-format','request-promise','moment','bluebird','mustache','util','path','sox','to-csv'];(function(_0x27972c,_0x16f37d){var _0x2ce05b=function(_0x106f14){while(--_0x106f14){_0x27972c['push'](_0x27972c['shift']());}};_0x2ce05b(++_0x16f37d);}(_0x661f,0x8c));var _0xf661=function(_0x22b68a,_0x2bffc3){_0x22b68a=_0x22b68a-0x0;var _0x1ac67a=_0x661f[_0x22b68a];return _0x1ac67a;};'use strict';var pdf=require(_0xf661('0x0'));var emlformat=require(_0xf661('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xf661('0x2'));var moment=require(_0xf661('0x3'));var BPromise=require(_0xf661('0x4'));var Mustache=require(_0xf661('0x5'));var util=require(_0xf661('0x6'));var path=require(_0xf661('0x7'));var sox=require(_0xf661('0x8'));var csv=require(_0xf661('0x9'));var ejs=require('ejs');var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xf661('0xa'));var jsforce=require('jsforce');var deskjs=require(_0xf661('0xb'));var toCsv=require(_0xf661('0x9'));var querystring=require(_0xf661('0xc'));var Papa=require(_0xf661('0xd'));var Redis=require(_0xf661('0xe'));var authService=require('../../components/auth/service');var qs=require(_0xf661('0xf'));var as=require(_0xf661('0x10'));var hardwareService=require(_0xf661('0x11'));var logger=require('../../config/logger')(_0xf661('0x12'));var utils=require(_0xf661('0x13'));var config=require(_0xf661('0x14'));var licenseUtil=require(_0xf661('0x15'));var db=require(_0xf661('0x16'))['db'];function respondWithStatusCode(_0x2a1e13,_0x5d2f30){_0x5d2f30=_0x5d2f30||0xcc;return function(_0x4d5e71){if(_0x4d5e71){return _0x2a1e13[_0xf661('0x17')](_0x5d2f30);}return _0x2a1e13[_0xf661('0x18')](_0x5d2f30)[_0xf661('0x19')]();};}function respondWithResult(_0x4b03ef,_0x5e2a4c){_0x5e2a4c=_0x5e2a4c||0xc8;return function(_0x35d193){if(_0x35d193){return _0x4b03ef[_0xf661('0x18')](_0x5e2a4c)[_0xf661('0x1a')](_0x35d193);}};}function respondWithFilteredResult(_0x44d64b,_0x4a4610){return function(_0x530ae3){if(_0x530ae3){var _0x34f699=_0x530ae3[_0xf661('0x1b')],_0x51e5b4=_0x4a4610[_0xf661('0x1c')],_0x43a92a=_0x4a4610[_0xf661('0x1c')]+_0x4a4610[_0xf661('0x1d')],_0x2c46e1;if(_0x43a92a>=_0x34f699){_0x43a92a=_0x34f699;_0x2c46e1=0xc8;}else{_0x2c46e1=0xce;}_0x44d64b[_0xf661('0x18')](_0x2c46e1);return _0x44d64b[_0xf661('0x1e')]('Content-Range',_0x51e5b4+'-'+_0x43a92a+'/'+_0x34f699)['json'](_0x530ae3);}return null;};}function patchUpdates(_0x4194a7){return function(_0x5258dc){try{jsonpatch[_0xf661('0x1f')](_0x5258dc,_0x4194a7,!![]);}catch(_0x1bac26){return BPromise[_0xf661('0x20')](_0x1bac26);}return _0x5258dc[_0xf661('0x21')]();};}function saveUpdates(_0x23528a,_0x5ab193){return function(_0x4ce606){if(_0x4ce606){return _0x4ce606[_0xf661('0x22')](_0x23528a)[_0xf661('0x23')](function(_0x17948){return _0x17948;});}return null;};}function removeEntity(_0xf142ba,_0x1d4193){return function(_0x5a32c3){if(_0x5a32c3){return _0x5a32c3[_0xf661('0x24')]()['then'](function(){_0xf142ba['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0xcb339,_0x2172e6){return function(_0x335089){if(!_0x335089){_0xcb339['sendStatus'](0x194);}return _0x335089;};}function handleError(_0x56e7ff,_0x597a89){_0x597a89=_0x597a89||0x1f4;return function(_0x5ef2a9){logger[_0xf661('0x25')](_0x5ef2a9[_0xf661('0x26')]);if(_0x5ef2a9['name']){delete _0x5ef2a9[_0xf661('0x27')];}_0x56e7ff[_0xf661('0x18')](_0x597a89)[_0xf661('0x28')](_0x5ef2a9);};}exports[_0xf661('0x29')]=function(_0x39d959,_0xc03b53){var _0x530e1a={},_0x55e725={},_0x5d78e3={'count':0x0,'rows':[]};var _0x2eb498=_[_0xf661('0x2a')](db['ChatQueueReport'][_0xf661('0x2b')],function(_0x125c9c){return{'name':_0x125c9c['fieldName'],'type':_0x125c9c[_0xf661('0x2c')][_0xf661('0x2d')]};});_0x55e725[_0xf661('0x2e')]=_['map'](_0x2eb498,_0xf661('0x27'));_0x55e725['query']=_[_0xf661('0x2f')](_0x39d959[_0xf661('0x30')]);_0x55e725[_0xf661('0x31')]=_[_0xf661('0x32')](_0x55e725[_0xf661('0x2e')],_0x55e725['query']);_0x530e1a[_0xf661('0x33')]=_[_0xf661('0x32')](_0x55e725[_0xf661('0x2e')],qs[_0xf661('0x34')](_0x39d959[_0xf661('0x30')]['fields']));_0x530e1a['attributes']=_0x530e1a['attributes'][_0xf661('0x35')]?_0x530e1a[_0xf661('0x33')]:_0x55e725[_0xf661('0x2e')];if(!_0x39d959['query']['hasOwnProperty'](_0xf661('0x36'))){_0x530e1a[_0xf661('0x1d')]=qs[_0xf661('0x1d')](_0x39d959[_0xf661('0x30')]['limit']);_0x530e1a[_0xf661('0x1c')]=qs[_0xf661('0x1c')](_0x39d959[_0xf661('0x30')][_0xf661('0x1c')]);}_0x530e1a[_0xf661('0x37')]=qs[_0xf661('0x38')](_0x39d959['query']['sort']);_0x530e1a[_0xf661('0x39')]=qs[_0xf661('0x31')](_[_0xf661('0x3a')](_0x39d959['query'],_0x55e725['filters']),_0x2eb498);if(_0x39d959[_0xf661('0x30')][_0xf661('0x3b')]){_0x530e1a[_0xf661('0x39')]=_[_0xf661('0x3c')](_0x530e1a[_0xf661('0x39')],{'$or':_[_0xf661('0x2a')](_0x2eb498,function(_0x2e082e){if(_0x2e082e[_0xf661('0x2c')]!==_0xf661('0x3d')){var _0x15993c={};_0x15993c[_0x2e082e[_0xf661('0x27')]]={'$like':'%'+_0x39d959[_0xf661('0x30')]['filter']+'%'};return _0x15993c;}})});}_0x530e1a=_[_0xf661('0x3c')]({},_0x530e1a,_0x39d959['options']);var _0x447a74={'where':_0x530e1a[_0xf661('0x39')]};return db[_0xf661('0x3e')][_0xf661('0x1b')](_0x447a74)['then'](function(_0x3deb12){_0x5d78e3[_0xf661('0x1b')]=_0x3deb12;if(_0x39d959[_0xf661('0x30')][_0xf661('0x3f')]){_0x530e1a[_0xf661('0x40')]=[{'all':!![]}];}return db[_0xf661('0x3e')][_0xf661('0x41')](_0x530e1a);})[_0xf661('0x23')](function(_0x1bb270){_0x5d78e3[_0xf661('0x42')]=_0x1bb270;return _0x5d78e3;})[_0xf661('0x23')](respondWithFilteredResult(_0xc03b53,_0x530e1a))[_0xf661('0x43')](handleError(_0xc03b53,null));};exports[_0xf661('0x44')]=function(_0x4b93d0,_0x8cabe2){var _0x1a17ae={'raw':!![],'where':{'id':_0x4b93d0[_0xf661('0x45')]['id']}},_0x3a0f30={};_0x3a0f30[_0xf661('0x2e')]=_[_0xf661('0x2f')](db[_0xf661('0x3e')][_0xf661('0x2b')]);_0x3a0f30[_0xf661('0x30')]=_[_0xf661('0x2f')](_0x4b93d0[_0xf661('0x30')]);_0x3a0f30[_0xf661('0x31')]=_[_0xf661('0x32')](_0x3a0f30[_0xf661('0x2e')],_0x3a0f30[_0xf661('0x30')]);_0x1a17ae['attributes']=_[_0xf661('0x32')](_0x3a0f30[_0xf661('0x2e')],qs['fields'](_0x4b93d0[_0xf661('0x30')][_0xf661('0x34')]));_0x1a17ae[_0xf661('0x33')]=_0x1a17ae[_0xf661('0x33')][_0xf661('0x35')]?_0x1a17ae['attributes']:_0x3a0f30['model'];if(_0x4b93d0[_0xf661('0x30')][_0xf661('0x3f')]){_0x1a17ae[_0xf661('0x40')]=[{'all':!![]}];}_0x1a17ae=_[_0xf661('0x3c')]({},_0x1a17ae,_0x4b93d0[_0xf661('0x46')]);return db[_0xf661('0x3e')][_0xf661('0x47')](_0x1a17ae)['then'](handleEntityNotFound(_0x8cabe2,null))[_0xf661('0x23')](respondWithResult(_0x8cabe2,null))[_0xf661('0x43')](handleError(_0x8cabe2,null));};exports[_0xf661('0x48')]=function(_0x523748,_0x5221e6){return db[_0xf661('0x3e')]['create'](_0x523748[_0xf661('0x49')],{})[_0xf661('0x23')](respondWithResult(_0x5221e6,0xc9))[_0xf661('0x43')](handleError(_0x5221e6,null));};exports['update']=function(_0xae571b,_0x1ec32b){if(_0xae571b[_0xf661('0x49')]['id']){delete _0xae571b[_0xf661('0x49')]['id'];}return db[_0xf661('0x3e')][_0xf661('0x47')]({'where':{'id':_0xae571b['params']['id']}})[_0xf661('0x23')](handleEntityNotFound(_0x1ec32b,null))[_0xf661('0x23')](saveUpdates(_0xae571b[_0xf661('0x49')],null))['then'](respondWithResult(_0x1ec32b,null))['catch'](handleError(_0x1ec32b,null));};exports['destroy']=function(_0x1f3214,_0x3b3a6a){return db[_0xf661('0x3e')][_0xf661('0x47')]({'where':{'id':_0x1f3214[_0xf661('0x45')]['id']}})[_0xf661('0x23')](handleEntityNotFound(_0x3b3a6a,null))[_0xf661('0x23')](removeEntity(_0x3b3a6a,null))['catch'](handleError(_0x3b3a6a,null));};exports[_0xf661('0x4a')]=function(_0x99573c,_0x1f8eea){return db['ChatQueueReport'][_0xf661('0x4a')]()[_0xf661('0x23')](respondWithResult(_0x1f8eea,null))[_0xf661('0x43')](handleError(_0x1f8eea,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