Built motion from commit 092f8824.|2.5.49
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index b30df34..a76bc17 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf626=['status','end','offset','undefined','count','Content-Range','json','apply','reject','save','update','then','destroy','error','name','send','ChatGroup','rawAttributes','fieldName','type','key','model','map','query','filters','intersection','attributes','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','VIRTUAL','options','includeAll','include','findAll','rows','catch','show','params','keys','fields','find','create','body','describe','user','toInteger','addMembers','ids','getMembers','User','removeMembers','addMessage','ChatInternalMessage','getMessages','findOne','$gte','format','YYYY-MM-DD\x20HH:mm:ss','rimraf','zip-dir','fast-json-patch','moment','bluebird','util','path','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./chatGroup.socket','sendStatus'];(function(_0x2b10c6,_0x185590){var _0x3789d2=function(_0x272987){while(--_0x272987){_0x2b10c6['push'](_0x2b10c6['shift']());}};_0x3789d2(++_0x185590);}(_0xf626,0x1be));var _0x6f62=function(_0x59a2a0,_0x487aaa){_0x59a2a0=_0x59a2a0-0x0;var _0x10e546=_0xf626[_0x59a2a0];return _0x10e546;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x6f62('0x0'));var zipdir=require(_0x6f62('0x1'));var jsonpatch=require(_0x6f62('0x2'));var rp=require('request-promise');var moment=require(_0x6f62('0x3'));var BPromise=require(_0x6f62('0x4'));var Mustache=require('mustache');var util=require(_0x6f62('0x5'));var path=require(_0x6f62('0x6'));var sox=require('sox');var csv=require(_0x6f62('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x6f62('0x8'));var squel=require('squel');var crypto=require(_0x6f62('0x9'));var jsforce=require(_0x6f62('0xa'));var deskjs=require(_0x6f62('0xb'));var toCsv=require('to-csv');var querystring=require(_0x6f62('0xc'));var Papa=require(_0x6f62('0xd'));var Redis=require('ioredis');var authService=require(_0x6f62('0xe'));var qs=require(_0x6f62('0xf'));var as=require(_0x6f62('0x10'));var hardwareService=require(_0x6f62('0x11'));var logger=require(_0x6f62('0x12'))(_0x6f62('0x13'));var utils=require(_0x6f62('0x14'));var config=require(_0x6f62('0x15'));var licenseUtil=require(_0x6f62('0x16'));var db=require('../../mysqldb')['db'];config[_0x6f62('0x17')]=_[_0x6f62('0x18')](config[_0x6f62('0x17')],{'host':_0x6f62('0x19'),'port':0x18eb});var socket=require(_0x6f62('0x1a'))(new Redis(config[_0x6f62('0x17')]));require(_0x6f62('0x1b'))['register'](socket);function respondWithStatusCode(_0x346e84,_0x247f5b){_0x247f5b=_0x247f5b||0xcc;return function(_0x16e941){if(_0x16e941){return _0x346e84[_0x6f62('0x1c')](_0x247f5b);}return _0x346e84[_0x6f62('0x1d')](_0x247f5b)[_0x6f62('0x1e')]();};}function respondWithResult(_0x25129d,_0x426414){_0x426414=_0x426414||0xc8;return function(_0x1aa848){if(_0x1aa848){return _0x25129d[_0x6f62('0x1d')](_0x426414)['json'](_0x1aa848);}};}function respondWithFilteredResult(_0x36349e,_0x7e6049){return function(_0x5cbc34){if(_0x5cbc34){var _0x468f60=typeof _0x7e6049[_0x6f62('0x1f')]==='undefined'&&typeof _0x7e6049['limit']===_0x6f62('0x20');var _0x425afb=_0x5cbc34[_0x6f62('0x21')];var _0x3d820a=_0x468f60?0x0:_0x7e6049[_0x6f62('0x1f')];var _0xca6cdc=_0x468f60?_0x5cbc34[_0x6f62('0x21')]:_0x7e6049[_0x6f62('0x1f')]+_0x7e6049['limit'];var _0x2fc490;if(_0xca6cdc>=_0x425afb){_0xca6cdc=_0x425afb;_0x2fc490=0xc8;}else{_0x2fc490=0xce;}_0x36349e[_0x6f62('0x1d')](_0x2fc490);return _0x36349e['set'](_0x6f62('0x22'),_0x3d820a+'-'+_0xca6cdc+'/'+_0x425afb)[_0x6f62('0x23')](_0x5cbc34);}return null;};}function patchUpdates(_0x3819b6){return function(_0x39221c){try{jsonpatch[_0x6f62('0x24')](_0x39221c,_0x3819b6,!![]);}catch(_0x257a8a){return BPromise[_0x6f62('0x25')](_0x257a8a);}return _0x39221c[_0x6f62('0x26')]();};}function saveUpdates(_0x361dc8,_0x4bd646){return function(_0x10b0dd){if(_0x10b0dd){return _0x10b0dd[_0x6f62('0x27')](_0x361dc8)[_0x6f62('0x28')](function(_0x4185e2){return _0x4185e2;});}return null;};}function removeEntity(_0x5816bb,_0x462146){return function(_0x37fa30){if(_0x37fa30){return _0x37fa30[_0x6f62('0x29')]()[_0x6f62('0x28')](function(){_0x5816bb[_0x6f62('0x1d')](0xcc)[_0x6f62('0x1e')]();});}};}function handleEntityNotFound(_0x252f61,_0x127ca0){return function(_0xaf0c40){if(!_0xaf0c40){_0x252f61[_0x6f62('0x1c')](0x194);}return _0xaf0c40;};}function handleError(_0x2a4706,_0x57693c){_0x57693c=_0x57693c||0x1f4;return function(_0x1b8533){logger[_0x6f62('0x2a')](_0x1b8533['stack']);if(_0x1b8533[_0x6f62('0x2b')]){delete _0x1b8533[_0x6f62('0x2b')];}_0x2a4706[_0x6f62('0x1d')](_0x57693c)[_0x6f62('0x2c')](_0x1b8533);};}exports['index']=function(_0x1e8cd1,_0x28f08c){var _0x39f6ab={},_0x294be6={},_0x153480={'count':0x0,'rows':[]};var _0x1aa4bf=_['map'](db[_0x6f62('0x2d')][_0x6f62('0x2e')],function(_0xf73b20){return{'name':_0xf73b20[_0x6f62('0x2f')],'type':_0xf73b20[_0x6f62('0x30')][_0x6f62('0x31')]};});_0x294be6[_0x6f62('0x32')]=_[_0x6f62('0x33')](_0x1aa4bf,_0x6f62('0x2b'));_0x294be6[_0x6f62('0x34')]=_['keys'](_0x1e8cd1[_0x6f62('0x34')]);_0x294be6[_0x6f62('0x35')]=_[_0x6f62('0x36')](_0x294be6[_0x6f62('0x32')],_0x294be6['query']);_0x39f6ab[_0x6f62('0x37')]=_[_0x6f62('0x36')](_0x294be6[_0x6f62('0x32')],qs['fields'](_0x1e8cd1[_0x6f62('0x34')]['fields']));_0x39f6ab[_0x6f62('0x37')]=_0x39f6ab[_0x6f62('0x37')][_0x6f62('0x38')]?_0x39f6ab[_0x6f62('0x37')]:_0x294be6[_0x6f62('0x32')];if(!_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x39')](_0x6f62('0x3a'))){_0x39f6ab[_0x6f62('0x3b')]=qs['limit'](_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x3b')]);_0x39f6ab['offset']=qs[_0x6f62('0x1f')](_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x1f')]);}_0x39f6ab[_0x6f62('0x3c')]=qs[_0x6f62('0x3d')](_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x3d')]);_0x39f6ab[_0x6f62('0x3e')]=qs['filters'](_[_0x6f62('0x3f')](_0x1e8cd1[_0x6f62('0x34')],_0x294be6['filters']),_0x1aa4bf);if(_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x40')]){_0x39f6ab[_0x6f62('0x3e')]=_[_0x6f62('0x41')](_0x39f6ab['where'],{'$or':_['map'](_0x1aa4bf,function(_0x45c099){if(_0x45c099[_0x6f62('0x30')]!==_0x6f62('0x42')){var _0x44c2ab={};_0x44c2ab[_0x45c099[_0x6f62('0x2b')]]={'$like':'%'+_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x40')]+'%'};return _0x44c2ab;}})});}_0x39f6ab=_[_0x6f62('0x41')]({},_0x39f6ab,_0x1e8cd1[_0x6f62('0x43')]);var _0x361fa3={'where':_0x39f6ab['where']};return db[_0x6f62('0x2d')]['count'](_0x361fa3)[_0x6f62('0x28')](function(_0x580a3b){_0x153480[_0x6f62('0x21')]=_0x580a3b;if(_0x1e8cd1[_0x6f62('0x34')][_0x6f62('0x44')]){_0x39f6ab[_0x6f62('0x45')]=[{'all':!![]}];}return db['ChatGroup'][_0x6f62('0x46')](_0x39f6ab);})['then'](function(_0x3333e9){_0x153480[_0x6f62('0x47')]=_0x3333e9;return _0x153480;})[_0x6f62('0x28')](respondWithFilteredResult(_0x28f08c,_0x39f6ab))[_0x6f62('0x48')](handleError(_0x28f08c,null));};exports[_0x6f62('0x49')]=function(_0x1a11b1,_0x326f62){var _0x151718={'raw':!![],'where':{'id':_0x1a11b1[_0x6f62('0x4a')]['id']}},_0x1f6918={};_0x1f6918[_0x6f62('0x32')]=_[_0x6f62('0x4b')](db[_0x6f62('0x2d')][_0x6f62('0x2e')]);_0x1f6918[_0x6f62('0x34')]=_['keys'](_0x1a11b1[_0x6f62('0x34')]);_0x1f6918['filters']=_['intersection'](_0x1f6918[_0x6f62('0x32')],_0x1f6918[_0x6f62('0x34')]);_0x151718[_0x6f62('0x37')]=_[_0x6f62('0x36')](_0x1f6918[_0x6f62('0x32')],qs['fields'](_0x1a11b1[_0x6f62('0x34')][_0x6f62('0x4c')]));_0x151718[_0x6f62('0x37')]=_0x151718[_0x6f62('0x37')][_0x6f62('0x38')]?_0x151718[_0x6f62('0x37')]:_0x1f6918[_0x6f62('0x32')];if(_0x1a11b1[_0x6f62('0x34')]['includeAll']){_0x151718[_0x6f62('0x45')]=[{'all':!![]}];}_0x151718=_[_0x6f62('0x41')]({},_0x151718,_0x1a11b1[_0x6f62('0x43')]);return db[_0x6f62('0x2d')][_0x6f62('0x4d')](_0x151718)[_0x6f62('0x28')](handleEntityNotFound(_0x326f62,null))[_0x6f62('0x28')](respondWithResult(_0x326f62,null))['catch'](handleError(_0x326f62,null));};exports['create']=function(_0x48c5ca,_0xd06fb){return db[_0x6f62('0x2d')][_0x6f62('0x4e')](_0x48c5ca['body'],{})[_0x6f62('0x28')](respondWithResult(_0xd06fb,0xc9))[_0x6f62('0x48')](handleError(_0xd06fb,null));};exports[_0x6f62('0x27')]=function(_0x3348a2,_0x2b7bbc){if(_0x3348a2[_0x6f62('0x4f')]['id']){delete _0x3348a2[_0x6f62('0x4f')]['id'];}return db[_0x6f62('0x2d')][_0x6f62('0x4d')]({'where':{'id':_0x3348a2[_0x6f62('0x4a')]['id']}})['then'](handleEntityNotFound(_0x2b7bbc,null))[_0x6f62('0x28')](saveUpdates(_0x3348a2[_0x6f62('0x4f')],null))[_0x6f62('0x28')](respondWithResult(_0x2b7bbc,null))['catch'](handleError(_0x2b7bbc,null));};exports['destroy']=function(_0x446aea,_0x2655e7){return db['ChatGroup']['find']({'where':{'id':_0x446aea[_0x6f62('0x4a')]['id']}})[_0x6f62('0x28')](handleEntityNotFound(_0x2655e7,null))['then'](removeEntity(_0x2655e7,null))['catch'](handleError(_0x2655e7,null));};exports[_0x6f62('0x50')]=function(_0xdd10a1,_0x43f78c){return db[_0x6f62('0x2d')][_0x6f62('0x50')]()[_0x6f62('0x28')](respondWithResult(_0x43f78c,null))[_0x6f62('0x48')](handleError(_0x43f78c,null));};exports['getUnread']=function(_0x2beaac,_0x2ded7f,_0x479aeb){return db['ChatInternalMessage'][_0x6f62('0x21')]({'where':{'ChatGroupId':_0x2beaac[_0x6f62('0x4a')]['id'],'ToId':_0x2beaac[_0x6f62('0x51')]['id'],'read':![]}})[_0x6f62('0x28')](function(_0x9f743e){return{'id':_[_0x6f62('0x52')](_0x2beaac[_0x6f62('0x4a')]['id']),'count':_0x9f743e};})['then'](respondWithResult(_0x2ded7f,null))[_0x6f62('0x48')](handleError(_0x2ded7f,null));};exports['addMembers']=function(_0x3c867a,_0x1112ba,_0x1b53c4){return db[_0x6f62('0x2d')][_0x6f62('0x4d')]({'where':{'id':_0x3c867a['params']['id']}})[_0x6f62('0x28')](handleEntityNotFound(_0x1112ba,null))[_0x6f62('0x28')](function(_0x1e87ff){if(_0x1e87ff){return _0x1e87ff[_0x6f62('0x53')](_0x3c867a[_0x6f62('0x4f')][_0x6f62('0x54')],_['omit'](_0x3c867a[_0x6f62('0x4f')],[_0x6f62('0x54'),'id'])||{});}})['then'](respondWithResult(_0x1112ba,null))[_0x6f62('0x48')](handleError(_0x1112ba,null));};exports[_0x6f62('0x55')]=function(_0xfe5f2b,_0x481128,_0x1e5234){var _0x4e9323={};var _0x460447={};var _0x772cc0;var _0x293dbb;return db['ChatGroup']['findOne']({'where':{'id':_0xfe5f2b['params']['id']}})[_0x6f62('0x28')](handleEntityNotFound(_0x481128,null))[_0x6f62('0x28')](function(_0x32b83b){if(_0x32b83b){_0x772cc0=_0x32b83b;_0x460447[_0x6f62('0x32')]=_[_0x6f62('0x4b')](db[_0x6f62('0x56')]['rawAttributes']);_0x460447[_0x6f62('0x34')]=_[_0x6f62('0x4b')](_0xfe5f2b[_0x6f62('0x34')]);_0x460447[_0x6f62('0x35')]=_[_0x6f62('0x36')](_0x460447['model'],_0x460447['query']);_0x4e9323[_0x6f62('0x37')]=_[_0x6f62('0x36')](_0x460447[_0x6f62('0x32')],qs[_0x6f62('0x4c')](_0xfe5f2b[_0x6f62('0x34')][_0x6f62('0x4c')]));_0x4e9323['attributes']=_0x4e9323['attributes'][_0x6f62('0x38')]?_0x4e9323[_0x6f62('0x37')]:_0x460447[_0x6f62('0x32')];_0x4e9323[_0x6f62('0x3c')]=qs['sort'](_0xfe5f2b[_0x6f62('0x34')]['sort']);_0x4e9323[_0x6f62('0x3e')]=qs[_0x6f62('0x35')](_['pick'](_0xfe5f2b[_0x6f62('0x34')],_0x460447[_0x6f62('0x35')]));if(_0xfe5f2b['query'][_0x6f62('0x40')]){_0x4e9323[_0x6f62('0x3e')]=_[_0x6f62('0x41')](_0x4e9323['where'],{'$or':_['map'](_0x4e9323[_0x6f62('0x37')],function(_0x53f872){var _0x29cb5d={};_0x29cb5d[_0x53f872]={'$like':'%'+_0xfe5f2b[_0x6f62('0x34')][_0x6f62('0x40')]+'%'};return _0x29cb5d;})});}_0x4e9323=_[_0x6f62('0x41')]({},_0x4e9323,_0xfe5f2b[_0x6f62('0x43')]);return _0x772cc0[_0x6f62('0x55')](_0x4e9323);}})['then'](function(_0x42b4fc){if(_0x42b4fc){_0x293dbb=_0x42b4fc[_0x6f62('0x38')];if(!_0xfe5f2b[_0x6f62('0x34')][_0x6f62('0x39')](_0x6f62('0x3a'))){_0x4e9323[_0x6f62('0x3b')]=qs[_0x6f62('0x3b')](_0xfe5f2b['query']['limit']);_0x4e9323[_0x6f62('0x1f')]=qs[_0x6f62('0x1f')](_0xfe5f2b[_0x6f62('0x34')][_0x6f62('0x1f')]);}return _0x772cc0[_0x6f62('0x55')](_0x4e9323);}})[_0x6f62('0x28')](function(_0x4d67f7){if(_0x4d67f7){return _0x4d67f7?{'count':_0x293dbb,'rows':_0x4d67f7}:null;}})[_0x6f62('0x28')](respondWithResult(_0x481128,null))[_0x6f62('0x48')](handleError(_0x481128,null));};exports[_0x6f62('0x57')]=function(_0x34603d,_0x1ad332,_0x5daecf){return db[_0x6f62('0x2d')][_0x6f62('0x4d')]({'where':{'id':_0x34603d['params']['id']}})['then'](handleEntityNotFound(_0x1ad332,null))[_0x6f62('0x28')](function(_0x2f3e4e){if(_0x2f3e4e){return _0x2f3e4e['removeMembers'](_0x34603d[_0x6f62('0x34')][_0x6f62('0x54')]);}})['then'](respondWithStatusCode(_0x1ad332,null))[_0x6f62('0x48')](handleError(_0x1ad332,null));};exports[_0x6f62('0x58')]=function(_0x4c51f7,_0x409d28,_0x30247a){if(_0x4c51f7[_0x6f62('0x4f')]['id']){delete _0x4c51f7['body']['id'];}return db['ChatGroup'][_0x6f62('0x4d')]({'where':{'id':_0x4c51f7['params']['id']}})['then'](handleEntityNotFound(_0x409d28,null))[_0x6f62('0x28')](function(_0x56d8ff){if(_0x56d8ff){_0x4c51f7[_0x6f62('0x4f')]['ChatGroupId']=_0x56d8ff['id'];return db[_0x6f62('0x59')][_0x6f62('0x4e')](_0x4c51f7['body']);}})[_0x6f62('0x28')](respondWithResult(_0x409d28,null))[_0x6f62('0x48')](handleError(_0x409d28,null));};exports[_0x6f62('0x5a')]=function(_0x380287,_0x2d662a,_0x352231){var _0x1f6395={};var _0x19e23c={};var _0x57cf71;var _0x1e06db;return db[_0x6f62('0x2d')][_0x6f62('0x5b')]({'where':{'id':_0x380287[_0x6f62('0x4a')]['id']}})[_0x6f62('0x28')](handleEntityNotFound(_0x2d662a,null))[_0x6f62('0x28')](function(_0x109a7a){if(_0x109a7a){_0x57cf71=_0x109a7a;_0x19e23c['model']=_[_0x6f62('0x4b')](db[_0x6f62('0x59')][_0x6f62('0x2e')]);_0x19e23c[_0x6f62('0x34')]=_[_0x6f62('0x4b')](_0x380287[_0x6f62('0x34')]);_0x19e23c[_0x6f62('0x35')]=_[_0x6f62('0x36')](_0x19e23c[_0x6f62('0x32')],_0x19e23c[_0x6f62('0x34')]);_0x1f6395[_0x6f62('0x37')]=_[_0x6f62('0x36')](_0x19e23c[_0x6f62('0x32')],qs[_0x6f62('0x4c')](_0x380287[_0x6f62('0x34')]['fields']));_0x1f6395[_0x6f62('0x37')]=_0x1f6395[_0x6f62('0x37')][_0x6f62('0x38')]?_0x1f6395[_0x6f62('0x37')]:_0x19e23c[_0x6f62('0x32')];_0x1f6395[_0x6f62('0x3c')]=qs[_0x6f62('0x3d')](_0x380287[_0x6f62('0x34')]['sort']);_0x1f6395[_0x6f62('0x3e')]=qs[_0x6f62('0x35')](_[_0x6f62('0x3f')](_0x380287[_0x6f62('0x34')],_0x19e23c[_0x6f62('0x35')]));if(_0x380287[_0x6f62('0x34')][_0x6f62('0x40')]){_0x1f6395[_0x6f62('0x3e')]=_['merge'](_0x1f6395[_0x6f62('0x3e')],{'$or':_[_0x6f62('0x33')](_0x1f6395[_0x6f62('0x37')],function(_0x2bb486){var _0x3ad3bf={};_0x3ad3bf[_0x2bb486]={'$like':'%'+_0x380287[_0x6f62('0x34')][_0x6f62('0x40')]+'%'};return _0x3ad3bf;})});}if(_0x380287['query']['$gte']){var _0x404f25=_0x380287[_0x6f62('0x34')][_0x6f62('0x5c')]['split'](',');var _0x208836={};_0x208836[_0x404f25[0x0]]={'$gte':moment(_0x404f25[0x1])[_0x6f62('0x5d')](_0x6f62('0x5e'))};_0x1f6395[_0x6f62('0x3e')]=_['merge'](_0x1f6395[_0x6f62('0x3e')],_0x208836);}_0x1f6395=_[_0x6f62('0x41')]({},_0x1f6395,_0x380287[_0x6f62('0x43')]);return _0x57cf71[_0x6f62('0x5a')](_0x1f6395);}})[_0x6f62('0x28')](function(_0x4b4d77){if(_0x4b4d77){_0x1e06db=_0x4b4d77[_0x6f62('0x38')];if(!_0x380287[_0x6f62('0x34')][_0x6f62('0x39')]('nolimit')){_0x1f6395['limit']=qs['limit'](_0x380287['query'][_0x6f62('0x3b')]);_0x1f6395[_0x6f62('0x1f')]=qs[_0x6f62('0x1f')](_0x380287[_0x6f62('0x34')][_0x6f62('0x1f')]);}return _0x57cf71[_0x6f62('0x5a')](_0x1f6395);}})[_0x6f62('0x28')](function(_0xe662bf){if(_0xe662bf){return _0xe662bf?{'count':_0x1e06db,'rows':_0xe662bf}:null;}})[_0x6f62('0x28')](respondWithResult(_0x2d662a,null))[_0x6f62('0x48')](handleError(_0x2d662a,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