Built motion from commit (unavailable).|2.5.7
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index c89a35d..726413d 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xef0f=['destroy','stack','name','send','index','map','ChatGroup','rawAttributes','fieldName','key','model','query','keys','intersection','attributes','length','hasOwnProperty','limit','order','sort','where','filters','filter','type','VIRTUAL','include','rows','params','fields','merge','options','find','create','body','getUnread','ChatInternalMessage','user','toInteger','addMembers','ids','getMembers','findOne','User','pick','nolimit','removeMembers','ChatGroupId','getMessages','split','format','YYYY-MM-DD\x20HH:mm:ss','html-pdf','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','path','sox','to-csv','ejs','lodash','squel','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','defaults','redis','localhost','socket.io-emitter','./chatGroup.socket','register','client','request','then','ChatGroup,\x20%s,\x20%s','request\x20sent','debug','ChatGroup,\x20%s,\x20%s,\x20%s','error','code','message','info','result','catch','sendStatus','status','end','json','count','offset'];(function(_0x597b14,_0x4eadc8){var _0x32dd31=function(_0x388ba3){while(--_0x388ba3){_0x597b14['push'](_0x597b14['shift']());}};_0x32dd31(++_0x4eadc8);}(_0xef0f,0x168));var _0xfef0=function(_0x445ac4,_0x5f0abb){_0x445ac4=_0x445ac4-0x0;var _0x5d6e45=_0xef0f[_0x445ac4];return _0x5d6e45;};'use strict';var pdf=require(_0xfef0('0x0'));var emlformat=require('eml-format');var rimraf=require(_0xfef0('0x1'));var zipdir=require(_0xfef0('0x2'));var jsonpatch=require(_0xfef0('0x3'));var rp=require('request-promise');var moment=require(_0xfef0('0x4'));var BPromise=require(_0xfef0('0x5'));var Mustache=require(_0xfef0('0x6'));var util=require('util');var path=require(_0xfef0('0x7'));var sox=require(_0xfef0('0x8'));var csv=require(_0xfef0('0x9'));var ejs=require(_0xfef0('0xa'));var fs=require('fs');var _=require(_0xfef0('0xb'));var squel=require(_0xfef0('0xc'));var crypto=require('crypto');var jsforce=require(_0xfef0('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xfef0('0x9'));var querystring=require(_0xfef0('0xe'));var Papa=require(_0xfef0('0xf'));var Redis=require(_0xfef0('0x10'));var authService=require(_0xfef0('0x11'));var qs=require(_0xfef0('0x12'));var as=require(_0xfef0('0x13'));var hardwareService=require(_0xfef0('0x14'));var logger=require(_0xfef0('0x15'))(_0xfef0('0x16'));var utils=require(_0xfef0('0x17'));var config=require(_0xfef0('0x18'));var licenseUtil=require(_0xfef0('0x19'));var db=require(_0xfef0('0x1a'))['db'];config['redis']=_[_0xfef0('0x1b')](config[_0xfef0('0x1c')],{'host':_0xfef0('0x1d'),'port':0x18eb});var socket=require(_0xfef0('0x1e'))(new Redis(config[_0xfef0('0x1c')]));require(_0xfef0('0x1f'))[_0xfef0('0x20')](socket);var jayson=require('jayson/promise');var client=jayson[_0xfef0('0x21')]['http']({'port':0x232a});function respondWithRpcPromise(_0x4b5bcf,_0x5acdd0,_0x118b8d,_0x284b6d){return new BPromise(function(_0x3510a7,_0x1bce2f){var _0x2a96d9=_0x284b6d||client;return _0x2a96d9[_0xfef0('0x22')](_0x4b5bcf,_0x118b8d)[_0xfef0('0x23')](function(_0x2887e6){logger['info'](_0xfef0('0x24'),_0x5acdd0,_0xfef0('0x25'));logger[_0xfef0('0x26')](_0xfef0('0x27'),_0x5acdd0,_0xfef0('0x25'),JSON['stringify'](_0x2887e6));if(_0x2887e6[_0xfef0('0x28')]){if(_0x2887e6['error'][_0xfef0('0x29')]===0x1f4){logger[_0xfef0('0x28')](_0xfef0('0x24'),_0x5acdd0,_0x2887e6['error'][_0xfef0('0x2a')]);return _0x1bce2f(_0x2887e6['error'][_0xfef0('0x2a')]);}logger[_0xfef0('0x28')]('ChatGroup,\x20%s,\x20%s',_0x5acdd0,_0x2887e6['error']['message']);return _0x3510a7(_0x2887e6[_0xfef0('0x28')]['message']);}else{logger[_0xfef0('0x2b')](_0xfef0('0x24'),_0x5acdd0,_0xfef0('0x25'));_0x3510a7(_0x2887e6[_0xfef0('0x2c')][_0xfef0('0x2a')]);}})[_0xfef0('0x2d')](function(_0x5c9085){logger['error'](_0xfef0('0x24'),_0x5acdd0,_0x5c9085);_0x1bce2f(_0x5c9085);});});}function respondWithStatusCode(_0x1ffaa4,_0x924f6e){_0x924f6e=_0x924f6e||0xcc;return function(_0x34ca65){if(_0x34ca65){return _0x1ffaa4[_0xfef0('0x2e')](_0x924f6e);}return _0x1ffaa4[_0xfef0('0x2f')](_0x924f6e)[_0xfef0('0x30')]();};}function respondWithResult(_0x168b98,_0x391279){_0x391279=_0x391279||0xc8;return function(_0x529d86){if(_0x529d86){return _0x168b98[_0xfef0('0x2f')](_0x391279)[_0xfef0('0x31')](_0x529d86);}};}function respondWithFilteredResult(_0xca0cce,_0x956de8){return function(_0x37921f){if(_0x37921f){var _0x1ac4a3=_0x37921f[_0xfef0('0x32')],_0x3e3c4c=_0x956de8[_0xfef0('0x33')],_0x3e026a=_0x956de8[_0xfef0('0x33')]+_0x956de8['limit'],_0x26cb9a;if(_0x3e026a>=_0x1ac4a3){_0x3e026a=_0x1ac4a3;_0x26cb9a=0xc8;}else{_0x26cb9a=0xce;}_0xca0cce[_0xfef0('0x2f')](_0x26cb9a);return _0xca0cce['set']('Content-Range',_0x3e3c4c+'-'+_0x3e026a+'/'+_0x1ac4a3)[_0xfef0('0x31')](_0x37921f);}return null;};}function patchUpdates(_0x2ae54a){return function(_0x4a481d){try{jsonpatch['apply'](_0x4a481d,_0x2ae54a,!![]);}catch(_0x5cf518){return BPromise['reject'](_0x5cf518);}return _0x4a481d['save']();};}function saveUpdates(_0x417535,_0x172d94){return function(_0x2fffae){if(_0x2fffae){return _0x2fffae['update'](_0x417535)['then'](function(_0x50430e){return _0x50430e;});}return null;};}function removeEntity(_0x1f8110,_0x55c458){return function(_0x215032){if(_0x215032){return _0x215032[_0xfef0('0x34')]()[_0xfef0('0x23')](function(){_0x1f8110['status'](0xcc)[_0xfef0('0x30')]();});}};}function handleEntityNotFound(_0x4c3a0f,_0x4234e4){return function(_0x1f21b7){if(!_0x1f21b7){_0x4c3a0f[_0xfef0('0x2e')](0x194);}return _0x1f21b7;};}function handleError(_0xe5188e,_0x3e1a64){_0x3e1a64=_0x3e1a64||0x1f4;return function(_0x103d1f){logger[_0xfef0('0x28')](_0x103d1f[_0xfef0('0x35')]);if(_0x103d1f['name']){delete _0x103d1f[_0xfef0('0x36')];}_0xe5188e[_0xfef0('0x2f')](_0x3e1a64)[_0xfef0('0x37')](_0x103d1f);};}exports[_0xfef0('0x38')]=function(_0xae697,_0x262341){var _0x43b54d={},_0xeb75e2={},_0x459d4a={'count':0x0,'rows':[]};var _0x109d0f=_[_0xfef0('0x39')](db[_0xfef0('0x3a')][_0xfef0('0x3b')],function(_0x4a8af4){return{'name':_0x4a8af4[_0xfef0('0x3c')],'type':_0x4a8af4['type'][_0xfef0('0x3d')]};});_0xeb75e2[_0xfef0('0x3e')]=_[_0xfef0('0x39')](_0x109d0f,'name');_0xeb75e2[_0xfef0('0x3f')]=_[_0xfef0('0x40')](_0xae697[_0xfef0('0x3f')]);_0xeb75e2['filters']=_[_0xfef0('0x41')](_0xeb75e2[_0xfef0('0x3e')],_0xeb75e2[_0xfef0('0x3f')]);_0x43b54d['attributes']=_[_0xfef0('0x41')](_0xeb75e2['model'],qs['fields'](_0xae697[_0xfef0('0x3f')]['fields']));_0x43b54d['attributes']=_0x43b54d[_0xfef0('0x42')][_0xfef0('0x43')]?_0x43b54d[_0xfef0('0x42')]:_0xeb75e2[_0xfef0('0x3e')];if(!_0xae697[_0xfef0('0x3f')][_0xfef0('0x44')]('nolimit')){_0x43b54d[_0xfef0('0x45')]=qs[_0xfef0('0x45')](_0xae697['query']['limit']);_0x43b54d[_0xfef0('0x33')]=qs['offset'](_0xae697[_0xfef0('0x3f')][_0xfef0('0x33')]);}_0x43b54d[_0xfef0('0x46')]=qs[_0xfef0('0x47')](_0xae697[_0xfef0('0x3f')][_0xfef0('0x47')]);_0x43b54d[_0xfef0('0x48')]=qs[_0xfef0('0x49')](_['pick'](_0xae697[_0xfef0('0x3f')],_0xeb75e2['filters']),_0x109d0f);if(_0xae697['query'][_0xfef0('0x4a')]){_0x43b54d[_0xfef0('0x48')]=_['merge'](_0x43b54d[_0xfef0('0x48')],{'$or':_['map'](_0x109d0f,function(_0x39df7c){if(_0x39df7c[_0xfef0('0x4b')]!==_0xfef0('0x4c')){var _0x115e64={};_0x115e64[_0x39df7c['name']]={'$like':'%'+_0xae697[_0xfef0('0x3f')][_0xfef0('0x4a')]+'%'};return _0x115e64;}})});}_0x43b54d=_['merge']({},_0x43b54d,_0xae697['options']);var _0x392607={'where':_0x43b54d['where']};return db[_0xfef0('0x3a')][_0xfef0('0x32')](_0x392607)[_0xfef0('0x23')](function(_0x19acde){_0x459d4a[_0xfef0('0x32')]=_0x19acde;if(_0xae697[_0xfef0('0x3f')]['includeAll']){_0x43b54d[_0xfef0('0x4d')]=[{'all':!![]}];}return db['ChatGroup']['findAll'](_0x43b54d);})[_0xfef0('0x23')](function(_0x25da1b){_0x459d4a[_0xfef0('0x4e')]=_0x25da1b;return _0x459d4a;})['then'](respondWithFilteredResult(_0x262341,_0x43b54d))[_0xfef0('0x2d')](handleError(_0x262341,null));};exports['show']=function(_0x5dd26b,_0x51f207){var _0x3a475a={'raw':!![],'where':{'id':_0x5dd26b[_0xfef0('0x4f')]['id']}},_0x3d471c={};_0x3d471c[_0xfef0('0x3e')]=_[_0xfef0('0x40')](db[_0xfef0('0x3a')][_0xfef0('0x3b')]);_0x3d471c[_0xfef0('0x3f')]=_[_0xfef0('0x40')](_0x5dd26b['query']);_0x3d471c['filters']=_[_0xfef0('0x41')](_0x3d471c[_0xfef0('0x3e')],_0x3d471c[_0xfef0('0x3f')]);_0x3a475a[_0xfef0('0x42')]=_[_0xfef0('0x41')](_0x3d471c[_0xfef0('0x3e')],qs[_0xfef0('0x50')](_0x5dd26b[_0xfef0('0x3f')]['fields']));_0x3a475a[_0xfef0('0x42')]=_0x3a475a[_0xfef0('0x42')][_0xfef0('0x43')]?_0x3a475a[_0xfef0('0x42')]:_0x3d471c[_0xfef0('0x3e')];if(_0x5dd26b['query']['includeAll']){_0x3a475a['include']=[{'all':!![]}];}_0x3a475a=_[_0xfef0('0x51')]({},_0x3a475a,_0x5dd26b[_0xfef0('0x52')]);return db[_0xfef0('0x3a')][_0xfef0('0x53')](_0x3a475a)['then'](handleEntityNotFound(_0x51f207,null))[_0xfef0('0x23')](respondWithResult(_0x51f207,null))[_0xfef0('0x2d')](handleError(_0x51f207,null));};exports[_0xfef0('0x54')]=function(_0x28b90c,_0x19dcd3){return db[_0xfef0('0x3a')][_0xfef0('0x54')](_0x28b90c['body'],{})[_0xfef0('0x23')](respondWithResult(_0x19dcd3,0xc9))[_0xfef0('0x2d')](handleError(_0x19dcd3,null));};exports['update']=function(_0x291f3f,_0x59e7c4){if(_0x291f3f[_0xfef0('0x55')]['id']){delete _0x291f3f[_0xfef0('0x55')]['id'];}return db['ChatGroup'][_0xfef0('0x53')]({'where':{'id':_0x291f3f['params']['id']}})['then'](handleEntityNotFound(_0x59e7c4,null))['then'](saveUpdates(_0x291f3f[_0xfef0('0x55')],null))[_0xfef0('0x23')](respondWithResult(_0x59e7c4,null))[_0xfef0('0x2d')](handleError(_0x59e7c4,null));};exports[_0xfef0('0x34')]=function(_0x16a498,_0x2d63e8){return db['ChatGroup'][_0xfef0('0x53')]({'where':{'id':_0x16a498[_0xfef0('0x4f')]['id']}})[_0xfef0('0x23')](handleEntityNotFound(_0x2d63e8,null))[_0xfef0('0x23')](removeEntity(_0x2d63e8,null))[_0xfef0('0x2d')](handleError(_0x2d63e8,null));};exports['describe']=function(_0x59d1b6,_0x4aef94){return db[_0xfef0('0x3a')]['describe']()[_0xfef0('0x23')](respondWithResult(_0x4aef94,null))[_0xfef0('0x2d')](handleError(_0x4aef94,null));};exports[_0xfef0('0x56')]=function(_0x281259,_0xd0255c,_0x4852c0){return db[_0xfef0('0x57')]['count']({'where':{'ChatGroupId':_0x281259[_0xfef0('0x4f')]['id'],'ToId':_0x281259[_0xfef0('0x58')]['id'],'read':![]}})['then'](function(_0x3a12c5){return{'id':_[_0xfef0('0x59')](_0x281259[_0xfef0('0x4f')]['id']),'count':_0x3a12c5};})[_0xfef0('0x23')](respondWithResult(_0xd0255c,null))[_0xfef0('0x2d')](handleError(_0xd0255c,null));};exports[_0xfef0('0x5a')]=function(_0x400028,_0x10045c,_0x17a595){return db[_0xfef0('0x3a')][_0xfef0('0x53')]({'where':{'id':_0x400028[_0xfef0('0x4f')]['id']}})['then'](handleEntityNotFound(_0x10045c,null))[_0xfef0('0x23')](function(_0x3b660c){if(_0x3b660c){return _0x3b660c[_0xfef0('0x5a')](_0x400028[_0xfef0('0x55')][_0xfef0('0x5b')],_['omit'](_0x400028[_0xfef0('0x55')],[_0xfef0('0x5b'),'id'])||{});}})[_0xfef0('0x23')](respondWithResult(_0x10045c,null))[_0xfef0('0x2d')](handleError(_0x10045c,null));};exports[_0xfef0('0x5c')]=function(_0x1765e2,_0xb9693b,_0x103ca3){var _0x14d53d={};var _0x3f26d9={};var _0x4f7ad3;var _0x100c6a;return db['ChatGroup'][_0xfef0('0x5d')]({'where':{'id':_0x1765e2[_0xfef0('0x4f')]['id']}})['then'](handleEntityNotFound(_0xb9693b,null))[_0xfef0('0x23')](function(_0x20c2ec){if(_0x20c2ec){_0x4f7ad3=_0x20c2ec;_0x3f26d9[_0xfef0('0x3e')]=_[_0xfef0('0x40')](db[_0xfef0('0x5e')]['rawAttributes']);_0x3f26d9[_0xfef0('0x3f')]=_[_0xfef0('0x40')](_0x1765e2[_0xfef0('0x3f')]);_0x3f26d9['filters']=_[_0xfef0('0x41')](_0x3f26d9[_0xfef0('0x3e')],_0x3f26d9[_0xfef0('0x3f')]);_0x14d53d[_0xfef0('0x42')]=_[_0xfef0('0x41')](_0x3f26d9[_0xfef0('0x3e')],qs[_0xfef0('0x50')](_0x1765e2['query'][_0xfef0('0x50')]));_0x14d53d[_0xfef0('0x42')]=_0x14d53d[_0xfef0('0x42')][_0xfef0('0x43')]?_0x14d53d[_0xfef0('0x42')]:_0x3f26d9[_0xfef0('0x3e')];_0x14d53d['order']=qs[_0xfef0('0x47')](_0x1765e2[_0xfef0('0x3f')][_0xfef0('0x47')]);_0x14d53d[_0xfef0('0x48')]=qs['filters'](_[_0xfef0('0x5f')](_0x1765e2[_0xfef0('0x3f')],_0x3f26d9['filters']));if(_0x1765e2[_0xfef0('0x3f')][_0xfef0('0x4a')]){_0x14d53d[_0xfef0('0x48')]=_[_0xfef0('0x51')](_0x14d53d[_0xfef0('0x48')],{'$or':_['map'](_0x14d53d['attributes'],function(_0x5c3ef1){var _0x118fe7={};_0x118fe7[_0x5c3ef1]={'$like':'%'+_0x1765e2[_0xfef0('0x3f')][_0xfef0('0x4a')]+'%'};return _0x118fe7;})});}_0x14d53d=_['merge']({},_0x14d53d,_0x1765e2[_0xfef0('0x52')]);return _0x4f7ad3['getMembers'](_0x14d53d);}})['then'](function(_0x519efe){if(_0x519efe){_0x100c6a=_0x519efe[_0xfef0('0x43')];if(!_0x1765e2[_0xfef0('0x3f')]['hasOwnProperty'](_0xfef0('0x60'))){_0x14d53d[_0xfef0('0x45')]=qs[_0xfef0('0x45')](_0x1765e2['query'][_0xfef0('0x45')]);_0x14d53d['offset']=qs['offset'](_0x1765e2[_0xfef0('0x3f')][_0xfef0('0x33')]);}return _0x4f7ad3[_0xfef0('0x5c')](_0x14d53d);}})[_0xfef0('0x23')](function(_0x4df63b){if(_0x4df63b){return _0x4df63b?{'count':_0x100c6a,'rows':_0x4df63b}:null;}})['then'](respondWithResult(_0xb9693b,null))['catch'](handleError(_0xb9693b,null));};exports[_0xfef0('0x61')]=function(_0x546455,_0x2e53e0,_0x3ce299){return db[_0xfef0('0x3a')][_0xfef0('0x53')]({'where':{'id':_0x546455[_0xfef0('0x4f')]['id']}})['then'](handleEntityNotFound(_0x2e53e0,null))[_0xfef0('0x23')](function(_0x501cda){if(_0x501cda){return _0x501cda['removeMembers'](_0x546455[_0xfef0('0x3f')][_0xfef0('0x5b')]);}})[_0xfef0('0x23')](respondWithStatusCode(_0x2e53e0,null))[_0xfef0('0x2d')](handleError(_0x2e53e0,null));};exports['addMessage']=function(_0x4f0e33,_0x40ee27,_0x3039a0){if(_0x4f0e33['body']['id']){delete _0x4f0e33[_0xfef0('0x55')]['id'];}return db[_0xfef0('0x3a')][_0xfef0('0x53')]({'where':{'id':_0x4f0e33[_0xfef0('0x4f')]['id']}})[_0xfef0('0x23')](handleEntityNotFound(_0x40ee27,null))[_0xfef0('0x23')](function(_0x23242b){if(_0x23242b){_0x4f0e33[_0xfef0('0x55')][_0xfef0('0x62')]=_0x23242b['id'];return db[_0xfef0('0x57')][_0xfef0('0x54')](_0x4f0e33[_0xfef0('0x55')]);}})[_0xfef0('0x23')](respondWithResult(_0x40ee27,null))[_0xfef0('0x2d')](handleError(_0x40ee27,null));};exports[_0xfef0('0x63')]=function(_0x2240da,_0x1a61e4,_0x5d8873){var _0x26530e={};var _0x2fe46f={};var _0x196d03;var _0x29d397;return db[_0xfef0('0x3a')][_0xfef0('0x5d')]({'where':{'id':_0x2240da[_0xfef0('0x4f')]['id']}})[_0xfef0('0x23')](handleEntityNotFound(_0x1a61e4,null))[_0xfef0('0x23')](function(_0x39c591){if(_0x39c591){_0x196d03=_0x39c591;_0x2fe46f[_0xfef0('0x3e')]=_[_0xfef0('0x40')](db[_0xfef0('0x57')]['rawAttributes']);_0x2fe46f[_0xfef0('0x3f')]=_['keys'](_0x2240da['query']);_0x2fe46f[_0xfef0('0x49')]=_[_0xfef0('0x41')](_0x2fe46f['model'],_0x2fe46f[_0xfef0('0x3f')]);_0x26530e['attributes']=_['intersection'](_0x2fe46f[_0xfef0('0x3e')],qs[_0xfef0('0x50')](_0x2240da[_0xfef0('0x3f')][_0xfef0('0x50')]));_0x26530e['attributes']=_0x26530e[_0xfef0('0x42')][_0xfef0('0x43')]?_0x26530e['attributes']:_0x2fe46f[_0xfef0('0x3e')];_0x26530e[_0xfef0('0x46')]=qs[_0xfef0('0x47')](_0x2240da['query']['sort']);_0x26530e[_0xfef0('0x48')]=qs['filters'](_['pick'](_0x2240da[_0xfef0('0x3f')],_0x2fe46f['filters']));if(_0x2240da[_0xfef0('0x3f')][_0xfef0('0x4a')]){_0x26530e[_0xfef0('0x48')]=_[_0xfef0('0x51')](_0x26530e[_0xfef0('0x48')],{'$or':_[_0xfef0('0x39')](_0x26530e[_0xfef0('0x42')],function(_0x28cc77){var _0x187238={};_0x187238[_0x28cc77]={'$like':'%'+_0x2240da[_0xfef0('0x3f')]['filter']+'%'};return _0x187238;})});}if(_0x2240da[_0xfef0('0x3f')]['$gte']){var _0x4ce93b=_0x2240da[_0xfef0('0x3f')]['$gte'][_0xfef0('0x64')](',');var _0x10e0cf={};_0x10e0cf[_0x4ce93b[0x0]]={'$gte':moment(_0x4ce93b[0x1])[_0xfef0('0x65')](_0xfef0('0x66'))};_0x26530e[_0xfef0('0x48')]=_[_0xfef0('0x51')](_0x26530e['where'],_0x10e0cf);}_0x26530e=_[_0xfef0('0x51')]({},_0x26530e,_0x2240da[_0xfef0('0x52')]);return _0x196d03[_0xfef0('0x63')](_0x26530e);}})[_0xfef0('0x23')](function(_0x17a7b7){if(_0x17a7b7){_0x29d397=_0x17a7b7[_0xfef0('0x43')];if(!_0x2240da[_0xfef0('0x3f')][_0xfef0('0x44')]('nolimit')){_0x26530e[_0xfef0('0x45')]=qs[_0xfef0('0x45')](_0x2240da['query'][_0xfef0('0x45')]);_0x26530e[_0xfef0('0x33')]=qs[_0xfef0('0x33')](_0x2240da['query'][_0xfef0('0x33')]);}return _0x196d03['getMessages'](_0x26530e);}})[_0xfef0('0x23')](function(_0x5ec7d2){if(_0x5ec7d2){return _0x5ec7d2?{'count':_0x29d397,'rows':_0x5ec7d2}:null;}})['then'](respondWithResult(_0x1a61e4,null))[_0xfef0('0x2d')](handleError(_0x1a61e4,null));};
\ No newline at end of file
+var _0xa848=['rawAttributes','fieldName','type','key','map','query','keys','filters','intersection','model','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','ChatGroup','includeAll','include','findAll','rows','params','create','update','body','find','describe','ChatInternalMessage','user','toInteger','omit','ids','getMembers','findOne','User','options','removeMembers','addMessage','ChatGroupId','$gte','YYYY-MM-DD\x20HH:mm:ss','html-pdf','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','register','jayson/promise','client','then','info','ChatGroup,\x20%s,\x20%s','request\x20sent','debug','error','code','message','result','catch','status','count','offset','limit','Content-Range','apply','reject','save','destroy','end','sendStatus','stack','name','send','index'];(function(_0x38cb2e,_0x5f0069){var _0x263e1e=function(_0x2fee42){while(--_0x2fee42){_0x38cb2e['push'](_0x38cb2e['shift']());}};_0x263e1e(++_0x5f0069);}(_0xa848,0x99));var _0x8a84=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0xa848[_0x167cc1];return _0x10bc4b;};'use strict';var pdf=require(_0x8a84('0x0'));var emlformat=require(_0x8a84('0x1'));var rimraf=require(_0x8a84('0x2'));var zipdir=require('zip-dir');var jsonpatch=require(_0x8a84('0x3'));var rp=require(_0x8a84('0x4'));var moment=require(_0x8a84('0x5'));var BPromise=require(_0x8a84('0x6'));var Mustache=require(_0x8a84('0x7'));var util=require(_0x8a84('0x8'));var path=require(_0x8a84('0x9'));var sox=require(_0x8a84('0xa'));var csv=require(_0x8a84('0xb'));var ejs=require(_0x8a84('0xc'));var fs=require('fs');var _=require(_0x8a84('0xd'));var squel=require(_0x8a84('0xe'));var crypto=require(_0x8a84('0xf'));var jsforce=require(_0x8a84('0x10'));var deskjs=require('desk.js');var toCsv=require(_0x8a84('0xb'));var querystring=require(_0x8a84('0x11'));var Papa=require(_0x8a84('0x12'));var Redis=require('ioredis');var authService=require(_0x8a84('0x13'));var qs=require(_0x8a84('0x14'));var as=require(_0x8a84('0x15'));var hardwareService=require(_0x8a84('0x16'));var logger=require(_0x8a84('0x17'))(_0x8a84('0x18'));var utils=require(_0x8a84('0x19'));var config=require(_0x8a84('0x1a'));var licenseUtil=require(_0x8a84('0x1b'));var db=require(_0x8a84('0x1c'))['db'];config[_0x8a84('0x1d')]=_[_0x8a84('0x1e')](config['redis'],{'host':_0x8a84('0x1f'),'port':0x18eb});var socket=require(_0x8a84('0x20'))(new Redis(config[_0x8a84('0x1d')]));require('./chatGroup.socket')[_0x8a84('0x21')](socket);var jayson=require(_0x8a84('0x22'));var client=jayson[_0x8a84('0x23')]['http']({'port':0x232a});function respondWithRpcPromise(_0x2a939e,_0x2558d9,_0x50a338,_0x44144a){return new BPromise(function(_0x335f65,_0x9e386a){var _0x209516=_0x44144a||client;return _0x209516['request'](_0x2a939e,_0x50a338)[_0x8a84('0x24')](function(_0x1082d8){logger[_0x8a84('0x25')](_0x8a84('0x26'),_0x2558d9,_0x8a84('0x27'));logger[_0x8a84('0x28')]('ChatGroup,\x20%s,\x20%s,\x20%s',_0x2558d9,_0x8a84('0x27'),JSON['stringify'](_0x1082d8));if(_0x1082d8[_0x8a84('0x29')]){if(_0x1082d8['error'][_0x8a84('0x2a')]===0x1f4){logger[_0x8a84('0x29')](_0x8a84('0x26'),_0x2558d9,_0x1082d8['error'][_0x8a84('0x2b')]);return _0x9e386a(_0x1082d8[_0x8a84('0x29')][_0x8a84('0x2b')]);}logger[_0x8a84('0x29')](_0x8a84('0x26'),_0x2558d9,_0x1082d8['error'][_0x8a84('0x2b')]);return _0x335f65(_0x1082d8[_0x8a84('0x29')][_0x8a84('0x2b')]);}else{logger[_0x8a84('0x25')](_0x8a84('0x26'),_0x2558d9,'request\x20sent');_0x335f65(_0x1082d8[_0x8a84('0x2c')][_0x8a84('0x2b')]);}})[_0x8a84('0x2d')](function(_0x3751d8){logger['error'](_0x8a84('0x26'),_0x2558d9,_0x3751d8);_0x9e386a(_0x3751d8);});});}function respondWithStatusCode(_0x244126,_0x260f6d){_0x260f6d=_0x260f6d||0xcc;return function(_0x34e448){if(_0x34e448){return _0x244126['sendStatus'](_0x260f6d);}return _0x244126['status'](_0x260f6d)['end']();};}function respondWithResult(_0x272252,_0x44632e){_0x44632e=_0x44632e||0xc8;return function(_0x5520bf){if(_0x5520bf){return _0x272252[_0x8a84('0x2e')](_0x44632e)['json'](_0x5520bf);}};}function respondWithFilteredResult(_0x508720,_0x47b658){return function(_0x4940af){if(_0x4940af){var _0x482067=_0x4940af[_0x8a84('0x2f')],_0x141921=_0x47b658[_0x8a84('0x30')],_0x3083c0=_0x47b658['offset']+_0x47b658[_0x8a84('0x31')],_0x396c46;if(_0x3083c0>=_0x482067){_0x3083c0=_0x482067;_0x396c46=0xc8;}else{_0x396c46=0xce;}_0x508720[_0x8a84('0x2e')](_0x396c46);return _0x508720['set'](_0x8a84('0x32'),_0x141921+'-'+_0x3083c0+'/'+_0x482067)['json'](_0x4940af);}return null;};}function patchUpdates(_0x5c9215){return function(_0x785abb){try{jsonpatch[_0x8a84('0x33')](_0x785abb,_0x5c9215,!![]);}catch(_0x150d4a){return BPromise[_0x8a84('0x34')](_0x150d4a);}return _0x785abb[_0x8a84('0x35')]();};}function saveUpdates(_0x16707a,_0x42cce4){return function(_0x572789){if(_0x572789){return _0x572789['update'](_0x16707a)[_0x8a84('0x24')](function(_0x4b2ab3){return _0x4b2ab3;});}return null;};}function removeEntity(_0x2479a8,_0x274316){return function(_0x25908d){if(_0x25908d){return _0x25908d[_0x8a84('0x36')]()['then'](function(){_0x2479a8[_0x8a84('0x2e')](0xcc)[_0x8a84('0x37')]();});}};}function handleEntityNotFound(_0x140d90,_0x4aa3bb){return function(_0x227eb6){if(!_0x227eb6){_0x140d90[_0x8a84('0x38')](0x194);}return _0x227eb6;};}function handleError(_0x1fcbb8,_0x58eea2){_0x58eea2=_0x58eea2||0x1f4;return function(_0x25ae1c){logger[_0x8a84('0x29')](_0x25ae1c[_0x8a84('0x39')]);if(_0x25ae1c[_0x8a84('0x3a')]){delete _0x25ae1c[_0x8a84('0x3a')];}_0x1fcbb8[_0x8a84('0x2e')](_0x58eea2)[_0x8a84('0x3b')](_0x25ae1c);};}exports[_0x8a84('0x3c')]=function(_0x5b81d6,_0x1f4a68){var _0x471572={},_0x335dcf={},_0x429051={'count':0x0,'rows':[]};var _0x25861d=_['map'](db['ChatGroup'][_0x8a84('0x3d')],function(_0x2c54eb){return{'name':_0x2c54eb[_0x8a84('0x3e')],'type':_0x2c54eb[_0x8a84('0x3f')][_0x8a84('0x40')]};});_0x335dcf['model']=_[_0x8a84('0x41')](_0x25861d,_0x8a84('0x3a'));_0x335dcf[_0x8a84('0x42')]=_[_0x8a84('0x43')](_0x5b81d6[_0x8a84('0x42')]);_0x335dcf[_0x8a84('0x44')]=_[_0x8a84('0x45')](_0x335dcf[_0x8a84('0x46')],_0x335dcf['query']);_0x471572['attributes']=_['intersection'](_0x335dcf[_0x8a84('0x46')],qs[_0x8a84('0x47')](_0x5b81d6['query'][_0x8a84('0x47')]));_0x471572[_0x8a84('0x48')]=_0x471572['attributes'][_0x8a84('0x49')]?_0x471572[_0x8a84('0x48')]:_0x335dcf[_0x8a84('0x46')];if(!_0x5b81d6[_0x8a84('0x42')][_0x8a84('0x4a')](_0x8a84('0x4b'))){_0x471572[_0x8a84('0x31')]=qs['limit'](_0x5b81d6[_0x8a84('0x42')]['limit']);_0x471572[_0x8a84('0x30')]=qs['offset'](_0x5b81d6['query'][_0x8a84('0x30')]);}_0x471572[_0x8a84('0x4c')]=qs[_0x8a84('0x4d')](_0x5b81d6['query'][_0x8a84('0x4d')]);_0x471572[_0x8a84('0x4e')]=qs[_0x8a84('0x44')](_[_0x8a84('0x4f')](_0x5b81d6['query'],_0x335dcf[_0x8a84('0x44')]),_0x25861d);if(_0x5b81d6[_0x8a84('0x42')][_0x8a84('0x50')]){_0x471572[_0x8a84('0x4e')]=_[_0x8a84('0x51')](_0x471572[_0x8a84('0x4e')],{'$or':_[_0x8a84('0x41')](_0x25861d,function(_0xf295f1){if(_0xf295f1[_0x8a84('0x3f')]!=='VIRTUAL'){var _0x590b34={};_0x590b34[_0xf295f1['name']]={'$like':'%'+_0x5b81d6[_0x8a84('0x42')][_0x8a84('0x50')]+'%'};return _0x590b34;}})});}_0x471572=_[_0x8a84('0x51')]({},_0x471572,_0x5b81d6['options']);var _0x872e1b={'where':_0x471572['where']};return db[_0x8a84('0x52')][_0x8a84('0x2f')](_0x872e1b)['then'](function(_0x1216c3){_0x429051[_0x8a84('0x2f')]=_0x1216c3;if(_0x5b81d6['query'][_0x8a84('0x53')]){_0x471572[_0x8a84('0x54')]=[{'all':!![]}];}return db[_0x8a84('0x52')][_0x8a84('0x55')](_0x471572);})['then'](function(_0x2274b0){_0x429051[_0x8a84('0x56')]=_0x2274b0;return _0x429051;})[_0x8a84('0x24')](respondWithFilteredResult(_0x1f4a68,_0x471572))[_0x8a84('0x2d')](handleError(_0x1f4a68,null));};exports['show']=function(_0x4bea7a,_0x4925af){var _0x5660e3={'raw':!![],'where':{'id':_0x4bea7a[_0x8a84('0x57')]['id']}},_0x5e87c9={};_0x5e87c9[_0x8a84('0x46')]=_[_0x8a84('0x43')](db[_0x8a84('0x52')][_0x8a84('0x3d')]);_0x5e87c9['query']=_[_0x8a84('0x43')](_0x4bea7a['query']);_0x5e87c9[_0x8a84('0x44')]=_[_0x8a84('0x45')](_0x5e87c9[_0x8a84('0x46')],_0x5e87c9['query']);_0x5660e3[_0x8a84('0x48')]=_[_0x8a84('0x45')](_0x5e87c9[_0x8a84('0x46')],qs[_0x8a84('0x47')](_0x4bea7a['query'][_0x8a84('0x47')]));_0x5660e3['attributes']=_0x5660e3['attributes'][_0x8a84('0x49')]?_0x5660e3['attributes']:_0x5e87c9[_0x8a84('0x46')];if(_0x4bea7a[_0x8a84('0x42')]['includeAll']){_0x5660e3['include']=[{'all':!![]}];}_0x5660e3=_['merge']({},_0x5660e3,_0x4bea7a['options']);return db[_0x8a84('0x52')]['find'](_0x5660e3)[_0x8a84('0x24')](handleEntityNotFound(_0x4925af,null))[_0x8a84('0x24')](respondWithResult(_0x4925af,null))[_0x8a84('0x2d')](handleError(_0x4925af,null));};exports[_0x8a84('0x58')]=function(_0x2c44c5,_0x269726){return db[_0x8a84('0x52')][_0x8a84('0x58')](_0x2c44c5['body'],{})[_0x8a84('0x24')](respondWithResult(_0x269726,0xc9))['catch'](handleError(_0x269726,null));};exports[_0x8a84('0x59')]=function(_0x1776cc,_0x5f3088){if(_0x1776cc[_0x8a84('0x5a')]['id']){delete _0x1776cc[_0x8a84('0x5a')]['id'];}return db['ChatGroup']['find']({'where':{'id':_0x1776cc[_0x8a84('0x57')]['id']}})[_0x8a84('0x24')](handleEntityNotFound(_0x5f3088,null))[_0x8a84('0x24')](saveUpdates(_0x1776cc['body'],null))[_0x8a84('0x24')](respondWithResult(_0x5f3088,null))[_0x8a84('0x2d')](handleError(_0x5f3088,null));};exports[_0x8a84('0x36')]=function(_0x27a2e5,_0x3f74dc){return db[_0x8a84('0x52')][_0x8a84('0x5b')]({'where':{'id':_0x27a2e5[_0x8a84('0x57')]['id']}})[_0x8a84('0x24')](handleEntityNotFound(_0x3f74dc,null))[_0x8a84('0x24')](removeEntity(_0x3f74dc,null))[_0x8a84('0x2d')](handleError(_0x3f74dc,null));};exports['describe']=function(_0x173085,_0xd92bb2){return db[_0x8a84('0x52')][_0x8a84('0x5c')]()[_0x8a84('0x24')](respondWithResult(_0xd92bb2,null))[_0x8a84('0x2d')](handleError(_0xd92bb2,null));};exports['getUnread']=function(_0xbe0618,_0x26269a,_0x1e1a24){return db[_0x8a84('0x5d')][_0x8a84('0x2f')]({'where':{'ChatGroupId':_0xbe0618[_0x8a84('0x57')]['id'],'ToId':_0xbe0618[_0x8a84('0x5e')]['id'],'read':![]}})[_0x8a84('0x24')](function(_0x3d8202){return{'id':_[_0x8a84('0x5f')](_0xbe0618[_0x8a84('0x57')]['id']),'count':_0x3d8202};})[_0x8a84('0x24')](respondWithResult(_0x26269a,null))[_0x8a84('0x2d')](handleError(_0x26269a,null));};exports['addMembers']=function(_0x2f10d5,_0x49b854,_0x40134c){return db[_0x8a84('0x52')]['find']({'where':{'id':_0x2f10d5[_0x8a84('0x57')]['id']}})[_0x8a84('0x24')](handleEntityNotFound(_0x49b854,null))['then'](function(_0x270934){if(_0x270934){return _0x270934['addMembers'](_0x2f10d5[_0x8a84('0x5a')]['ids'],_[_0x8a84('0x60')](_0x2f10d5[_0x8a84('0x5a')],[_0x8a84('0x61'),'id'])||{});}})[_0x8a84('0x24')](respondWithResult(_0x49b854,null))['catch'](handleError(_0x49b854,null));};exports[_0x8a84('0x62')]=function(_0x4a3bcc,_0x2a5d9f,_0x23e261){var _0x208b01={};var _0x4000e1={};var _0x5ca8e6;var _0x2c7428;return db[_0x8a84('0x52')][_0x8a84('0x63')]({'where':{'id':_0x4a3bcc[_0x8a84('0x57')]['id']}})['then'](handleEntityNotFound(_0x2a5d9f,null))['then'](function(_0x5c61b1){if(_0x5c61b1){_0x5ca8e6=_0x5c61b1;_0x4000e1['model']=_[_0x8a84('0x43')](db[_0x8a84('0x64')][_0x8a84('0x3d')]);_0x4000e1['query']=_[_0x8a84('0x43')](_0x4a3bcc['query']);_0x4000e1[_0x8a84('0x44')]=_[_0x8a84('0x45')](_0x4000e1[_0x8a84('0x46')],_0x4000e1['query']);_0x208b01['attributes']=_['intersection'](_0x4000e1[_0x8a84('0x46')],qs[_0x8a84('0x47')](_0x4a3bcc['query'][_0x8a84('0x47')]));_0x208b01['attributes']=_0x208b01['attributes'][_0x8a84('0x49')]?_0x208b01[_0x8a84('0x48')]:_0x4000e1[_0x8a84('0x46')];_0x208b01[_0x8a84('0x4c')]=qs[_0x8a84('0x4d')](_0x4a3bcc['query'][_0x8a84('0x4d')]);_0x208b01[_0x8a84('0x4e')]=qs[_0x8a84('0x44')](_['pick'](_0x4a3bcc[_0x8a84('0x42')],_0x4000e1[_0x8a84('0x44')]));if(_0x4a3bcc[_0x8a84('0x42')]['filter']){_0x208b01[_0x8a84('0x4e')]=_[_0x8a84('0x51')](_0x208b01['where'],{'$or':_[_0x8a84('0x41')](_0x208b01['attributes'],function(_0x1d7b44){var _0x2c4403={};_0x2c4403[_0x1d7b44]={'$like':'%'+_0x4a3bcc['query'][_0x8a84('0x50')]+'%'};return _0x2c4403;})});}_0x208b01=_[_0x8a84('0x51')]({},_0x208b01,_0x4a3bcc[_0x8a84('0x65')]);return _0x5ca8e6[_0x8a84('0x62')](_0x208b01);}})[_0x8a84('0x24')](function(_0x2bf938){if(_0x2bf938){_0x2c7428=_0x2bf938['length'];if(!_0x4a3bcc[_0x8a84('0x42')][_0x8a84('0x4a')](_0x8a84('0x4b'))){_0x208b01[_0x8a84('0x31')]=qs[_0x8a84('0x31')](_0x4a3bcc['query'][_0x8a84('0x31')]);_0x208b01[_0x8a84('0x30')]=qs[_0x8a84('0x30')](_0x4a3bcc[_0x8a84('0x42')]['offset']);}return _0x5ca8e6['getMembers'](_0x208b01);}})[_0x8a84('0x24')](function(_0x1979f6){if(_0x1979f6){return _0x1979f6?{'count':_0x2c7428,'rows':_0x1979f6}:null;}})['then'](respondWithResult(_0x2a5d9f,null))[_0x8a84('0x2d')](handleError(_0x2a5d9f,null));};exports[_0x8a84('0x66')]=function(_0x50fefd,_0x49c5eb,_0x961e35){return db[_0x8a84('0x52')][_0x8a84('0x5b')]({'where':{'id':_0x50fefd[_0x8a84('0x57')]['id']}})[_0x8a84('0x24')](handleEntityNotFound(_0x49c5eb,null))['then'](function(_0x3acdfb){if(_0x3acdfb){return _0x3acdfb[_0x8a84('0x66')](_0x50fefd['query']['ids']);}})['then'](respondWithStatusCode(_0x49c5eb,null))['catch'](handleError(_0x49c5eb,null));};exports[_0x8a84('0x67')]=function(_0x591fe4,_0xb37e89,_0x37ae8f){if(_0x591fe4['body']['id']){delete _0x591fe4[_0x8a84('0x5a')]['id'];}return db['ChatGroup'][_0x8a84('0x5b')]({'where':{'id':_0x591fe4[_0x8a84('0x57')]['id']}})[_0x8a84('0x24')](handleEntityNotFound(_0xb37e89,null))['then'](function(_0x5b3dcb){if(_0x5b3dcb){_0x591fe4[_0x8a84('0x5a')][_0x8a84('0x68')]=_0x5b3dcb['id'];return db[_0x8a84('0x5d')][_0x8a84('0x58')](_0x591fe4[_0x8a84('0x5a')]);}})[_0x8a84('0x24')](respondWithResult(_0xb37e89,null))[_0x8a84('0x2d')](handleError(_0xb37e89,null));};exports['getMessages']=function(_0x3995db,_0x4aa7a6,_0xf9422e){var _0x4336d8={};var _0x15ef64={};var _0x1a8be9;var _0x353bb5;return db['ChatGroup'][_0x8a84('0x63')]({'where':{'id':_0x3995db['params']['id']}})[_0x8a84('0x24')](handleEntityNotFound(_0x4aa7a6,null))[_0x8a84('0x24')](function(_0x3a4e62){if(_0x3a4e62){_0x1a8be9=_0x3a4e62;_0x15ef64[_0x8a84('0x46')]=_['keys'](db[_0x8a84('0x5d')][_0x8a84('0x3d')]);_0x15ef64[_0x8a84('0x42')]=_[_0x8a84('0x43')](_0x3995db[_0x8a84('0x42')]);_0x15ef64['filters']=_[_0x8a84('0x45')](_0x15ef64['model'],_0x15ef64[_0x8a84('0x42')]);_0x4336d8[_0x8a84('0x48')]=_[_0x8a84('0x45')](_0x15ef64[_0x8a84('0x46')],qs[_0x8a84('0x47')](_0x3995db[_0x8a84('0x42')][_0x8a84('0x47')]));_0x4336d8[_0x8a84('0x48')]=_0x4336d8[_0x8a84('0x48')][_0x8a84('0x49')]?_0x4336d8[_0x8a84('0x48')]:_0x15ef64[_0x8a84('0x46')];_0x4336d8[_0x8a84('0x4c')]=qs[_0x8a84('0x4d')](_0x3995db[_0x8a84('0x42')][_0x8a84('0x4d')]);_0x4336d8[_0x8a84('0x4e')]=qs[_0x8a84('0x44')](_[_0x8a84('0x4f')](_0x3995db[_0x8a84('0x42')],_0x15ef64[_0x8a84('0x44')]));if(_0x3995db[_0x8a84('0x42')]['filter']){_0x4336d8[_0x8a84('0x4e')]=_[_0x8a84('0x51')](_0x4336d8[_0x8a84('0x4e')],{'$or':_[_0x8a84('0x41')](_0x4336d8[_0x8a84('0x48')],function(_0x19ccc4){var _0x8730e3={};_0x8730e3[_0x19ccc4]={'$like':'%'+_0x3995db[_0x8a84('0x42')][_0x8a84('0x50')]+'%'};return _0x8730e3;})});}if(_0x3995db[_0x8a84('0x42')][_0x8a84('0x69')]){var _0x1cd699=_0x3995db[_0x8a84('0x42')][_0x8a84('0x69')]['split'](',');var _0x2e1320={};_0x2e1320[_0x1cd699[0x0]]={'$gte':moment(_0x1cd699[0x1])['format'](_0x8a84('0x6a'))};_0x4336d8[_0x8a84('0x4e')]=_[_0x8a84('0x51')](_0x4336d8[_0x8a84('0x4e')],_0x2e1320);}_0x4336d8=_[_0x8a84('0x51')]({},_0x4336d8,_0x3995db[_0x8a84('0x65')]);return _0x1a8be9['getMessages'](_0x4336d8);}})[_0x8a84('0x24')](function(_0x3fb197){if(_0x3fb197){_0x353bb5=_0x3fb197['length'];if(!_0x3995db[_0x8a84('0x42')]['hasOwnProperty'](_0x8a84('0x4b'))){_0x4336d8[_0x8a84('0x31')]=qs['limit'](_0x3995db['query'][_0x8a84('0x31')]);_0x4336d8['offset']=qs[_0x8a84('0x30')](_0x3995db[_0x8a84('0x42')][_0x8a84('0x30')]);}return _0x1a8be9['getMessages'](_0x4336d8);}})[_0x8a84('0x24')](function(_0x53a913){if(_0x53a913){return _0x53a913?{'count':_0x353bb5,'rows':_0x53a913}:null;}})['then'](respondWithResult(_0x4aa7a6,null))['catch'](handleError(_0x4aa7a6,null));};
\ No newline at end of file