Built motion from commit 20b39a97.|2.6.29
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index a286f49..89b1717 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb9fb=['../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/license/util','../../mysqldb','redis','socket.io-emitter','./chatGroup.socket','register','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','then','destroy','end','sendStatus','error','name','send','index','map','type','key','model','query','keys','filters','intersection','attributes','length','nolimit','sort','where','pick','VIRTUAL','filter','merge','ChatGroup','findAll','rows','catch','show','params','rawAttributes','fields','includeAll','options','find','create','body','describe','getUnread','ChatInternalMessage','toInteger','ids','omit','getMembers','findOne','User','order','hasOwnProperty','removeMembers','addMessage','ChatGroupId','getMessages','$gte','split','format','YYYY-MM-DD\x20HH:mm:ss','eml-format','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x7f3667,_0x30c3f1){var _0x2c4c24=function(_0xf070f3){while(--_0xf070f3){_0x7f3667['push'](_0x7f3667['shift']());}};_0x2c4c24(++_0x30c3f1);}(_0xb9fb,0x171));var _0xbb9f=function(_0x9df060,_0x253d33){_0x9df060=_0x9df060-0x0;var _0x338dfe=_0xb9fb[_0x9df060];return _0x338dfe;};'use strict';var emlformat=require(_0xbb9f('0x0'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xbb9f('0x1'));var rp=require(_0xbb9f('0x2'));var moment=require(_0xbb9f('0x3'));var BPromise=require(_0xbb9f('0x4'));var Mustache=require(_0xbb9f('0x5'));var util=require(_0xbb9f('0x6'));var path=require(_0xbb9f('0x7'));var sox=require('sox');var csv=require(_0xbb9f('0x8'));var ejs=require(_0xbb9f('0x9'));var fs=require('fs');var fs_extra=require(_0xbb9f('0xa'));var _=require(_0xbb9f('0xb'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xbb9f('0xc'));var deskjs=require(_0xbb9f('0xd'));var toCsv=require('to-csv');var querystring=require(_0xbb9f('0xe'));var Papa=require(_0xbb9f('0xf'));var Redis=require(_0xbb9f('0x10'));var authService=require(_0xbb9f('0x11'));var qs=require(_0xbb9f('0x12'));var as=require(_0xbb9f('0x13'));var hardwareService=require(_0xbb9f('0x14'));var logger=require('../../config/logger')(_0xbb9f('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require(_0xbb9f('0x16'));var db=require(_0xbb9f('0x17'))['db'];config[_0xbb9f('0x18')]=_['defaults'](config[_0xbb9f('0x18')],{'host':'localhost','port':0x18eb});var socket=require(_0xbb9f('0x19'))(new Redis(config[_0xbb9f('0x18')]));require(_0xbb9f('0x1a'))[_0xbb9f('0x1b')](socket);function respondWithStatusCode(_0x1c8a27,_0x4338c7){_0x4338c7=_0x4338c7||0xcc;return function(_0x5c1dcd){if(_0x5c1dcd){return _0x1c8a27['sendStatus'](_0x4338c7);}return _0x1c8a27['status'](_0x4338c7)['end']();};}function respondWithResult(_0x3dbcbb,_0x545c67){_0x545c67=_0x545c67||0xc8;return function(_0x3b6bf3){if(_0x3b6bf3){return _0x3dbcbb[_0xbb9f('0x1c')](_0x545c67)[_0xbb9f('0x1d')](_0x3b6bf3);}};}function respondWithFilteredResult(_0x2e4611,_0xd2c364){return function(_0xd2f752){if(_0xd2f752){var _0x1d5bb3=typeof _0xd2c364[_0xbb9f('0x1e')]===_0xbb9f('0x1f')&&typeof _0xd2c364[_0xbb9f('0x20')]===_0xbb9f('0x1f');var _0x1d8ce7=_0xd2f752[_0xbb9f('0x21')];var _0x49a9c5=_0x1d5bb3?0x0:_0xd2c364[_0xbb9f('0x1e')];var _0x32d6ca=_0x1d5bb3?_0xd2f752[_0xbb9f('0x21')]:_0xd2c364[_0xbb9f('0x1e')]+_0xd2c364[_0xbb9f('0x20')];var _0xe08dee;if(_0x32d6ca>=_0x1d8ce7){_0x32d6ca=_0x1d8ce7;_0xe08dee=0xc8;}else{_0xe08dee=0xce;}_0x2e4611['status'](_0xe08dee);return _0x2e4611[_0xbb9f('0x22')](_0xbb9f('0x23'),_0x49a9c5+'-'+_0x32d6ca+'/'+_0x1d8ce7)['json'](_0xd2f752);}return null;};}function patchUpdates(_0x2f50f6){return function(_0xf7f64c){try{jsonpatch[_0xbb9f('0x24')](_0xf7f64c,_0x2f50f6,!![]);}catch(_0x57b2ae){return BPromise[_0xbb9f('0x25')](_0x57b2ae);}return _0xf7f64c[_0xbb9f('0x26')]();};}function saveUpdates(_0x370c24,_0x59d15d){return function(_0x4983df){if(_0x4983df){return _0x4983df[_0xbb9f('0x27')](_0x370c24)[_0xbb9f('0x28')](function(_0x35ab35){return _0x35ab35;});}return null;};}function removeEntity(_0x2a9d77,_0x252d86){return function(_0x1a7f7b){if(_0x1a7f7b){return _0x1a7f7b[_0xbb9f('0x29')]()[_0xbb9f('0x28')](function(){_0x2a9d77[_0xbb9f('0x1c')](0xcc)[_0xbb9f('0x2a')]();});}};}function handleEntityNotFound(_0x38c0db,_0x40c1a0){return function(_0x354c73){if(!_0x354c73){_0x38c0db[_0xbb9f('0x2b')](0x194);}return _0x354c73;};}function handleError(_0x3304e5,_0x1ad038){_0x1ad038=_0x1ad038||0x1f4;return function(_0x13f367){logger[_0xbb9f('0x2c')](_0x13f367['stack']);if(_0x13f367[_0xbb9f('0x2d')]){delete _0x13f367[_0xbb9f('0x2d')];}_0x3304e5[_0xbb9f('0x1c')](_0x1ad038)[_0xbb9f('0x2e')](_0x13f367);};}exports[_0xbb9f('0x2f')]=function(_0xa1026a,_0x1e6c1f){var _0x581e0c={},_0x1173d8={},_0x14fe35={'count':0x0,'rows':[]};var _0x506ef5=_[_0xbb9f('0x30')](db['ChatGroup']['rawAttributes'],function(_0x81e427){return{'name':_0x81e427['fieldName'],'type':_0x81e427[_0xbb9f('0x31')][_0xbb9f('0x32')]};});_0x1173d8[_0xbb9f('0x33')]=_[_0xbb9f('0x30')](_0x506ef5,_0xbb9f('0x2d'));_0x1173d8[_0xbb9f('0x34')]=_[_0xbb9f('0x35')](_0xa1026a[_0xbb9f('0x34')]);_0x1173d8[_0xbb9f('0x36')]=_[_0xbb9f('0x37')](_0x1173d8[_0xbb9f('0x33')],_0x1173d8['query']);_0x581e0c[_0xbb9f('0x38')]=_['intersection'](_0x1173d8[_0xbb9f('0x33')],qs['fields'](_0xa1026a[_0xbb9f('0x34')]['fields']));_0x581e0c[_0xbb9f('0x38')]=_0x581e0c[_0xbb9f('0x38')][_0xbb9f('0x39')]?_0x581e0c[_0xbb9f('0x38')]:_0x1173d8['model'];if(!_0xa1026a['query']['hasOwnProperty'](_0xbb9f('0x3a'))){_0x581e0c[_0xbb9f('0x20')]=qs['limit'](_0xa1026a[_0xbb9f('0x34')][_0xbb9f('0x20')]);_0x581e0c[_0xbb9f('0x1e')]=qs[_0xbb9f('0x1e')](_0xa1026a[_0xbb9f('0x34')]['offset']);}_0x581e0c['order']=qs[_0xbb9f('0x3b')](_0xa1026a[_0xbb9f('0x34')][_0xbb9f('0x3b')]);_0x581e0c[_0xbb9f('0x3c')]=qs[_0xbb9f('0x36')](_[_0xbb9f('0x3d')](_0xa1026a[_0xbb9f('0x34')],_0x1173d8[_0xbb9f('0x36')]),_0x506ef5);if(_0xa1026a[_0xbb9f('0x34')]['filter']){_0x581e0c['where']=_['merge'](_0x581e0c['where'],{'$or':_[_0xbb9f('0x30')](_0x506ef5,function(_0x54c016){if(_0x54c016[_0xbb9f('0x31')]!==_0xbb9f('0x3e')){var _0x22322c={};_0x22322c[_0x54c016['name']]={'$like':'%'+_0xa1026a[_0xbb9f('0x34')][_0xbb9f('0x3f')]+'%'};return _0x22322c;}})});}_0x581e0c=_[_0xbb9f('0x40')]({},_0x581e0c,_0xa1026a['options']);var _0x5a18e0={'where':_0x581e0c[_0xbb9f('0x3c')]};return db[_0xbb9f('0x41')][_0xbb9f('0x21')](_0x5a18e0)[_0xbb9f('0x28')](function(_0x15f8df){_0x14fe35[_0xbb9f('0x21')]=_0x15f8df;if(_0xa1026a[_0xbb9f('0x34')]['includeAll']){_0x581e0c['include']=[{'all':!![]}];}return db['ChatGroup'][_0xbb9f('0x42')](_0x581e0c);})['then'](function(_0x45bbe7){_0x14fe35[_0xbb9f('0x43')]=_0x45bbe7;return _0x14fe35;})[_0xbb9f('0x28')](respondWithFilteredResult(_0x1e6c1f,_0x581e0c))[_0xbb9f('0x44')](handleError(_0x1e6c1f,null));};exports[_0xbb9f('0x45')]=function(_0x3df174,_0x592dd2){var _0x5d8264={'raw':!![],'where':{'id':_0x3df174[_0xbb9f('0x46')]['id']}},_0x28b0f5={};_0x28b0f5['model']=_[_0xbb9f('0x35')](db[_0xbb9f('0x41')][_0xbb9f('0x47')]);_0x28b0f5[_0xbb9f('0x34')]=_[_0xbb9f('0x35')](_0x3df174[_0xbb9f('0x34')]);_0x28b0f5['filters']=_[_0xbb9f('0x37')](_0x28b0f5['model'],_0x28b0f5['query']);_0x5d8264['attributes']=_['intersection'](_0x28b0f5['model'],qs[_0xbb9f('0x48')](_0x3df174[_0xbb9f('0x34')][_0xbb9f('0x48')]));_0x5d8264[_0xbb9f('0x38')]=_0x5d8264[_0xbb9f('0x38')][_0xbb9f('0x39')]?_0x5d8264[_0xbb9f('0x38')]:_0x28b0f5[_0xbb9f('0x33')];if(_0x3df174[_0xbb9f('0x34')][_0xbb9f('0x49')]){_0x5d8264['include']=[{'all':!![]}];}_0x5d8264=_[_0xbb9f('0x40')]({},_0x5d8264,_0x3df174[_0xbb9f('0x4a')]);return db['ChatGroup'][_0xbb9f('0x4b')](_0x5d8264)['then'](handleEntityNotFound(_0x592dd2,null))[_0xbb9f('0x28')](respondWithResult(_0x592dd2,null))['catch'](handleError(_0x592dd2,null));};exports[_0xbb9f('0x4c')]=function(_0x392647,_0x53984f){return db['ChatGroup'][_0xbb9f('0x4c')](_0x392647[_0xbb9f('0x4d')],{})[_0xbb9f('0x28')](respondWithResult(_0x53984f,0xc9))[_0xbb9f('0x44')](handleError(_0x53984f,null));};exports[_0xbb9f('0x27')]=function(_0xe5bb4,_0x2a14ec){if(_0xe5bb4['body']['id']){delete _0xe5bb4[_0xbb9f('0x4d')]['id'];}return db['ChatGroup'][_0xbb9f('0x4b')]({'where':{'id':_0xe5bb4[_0xbb9f('0x46')]['id']}})[_0xbb9f('0x28')](handleEntityNotFound(_0x2a14ec,null))['then'](saveUpdates(_0xe5bb4[_0xbb9f('0x4d')],null))[_0xbb9f('0x28')](respondWithResult(_0x2a14ec,null))[_0xbb9f('0x44')](handleError(_0x2a14ec,null));};exports['destroy']=function(_0x4c894f,_0x5ddc70){return db['ChatGroup'][_0xbb9f('0x4b')]({'where':{'id':_0x4c894f[_0xbb9f('0x46')]['id']}})['then'](handleEntityNotFound(_0x5ddc70,null))[_0xbb9f('0x28')](removeEntity(_0x5ddc70,null))['catch'](handleError(_0x5ddc70,null));};exports[_0xbb9f('0x4e')]=function(_0x12c541,_0x487953){return db[_0xbb9f('0x41')][_0xbb9f('0x4e')]()[_0xbb9f('0x28')](respondWithResult(_0x487953,null))[_0xbb9f('0x44')](handleError(_0x487953,null));};exports[_0xbb9f('0x4f')]=function(_0x557a1c,_0x574d64,_0x30fe10){return db[_0xbb9f('0x50')]['count']({'where':{'ChatGroupId':_0x557a1c['params']['id'],'ToId':_0x557a1c['user']['id'],'read':![]}})['then'](function(_0x2d5e80){return{'id':_[_0xbb9f('0x51')](_0x557a1c[_0xbb9f('0x46')]['id']),'count':_0x2d5e80};})[_0xbb9f('0x28')](respondWithResult(_0x574d64,null))[_0xbb9f('0x44')](handleError(_0x574d64,null));};exports['addMembers']=function(_0x2fbcd,_0x14910e,_0x55c4d9){return db[_0xbb9f('0x41')][_0xbb9f('0x4b')]({'where':{'id':_0x2fbcd[_0xbb9f('0x46')]['id']}})[_0xbb9f('0x28')](handleEntityNotFound(_0x14910e,null))[_0xbb9f('0x28')](function(_0x5245bd){if(_0x5245bd){return _0x5245bd['addMembers'](_0x2fbcd[_0xbb9f('0x4d')][_0xbb9f('0x52')],_[_0xbb9f('0x53')](_0x2fbcd[_0xbb9f('0x4d')],[_0xbb9f('0x52'),'id'])||{});}})[_0xbb9f('0x28')](respondWithResult(_0x14910e,null))[_0xbb9f('0x44')](handleError(_0x14910e,null));};exports[_0xbb9f('0x54')]=function(_0x536190,_0x349cf6,_0x282c35){var _0x17aa28={};var _0x1ec0b8={};var _0x5a1220;var _0x3d6542;return db[_0xbb9f('0x41')][_0xbb9f('0x55')]({'where':{'id':_0x536190['params']['id']}})[_0xbb9f('0x28')](handleEntityNotFound(_0x349cf6,null))[_0xbb9f('0x28')](function(_0x550338){if(_0x550338){_0x5a1220=_0x550338;_0x1ec0b8[_0xbb9f('0x33')]=_[_0xbb9f('0x35')](db[_0xbb9f('0x56')][_0xbb9f('0x47')]);_0x1ec0b8['query']=_['keys'](_0x536190[_0xbb9f('0x34')]);_0x1ec0b8[_0xbb9f('0x36')]=_[_0xbb9f('0x37')](_0x1ec0b8['model'],_0x1ec0b8[_0xbb9f('0x34')]);_0x17aa28['attributes']=_['intersection'](_0x1ec0b8[_0xbb9f('0x33')],qs[_0xbb9f('0x48')](_0x536190[_0xbb9f('0x34')][_0xbb9f('0x48')]));_0x17aa28[_0xbb9f('0x38')]=_0x17aa28[_0xbb9f('0x38')][_0xbb9f('0x39')]?_0x17aa28[_0xbb9f('0x38')]:_0x1ec0b8['model'];_0x17aa28[_0xbb9f('0x57')]=qs['sort'](_0x536190[_0xbb9f('0x34')]['sort']);_0x17aa28[_0xbb9f('0x3c')]=qs['filters'](_[_0xbb9f('0x3d')](_0x536190[_0xbb9f('0x34')],_0x1ec0b8[_0xbb9f('0x36')]));if(_0x536190[_0xbb9f('0x34')][_0xbb9f('0x3f')]){_0x17aa28[_0xbb9f('0x3c')]=_['merge'](_0x17aa28[_0xbb9f('0x3c')],{'$or':_[_0xbb9f('0x30')](_0x17aa28['attributes'],function(_0x3916b3){var _0x1e4c37={};_0x1e4c37[_0x3916b3]={'$like':'%'+_0x536190[_0xbb9f('0x34')][_0xbb9f('0x3f')]+'%'};return _0x1e4c37;})});}_0x17aa28=_[_0xbb9f('0x40')]({},_0x17aa28,_0x536190[_0xbb9f('0x4a')]);return _0x5a1220['getMembers'](_0x17aa28);}})[_0xbb9f('0x28')](function(_0x4cfa86){if(_0x4cfa86){_0x3d6542=_0x4cfa86[_0xbb9f('0x39')];if(!_0x536190[_0xbb9f('0x34')][_0xbb9f('0x58')](_0xbb9f('0x3a'))){_0x17aa28[_0xbb9f('0x20')]=qs[_0xbb9f('0x20')](_0x536190[_0xbb9f('0x34')][_0xbb9f('0x20')]);_0x17aa28[_0xbb9f('0x1e')]=qs['offset'](_0x536190[_0xbb9f('0x34')][_0xbb9f('0x1e')]);}return _0x5a1220[_0xbb9f('0x54')](_0x17aa28);}})['then'](function(_0x36e49d){if(_0x36e49d){return _0x36e49d?{'count':_0x3d6542,'rows':_0x36e49d}:null;}})[_0xbb9f('0x28')](respondWithResult(_0x349cf6,null))[_0xbb9f('0x44')](handleError(_0x349cf6,null));};exports['removeMembers']=function(_0x226698,_0x59d9e9,_0x55ae78){return db[_0xbb9f('0x41')][_0xbb9f('0x4b')]({'where':{'id':_0x226698[_0xbb9f('0x46')]['id']}})['then'](handleEntityNotFound(_0x59d9e9,null))[_0xbb9f('0x28')](function(_0x514e70){if(_0x514e70){return _0x514e70[_0xbb9f('0x59')](_0x226698[_0xbb9f('0x34')][_0xbb9f('0x52')]);}})[_0xbb9f('0x28')](respondWithStatusCode(_0x59d9e9,null))[_0xbb9f('0x44')](handleError(_0x59d9e9,null));};exports[_0xbb9f('0x5a')]=function(_0x11dd00,_0x2835e0,_0x51f933){if(_0x11dd00[_0xbb9f('0x4d')]['id']){delete _0x11dd00[_0xbb9f('0x4d')]['id'];}return db[_0xbb9f('0x41')][_0xbb9f('0x4b')]({'where':{'id':_0x11dd00['params']['id']}})[_0xbb9f('0x28')](handleEntityNotFound(_0x2835e0,null))['then'](function(_0x138b18){if(_0x138b18){_0x11dd00['body'][_0xbb9f('0x5b')]=_0x138b18['id'];return db[_0xbb9f('0x50')][_0xbb9f('0x4c')](_0x11dd00[_0xbb9f('0x4d')]);}})[_0xbb9f('0x28')](respondWithResult(_0x2835e0,null))[_0xbb9f('0x44')](handleError(_0x2835e0,null));};exports[_0xbb9f('0x5c')]=function(_0x161e81,_0x4ed003,_0xa3d020){var _0x500d94={};var _0x23b03b={};var _0x4a7589;var _0x27f1f5;return db[_0xbb9f('0x41')]['findOne']({'where':{'id':_0x161e81[_0xbb9f('0x46')]['id']}})[_0xbb9f('0x28')](handleEntityNotFound(_0x4ed003,null))[_0xbb9f('0x28')](function(_0x322b52){if(_0x322b52){_0x4a7589=_0x322b52;_0x23b03b['model']=_[_0xbb9f('0x35')](db[_0xbb9f('0x50')][_0xbb9f('0x47')]);_0x23b03b[_0xbb9f('0x34')]=_[_0xbb9f('0x35')](_0x161e81[_0xbb9f('0x34')]);_0x23b03b[_0xbb9f('0x36')]=_[_0xbb9f('0x37')](_0x23b03b[_0xbb9f('0x33')],_0x23b03b[_0xbb9f('0x34')]);_0x500d94[_0xbb9f('0x38')]=_[_0xbb9f('0x37')](_0x23b03b[_0xbb9f('0x33')],qs[_0xbb9f('0x48')](_0x161e81[_0xbb9f('0x34')]['fields']));_0x500d94[_0xbb9f('0x38')]=_0x500d94[_0xbb9f('0x38')][_0xbb9f('0x39')]?_0x500d94[_0xbb9f('0x38')]:_0x23b03b[_0xbb9f('0x33')];_0x500d94['order']=qs[_0xbb9f('0x3b')](_0x161e81[_0xbb9f('0x34')][_0xbb9f('0x3b')]);_0x500d94[_0xbb9f('0x3c')]=qs['filters'](_['pick'](_0x161e81[_0xbb9f('0x34')],_0x23b03b['filters']));if(_0x161e81[_0xbb9f('0x34')][_0xbb9f('0x3f')]){_0x500d94[_0xbb9f('0x3c')]=_[_0xbb9f('0x40')](_0x500d94[_0xbb9f('0x3c')],{'$or':_[_0xbb9f('0x30')](_0x500d94[_0xbb9f('0x38')],function(_0x1d4da9){var _0xb2f9a9={};_0xb2f9a9[_0x1d4da9]={'$like':'%'+_0x161e81[_0xbb9f('0x34')][_0xbb9f('0x3f')]+'%'};return _0xb2f9a9;})});}if(_0x161e81[_0xbb9f('0x34')][_0xbb9f('0x5d')]){var _0x471aaf=_0x161e81[_0xbb9f('0x34')][_0xbb9f('0x5d')][_0xbb9f('0x5e')](',');var _0x27fbe3={};_0x27fbe3[_0x471aaf[0x0]]={'$gte':moment(_0x471aaf[0x1])[_0xbb9f('0x5f')](_0xbb9f('0x60'))};_0x500d94[_0xbb9f('0x3c')]=_[_0xbb9f('0x40')](_0x500d94['where'],_0x27fbe3);}_0x500d94=_[_0xbb9f('0x40')]({},_0x500d94,_0x161e81[_0xbb9f('0x4a')]);return _0x4a7589[_0xbb9f('0x5c')](_0x500d94);}})['then'](function(_0x20e96a){if(_0x20e96a){_0x27f1f5=_0x20e96a[_0xbb9f('0x39')];if(!_0x161e81[_0xbb9f('0x34')]['hasOwnProperty'](_0xbb9f('0x3a'))){_0x500d94['limit']=qs['limit'](_0x161e81['query'][_0xbb9f('0x20')]);_0x500d94[_0xbb9f('0x1e')]=qs[_0xbb9f('0x1e')](_0x161e81['query'][_0xbb9f('0x1e')]);}return _0x4a7589[_0xbb9f('0x5c')](_0x500d94);}})[_0xbb9f('0x28')](function(_0x10d092){if(_0x10d092){return _0x10d092?{'count':_0x27f1f5,'rows':_0x10d092}:null;}})[_0xbb9f('0x28')](respondWithResult(_0x4ed003,null))[_0xbb9f('0x44')](handleError(_0x4ed003,null));};
\ No newline at end of file
+var _0xbd02=['getUnread','ChatInternalMessage','user','toInteger','addMembers','ids','omit','User','order','hasOwnProperty','nolimit','getMembers','removeMembers','addMessage','findOne','$gte','split','format','getMessages','eml-format','rimraf','request-promise','moment','mustache','util','path','sox','ejs','fs-extra','squel','crypto','jsforce','to-csv','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','redis','defaults','localhost','./chatGroup.socket','end','status','json','offset','undefined','limit','count','set','apply','save','update','destroy','then','sendStatus','error','stack','name','send','index','map','ChatGroup','rawAttributes','type','model','keys','query','filters','intersection','fields','attributes','length','sort','where','pick','merge','VIRTUAL','filter','options','includeAll','include','findAll','catch','params','create','body','find','describe'];(function(_0x6651c3,_0x13210f){var _0x3d1598=function(_0x53dc1c){while(--_0x53dc1c){_0x6651c3['push'](_0x6651c3['shift']());}};_0x3d1598(++_0x13210f);}(_0xbd02,0xcd));var _0x2bd0=function(_0x4ff09b,_0x53f67d){_0x4ff09b=_0x4ff09b-0x0;var _0x3f5c2e=_0xbd02[_0x4ff09b];return _0x3f5c2e;};'use strict';var emlformat=require(_0x2bd0('0x0'));var rimraf=require(_0x2bd0('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x2bd0('0x2'));var moment=require(_0x2bd0('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x2bd0('0x4'));var util=require(_0x2bd0('0x5'));var path=require(_0x2bd0('0x6'));var sox=require(_0x2bd0('0x7'));var csv=require('to-csv');var ejs=require(_0x2bd0('0x8'));var fs=require('fs');var fs_extra=require(_0x2bd0('0x9'));var _=require('lodash');var squel=require(_0x2bd0('0xa'));var crypto=require(_0x2bd0('0xb'));var jsforce=require(_0x2bd0('0xc'));var deskjs=require('desk.js');var toCsv=require(_0x2bd0('0xd'));var querystring=require(_0x2bd0('0xe'));var Papa=require(_0x2bd0('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x2bd0('0x10'));var as=require(_0x2bd0('0x11'));var hardwareService=require(_0x2bd0('0x12'));var logger=require(_0x2bd0('0x13'))(_0x2bd0('0x14'));var utils=require(_0x2bd0('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0x2bd0('0x16'));var db=require('../../mysqldb')['db'];config[_0x2bd0('0x17')]=_[_0x2bd0('0x18')](config[_0x2bd0('0x17')],{'host':_0x2bd0('0x19'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0x2bd0('0x17')]));require(_0x2bd0('0x1a'))['register'](socket);function respondWithStatusCode(_0x10aba5,_0x5088bb){_0x5088bb=_0x5088bb||0xcc;return function(_0x158a06){if(_0x158a06){return _0x10aba5['sendStatus'](_0x5088bb);}return _0x10aba5['status'](_0x5088bb)[_0x2bd0('0x1b')]();};}function respondWithResult(_0x25f79c,_0x20e975){_0x20e975=_0x20e975||0xc8;return function(_0x50df73){if(_0x50df73){return _0x25f79c[_0x2bd0('0x1c')](_0x20e975)[_0x2bd0('0x1d')](_0x50df73);}};}function respondWithFilteredResult(_0x54dc78,_0x52b4a3){return function(_0x411b38){if(_0x411b38){var _0x297d44=typeof _0x52b4a3[_0x2bd0('0x1e')]===_0x2bd0('0x1f')&&typeof _0x52b4a3[_0x2bd0('0x20')]===_0x2bd0('0x1f');var _0x1db952=_0x411b38[_0x2bd0('0x21')];var _0x472c33=_0x297d44?0x0:_0x52b4a3[_0x2bd0('0x1e')];var _0xbf0771=_0x297d44?_0x411b38[_0x2bd0('0x21')]:_0x52b4a3[_0x2bd0('0x1e')]+_0x52b4a3[_0x2bd0('0x20')];var _0x509efb;if(_0xbf0771>=_0x1db952){_0xbf0771=_0x1db952;_0x509efb=0xc8;}else{_0x509efb=0xce;}_0x54dc78[_0x2bd0('0x1c')](_0x509efb);return _0x54dc78[_0x2bd0('0x22')]('Content-Range',_0x472c33+'-'+_0xbf0771+'/'+_0x1db952)['json'](_0x411b38);}return null;};}function patchUpdates(_0x2c5f65){return function(_0x31722f){try{jsonpatch[_0x2bd0('0x23')](_0x31722f,_0x2c5f65,!![]);}catch(_0x991c5){return BPromise['reject'](_0x991c5);}return _0x31722f[_0x2bd0('0x24')]();};}function saveUpdates(_0x5e7fd0,_0x4b486e){return function(_0x1aa0c5){if(_0x1aa0c5){return _0x1aa0c5[_0x2bd0('0x25')](_0x5e7fd0)['then'](function(_0x4b9a90){return _0x4b9a90;});}return null;};}function removeEntity(_0x493985,_0x42c85e){return function(_0x233412){if(_0x233412){return _0x233412[_0x2bd0('0x26')]()[_0x2bd0('0x27')](function(){_0x493985[_0x2bd0('0x1c')](0xcc)['end']();});}};}function handleEntityNotFound(_0x34c5de,_0x3a6d55){return function(_0x404e05){if(!_0x404e05){_0x34c5de[_0x2bd0('0x28')](0x194);}return _0x404e05;};}function handleError(_0x2b4f29,_0x197ef4){_0x197ef4=_0x197ef4||0x1f4;return function(_0x5c49d3){logger[_0x2bd0('0x29')](_0x5c49d3[_0x2bd0('0x2a')]);if(_0x5c49d3[_0x2bd0('0x2b')]){delete _0x5c49d3['name'];}_0x2b4f29[_0x2bd0('0x1c')](_0x197ef4)[_0x2bd0('0x2c')](_0x5c49d3);};}exports[_0x2bd0('0x2d')]=function(_0x56124c,_0x45be09){var _0x1fb9b7={},_0x10abac={},_0x267c73={'count':0x0,'rows':[]};var _0x3fbc5f=_[_0x2bd0('0x2e')](db[_0x2bd0('0x2f')][_0x2bd0('0x30')],function(_0x57243e){return{'name':_0x57243e['fieldName'],'type':_0x57243e[_0x2bd0('0x31')]['key']};});_0x10abac[_0x2bd0('0x32')]=_[_0x2bd0('0x2e')](_0x3fbc5f,'name');_0x10abac['query']=_[_0x2bd0('0x33')](_0x56124c[_0x2bd0('0x34')]);_0x10abac[_0x2bd0('0x35')]=_[_0x2bd0('0x36')](_0x10abac[_0x2bd0('0x32')],_0x10abac[_0x2bd0('0x34')]);_0x1fb9b7['attributes']=_[_0x2bd0('0x36')](_0x10abac[_0x2bd0('0x32')],qs[_0x2bd0('0x37')](_0x56124c['query'][_0x2bd0('0x37')]));_0x1fb9b7[_0x2bd0('0x38')]=_0x1fb9b7['attributes'][_0x2bd0('0x39')]?_0x1fb9b7[_0x2bd0('0x38')]:_0x10abac[_0x2bd0('0x32')];if(!_0x56124c[_0x2bd0('0x34')]['hasOwnProperty']('nolimit')){_0x1fb9b7['limit']=qs['limit'](_0x56124c[_0x2bd0('0x34')][_0x2bd0('0x20')]);_0x1fb9b7[_0x2bd0('0x1e')]=qs['offset'](_0x56124c[_0x2bd0('0x34')][_0x2bd0('0x1e')]);}_0x1fb9b7['order']=qs[_0x2bd0('0x3a')](_0x56124c[_0x2bd0('0x34')][_0x2bd0('0x3a')]);_0x1fb9b7[_0x2bd0('0x3b')]=qs['filters'](_[_0x2bd0('0x3c')](_0x56124c[_0x2bd0('0x34')],_0x10abac[_0x2bd0('0x35')]),_0x3fbc5f);if(_0x56124c['query']['filter']){_0x1fb9b7[_0x2bd0('0x3b')]=_[_0x2bd0('0x3d')](_0x1fb9b7['where'],{'$or':_['map'](_0x3fbc5f,function(_0x279b97){if(_0x279b97[_0x2bd0('0x31')]!==_0x2bd0('0x3e')){var _0x4f88c3={};_0x4f88c3[_0x279b97['name']]={'$like':'%'+_0x56124c[_0x2bd0('0x34')][_0x2bd0('0x3f')]+'%'};return _0x4f88c3;}})});}_0x1fb9b7=_[_0x2bd0('0x3d')]({},_0x1fb9b7,_0x56124c[_0x2bd0('0x40')]);var _0x57c69d={'where':_0x1fb9b7[_0x2bd0('0x3b')]};return db[_0x2bd0('0x2f')][_0x2bd0('0x21')](_0x57c69d)[_0x2bd0('0x27')](function(_0x33e015){_0x267c73[_0x2bd0('0x21')]=_0x33e015;if(_0x56124c[_0x2bd0('0x34')][_0x2bd0('0x41')]){_0x1fb9b7[_0x2bd0('0x42')]=[{'all':!![]}];}return db[_0x2bd0('0x2f')][_0x2bd0('0x43')](_0x1fb9b7);})[_0x2bd0('0x27')](function(_0x4b8ee4){_0x267c73['rows']=_0x4b8ee4;return _0x267c73;})[_0x2bd0('0x27')](respondWithFilteredResult(_0x45be09,_0x1fb9b7))[_0x2bd0('0x44')](handleError(_0x45be09,null));};exports['show']=function(_0x35c505,_0x4aa966){var _0x598db7={'raw':!![],'where':{'id':_0x35c505[_0x2bd0('0x45')]['id']}},_0x2cd0b4={};_0x2cd0b4[_0x2bd0('0x32')]=_['keys'](db[_0x2bd0('0x2f')][_0x2bd0('0x30')]);_0x2cd0b4[_0x2bd0('0x34')]=_[_0x2bd0('0x33')](_0x35c505[_0x2bd0('0x34')]);_0x2cd0b4['filters']=_[_0x2bd0('0x36')](_0x2cd0b4[_0x2bd0('0x32')],_0x2cd0b4['query']);_0x598db7[_0x2bd0('0x38')]=_[_0x2bd0('0x36')](_0x2cd0b4['model'],qs[_0x2bd0('0x37')](_0x35c505[_0x2bd0('0x34')]['fields']));_0x598db7[_0x2bd0('0x38')]=_0x598db7[_0x2bd0('0x38')][_0x2bd0('0x39')]?_0x598db7[_0x2bd0('0x38')]:_0x2cd0b4[_0x2bd0('0x32')];if(_0x35c505[_0x2bd0('0x34')]['includeAll']){_0x598db7[_0x2bd0('0x42')]=[{'all':!![]}];}_0x598db7=_['merge']({},_0x598db7,_0x35c505[_0x2bd0('0x40')]);return db[_0x2bd0('0x2f')]['find'](_0x598db7)[_0x2bd0('0x27')](handleEntityNotFound(_0x4aa966,null))['then'](respondWithResult(_0x4aa966,null))[_0x2bd0('0x44')](handleError(_0x4aa966,null));};exports[_0x2bd0('0x46')]=function(_0x5819fe,_0x39297c){return db['ChatGroup'][_0x2bd0('0x46')](_0x5819fe[_0x2bd0('0x47')],{})[_0x2bd0('0x27')](respondWithResult(_0x39297c,0xc9))[_0x2bd0('0x44')](handleError(_0x39297c,null));};exports[_0x2bd0('0x25')]=function(_0x25e581,_0x37d712){if(_0x25e581[_0x2bd0('0x47')]['id']){delete _0x25e581[_0x2bd0('0x47')]['id'];}return db[_0x2bd0('0x2f')][_0x2bd0('0x48')]({'where':{'id':_0x25e581[_0x2bd0('0x45')]['id']}})[_0x2bd0('0x27')](handleEntityNotFound(_0x37d712,null))[_0x2bd0('0x27')](saveUpdates(_0x25e581['body'],null))[_0x2bd0('0x27')](respondWithResult(_0x37d712,null))[_0x2bd0('0x44')](handleError(_0x37d712,null));};exports['destroy']=function(_0x47a0c6,_0x1d5c27){return db[_0x2bd0('0x2f')][_0x2bd0('0x48')]({'where':{'id':_0x47a0c6[_0x2bd0('0x45')]['id']}})[_0x2bd0('0x27')](handleEntityNotFound(_0x1d5c27,null))[_0x2bd0('0x27')](removeEntity(_0x1d5c27,null))[_0x2bd0('0x44')](handleError(_0x1d5c27,null));};exports[_0x2bd0('0x49')]=function(_0x124fcf,_0x554253){return db[_0x2bd0('0x2f')]['describe']()[_0x2bd0('0x27')](respondWithResult(_0x554253,null))['catch'](handleError(_0x554253,null));};exports[_0x2bd0('0x4a')]=function(_0x469230,_0xabe037,_0x1bc2d3){return db[_0x2bd0('0x4b')][_0x2bd0('0x21')]({'where':{'ChatGroupId':_0x469230[_0x2bd0('0x45')]['id'],'ToId':_0x469230[_0x2bd0('0x4c')]['id'],'read':![]}})[_0x2bd0('0x27')](function(_0x1c2108){return{'id':_[_0x2bd0('0x4d')](_0x469230[_0x2bd0('0x45')]['id']),'count':_0x1c2108};})[_0x2bd0('0x27')](respondWithResult(_0xabe037,null))[_0x2bd0('0x44')](handleError(_0xabe037,null));};exports[_0x2bd0('0x4e')]=function(_0x3c1bfe,_0x191b9d,_0x3c7165){return db[_0x2bd0('0x2f')][_0x2bd0('0x48')]({'where':{'id':_0x3c1bfe[_0x2bd0('0x45')]['id']}})[_0x2bd0('0x27')](handleEntityNotFound(_0x191b9d,null))[_0x2bd0('0x27')](function(_0x53f3b9){if(_0x53f3b9){return _0x53f3b9['addMembers'](_0x3c1bfe[_0x2bd0('0x47')][_0x2bd0('0x4f')],_[_0x2bd0('0x50')](_0x3c1bfe[_0x2bd0('0x47')],[_0x2bd0('0x4f'),'id'])||{});}})[_0x2bd0('0x27')](respondWithResult(_0x191b9d,null))[_0x2bd0('0x44')](handleError(_0x191b9d,null));};exports['getMembers']=function(_0x106e20,_0x59fe59,_0x1ea6cb){var _0x2660a0={};var _0xee17cf={};var _0x3bf848;var _0x3832fe;return db[_0x2bd0('0x2f')]['findOne']({'where':{'id':_0x106e20[_0x2bd0('0x45')]['id']}})[_0x2bd0('0x27')](handleEntityNotFound(_0x59fe59,null))[_0x2bd0('0x27')](function(_0x5a269e){if(_0x5a269e){_0x3bf848=_0x5a269e;_0xee17cf[_0x2bd0('0x32')]=_[_0x2bd0('0x33')](db[_0x2bd0('0x51')][_0x2bd0('0x30')]);_0xee17cf[_0x2bd0('0x34')]=_[_0x2bd0('0x33')](_0x106e20[_0x2bd0('0x34')]);_0xee17cf[_0x2bd0('0x35')]=_[_0x2bd0('0x36')](_0xee17cf[_0x2bd0('0x32')],_0xee17cf['query']);_0x2660a0[_0x2bd0('0x38')]=_[_0x2bd0('0x36')](_0xee17cf['model'],qs[_0x2bd0('0x37')](_0x106e20[_0x2bd0('0x34')]['fields']));_0x2660a0[_0x2bd0('0x38')]=_0x2660a0[_0x2bd0('0x38')][_0x2bd0('0x39')]?_0x2660a0['attributes']:_0xee17cf[_0x2bd0('0x32')];_0x2660a0[_0x2bd0('0x52')]=qs['sort'](_0x106e20[_0x2bd0('0x34')][_0x2bd0('0x3a')]);_0x2660a0[_0x2bd0('0x3b')]=qs[_0x2bd0('0x35')](_[_0x2bd0('0x3c')](_0x106e20[_0x2bd0('0x34')],_0xee17cf[_0x2bd0('0x35')]));if(_0x106e20['query'][_0x2bd0('0x3f')]){_0x2660a0[_0x2bd0('0x3b')]=_[_0x2bd0('0x3d')](_0x2660a0[_0x2bd0('0x3b')],{'$or':_[_0x2bd0('0x2e')](_0x2660a0[_0x2bd0('0x38')],function(_0x30ba61){var _0x2b313d={};_0x2b313d[_0x30ba61]={'$like':'%'+_0x106e20['query'][_0x2bd0('0x3f')]+'%'};return _0x2b313d;})});}_0x2660a0=_['merge']({},_0x2660a0,_0x106e20[_0x2bd0('0x40')]);return _0x3bf848['getMembers'](_0x2660a0);}})[_0x2bd0('0x27')](function(_0x582e2a){if(_0x582e2a){_0x3832fe=_0x582e2a['length'];if(!_0x106e20[_0x2bd0('0x34')][_0x2bd0('0x53')](_0x2bd0('0x54'))){_0x2660a0[_0x2bd0('0x20')]=qs[_0x2bd0('0x20')](_0x106e20['query'][_0x2bd0('0x20')]);_0x2660a0[_0x2bd0('0x1e')]=qs['offset'](_0x106e20[_0x2bd0('0x34')][_0x2bd0('0x1e')]);}return _0x3bf848[_0x2bd0('0x55')](_0x2660a0);}})[_0x2bd0('0x27')](function(_0x1a8889){if(_0x1a8889){return _0x1a8889?{'count':_0x3832fe,'rows':_0x1a8889}:null;}})['then'](respondWithResult(_0x59fe59,null))[_0x2bd0('0x44')](handleError(_0x59fe59,null));};exports[_0x2bd0('0x56')]=function(_0x53845f,_0x4e8790,_0x2071fd){return db[_0x2bd0('0x2f')][_0x2bd0('0x48')]({'where':{'id':_0x53845f[_0x2bd0('0x45')]['id']}})[_0x2bd0('0x27')](handleEntityNotFound(_0x4e8790,null))[_0x2bd0('0x27')](function(_0x2ea2fe){if(_0x2ea2fe){return _0x2ea2fe[_0x2bd0('0x56')](_0x53845f[_0x2bd0('0x34')][_0x2bd0('0x4f')]);}})['then'](respondWithStatusCode(_0x4e8790,null))['catch'](handleError(_0x4e8790,null));};exports[_0x2bd0('0x57')]=function(_0x2be007,_0x194fb1,_0x4f420d){if(_0x2be007[_0x2bd0('0x47')]['id']){delete _0x2be007['body']['id'];}return db[_0x2bd0('0x2f')][_0x2bd0('0x48')]({'where':{'id':_0x2be007[_0x2bd0('0x45')]['id']}})[_0x2bd0('0x27')](handleEntityNotFound(_0x194fb1,null))[_0x2bd0('0x27')](function(_0x3648b2){if(_0x3648b2){_0x2be007[_0x2bd0('0x47')]['ChatGroupId']=_0x3648b2['id'];return db[_0x2bd0('0x4b')]['create'](_0x2be007[_0x2bd0('0x47')]);}})[_0x2bd0('0x27')](respondWithResult(_0x194fb1,null))[_0x2bd0('0x44')](handleError(_0x194fb1,null));};exports['getMessages']=function(_0x58c90c,_0x339aa7,_0xfbff77){var _0x524bfb={};var _0xea3039={};var _0x5e9640;var _0x42bf9f;return db[_0x2bd0('0x2f')][_0x2bd0('0x58')]({'where':{'id':_0x58c90c[_0x2bd0('0x45')]['id']}})['then'](handleEntityNotFound(_0x339aa7,null))[_0x2bd0('0x27')](function(_0x565ca7){if(_0x565ca7){_0x5e9640=_0x565ca7;_0xea3039[_0x2bd0('0x32')]=_[_0x2bd0('0x33')](db['ChatInternalMessage'][_0x2bd0('0x30')]);_0xea3039[_0x2bd0('0x34')]=_[_0x2bd0('0x33')](_0x58c90c[_0x2bd0('0x34')]);_0xea3039[_0x2bd0('0x35')]=_[_0x2bd0('0x36')](_0xea3039['model'],_0xea3039[_0x2bd0('0x34')]);_0x524bfb[_0x2bd0('0x38')]=_['intersection'](_0xea3039[_0x2bd0('0x32')],qs[_0x2bd0('0x37')](_0x58c90c[_0x2bd0('0x34')][_0x2bd0('0x37')]));_0x524bfb[_0x2bd0('0x38')]=_0x524bfb[_0x2bd0('0x38')]['length']?_0x524bfb[_0x2bd0('0x38')]:_0xea3039[_0x2bd0('0x32')];_0x524bfb['order']=qs[_0x2bd0('0x3a')](_0x58c90c['query'][_0x2bd0('0x3a')]);_0x524bfb[_0x2bd0('0x3b')]=qs['filters'](_['pick'](_0x58c90c['query'],_0xea3039['filters']));if(_0x58c90c['query'][_0x2bd0('0x3f')]){_0x524bfb[_0x2bd0('0x3b')]=_[_0x2bd0('0x3d')](_0x524bfb[_0x2bd0('0x3b')],{'$or':_[_0x2bd0('0x2e')](_0x524bfb[_0x2bd0('0x38')],function(_0x50e538){var _0x52a566={};_0x52a566[_0x50e538]={'$like':'%'+_0x58c90c[_0x2bd0('0x34')]['filter']+'%'};return _0x52a566;})});}if(_0x58c90c[_0x2bd0('0x34')][_0x2bd0('0x59')]){var _0x22f69c=_0x58c90c[_0x2bd0('0x34')]['$gte'][_0x2bd0('0x5a')](',');var _0x2eadaa={};_0x2eadaa[_0x22f69c[0x0]]={'$gte':moment(_0x22f69c[0x1])[_0x2bd0('0x5b')]('YYYY-MM-DD\x20HH:mm:ss')};_0x524bfb[_0x2bd0('0x3b')]=_[_0x2bd0('0x3d')](_0x524bfb[_0x2bd0('0x3b')],_0x2eadaa);}_0x524bfb=_['merge']({},_0x524bfb,_0x58c90c[_0x2bd0('0x40')]);return _0x5e9640[_0x2bd0('0x5c')](_0x524bfb);}})['then'](function(_0x315a57){if(_0x315a57){_0x42bf9f=_0x315a57[_0x2bd0('0x39')];if(!_0x58c90c['query'][_0x2bd0('0x53')](_0x2bd0('0x54'))){_0x524bfb['limit']=qs[_0x2bd0('0x20')](_0x58c90c[_0x2bd0('0x34')][_0x2bd0('0x20')]);_0x524bfb['offset']=qs['offset'](_0x58c90c['query'][_0x2bd0('0x1e')]);}return _0x5e9640[_0x2bd0('0x5c')](_0x524bfb);}})[_0x2bd0('0x27')](function(_0x496cad){if(_0x496cad){return _0x496cad?{'count':_0x42bf9f,'rows':_0x496cad}:null;}})[_0x2bd0('0x27')](respondWithResult(_0x339aa7,null))[_0x2bd0('0x44')](handleError(_0x339aa7,null));};
\ No newline at end of file