Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index dcd38ce..a76bc17 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x1bb4=['fields','options','find','create','body','describe','getUnread','ChatInternalMessage','user','toInteger','addMembers','ids','omit','findOne','User','getMembers','addMessage','ChatGroupId','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','moment','mustache','path','to-csv','ejs','lodash','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','register','jayson/promise','client','request','info','request\x20sent','debug','stringify','error','code','ChatGroup,\x20%s,\x20%s','message','result','catch','sendStatus','status','end','json','count','offset','limit','set','Content-Range','apply','reject','save','update','then','destroy','name','send','index','map','ChatGroup','rawAttributes','fieldName','type','query','keys','intersection','model','attributes','length','hasOwnProperty','nolimit','order','sort','where','filters','pick','filter','merge','VIRTUAL','includeAll','include','findAll','rows','params'];(function(_0x568829,_0x4e600e){var _0x44d0a2=function(_0xb79afc){while(--_0xb79afc){_0x568829['push'](_0x568829['shift']());}};_0x44d0a2(++_0x4e600e);}(_0x1bb4,0x1c7));var _0x41bb=function(_0x2fd434,_0x4fb2b2){_0x2fd434=_0x2fd434-0x0;var _0x3f987e=_0x1bb4[_0x2fd434];return _0x3f987e;};'use strict';var pdf=require(_0x41bb('0x0'));var emlformat=require(_0x41bb('0x1'));var rimraf=require(_0x41bb('0x2'));var zipdir=require(_0x41bb('0x3'));var jsonpatch=require(_0x41bb('0x4'));var rp=require('request-promise');var moment=require(_0x41bb('0x5'));var BPromise=require('bluebird');var Mustache=require(_0x41bb('0x6'));var util=require('util');var path=require(_0x41bb('0x7'));var sox=require('sox');var csv=require(_0x41bb('0x8'));var ejs=require(_0x41bb('0x9'));var fs=require('fs');var _=require(_0x41bb('0xa'));var squel=require('squel');var crypto=require(_0x41bb('0xb'));var jsforce=require(_0x41bb('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x41bb('0x8'));var querystring=require(_0x41bb('0xd'));var Papa=require(_0x41bb('0xe'));var Redis=require('ioredis');var authService=require(_0x41bb('0xf'));var qs=require(_0x41bb('0x10'));var as=require(_0x41bb('0x11'));var hardwareService=require(_0x41bb('0x12'));var logger=require(_0x41bb('0x13'))('api');var utils=require(_0x41bb('0x14'));var config=require(_0x41bb('0x15'));var licenseUtil=require(_0x41bb('0x16'));var db=require(_0x41bb('0x17'))['db'];config[_0x41bb('0x18')]=_[_0x41bb('0x19')](config[_0x41bb('0x18')],{'host':_0x41bb('0x1a'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require('./chatGroup.socket')[_0x41bb('0x1b')](socket);var jayson=require(_0x41bb('0x1c'));var client=jayson[_0x41bb('0x1d')]['http']({'port':0x232a});function respondWithRpcPromise(_0x514d8f,_0x18bf70,_0xa66c46,_0xfa8f14){return new BPromise(function(_0x2b3dbd,_0x358246){var _0x4a1687=_0xfa8f14||client;return _0x4a1687[_0x41bb('0x1e')](_0x514d8f,_0xa66c46)['then'](function(_0x1d2ead){logger[_0x41bb('0x1f')]('ChatGroup,\x20%s,\x20%s',_0x18bf70,_0x41bb('0x20'));logger[_0x41bb('0x21')]('ChatGroup,\x20%s,\x20%s,\x20%s',_0x18bf70,'request\x20sent',JSON[_0x41bb('0x22')](_0x1d2ead));if(_0x1d2ead['error']){if(_0x1d2ead[_0x41bb('0x23')][_0x41bb('0x24')]===0x1f4){logger[_0x41bb('0x23')](_0x41bb('0x25'),_0x18bf70,_0x1d2ead[_0x41bb('0x23')][_0x41bb('0x26')]);return _0x358246(_0x1d2ead[_0x41bb('0x23')][_0x41bb('0x26')]);}logger[_0x41bb('0x23')](_0x41bb('0x25'),_0x18bf70,_0x1d2ead['error'][_0x41bb('0x26')]);return _0x2b3dbd(_0x1d2ead[_0x41bb('0x23')][_0x41bb('0x26')]);}else{logger[_0x41bb('0x1f')]('ChatGroup,\x20%s,\x20%s',_0x18bf70,'request\x20sent');_0x2b3dbd(_0x1d2ead[_0x41bb('0x27')][_0x41bb('0x26')]);}})[_0x41bb('0x28')](function(_0x58c3f7){logger[_0x41bb('0x23')](_0x41bb('0x25'),_0x18bf70,_0x58c3f7);_0x358246(_0x58c3f7);});});}function respondWithStatusCode(_0x592239,_0x310f09){_0x310f09=_0x310f09||0xcc;return function(_0x5c09bf){if(_0x5c09bf){return _0x592239[_0x41bb('0x29')](_0x310f09);}return _0x592239[_0x41bb('0x2a')](_0x310f09)[_0x41bb('0x2b')]();};}function respondWithResult(_0x1ed303,_0x3d515e){_0x3d515e=_0x3d515e||0xc8;return function(_0x237817){if(_0x237817){return _0x1ed303[_0x41bb('0x2a')](_0x3d515e)[_0x41bb('0x2c')](_0x237817);}};}function respondWithFilteredResult(_0x3f28b0,_0x2ba1cd){return function(_0x430131){if(_0x430131){var _0x16b1f6=_0x430131[_0x41bb('0x2d')],_0x148ea5=_0x2ba1cd[_0x41bb('0x2e')],_0x4645c8=_0x2ba1cd[_0x41bb('0x2e')]+_0x2ba1cd[_0x41bb('0x2f')],_0x501f78;if(_0x4645c8>=_0x16b1f6){_0x4645c8=_0x16b1f6;_0x501f78=0xc8;}else{_0x501f78=0xce;}_0x3f28b0[_0x41bb('0x2a')](_0x501f78);return _0x3f28b0[_0x41bb('0x30')](_0x41bb('0x31'),_0x148ea5+'-'+_0x4645c8+'/'+_0x16b1f6)[_0x41bb('0x2c')](_0x430131);}return null;};}function patchUpdates(_0x3590d6){return function(_0x76c3c7){try{jsonpatch[_0x41bb('0x32')](_0x76c3c7,_0x3590d6,!![]);}catch(_0x7c3a3c){return BPromise[_0x41bb('0x33')](_0x7c3a3c);}return _0x76c3c7[_0x41bb('0x34')]();};}function saveUpdates(_0x142661,_0xfb737f){return function(_0x58eb96){if(_0x58eb96){return _0x58eb96[_0x41bb('0x35')](_0x142661)[_0x41bb('0x36')](function(_0x28faac){return _0x28faac;});}return null;};}function removeEntity(_0x7a9b34,_0x8df1f3){return function(_0xb2041a){if(_0xb2041a){return _0xb2041a[_0x41bb('0x37')]()['then'](function(){_0x7a9b34['status'](0xcc)[_0x41bb('0x2b')]();});}};}function handleEntityNotFound(_0xe7d034,_0x2ca65f){return function(_0x7c4fb2){if(!_0x7c4fb2){_0xe7d034[_0x41bb('0x29')](0x194);}return _0x7c4fb2;};}function handleError(_0x11f3c9,_0x346cbc){_0x346cbc=_0x346cbc||0x1f4;return function(_0x333738){logger['error'](_0x333738['stack']);if(_0x333738['name']){delete _0x333738[_0x41bb('0x38')];}_0x11f3c9[_0x41bb('0x2a')](_0x346cbc)[_0x41bb('0x39')](_0x333738);};}exports[_0x41bb('0x3a')]=function(_0x243ecd,_0x5b130a){var _0x233fa2={},_0x2293c7={},_0x463fd0={'count':0x0,'rows':[]};var _0x1a8a53=_[_0x41bb('0x3b')](db[_0x41bb('0x3c')][_0x41bb('0x3d')],function(_0x3ecb67){return{'name':_0x3ecb67[_0x41bb('0x3e')],'type':_0x3ecb67[_0x41bb('0x3f')]['key']};});_0x2293c7['model']=_['map'](_0x1a8a53,_0x41bb('0x38'));_0x2293c7[_0x41bb('0x40')]=_[_0x41bb('0x41')](_0x243ecd[_0x41bb('0x40')]);_0x2293c7['filters']=_[_0x41bb('0x42')](_0x2293c7[_0x41bb('0x43')],_0x2293c7['query']);_0x233fa2['attributes']=_[_0x41bb('0x42')](_0x2293c7[_0x41bb('0x43')],qs['fields'](_0x243ecd[_0x41bb('0x40')]['fields']));_0x233fa2[_0x41bb('0x44')]=_0x233fa2[_0x41bb('0x44')][_0x41bb('0x45')]?_0x233fa2[_0x41bb('0x44')]:_0x2293c7[_0x41bb('0x43')];if(!_0x243ecd[_0x41bb('0x40')][_0x41bb('0x46')](_0x41bb('0x47'))){_0x233fa2[_0x41bb('0x2f')]=qs[_0x41bb('0x2f')](_0x243ecd['query'][_0x41bb('0x2f')]);_0x233fa2[_0x41bb('0x2e')]=qs[_0x41bb('0x2e')](_0x243ecd['query'][_0x41bb('0x2e')]);}_0x233fa2[_0x41bb('0x48')]=qs[_0x41bb('0x49')](_0x243ecd['query'][_0x41bb('0x49')]);_0x233fa2[_0x41bb('0x4a')]=qs[_0x41bb('0x4b')](_[_0x41bb('0x4c')](_0x243ecd[_0x41bb('0x40')],_0x2293c7[_0x41bb('0x4b')]),_0x1a8a53);if(_0x243ecd[_0x41bb('0x40')][_0x41bb('0x4d')]){_0x233fa2['where']=_[_0x41bb('0x4e')](_0x233fa2[_0x41bb('0x4a')],{'$or':_[_0x41bb('0x3b')](_0x1a8a53,function(_0x520754){if(_0x520754[_0x41bb('0x3f')]!==_0x41bb('0x4f')){var _0x4034c1={};_0x4034c1[_0x520754[_0x41bb('0x38')]]={'$like':'%'+_0x243ecd[_0x41bb('0x40')][_0x41bb('0x4d')]+'%'};return _0x4034c1;}})});}_0x233fa2=_['merge']({},_0x233fa2,_0x243ecd['options']);var _0x4c5b15={'where':_0x233fa2[_0x41bb('0x4a')]};return db[_0x41bb('0x3c')][_0x41bb('0x2d')](_0x4c5b15)['then'](function(_0x595cb5){_0x463fd0['count']=_0x595cb5;if(_0x243ecd[_0x41bb('0x40')][_0x41bb('0x50')]){_0x233fa2[_0x41bb('0x51')]=[{'all':!![]}];}return db[_0x41bb('0x3c')][_0x41bb('0x52')](_0x233fa2);})[_0x41bb('0x36')](function(_0x4a72eb){_0x463fd0[_0x41bb('0x53')]=_0x4a72eb;return _0x463fd0;})[_0x41bb('0x36')](respondWithFilteredResult(_0x5b130a,_0x233fa2))[_0x41bb('0x28')](handleError(_0x5b130a,null));};exports['show']=function(_0x590f8f,_0x5d2e2e){var _0x1efcd1={'raw':!![],'where':{'id':_0x590f8f[_0x41bb('0x54')]['id']}},_0x2147b6={};_0x2147b6[_0x41bb('0x43')]=_[_0x41bb('0x41')](db['ChatGroup'][_0x41bb('0x3d')]);_0x2147b6[_0x41bb('0x40')]=_['keys'](_0x590f8f[_0x41bb('0x40')]);_0x2147b6[_0x41bb('0x4b')]=_[_0x41bb('0x42')](_0x2147b6['model'],_0x2147b6[_0x41bb('0x40')]);_0x1efcd1['attributes']=_[_0x41bb('0x42')](_0x2147b6['model'],qs[_0x41bb('0x55')](_0x590f8f[_0x41bb('0x40')]['fields']));_0x1efcd1[_0x41bb('0x44')]=_0x1efcd1['attributes']['length']?_0x1efcd1[_0x41bb('0x44')]:_0x2147b6[_0x41bb('0x43')];if(_0x590f8f[_0x41bb('0x40')]['includeAll']){_0x1efcd1[_0x41bb('0x51')]=[{'all':!![]}];}_0x1efcd1=_['merge']({},_0x1efcd1,_0x590f8f[_0x41bb('0x56')]);return db[_0x41bb('0x3c')][_0x41bb('0x57')](_0x1efcd1)['then'](handleEntityNotFound(_0x5d2e2e,null))['then'](respondWithResult(_0x5d2e2e,null))['catch'](handleError(_0x5d2e2e,null));};exports['create']=function(_0x27bd50,_0x19cd26){return db[_0x41bb('0x3c')][_0x41bb('0x58')](_0x27bd50['body'],{})[_0x41bb('0x36')](respondWithResult(_0x19cd26,0xc9))[_0x41bb('0x28')](handleError(_0x19cd26,null));};exports[_0x41bb('0x35')]=function(_0x3f407c,_0x336630){if(_0x3f407c[_0x41bb('0x59')]['id']){delete _0x3f407c['body']['id'];}return db[_0x41bb('0x3c')]['find']({'where':{'id':_0x3f407c[_0x41bb('0x54')]['id']}})[_0x41bb('0x36')](handleEntityNotFound(_0x336630,null))[_0x41bb('0x36')](saveUpdates(_0x3f407c[_0x41bb('0x59')],null))[_0x41bb('0x36')](respondWithResult(_0x336630,null))[_0x41bb('0x28')](handleError(_0x336630,null));};exports[_0x41bb('0x37')]=function(_0xc7c4c,_0x1bae35){return db[_0x41bb('0x3c')][_0x41bb('0x57')]({'where':{'id':_0xc7c4c[_0x41bb('0x54')]['id']}})[_0x41bb('0x36')](handleEntityNotFound(_0x1bae35,null))['then'](removeEntity(_0x1bae35,null))[_0x41bb('0x28')](handleError(_0x1bae35,null));};exports[_0x41bb('0x5a')]=function(_0x5cfa0f,_0xceb0df){return db[_0x41bb('0x3c')][_0x41bb('0x5a')]()['then'](respondWithResult(_0xceb0df,null))['catch'](handleError(_0xceb0df,null));};exports[_0x41bb('0x5b')]=function(_0xaa011c,_0xfc7c88,_0x34aa8a){return db[_0x41bb('0x5c')][_0x41bb('0x2d')]({'where':{'ChatGroupId':_0xaa011c[_0x41bb('0x54')]['id'],'ToId':_0xaa011c[_0x41bb('0x5d')]['id'],'read':![]}})[_0x41bb('0x36')](function(_0x103d28){return{'id':_[_0x41bb('0x5e')](_0xaa011c[_0x41bb('0x54')]['id']),'count':_0x103d28};})[_0x41bb('0x36')](respondWithResult(_0xfc7c88,null))[_0x41bb('0x28')](handleError(_0xfc7c88,null));};exports[_0x41bb('0x5f')]=function(_0x219e6c,_0xb083f0,_0x1aab5a){return db[_0x41bb('0x3c')][_0x41bb('0x57')]({'where':{'id':_0x219e6c[_0x41bb('0x54')]['id']}})[_0x41bb('0x36')](handleEntityNotFound(_0xb083f0,null))['then'](function(_0x5e6b79){if(_0x5e6b79){return _0x5e6b79[_0x41bb('0x5f')](_0x219e6c[_0x41bb('0x59')][_0x41bb('0x60')],_[_0x41bb('0x61')](_0x219e6c[_0x41bb('0x59')],['ids','id'])||{});}})[_0x41bb('0x36')](respondWithResult(_0xb083f0,null))[_0x41bb('0x28')](handleError(_0xb083f0,null));};exports['getMembers']=function(_0x215ef6,_0x58f1ce,_0x1ef3f2){var _0x103651={};var _0x16a281={};var _0x1422ea;var _0x250e59;return db[_0x41bb('0x3c')][_0x41bb('0x62')]({'where':{'id':_0x215ef6[_0x41bb('0x54')]['id']}})[_0x41bb('0x36')](handleEntityNotFound(_0x58f1ce,null))[_0x41bb('0x36')](function(_0x12d23c){if(_0x12d23c){_0x1422ea=_0x12d23c;_0x16a281[_0x41bb('0x43')]=_[_0x41bb('0x41')](db[_0x41bb('0x63')]['rawAttributes']);_0x16a281[_0x41bb('0x40')]=_[_0x41bb('0x41')](_0x215ef6['query']);_0x16a281['filters']=_[_0x41bb('0x42')](_0x16a281[_0x41bb('0x43')],_0x16a281[_0x41bb('0x40')]);_0x103651[_0x41bb('0x44')]=_['intersection'](_0x16a281[_0x41bb('0x43')],qs[_0x41bb('0x55')](_0x215ef6[_0x41bb('0x40')]['fields']));_0x103651[_0x41bb('0x44')]=_0x103651['attributes'][_0x41bb('0x45')]?_0x103651[_0x41bb('0x44')]:_0x16a281['model'];_0x103651[_0x41bb('0x48')]=qs[_0x41bb('0x49')](_0x215ef6[_0x41bb('0x40')][_0x41bb('0x49')]);_0x103651[_0x41bb('0x4a')]=qs[_0x41bb('0x4b')](_[_0x41bb('0x4c')](_0x215ef6['query'],_0x16a281[_0x41bb('0x4b')]));if(_0x215ef6[_0x41bb('0x40')]['filter']){_0x103651[_0x41bb('0x4a')]=_['merge'](_0x103651[_0x41bb('0x4a')],{'$or':_[_0x41bb('0x3b')](_0x103651['attributes'],function(_0x3a1eb2){var _0x3a830a={};_0x3a830a[_0x3a1eb2]={'$like':'%'+_0x215ef6[_0x41bb('0x40')]['filter']+'%'};return _0x3a830a;})});}_0x103651=_[_0x41bb('0x4e')]({},_0x103651,_0x215ef6[_0x41bb('0x56')]);return _0x1422ea[_0x41bb('0x64')](_0x103651);}})['then'](function(_0xcd9ae6){if(_0xcd9ae6){_0x250e59=_0xcd9ae6[_0x41bb('0x45')];if(!_0x215ef6[_0x41bb('0x40')][_0x41bb('0x46')](_0x41bb('0x47'))){_0x103651['limit']=qs[_0x41bb('0x2f')](_0x215ef6['query'][_0x41bb('0x2f')]);_0x103651[_0x41bb('0x2e')]=qs[_0x41bb('0x2e')](_0x215ef6['query'][_0x41bb('0x2e')]);}return _0x1422ea['getMembers'](_0x103651);}})['then'](function(_0x4d0505){if(_0x4d0505){return _0x4d0505?{'count':_0x250e59,'rows':_0x4d0505}:null;}})['then'](respondWithResult(_0x58f1ce,null))[_0x41bb('0x28')](handleError(_0x58f1ce,null));};exports['removeMembers']=function(_0x41f287,_0x47194d,_0x5deb5d){return db['ChatGroup']['find']({'where':{'id':_0x41f287[_0x41bb('0x54')]['id']}})['then'](handleEntityNotFound(_0x47194d,null))['then'](function(_0x2068a2){if(_0x2068a2){return _0x2068a2['removeMembers'](_0x41f287[_0x41bb('0x40')][_0x41bb('0x60')]);}})['then'](respondWithStatusCode(_0x47194d,null))['catch'](handleError(_0x47194d,null));};exports[_0x41bb('0x65')]=function(_0xd7619,_0x42bd49,_0x289430){if(_0xd7619[_0x41bb('0x59')]['id']){delete _0xd7619[_0x41bb('0x59')]['id'];}return db[_0x41bb('0x3c')][_0x41bb('0x57')]({'where':{'id':_0xd7619[_0x41bb('0x54')]['id']}})[_0x41bb('0x36')](handleEntityNotFound(_0x42bd49,null))[_0x41bb('0x36')](function(_0x3d8a3d){if(_0x3d8a3d){_0xd7619['body'][_0x41bb('0x66')]=_0x3d8a3d['id'];return db[_0x41bb('0x5c')][_0x41bb('0x58')](_0xd7619[_0x41bb('0x59')]);}})[_0x41bb('0x36')](respondWithResult(_0x42bd49,null))[_0x41bb('0x28')](handleError(_0x42bd49,null));};exports[_0x41bb('0x67')]=function(_0x23e66a,_0x13aec1,_0x6e988f){var _0x2a4df8={};var _0x1a1009={};var _0x4977eb;var _0x2de632;return db['ChatGroup'][_0x41bb('0x62')]({'where':{'id':_0x23e66a[_0x41bb('0x54')]['id']}})[_0x41bb('0x36')](handleEntityNotFound(_0x13aec1,null))[_0x41bb('0x36')](function(_0x4c70d9){if(_0x4c70d9){_0x4977eb=_0x4c70d9;_0x1a1009[_0x41bb('0x43')]=_[_0x41bb('0x41')](db['ChatInternalMessage'][_0x41bb('0x3d')]);_0x1a1009[_0x41bb('0x40')]=_[_0x41bb('0x41')](_0x23e66a[_0x41bb('0x40')]);_0x1a1009[_0x41bb('0x4b')]=_[_0x41bb('0x42')](_0x1a1009['model'],_0x1a1009[_0x41bb('0x40')]);_0x2a4df8[_0x41bb('0x44')]=_['intersection'](_0x1a1009[_0x41bb('0x43')],qs[_0x41bb('0x55')](_0x23e66a[_0x41bb('0x40')]['fields']));_0x2a4df8['attributes']=_0x2a4df8['attributes'][_0x41bb('0x45')]?_0x2a4df8[_0x41bb('0x44')]:_0x1a1009['model'];_0x2a4df8[_0x41bb('0x48')]=qs[_0x41bb('0x49')](_0x23e66a['query'][_0x41bb('0x49')]);_0x2a4df8['where']=qs[_0x41bb('0x4b')](_[_0x41bb('0x4c')](_0x23e66a[_0x41bb('0x40')],_0x1a1009['filters']));if(_0x23e66a[_0x41bb('0x40')][_0x41bb('0x4d')]){_0x2a4df8['where']=_[_0x41bb('0x4e')](_0x2a4df8[_0x41bb('0x4a')],{'$or':_[_0x41bb('0x3b')](_0x2a4df8[_0x41bb('0x44')],function(_0x857e70){var _0x2d6c12={};_0x2d6c12[_0x857e70]={'$like':'%'+_0x23e66a[_0x41bb('0x40')][_0x41bb('0x4d')]+'%'};return _0x2d6c12;})});}if(_0x23e66a[_0x41bb('0x40')][_0x41bb('0x68')]){var _0x26205d=_0x23e66a['query'][_0x41bb('0x68')][_0x41bb('0x69')](',');var _0x31e373={};_0x31e373[_0x26205d[0x0]]={'$gte':moment(_0x26205d[0x1])[_0x41bb('0x6a')](_0x41bb('0x6b'))};_0x2a4df8[_0x41bb('0x4a')]=_[_0x41bb('0x4e')](_0x2a4df8[_0x41bb('0x4a')],_0x31e373);}_0x2a4df8=_[_0x41bb('0x4e')]({},_0x2a4df8,_0x23e66a['options']);return _0x4977eb['getMessages'](_0x2a4df8);}})[_0x41bb('0x36')](function(_0x758bed){if(_0x758bed){_0x2de632=_0x758bed[_0x41bb('0x45')];if(!_0x23e66a[_0x41bb('0x40')][_0x41bb('0x46')](_0x41bb('0x47'))){_0x2a4df8[_0x41bb('0x2f')]=qs[_0x41bb('0x2f')](_0x23e66a[_0x41bb('0x40')][_0x41bb('0x2f')]);_0x2a4df8[_0x41bb('0x2e')]=qs[_0x41bb('0x2e')](_0x23e66a['query']['offset']);}return _0x4977eb[_0x41bb('0x67')](_0x2a4df8);}})[_0x41bb('0x36')](function(_0x4c1b4b){if(_0x4c1b4b){return _0x4c1b4b?{'count':_0x2de632,'rows':_0x4c1b4b}:null;}})[_0x41bb('0x36')](respondWithResult(_0x13aec1,null))[_0x41bb('0x28')](handleError(_0x13aec1,null));};
\ No newline at end of file
+var _0x1a41=['intersection','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','VIRTUAL','options','include','rows','catch','show','params','attributes','includeAll','create','body','find','describe','ChatInternalMessage','toInteger','addMembers','ids','omit','getMembers','User','removeMembers','addMessage','ChatGroupId','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','getMessages','eml-format','rimraf','fast-json-patch','request-promise','mustache','util','path','sox','ejs','lodash','squel','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','reject','update','destroy','then','error','name','send','index','map','ChatGroup','rawAttributes','fieldName','key','model','query','keys','filters'];(function(_0xfc02eb,_0xa1dce9){var _0x1908ef=function(_0x384f01){while(--_0x384f01){_0xfc02eb['push'](_0xfc02eb['shift']());}};_0x1908ef(++_0xa1dce9);}(_0x1a41,0x147));var _0x11a4=function(_0x196013,_0x4dfcbf){_0x196013=_0x196013-0x0;var _0x151db6=_0x1a41[_0x196013];return _0x151db6;};'use strict';var emlformat=require(_0x11a4('0x0'));var rimraf=require(_0x11a4('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x11a4('0x2'));var rp=require(_0x11a4('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x11a4('0x4'));var util=require(_0x11a4('0x5'));var path=require(_0x11a4('0x6'));var sox=require(_0x11a4('0x7'));var csv=require('to-csv');var ejs=require(_0x11a4('0x8'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x11a4('0x9'));var squel=require(_0x11a4('0xa'));var crypto=require('crypto');var jsforce=require(_0x11a4('0xb'));var deskjs=require(_0x11a4('0xc'));var toCsv=require(_0x11a4('0xd'));var querystring=require(_0x11a4('0xe'));var Papa=require(_0x11a4('0xf'));var Redis=require(_0x11a4('0x10'));var authService=require('../../components/auth/service');var qs=require(_0x11a4('0x11'));var as=require(_0x11a4('0x12'));var hardwareService=require(_0x11a4('0x13'));var logger=require(_0x11a4('0x14'))(_0x11a4('0x15'));var utils=require(_0x11a4('0x16'));var config=require(_0x11a4('0x17'));var licenseUtil=require(_0x11a4('0x18'));var db=require(_0x11a4('0x19'))['db'];config[_0x11a4('0x1a')]=_['defaults'](config[_0x11a4('0x1a')],{'host':_0x11a4('0x1b'),'port':0x18eb});var socket=require(_0x11a4('0x1c'))(new Redis(config[_0x11a4('0x1a')]));require('./chatGroup.socket')[_0x11a4('0x1d')](socket);function respondWithStatusCode(_0x35c6d8,_0x22c070){_0x22c070=_0x22c070||0xcc;return function(_0x11c844){if(_0x11c844){return _0x35c6d8[_0x11a4('0x1e')](_0x22c070);}return _0x35c6d8[_0x11a4('0x1f')](_0x22c070)[_0x11a4('0x20')]();};}function respondWithResult(_0x391ff5,_0x1c2d15){_0x1c2d15=_0x1c2d15||0xc8;return function(_0x1b9cdf){if(_0x1b9cdf){return _0x391ff5[_0x11a4('0x1f')](_0x1c2d15)[_0x11a4('0x21')](_0x1b9cdf);}};}function respondWithFilteredResult(_0x4053bf,_0x7a30b5){return function(_0x25a1e7){if(_0x25a1e7){var _0x27130c=typeof _0x7a30b5[_0x11a4('0x22')]===_0x11a4('0x23')&&typeof _0x7a30b5[_0x11a4('0x24')]==='undefined';var _0x36e7e8=_0x25a1e7[_0x11a4('0x25')];var _0x2db527=_0x27130c?0x0:_0x7a30b5[_0x11a4('0x22')];var _0x1635ff=_0x27130c?_0x25a1e7[_0x11a4('0x25')]:_0x7a30b5[_0x11a4('0x22')]+_0x7a30b5[_0x11a4('0x24')];var _0x151933;if(_0x1635ff>=_0x36e7e8){_0x1635ff=_0x36e7e8;_0x151933=0xc8;}else{_0x151933=0xce;}_0x4053bf['status'](_0x151933);return _0x4053bf[_0x11a4('0x26')](_0x11a4('0x27'),_0x2db527+'-'+_0x1635ff+'/'+_0x36e7e8)[_0x11a4('0x21')](_0x25a1e7);}return null;};}function patchUpdates(_0xa883b7){return function(_0x154ab8){try{jsonpatch['apply'](_0x154ab8,_0xa883b7,!![]);}catch(_0x2b4a09){return BPromise[_0x11a4('0x28')](_0x2b4a09);}return _0x154ab8['save']();};}function saveUpdates(_0x2035e4,_0x401b40){return function(_0xf7da80){if(_0xf7da80){return _0xf7da80[_0x11a4('0x29')](_0x2035e4)['then'](function(_0xd823cb){return _0xd823cb;});}return null;};}function removeEntity(_0x383aa3,_0x4ca3d2){return function(_0x3bcc08){if(_0x3bcc08){return _0x3bcc08[_0x11a4('0x2a')]()[_0x11a4('0x2b')](function(){_0x383aa3[_0x11a4('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x561da5,_0x18a6ce){return function(_0xaecdad){if(!_0xaecdad){_0x561da5[_0x11a4('0x1e')](0x194);}return _0xaecdad;};}function handleError(_0x337f35,_0x553b8f){_0x553b8f=_0x553b8f||0x1f4;return function(_0x546609){logger[_0x11a4('0x2c')](_0x546609['stack']);if(_0x546609[_0x11a4('0x2d')]){delete _0x546609[_0x11a4('0x2d')];}_0x337f35[_0x11a4('0x1f')](_0x553b8f)[_0x11a4('0x2e')](_0x546609);};}exports[_0x11a4('0x2f')]=function(_0x23dc24,_0x248059){var _0x57a40c={},_0x4867d3={},_0x32ec27={'count':0x0,'rows':[]};var _0x3165d9=_[_0x11a4('0x30')](db[_0x11a4('0x31')][_0x11a4('0x32')],function(_0x52a0b3){return{'name':_0x52a0b3[_0x11a4('0x33')],'type':_0x52a0b3['type'][_0x11a4('0x34')]};});_0x4867d3[_0x11a4('0x35')]=_[_0x11a4('0x30')](_0x3165d9,_0x11a4('0x2d'));_0x4867d3[_0x11a4('0x36')]=_[_0x11a4('0x37')](_0x23dc24[_0x11a4('0x36')]);_0x4867d3[_0x11a4('0x38')]=_[_0x11a4('0x39')](_0x4867d3[_0x11a4('0x35')],_0x4867d3[_0x11a4('0x36')]);_0x57a40c['attributes']=_[_0x11a4('0x39')](_0x4867d3[_0x11a4('0x35')],qs[_0x11a4('0x3a')](_0x23dc24[_0x11a4('0x36')]['fields']));_0x57a40c['attributes']=_0x57a40c['attributes'][_0x11a4('0x3b')]?_0x57a40c['attributes']:_0x4867d3['model'];if(!_0x23dc24[_0x11a4('0x36')][_0x11a4('0x3c')](_0x11a4('0x3d'))){_0x57a40c[_0x11a4('0x24')]=qs[_0x11a4('0x24')](_0x23dc24[_0x11a4('0x36')][_0x11a4('0x24')]);_0x57a40c['offset']=qs[_0x11a4('0x22')](_0x23dc24[_0x11a4('0x36')]['offset']);}_0x57a40c[_0x11a4('0x3e')]=qs[_0x11a4('0x3f')](_0x23dc24[_0x11a4('0x36')][_0x11a4('0x3f')]);_0x57a40c[_0x11a4('0x40')]=qs[_0x11a4('0x38')](_[_0x11a4('0x41')](_0x23dc24['query'],_0x4867d3[_0x11a4('0x38')]),_0x3165d9);if(_0x23dc24[_0x11a4('0x36')][_0x11a4('0x42')]){_0x57a40c['where']=_[_0x11a4('0x43')](_0x57a40c['where'],{'$or':_[_0x11a4('0x30')](_0x3165d9,function(_0x9164eb){if(_0x9164eb['type']!==_0x11a4('0x44')){var _0x4f570a={};_0x4f570a[_0x9164eb[_0x11a4('0x2d')]]={'$like':'%'+_0x23dc24[_0x11a4('0x36')]['filter']+'%'};return _0x4f570a;}})});}_0x57a40c=_[_0x11a4('0x43')]({},_0x57a40c,_0x23dc24[_0x11a4('0x45')]);var _0x26d236={'where':_0x57a40c[_0x11a4('0x40')]};return db['ChatGroup'][_0x11a4('0x25')](_0x26d236)['then'](function(_0x432d40){_0x32ec27[_0x11a4('0x25')]=_0x432d40;if(_0x23dc24['query']['includeAll']){_0x57a40c[_0x11a4('0x46')]=[{'all':!![]}];}return db[_0x11a4('0x31')]['findAll'](_0x57a40c);})['then'](function(_0x3604d1){_0x32ec27[_0x11a4('0x47')]=_0x3604d1;return _0x32ec27;})[_0x11a4('0x2b')](respondWithFilteredResult(_0x248059,_0x57a40c))[_0x11a4('0x48')](handleError(_0x248059,null));};exports[_0x11a4('0x49')]=function(_0x41f1ea,_0x527223){var _0x1ecf3b={'raw':!![],'where':{'id':_0x41f1ea[_0x11a4('0x4a')]['id']}},_0x255c6d={};_0x255c6d[_0x11a4('0x35')]=_[_0x11a4('0x37')](db['ChatGroup'][_0x11a4('0x32')]);_0x255c6d[_0x11a4('0x36')]=_[_0x11a4('0x37')](_0x41f1ea[_0x11a4('0x36')]);_0x255c6d[_0x11a4('0x38')]=_[_0x11a4('0x39')](_0x255c6d[_0x11a4('0x35')],_0x255c6d['query']);_0x1ecf3b[_0x11a4('0x4b')]=_[_0x11a4('0x39')](_0x255c6d['model'],qs[_0x11a4('0x3a')](_0x41f1ea[_0x11a4('0x36')][_0x11a4('0x3a')]));_0x1ecf3b['attributes']=_0x1ecf3b[_0x11a4('0x4b')][_0x11a4('0x3b')]?_0x1ecf3b[_0x11a4('0x4b')]:_0x255c6d[_0x11a4('0x35')];if(_0x41f1ea[_0x11a4('0x36')][_0x11a4('0x4c')]){_0x1ecf3b['include']=[{'all':!![]}];}_0x1ecf3b=_['merge']({},_0x1ecf3b,_0x41f1ea[_0x11a4('0x45')]);return db[_0x11a4('0x31')]['find'](_0x1ecf3b)[_0x11a4('0x2b')](handleEntityNotFound(_0x527223,null))[_0x11a4('0x2b')](respondWithResult(_0x527223,null))[_0x11a4('0x48')](handleError(_0x527223,null));};exports['create']=function(_0x3a3498,_0x3ef2b9){return db[_0x11a4('0x31')][_0x11a4('0x4d')](_0x3a3498[_0x11a4('0x4e')],{})[_0x11a4('0x2b')](respondWithResult(_0x3ef2b9,0xc9))[_0x11a4('0x48')](handleError(_0x3ef2b9,null));};exports['update']=function(_0x1238ce,_0x3e9080){if(_0x1238ce[_0x11a4('0x4e')]['id']){delete _0x1238ce[_0x11a4('0x4e')]['id'];}return db[_0x11a4('0x31')]['find']({'where':{'id':_0x1238ce[_0x11a4('0x4a')]['id']}})[_0x11a4('0x2b')](handleEntityNotFound(_0x3e9080,null))[_0x11a4('0x2b')](saveUpdates(_0x1238ce[_0x11a4('0x4e')],null))['then'](respondWithResult(_0x3e9080,null))[_0x11a4('0x48')](handleError(_0x3e9080,null));};exports['destroy']=function(_0x2f9f2f,_0x527c91){return db[_0x11a4('0x31')][_0x11a4('0x4f')]({'where':{'id':_0x2f9f2f[_0x11a4('0x4a')]['id']}})['then'](handleEntityNotFound(_0x527c91,null))[_0x11a4('0x2b')](removeEntity(_0x527c91,null))[_0x11a4('0x48')](handleError(_0x527c91,null));};exports[_0x11a4('0x50')]=function(_0x19b2d5,_0x5e0270){return db[_0x11a4('0x31')][_0x11a4('0x50')]()[_0x11a4('0x2b')](respondWithResult(_0x5e0270,null))[_0x11a4('0x48')](handleError(_0x5e0270,null));};exports['getUnread']=function(_0x394616,_0x274aa6,_0x30247f){return db[_0x11a4('0x51')][_0x11a4('0x25')]({'where':{'ChatGroupId':_0x394616['params']['id'],'ToId':_0x394616['user']['id'],'read':![]}})['then'](function(_0x26040c){return{'id':_[_0x11a4('0x52')](_0x394616[_0x11a4('0x4a')]['id']),'count':_0x26040c};})[_0x11a4('0x2b')](respondWithResult(_0x274aa6,null))[_0x11a4('0x48')](handleError(_0x274aa6,null));};exports[_0x11a4('0x53')]=function(_0x21d93c,_0x370356,_0x23ad41){return db[_0x11a4('0x31')][_0x11a4('0x4f')]({'where':{'id':_0x21d93c['params']['id']}})[_0x11a4('0x2b')](handleEntityNotFound(_0x370356,null))['then'](function(_0x19e82e){if(_0x19e82e){return _0x19e82e[_0x11a4('0x53')](_0x21d93c[_0x11a4('0x4e')][_0x11a4('0x54')],_[_0x11a4('0x55')](_0x21d93c[_0x11a4('0x4e')],[_0x11a4('0x54'),'id'])||{});}})[_0x11a4('0x2b')](respondWithResult(_0x370356,null))['catch'](handleError(_0x370356,null));};exports[_0x11a4('0x56')]=function(_0x51f4a2,_0x16dcae,_0x67affa){var _0x2e9f42={};var _0x17a3ea={};var _0x4e1a19;var _0x6790cf;return db[_0x11a4('0x31')]['findOne']({'where':{'id':_0x51f4a2['params']['id']}})['then'](handleEntityNotFound(_0x16dcae,null))[_0x11a4('0x2b')](function(_0x18f756){if(_0x18f756){_0x4e1a19=_0x18f756;_0x17a3ea[_0x11a4('0x35')]=_[_0x11a4('0x37')](db[_0x11a4('0x57')][_0x11a4('0x32')]);_0x17a3ea[_0x11a4('0x36')]=_['keys'](_0x51f4a2[_0x11a4('0x36')]);_0x17a3ea[_0x11a4('0x38')]=_['intersection'](_0x17a3ea[_0x11a4('0x35')],_0x17a3ea[_0x11a4('0x36')]);_0x2e9f42[_0x11a4('0x4b')]=_[_0x11a4('0x39')](_0x17a3ea[_0x11a4('0x35')],qs[_0x11a4('0x3a')](_0x51f4a2[_0x11a4('0x36')]['fields']));_0x2e9f42[_0x11a4('0x4b')]=_0x2e9f42[_0x11a4('0x4b')][_0x11a4('0x3b')]?_0x2e9f42[_0x11a4('0x4b')]:_0x17a3ea['model'];_0x2e9f42[_0x11a4('0x3e')]=qs[_0x11a4('0x3f')](_0x51f4a2[_0x11a4('0x36')][_0x11a4('0x3f')]);_0x2e9f42['where']=qs[_0x11a4('0x38')](_[_0x11a4('0x41')](_0x51f4a2[_0x11a4('0x36')],_0x17a3ea[_0x11a4('0x38')]));if(_0x51f4a2[_0x11a4('0x36')][_0x11a4('0x42')]){_0x2e9f42['where']=_[_0x11a4('0x43')](_0x2e9f42[_0x11a4('0x40')],{'$or':_[_0x11a4('0x30')](_0x2e9f42[_0x11a4('0x4b')],function(_0x783b67){var _0x3f7dba={};_0x3f7dba[_0x783b67]={'$like':'%'+_0x51f4a2[_0x11a4('0x36')][_0x11a4('0x42')]+'%'};return _0x3f7dba;})});}_0x2e9f42=_[_0x11a4('0x43')]({},_0x2e9f42,_0x51f4a2[_0x11a4('0x45')]);return _0x4e1a19[_0x11a4('0x56')](_0x2e9f42);}})[_0x11a4('0x2b')](function(_0x4c2a1b){if(_0x4c2a1b){_0x6790cf=_0x4c2a1b['length'];if(!_0x51f4a2['query'][_0x11a4('0x3c')]('nolimit')){_0x2e9f42[_0x11a4('0x24')]=qs[_0x11a4('0x24')](_0x51f4a2[_0x11a4('0x36')]['limit']);_0x2e9f42[_0x11a4('0x22')]=qs[_0x11a4('0x22')](_0x51f4a2['query'][_0x11a4('0x22')]);}return _0x4e1a19[_0x11a4('0x56')](_0x2e9f42);}})[_0x11a4('0x2b')](function(_0x23f2cd){if(_0x23f2cd){return _0x23f2cd?{'count':_0x6790cf,'rows':_0x23f2cd}:null;}})[_0x11a4('0x2b')](respondWithResult(_0x16dcae,null))[_0x11a4('0x48')](handleError(_0x16dcae,null));};exports[_0x11a4('0x58')]=function(_0x5c2a70,_0x301543,_0x4a65fd){return db[_0x11a4('0x31')][_0x11a4('0x4f')]({'where':{'id':_0x5c2a70[_0x11a4('0x4a')]['id']}})[_0x11a4('0x2b')](handleEntityNotFound(_0x301543,null))['then'](function(_0x4b507f){if(_0x4b507f){return _0x4b507f['removeMembers'](_0x5c2a70['query'][_0x11a4('0x54')]);}})[_0x11a4('0x2b')](respondWithStatusCode(_0x301543,null))['catch'](handleError(_0x301543,null));};exports[_0x11a4('0x59')]=function(_0x1f5fd1,_0x30ab7b,_0x65380e){if(_0x1f5fd1['body']['id']){delete _0x1f5fd1['body']['id'];}return db['ChatGroup'][_0x11a4('0x4f')]({'where':{'id':_0x1f5fd1[_0x11a4('0x4a')]['id']}})['then'](handleEntityNotFound(_0x30ab7b,null))['then'](function(_0x262608){if(_0x262608){_0x1f5fd1[_0x11a4('0x4e')][_0x11a4('0x5a')]=_0x262608['id'];return db[_0x11a4('0x51')]['create'](_0x1f5fd1[_0x11a4('0x4e')]);}})['then'](respondWithResult(_0x30ab7b,null))[_0x11a4('0x48')](handleError(_0x30ab7b,null));};exports['getMessages']=function(_0x51863c,_0x578266,_0x54e21b){var _0x5b6e90={};var _0x1ee9df={};var _0x3491dd;var _0x529add;return db[_0x11a4('0x31')]['findOne']({'where':{'id':_0x51863c[_0x11a4('0x4a')]['id']}})['then'](handleEntityNotFound(_0x578266,null))[_0x11a4('0x2b')](function(_0x4aa344){if(_0x4aa344){_0x3491dd=_0x4aa344;_0x1ee9df[_0x11a4('0x35')]=_[_0x11a4('0x37')](db[_0x11a4('0x51')][_0x11a4('0x32')]);_0x1ee9df['query']=_[_0x11a4('0x37')](_0x51863c['query']);_0x1ee9df[_0x11a4('0x38')]=_[_0x11a4('0x39')](_0x1ee9df[_0x11a4('0x35')],_0x1ee9df[_0x11a4('0x36')]);_0x5b6e90[_0x11a4('0x4b')]=_[_0x11a4('0x39')](_0x1ee9df['model'],qs[_0x11a4('0x3a')](_0x51863c[_0x11a4('0x36')][_0x11a4('0x3a')]));_0x5b6e90['attributes']=_0x5b6e90[_0x11a4('0x4b')][_0x11a4('0x3b')]?_0x5b6e90['attributes']:_0x1ee9df[_0x11a4('0x35')];_0x5b6e90[_0x11a4('0x3e')]=qs['sort'](_0x51863c[_0x11a4('0x36')]['sort']);_0x5b6e90[_0x11a4('0x40')]=qs[_0x11a4('0x38')](_[_0x11a4('0x41')](_0x51863c[_0x11a4('0x36')],_0x1ee9df[_0x11a4('0x38')]));if(_0x51863c['query'][_0x11a4('0x42')]){_0x5b6e90[_0x11a4('0x40')]=_['merge'](_0x5b6e90[_0x11a4('0x40')],{'$or':_['map'](_0x5b6e90[_0x11a4('0x4b')],function(_0x2ca900){var _0x24f929={};_0x24f929[_0x2ca900]={'$like':'%'+_0x51863c[_0x11a4('0x36')][_0x11a4('0x42')]+'%'};return _0x24f929;})});}if(_0x51863c[_0x11a4('0x36')][_0x11a4('0x5b')]){var _0x3e49f8=_0x51863c['query'][_0x11a4('0x5b')][_0x11a4('0x5c')](',');var _0x1938f3={};_0x1938f3[_0x3e49f8[0x0]]={'$gte':moment(_0x3e49f8[0x1])[_0x11a4('0x5d')](_0x11a4('0x5e'))};_0x5b6e90[_0x11a4('0x40')]=_[_0x11a4('0x43')](_0x5b6e90[_0x11a4('0x40')],_0x1938f3);}_0x5b6e90=_[_0x11a4('0x43')]({},_0x5b6e90,_0x51863c[_0x11a4('0x45')]);return _0x3491dd['getMessages'](_0x5b6e90);}})['then'](function(_0x4f87e8){if(_0x4f87e8){_0x529add=_0x4f87e8[_0x11a4('0x3b')];if(!_0x51863c[_0x11a4('0x36')]['hasOwnProperty']('nolimit')){_0x5b6e90['limit']=qs[_0x11a4('0x24')](_0x51863c['query']['limit']);_0x5b6e90[_0x11a4('0x22')]=qs['offset'](_0x51863c[_0x11a4('0x36')][_0x11a4('0x22')]);}return _0x3491dd[_0x11a4('0x5f')](_0x5b6e90);}})[_0x11a4('0x2b')](function(_0x225cd0){if(_0x225cd0){return _0x225cd0?{'count':_0x529add,'rows':_0x225cd0}:null;}})[_0x11a4('0x2b')](respondWithResult(_0x578266,null))[_0x11a4('0x48')](handleError(_0x578266,null));};
\ No newline at end of file