Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / chatQueueReport / chatQueueReport.controller.js
index 3e2e2aa..af9abeb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x06ae=['../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','sendStatus','status','end','offset','limit','set','Content-Range','json','apply','reject','save','update','then','destroy','error','stack','name','index','map','rawAttributes','fieldName','type','key','query','keys','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','VIRTUAL','merge','ChatQueueReport','count','includeAll','findAll','rows','show','params','options','find','catch','create','body','describe','eml-format','rimraf','zip-dir','request-promise','moment','bluebird','mustache','sox','lodash','crypto','desk.js','to-csv','querystring','../../components/auth/service'];(function(_0x14add3,_0x13ce8d){var _0x4a174f=function(_0x2b3ed7){while(--_0x2b3ed7){_0x14add3['push'](_0x14add3['shift']());}};_0x4a174f(++_0x13ce8d);}(_0x06ae,0x7e));var _0xe06a=function(_0x2dafbe,_0x5d04de){_0x2dafbe=_0x2dafbe-0x0;var _0x58a45a=_0x06ae[_0x2dafbe];return _0x58a45a;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0xe06a('0x0'));var rimraf=require(_0xe06a('0x1'));var zipdir=require(_0xe06a('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe06a('0x3'));var moment=require(_0xe06a('0x4'));var BPromise=require(_0xe06a('0x5'));var Mustache=require(_0xe06a('0x6'));var util=require('util');var path=require('path');var sox=require(_0xe06a('0x7'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var _=require(_0xe06a('0x8'));var squel=require('squel');var crypto=require(_0xe06a('0x9'));var jsforce=require('jsforce');var deskjs=require(_0xe06a('0xa'));var toCsv=require(_0xe06a('0xb'));var querystring=require(_0xe06a('0xc'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe06a('0xd'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xe06a('0xe'));var logger=require(_0xe06a('0xf'))('api');var utils=require('../../config/utils');var config=require(_0xe06a('0x10'));var db=require(_0xe06a('0x11'))['db'];function respondWithStatusCode(_0x465853,_0x2aadcb){_0x2aadcb=_0x2aadcb||0xcc;return function(_0x3e2d42){if(_0x3e2d42){return _0x465853[_0xe06a('0x12')](_0x2aadcb);}return _0x465853[_0xe06a('0x13')](_0x2aadcb)[_0xe06a('0x14')]();};}function respondWithResult(_0x5806f0,_0x4d7618){_0x4d7618=_0x4d7618||0xc8;return function(_0x459824){if(_0x459824){return _0x5806f0[_0xe06a('0x13')](_0x4d7618)['json'](_0x459824);}};}function respondWithFilteredResult(_0x30559b,_0x1a0f40){return function(_0x26f7c1){if(_0x26f7c1){var _0x274428=_0x26f7c1['count'],_0x5a3926=_0x1a0f40[_0xe06a('0x15')],_0x4263a4=_0x1a0f40[_0xe06a('0x15')]+_0x1a0f40[_0xe06a('0x16')],_0x3e5deb;if(_0x4263a4>=_0x274428){_0x4263a4=_0x274428;_0x3e5deb=0xc8;}else{_0x3e5deb=0xce;}_0x30559b['status'](_0x3e5deb);return _0x30559b[_0xe06a('0x17')](_0xe06a('0x18'),_0x5a3926+'-'+_0x4263a4+'/'+_0x274428)[_0xe06a('0x19')](_0x26f7c1);}return null;};}function patchUpdates(_0x1bfd89){return function(_0x3d8f28){try{jsonpatch[_0xe06a('0x1a')](_0x3d8f28,_0x1bfd89,!![]);}catch(_0xcd6589){return BPromise[_0xe06a('0x1b')](_0xcd6589);}return _0x3d8f28[_0xe06a('0x1c')]();};}function saveUpdates(_0x300766,_0x3b5603){return function(_0x570570){if(_0x570570){return _0x570570[_0xe06a('0x1d')](_0x300766)[_0xe06a('0x1e')](function(_0x43d974){return _0x43d974;});}return null;};}function removeEntity(_0x5c0b03,_0x5b1469){return function(_0x263caf){if(_0x263caf){return _0x263caf[_0xe06a('0x1f')]()[_0xe06a('0x1e')](function(){_0x5c0b03[_0xe06a('0x13')](0xcc)[_0xe06a('0x14')]();});}};}function handleEntityNotFound(_0x5c9b6f,_0x313a7e){return function(_0x5662be){if(!_0x5662be){_0x5c9b6f['sendStatus'](0x194);}return _0x5662be;};}function handleError(_0x3ad548,_0x5564b0){_0x5564b0=_0x5564b0||0x1f4;return function(_0x4d7852){logger[_0xe06a('0x20')](_0x4d7852[_0xe06a('0x21')]);if(_0x4d7852['name']){delete _0x4d7852[_0xe06a('0x22')];}_0x3ad548[_0xe06a('0x13')](_0x5564b0)['send'](_0x4d7852);};}exports[_0xe06a('0x23')]=function(_0x11b050,_0xe440d0){var _0x564c64={},_0xd7a0cf={},_0x65fcf8={'count':0x0,'rows':[]};var _0x4c45c3=_[_0xe06a('0x24')](db['ChatQueueReport'][_0xe06a('0x25')],function(_0x56d83f){return{'name':_0x56d83f[_0xe06a('0x26')],'type':_0x56d83f[_0xe06a('0x27')][_0xe06a('0x28')]};});_0xd7a0cf['model']=_[_0xe06a('0x24')](_0x4c45c3,_0xe06a('0x22'));_0xd7a0cf[_0xe06a('0x29')]=_[_0xe06a('0x2a')](_0x11b050[_0xe06a('0x29')]);_0xd7a0cf[_0xe06a('0x2b')]=_[_0xe06a('0x2c')](_0xd7a0cf[_0xe06a('0x2d')],_0xd7a0cf[_0xe06a('0x29')]);_0x564c64[_0xe06a('0x2e')]=_[_0xe06a('0x2c')](_0xd7a0cf[_0xe06a('0x2d')],qs[_0xe06a('0x2f')](_0x11b050['query'][_0xe06a('0x2f')]));_0x564c64[_0xe06a('0x2e')]=_0x564c64['attributes'][_0xe06a('0x30')]?_0x564c64[_0xe06a('0x2e')]:_0xd7a0cf['model'];if(!_0x11b050[_0xe06a('0x29')][_0xe06a('0x31')](_0xe06a('0x32'))){_0x564c64[_0xe06a('0x16')]=qs['limit'](_0x11b050['query']['limit']);_0x564c64[_0xe06a('0x15')]=qs[_0xe06a('0x15')](_0x11b050[_0xe06a('0x29')][_0xe06a('0x15')]);}_0x564c64['order']=qs[_0xe06a('0x33')](_0x11b050[_0xe06a('0x29')][_0xe06a('0x33')]);_0x564c64[_0xe06a('0x34')]=qs[_0xe06a('0x2b')](_[_0xe06a('0x35')](_0x11b050[_0xe06a('0x29')],_0xd7a0cf[_0xe06a('0x2b')]));if(_0x11b050[_0xe06a('0x29')][_0xe06a('0x36')]){_0x564c64[_0xe06a('0x34')]=_['merge'](_0x564c64[_0xe06a('0x34')],{'$or':_['map'](_0x4c45c3,function(_0x2e1e42){if(_0x2e1e42[_0xe06a('0x27')]!==_0xe06a('0x37')){var _0xc84aac={};_0xc84aac[_0x2e1e42['name']]={'$like':'%'+_0x11b050['query'][_0xe06a('0x36')]+'%'};return _0xc84aac;}})});}_0x564c64=_[_0xe06a('0x38')]({},_0x564c64,_0x11b050['options']);var _0x4bb127={'where':_0x564c64[_0xe06a('0x34')]};return db[_0xe06a('0x39')][_0xe06a('0x3a')](_0x4bb127)[_0xe06a('0x1e')](function(_0x1c7fc8){_0x65fcf8[_0xe06a('0x3a')]=_0x1c7fc8;if(_0x11b050[_0xe06a('0x29')][_0xe06a('0x3b')]){_0x564c64['include']=[{'all':!![]}];}return db[_0xe06a('0x39')][_0xe06a('0x3c')](_0x564c64);})[_0xe06a('0x1e')](function(_0x441752){_0x65fcf8[_0xe06a('0x3d')]=_0x441752;return _0x65fcf8;})['then'](respondWithFilteredResult(_0xe440d0,_0x564c64))['catch'](handleError(_0xe440d0,null));};exports[_0xe06a('0x3e')]=function(_0x3558e1,_0x24401c){var _0x3350ab={'raw':!![],'where':{'id':_0x3558e1[_0xe06a('0x3f')]['id']}},_0x447518={};_0x447518[_0xe06a('0x2d')]=_[_0xe06a('0x2a')](db['ChatQueueReport'][_0xe06a('0x25')]);_0x447518[_0xe06a('0x29')]=_[_0xe06a('0x2a')](_0x3558e1[_0xe06a('0x29')]);_0x447518[_0xe06a('0x2b')]=_['intersection'](_0x447518['model'],_0x447518[_0xe06a('0x29')]);_0x3350ab[_0xe06a('0x2e')]=_[_0xe06a('0x2c')](_0x447518[_0xe06a('0x2d')],qs[_0xe06a('0x2f')](_0x3558e1[_0xe06a('0x29')][_0xe06a('0x2f')]));_0x3350ab['attributes']=_0x3350ab[_0xe06a('0x2e')][_0xe06a('0x30')]?_0x3350ab[_0xe06a('0x2e')]:_0x447518[_0xe06a('0x2d')];if(_0x3558e1[_0xe06a('0x29')][_0xe06a('0x3b')]){_0x3350ab['include']=[{'all':!![]}];}_0x3350ab=_['merge']({},_0x3350ab,_0x3558e1[_0xe06a('0x40')]);return db[_0xe06a('0x39')][_0xe06a('0x41')](_0x3350ab)[_0xe06a('0x1e')](handleEntityNotFound(_0x24401c,null))[_0xe06a('0x1e')](respondWithResult(_0x24401c,null))[_0xe06a('0x42')](handleError(_0x24401c,null));};exports['create']=function(_0x56673f,_0x2cfc42){return db[_0xe06a('0x39')][_0xe06a('0x43')](_0x56673f[_0xe06a('0x44')],{})['then'](respondWithResult(_0x2cfc42,0xc9))[_0xe06a('0x42')](handleError(_0x2cfc42,null));};exports[_0xe06a('0x1d')]=function(_0xb4640c,_0x1da4d6){if(_0xb4640c[_0xe06a('0x44')]['id']){delete _0xb4640c[_0xe06a('0x44')]['id'];}return db[_0xe06a('0x39')][_0xe06a('0x41')]({'where':{'id':_0xb4640c[_0xe06a('0x3f')]['id']}})[_0xe06a('0x1e')](handleEntityNotFound(_0x1da4d6,null))[_0xe06a('0x1e')](saveUpdates(_0xb4640c[_0xe06a('0x44')],null))[_0xe06a('0x1e')](respondWithResult(_0x1da4d6,null))[_0xe06a('0x42')](handleError(_0x1da4d6,null));};exports[_0xe06a('0x1f')]=function(_0x189e5d,_0x30e09c){return db['ChatQueueReport'][_0xe06a('0x41')]({'where':{'id':_0x189e5d[_0xe06a('0x3f')]['id']}})['then'](handleEntityNotFound(_0x30e09c,null))[_0xe06a('0x1e')](removeEntity(_0x30e09c,null))[_0xe06a('0x42')](handleError(_0x30e09c,null));};exports[_0xe06a('0x45')]=function(_0x48d110,_0x56d92f){return db['ChatQueueReport']['describe']()[_0xe06a('0x1e')](respondWithResult(_0x56d92f,null))[_0xe06a('0x42')](handleError(_0x56d92f,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