Built motion from commit 3061e47c.|2.6.31
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index 4bb3cb6..44c3221 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x87bf=['destroy','error','stack','name','index','map','rawAttributes','fieldName','type','key','model','query','intersection','attributes','fields','length','sort','where','filters','pick','filter','merge','VIRTUAL','options','ChatGroup','include','findAll','rows','show','keys','includeAll','find','catch','create','update','body','params','describe','getUnread','ChatInternalMessage','user','toInteger','addMembers','ids','omit','getMembers','findOne','User','removeMembers','addMessage','ChatGroupId','getMessages','order','$gte','split','format','hasOwnProperty','nolimit','eml-format','rimraf','fast-json-patch','request-promise','mustache','path','sox','ejs','fs-extra','lodash','crypto','jsforce','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatGroup.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','apply','reject','then'];(function(_0x7148b6,_0xa61534){var _0x111019=function(_0x452d96){while(--_0x452d96){_0x7148b6['push'](_0x7148b6['shift']());}};_0x111019(++_0xa61534);}(_0x87bf,0x1c6));var _0xf87b=function(_0x272fa4,_0xf712d1){_0x272fa4=_0x272fa4-0x0;var _0x25ec85=_0x87bf[_0x272fa4];return _0x25ec85;};'use strict';var emlformat=require(_0xf87b('0x0'));var rimraf=require(_0xf87b('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf87b('0x2'));var rp=require(_0xf87b('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0xf87b('0x4'));var util=require('util');var path=require(_0xf87b('0x5'));var sox=require(_0xf87b('0x6'));var csv=require('to-csv');var ejs=require(_0xf87b('0x7'));var fs=require('fs');var fs_extra=require(_0xf87b('0x8'));var _=require(_0xf87b('0x9'));var squel=require('squel');var crypto=require(_0xf87b('0xa'));var jsforce=require(_0xf87b('0xb'));var deskjs=require('desk.js');var toCsv=require(_0xf87b('0xc'));var querystring=require(_0xf87b('0xd'));var Papa=require(_0xf87b('0xe'));var Redis=require(_0xf87b('0xf'));var authService=require(_0xf87b('0x10'));var qs=require(_0xf87b('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf87b('0x12'));var logger=require('../../config/logger')('api');var utils=require(_0xf87b('0x13'));var config=require(_0xf87b('0x14'));var licenseUtil=require(_0xf87b('0x15'));var db=require(_0xf87b('0x16'))['db'];config[_0xf87b('0x17')]=_[_0xf87b('0x18')](config[_0xf87b('0x17')],{'host':_0xf87b('0x19'),'port':0x18eb});var socket=require(_0xf87b('0x1a'))(new Redis(config[_0xf87b('0x17')]));require(_0xf87b('0x1b'))[_0xf87b('0x1c')](socket);function respondWithStatusCode(_0x4707dd,_0x129597){_0x129597=_0x129597||0xcc;return function(_0x14c40a){if(_0x14c40a){return _0x4707dd[_0xf87b('0x1d')](_0x129597);}return _0x4707dd[_0xf87b('0x1e')](_0x129597)[_0xf87b('0x1f')]();};}function respondWithResult(_0x532d2f,_0x4eaa2a){_0x4eaa2a=_0x4eaa2a||0xc8;return function(_0xeb91de){if(_0xeb91de){return _0x532d2f[_0xf87b('0x1e')](_0x4eaa2a)[_0xf87b('0x20')](_0xeb91de);}};}function respondWithFilteredResult(_0x2d0aa1,_0xad65a4){return function(_0x183239){if(_0x183239){var _0x53cd55=typeof _0xad65a4[_0xf87b('0x21')]===_0xf87b('0x22')&&typeof _0xad65a4[_0xf87b('0x23')]===_0xf87b('0x22');var _0x35ec92=_0x183239[_0xf87b('0x24')];var _0x3392d8=_0x53cd55?0x0:_0xad65a4[_0xf87b('0x21')];var _0x363917=_0x53cd55?_0x183239[_0xf87b('0x24')]:_0xad65a4[_0xf87b('0x21')]+_0xad65a4['limit'];var _0x305bea;if(_0x363917>=_0x35ec92){_0x363917=_0x35ec92;_0x305bea=0xc8;}else{_0x305bea=0xce;}_0x2d0aa1[_0xf87b('0x1e')](_0x305bea);return _0x2d0aa1[_0xf87b('0x25')]('Content-Range',_0x3392d8+'-'+_0x363917+'/'+_0x35ec92)[_0xf87b('0x20')](_0x183239);}return null;};}function patchUpdates(_0x18609d){return function(_0x23b01c){try{jsonpatch[_0xf87b('0x26')](_0x23b01c,_0x18609d,!![]);}catch(_0x3856a6){return BPromise[_0xf87b('0x27')](_0x3856a6);}return _0x23b01c['save']();};}function saveUpdates(_0x1b7bea,_0x3367f1){return function(_0x2ba79d){if(_0x2ba79d){return _0x2ba79d['update'](_0x1b7bea)[_0xf87b('0x28')](function(_0x4ad7e3){return _0x4ad7e3;});}return null;};}function removeEntity(_0x193247,_0x1f9063){return function(_0x5491af){if(_0x5491af){return _0x5491af[_0xf87b('0x29')]()[_0xf87b('0x28')](function(){_0x193247[_0xf87b('0x1e')](0xcc)[_0xf87b('0x1f')]();});}};}function handleEntityNotFound(_0x2a9c68,_0x408ec6){return function(_0x18b8ca){if(!_0x18b8ca){_0x2a9c68[_0xf87b('0x1d')](0x194);}return _0x18b8ca;};}function handleError(_0x2e4f2e,_0x5c21ac){_0x5c21ac=_0x5c21ac||0x1f4;return function(_0x5d39e5){logger[_0xf87b('0x2a')](_0x5d39e5[_0xf87b('0x2b')]);if(_0x5d39e5['name']){delete _0x5d39e5[_0xf87b('0x2c')];}_0x2e4f2e['status'](_0x5c21ac)['send'](_0x5d39e5);};}exports[_0xf87b('0x2d')]=function(_0x2e1269,_0x340002){var _0x14a121={},_0x1a07a1={},_0x271ff8={'count':0x0,'rows':[]};var _0x37facf=_[_0xf87b('0x2e')](db['ChatGroup'][_0xf87b('0x2f')],function(_0x50a24f){return{'name':_0x50a24f[_0xf87b('0x30')],'type':_0x50a24f[_0xf87b('0x31')][_0xf87b('0x32')]};});_0x1a07a1[_0xf87b('0x33')]=_[_0xf87b('0x2e')](_0x37facf,_0xf87b('0x2c'));_0x1a07a1[_0xf87b('0x34')]=_['keys'](_0x2e1269['query']);_0x1a07a1['filters']=_[_0xf87b('0x35')](_0x1a07a1[_0xf87b('0x33')],_0x1a07a1[_0xf87b('0x34')]);_0x14a121[_0xf87b('0x36')]=_['intersection'](_0x1a07a1[_0xf87b('0x33')],qs['fields'](_0x2e1269[_0xf87b('0x34')][_0xf87b('0x37')]));_0x14a121[_0xf87b('0x36')]=_0x14a121[_0xf87b('0x36')][_0xf87b('0x38')]?_0x14a121[_0xf87b('0x36')]:_0x1a07a1[_0xf87b('0x33')];if(!_0x2e1269[_0xf87b('0x34')]['hasOwnProperty']('nolimit')){_0x14a121['limit']=qs['limit'](_0x2e1269[_0xf87b('0x34')][_0xf87b('0x23')]);_0x14a121[_0xf87b('0x21')]=qs[_0xf87b('0x21')](_0x2e1269[_0xf87b('0x34')][_0xf87b('0x21')]);}_0x14a121['order']=qs[_0xf87b('0x39')](_0x2e1269['query'][_0xf87b('0x39')]);_0x14a121[_0xf87b('0x3a')]=qs[_0xf87b('0x3b')](_[_0xf87b('0x3c')](_0x2e1269[_0xf87b('0x34')],_0x1a07a1['filters']),_0x37facf);if(_0x2e1269[_0xf87b('0x34')][_0xf87b('0x3d')]){_0x14a121[_0xf87b('0x3a')]=_[_0xf87b('0x3e')](_0x14a121[_0xf87b('0x3a')],{'$or':_['map'](_0x37facf,function(_0x4c7a77){if(_0x4c7a77[_0xf87b('0x31')]!==_0xf87b('0x3f')){var _0x3c2b29={};_0x3c2b29[_0x4c7a77['name']]={'$like':'%'+_0x2e1269[_0xf87b('0x34')][_0xf87b('0x3d')]+'%'};return _0x3c2b29;}})});}_0x14a121=_[_0xf87b('0x3e')]({},_0x14a121,_0x2e1269[_0xf87b('0x40')]);var _0x2df338={'where':_0x14a121['where']};return db[_0xf87b('0x41')]['count'](_0x2df338)[_0xf87b('0x28')](function(_0x19ae12){_0x271ff8[_0xf87b('0x24')]=_0x19ae12;if(_0x2e1269['query']['includeAll']){_0x14a121[_0xf87b('0x42')]=[{'all':!![]}];}return db[_0xf87b('0x41')][_0xf87b('0x43')](_0x14a121);})[_0xf87b('0x28')](function(_0x4bdef4){_0x271ff8[_0xf87b('0x44')]=_0x4bdef4;return _0x271ff8;})[_0xf87b('0x28')](respondWithFilteredResult(_0x340002,_0x14a121))['catch'](handleError(_0x340002,null));};exports[_0xf87b('0x45')]=function(_0x418846,_0x17d937){var _0x369c60={'raw':!![],'where':{'id':_0x418846['params']['id']}},_0x5297b4={};_0x5297b4[_0xf87b('0x33')]=_[_0xf87b('0x46')](db[_0xf87b('0x41')][_0xf87b('0x2f')]);_0x5297b4[_0xf87b('0x34')]=_[_0xf87b('0x46')](_0x418846[_0xf87b('0x34')]);_0x5297b4[_0xf87b('0x3b')]=_[_0xf87b('0x35')](_0x5297b4[_0xf87b('0x33')],_0x5297b4[_0xf87b('0x34')]);_0x369c60[_0xf87b('0x36')]=_['intersection'](_0x5297b4['model'],qs[_0xf87b('0x37')](_0x418846['query'][_0xf87b('0x37')]));_0x369c60['attributes']=_0x369c60['attributes']['length']?_0x369c60[_0xf87b('0x36')]:_0x5297b4['model'];if(_0x418846['query'][_0xf87b('0x47')]){_0x369c60[_0xf87b('0x42')]=[{'all':!![]}];}_0x369c60=_[_0xf87b('0x3e')]({},_0x369c60,_0x418846[_0xf87b('0x40')]);return db[_0xf87b('0x41')][_0xf87b('0x48')](_0x369c60)[_0xf87b('0x28')](handleEntityNotFound(_0x17d937,null))[_0xf87b('0x28')](respondWithResult(_0x17d937,null))[_0xf87b('0x49')](handleError(_0x17d937,null));};exports[_0xf87b('0x4a')]=function(_0xf59657,_0x1f8acf){return db[_0xf87b('0x41')][_0xf87b('0x4a')](_0xf59657['body'],{})[_0xf87b('0x28')](respondWithResult(_0x1f8acf,0xc9))['catch'](handleError(_0x1f8acf,null));};exports[_0xf87b('0x4b')]=function(_0xc7e7d8,_0xe531cb){if(_0xc7e7d8[_0xf87b('0x4c')]['id']){delete _0xc7e7d8[_0xf87b('0x4c')]['id'];}return db[_0xf87b('0x41')]['find']({'where':{'id':_0xc7e7d8[_0xf87b('0x4d')]['id']}})[_0xf87b('0x28')](handleEntityNotFound(_0xe531cb,null))[_0xf87b('0x28')](saveUpdates(_0xc7e7d8[_0xf87b('0x4c')],null))[_0xf87b('0x28')](respondWithResult(_0xe531cb,null))[_0xf87b('0x49')](handleError(_0xe531cb,null));};exports[_0xf87b('0x29')]=function(_0x796a9a,_0x580734){return db[_0xf87b('0x41')][_0xf87b('0x48')]({'where':{'id':_0x796a9a[_0xf87b('0x4d')]['id']}})['then'](handleEntityNotFound(_0x580734,null))[_0xf87b('0x28')](removeEntity(_0x580734,null))['catch'](handleError(_0x580734,null));};exports[_0xf87b('0x4e')]=function(_0x36fd58,_0x1f72d2){return db[_0xf87b('0x41')]['describe']()[_0xf87b('0x28')](respondWithResult(_0x1f72d2,null))['catch'](handleError(_0x1f72d2,null));};exports[_0xf87b('0x4f')]=function(_0xbcf998,_0x27f92d,_0x282956){return db[_0xf87b('0x50')]['count']({'where':{'ChatGroupId':_0xbcf998[_0xf87b('0x4d')]['id'],'ToId':_0xbcf998[_0xf87b('0x51')]['id'],'read':![]}})[_0xf87b('0x28')](function(_0x35e013){return{'id':_[_0xf87b('0x52')](_0xbcf998[_0xf87b('0x4d')]['id']),'count':_0x35e013};})['then'](respondWithResult(_0x27f92d,null))[_0xf87b('0x49')](handleError(_0x27f92d,null));};exports['addMembers']=function(_0x24bd09,_0x20a5ba,_0x122f0a){return db['ChatGroup']['find']({'where':{'id':_0x24bd09[_0xf87b('0x4d')]['id']}})[_0xf87b('0x28')](handleEntityNotFound(_0x20a5ba,null))[_0xf87b('0x28')](function(_0x2b3778){if(_0x2b3778){return _0x2b3778[_0xf87b('0x53')](_0x24bd09[_0xf87b('0x4c')][_0xf87b('0x54')],_[_0xf87b('0x55')](_0x24bd09[_0xf87b('0x4c')],[_0xf87b('0x54'),'id'])||{});}})['then'](respondWithResult(_0x20a5ba,null))[_0xf87b('0x49')](handleError(_0x20a5ba,null));};exports[_0xf87b('0x56')]=function(_0x1e4c76,_0x5cc5e5,_0x425c14){var _0x281a4d={};var _0x1fc48a={};var _0x280643;var _0xfa778a;return db['ChatGroup'][_0xf87b('0x57')]({'where':{'id':_0x1e4c76[_0xf87b('0x4d')]['id']}})['then'](handleEntityNotFound(_0x5cc5e5,null))[_0xf87b('0x28')](function(_0x5b8219){if(_0x5b8219){_0x280643=_0x5b8219;_0x1fc48a[_0xf87b('0x33')]=_[_0xf87b('0x46')](db[_0xf87b('0x58')][_0xf87b('0x2f')]);_0x1fc48a[_0xf87b('0x34')]=_['keys'](_0x1e4c76[_0xf87b('0x34')]);_0x1fc48a['filters']=_['intersection'](_0x1fc48a['model'],_0x1fc48a[_0xf87b('0x34')]);_0x281a4d['attributes']=_[_0xf87b('0x35')](_0x1fc48a[_0xf87b('0x33')],qs[_0xf87b('0x37')](_0x1e4c76[_0xf87b('0x34')]['fields']));_0x281a4d[_0xf87b('0x36')]=_0x281a4d[_0xf87b('0x36')][_0xf87b('0x38')]?_0x281a4d[_0xf87b('0x36')]:_0x1fc48a[_0xf87b('0x33')];_0x281a4d['order']=qs[_0xf87b('0x39')](_0x1e4c76['query'][_0xf87b('0x39')]);_0x281a4d[_0xf87b('0x3a')]=qs[_0xf87b('0x3b')](_[_0xf87b('0x3c')](_0x1e4c76[_0xf87b('0x34')],_0x1fc48a[_0xf87b('0x3b')]));if(_0x1e4c76['query'][_0xf87b('0x3d')]){_0x281a4d['where']=_[_0xf87b('0x3e')](_0x281a4d[_0xf87b('0x3a')],{'$or':_[_0xf87b('0x2e')](_0x281a4d[_0xf87b('0x36')],function(_0x7d6d03){var _0xd4096c={};_0xd4096c[_0x7d6d03]={'$like':'%'+_0x1e4c76['query'][_0xf87b('0x3d')]+'%'};return _0xd4096c;})});}_0x281a4d=_[_0xf87b('0x3e')]({},_0x281a4d,_0x1e4c76[_0xf87b('0x40')]);return _0x280643[_0xf87b('0x56')](_0x281a4d);}})[_0xf87b('0x28')](function(_0x5da5b4){if(_0x5da5b4){_0xfa778a=_0x5da5b4[_0xf87b('0x38')];if(!_0x1e4c76['query']['hasOwnProperty']('nolimit')){_0x281a4d[_0xf87b('0x23')]=qs['limit'](_0x1e4c76[_0xf87b('0x34')]['limit']);_0x281a4d[_0xf87b('0x21')]=qs['offset'](_0x1e4c76[_0xf87b('0x34')][_0xf87b('0x21')]);}return _0x280643['getMembers'](_0x281a4d);}})['then'](function(_0x9f848){if(_0x9f848){return _0x9f848?{'count':_0xfa778a,'rows':_0x9f848}:null;}})[_0xf87b('0x28')](respondWithResult(_0x5cc5e5,null))[_0xf87b('0x49')](handleError(_0x5cc5e5,null));};exports[_0xf87b('0x59')]=function(_0x2fc9ba,_0x215e12,_0x4dd44d){return db[_0xf87b('0x41')]['find']({'where':{'id':_0x2fc9ba[_0xf87b('0x4d')]['id']}})[_0xf87b('0x28')](handleEntityNotFound(_0x215e12,null))[_0xf87b('0x28')](function(_0x3f2046){if(_0x3f2046){return _0x3f2046[_0xf87b('0x59')](_0x2fc9ba[_0xf87b('0x34')][_0xf87b('0x54')]);}})[_0xf87b('0x28')](respondWithStatusCode(_0x215e12,null))[_0xf87b('0x49')](handleError(_0x215e12,null));};exports[_0xf87b('0x5a')]=function(_0x46c6d9,_0x58bd6e,_0x2ed9e0){if(_0x46c6d9['body']['id']){delete _0x46c6d9['body']['id'];}return db[_0xf87b('0x41')][_0xf87b('0x48')]({'where':{'id':_0x46c6d9[_0xf87b('0x4d')]['id']}})[_0xf87b('0x28')](handleEntityNotFound(_0x58bd6e,null))[_0xf87b('0x28')](function(_0x118d55){if(_0x118d55){_0x46c6d9[_0xf87b('0x4c')][_0xf87b('0x5b')]=_0x118d55['id'];return db[_0xf87b('0x50')][_0xf87b('0x4a')](_0x46c6d9[_0xf87b('0x4c')]);}})[_0xf87b('0x28')](respondWithResult(_0x58bd6e,null))['catch'](handleError(_0x58bd6e,null));};exports[_0xf87b('0x5c')]=function(_0x4c5ecd,_0x10917f,_0x513cf6){var _0x180275={};var _0x5e3beb={};var _0x2e28d8;var _0x14d969;return db[_0xf87b('0x41')][_0xf87b('0x57')]({'where':{'id':_0x4c5ecd[_0xf87b('0x4d')]['id']}})[_0xf87b('0x28')](handleEntityNotFound(_0x10917f,null))[_0xf87b('0x28')](function(_0x22c716){if(_0x22c716){_0x2e28d8=_0x22c716;_0x5e3beb[_0xf87b('0x33')]=_[_0xf87b('0x46')](db[_0xf87b('0x50')]['rawAttributes']);_0x5e3beb[_0xf87b('0x34')]=_[_0xf87b('0x46')](_0x4c5ecd['query']);_0x5e3beb[_0xf87b('0x3b')]=_[_0xf87b('0x35')](_0x5e3beb[_0xf87b('0x33')],_0x5e3beb[_0xf87b('0x34')]);_0x180275['attributes']=_[_0xf87b('0x35')](_0x5e3beb[_0xf87b('0x33')],qs[_0xf87b('0x37')](_0x4c5ecd['query'][_0xf87b('0x37')]));_0x180275[_0xf87b('0x36')]=_0x180275[_0xf87b('0x36')][_0xf87b('0x38')]?_0x180275['attributes']:_0x5e3beb['model'];_0x180275[_0xf87b('0x5d')]=qs[_0xf87b('0x39')](_0x4c5ecd[_0xf87b('0x34')][_0xf87b('0x39')]);_0x180275[_0xf87b('0x3a')]=qs[_0xf87b('0x3b')](_[_0xf87b('0x3c')](_0x4c5ecd[_0xf87b('0x34')],_0x5e3beb[_0xf87b('0x3b')]));if(_0x4c5ecd['query'][_0xf87b('0x3d')]){_0x180275[_0xf87b('0x3a')]=_[_0xf87b('0x3e')](_0x180275[_0xf87b('0x3a')],{'$or':_[_0xf87b('0x2e')](_0x180275['attributes'],function(_0x14c086){var _0x2b47fb={};_0x2b47fb[_0x14c086]={'$like':'%'+_0x4c5ecd['query'][_0xf87b('0x3d')]+'%'};return _0x2b47fb;})});}if(_0x4c5ecd[_0xf87b('0x34')][_0xf87b('0x5e')]){var _0x586742=_0x4c5ecd[_0xf87b('0x34')]['$gte'][_0xf87b('0x5f')](',');var _0x4fa075={};_0x4fa075[_0x586742[0x0]]={'$gte':moment(_0x586742[0x1])[_0xf87b('0x60')]('YYYY-MM-DD\x20HH:mm:ss')};_0x180275[_0xf87b('0x3a')]=_['merge'](_0x180275[_0xf87b('0x3a')],_0x4fa075);}_0x180275=_[_0xf87b('0x3e')]({},_0x180275,_0x4c5ecd[_0xf87b('0x40')]);return _0x2e28d8[_0xf87b('0x5c')](_0x180275);}})[_0xf87b('0x28')](function(_0x19ebed){if(_0x19ebed){_0x14d969=_0x19ebed[_0xf87b('0x38')];if(!_0x4c5ecd['query'][_0xf87b('0x61')](_0xf87b('0x62'))){_0x180275[_0xf87b('0x23')]=qs[_0xf87b('0x23')](_0x4c5ecd[_0xf87b('0x34')][_0xf87b('0x23')]);_0x180275['offset']=qs[_0xf87b('0x21')](_0x4c5ecd[_0xf87b('0x34')]['offset']);}return _0x2e28d8['getMessages'](_0x180275);}})[_0xf87b('0x28')](function(_0x530484){if(_0x530484){return _0x530484?{'count':_0x14d969,'rows':_0x530484}:null;}})['then'](respondWithResult(_0x10917f,null))[_0xf87b('0x49')](handleError(_0x10917f,null));};
\ No newline at end of file
+var _0xf416=['rimraf','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/utils','../../config/environment','../../config/license/util','redis','defaults','localhost','socket.io-emitter','./chatGroup.socket','register','sendStatus','status','json','undefined','limit','count','offset','set','Content-Range','apply','reject','save','update','then','destroy','error','name','send','map','rawAttributes','fieldName','key','model','query','keys','filters','intersection','attributes','fields','order','sort','where','pick','merge','type','VIRTUAL','filter','options','ChatGroup','includeAll','include','findAll','catch','show','params','length','find','create','body','describe','user','toInteger','addMembers','ids','omit','getMembers','findOne','User','nolimit','removeMembers','addMessage','ChatGroupId','ChatInternalMessage','$gte','split','YYYY-MM-DD\x20HH:mm:ss','getMessages','eml-format'];(function(_0x2a6572,_0x5c1f97){var _0x5482f9=function(_0x4f23cc){while(--_0x4f23cc){_0x2a6572['push'](_0x2a6572['shift']());}};_0x5482f9(++_0x5c1f97);}(_0xf416,0x183));var _0x6f41=function(_0x425fa5,_0x79182e){_0x425fa5=_0x425fa5-0x0;var _0x3d4402=_0xf416[_0x425fa5];return _0x3d4402;};'use strict';var emlformat=require(_0x6f41('0x0'));var rimraf=require(_0x6f41('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x6f41('0x2'));var rp=require(_0x6f41('0x3'));var moment=require('moment');var BPromise=require(_0x6f41('0x4'));var Mustache=require(_0x6f41('0x5'));var util=require(_0x6f41('0x6'));var path=require(_0x6f41('0x7'));var sox=require(_0x6f41('0x8'));var csv=require(_0x6f41('0x9'));var ejs=require(_0x6f41('0xa'));var fs=require('fs');var fs_extra=require(_0x6f41('0xb'));var _=require(_0x6f41('0xc'));var squel=require(_0x6f41('0xd'));var crypto=require(_0x6f41('0xe'));var jsforce=require(_0x6f41('0xf'));var deskjs=require(_0x6f41('0x10'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x6f41('0x11'));var Redis=require(_0x6f41('0x12'));var authService=require(_0x6f41('0x13'));var qs=require(_0x6f41('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require('../../config/license/hardware');var logger=require('../../config/logger')('api');var utils=require(_0x6f41('0x15'));var config=require(_0x6f41('0x16'));var licenseUtil=require(_0x6f41('0x17'));var db=require('../../mysqldb')['db'];config[_0x6f41('0x18')]=_[_0x6f41('0x19')](config[_0x6f41('0x18')],{'host':_0x6f41('0x1a'),'port':0x18eb});var socket=require(_0x6f41('0x1b'))(new Redis(config[_0x6f41('0x18')]));require(_0x6f41('0x1c'))[_0x6f41('0x1d')](socket);function respondWithStatusCode(_0x44e31a,_0x4eb09b){_0x4eb09b=_0x4eb09b||0xcc;return function(_0x30bd04){if(_0x30bd04){return _0x44e31a[_0x6f41('0x1e')](_0x4eb09b);}return _0x44e31a[_0x6f41('0x1f')](_0x4eb09b)['end']();};}function respondWithResult(_0x782a47,_0x30fdf1){_0x30fdf1=_0x30fdf1||0xc8;return function(_0x272437){if(_0x272437){return _0x782a47[_0x6f41('0x1f')](_0x30fdf1)[_0x6f41('0x20')](_0x272437);}};}function respondWithFilteredResult(_0x4c0102,_0x19db03){return function(_0x3b6af5){if(_0x3b6af5){var _0x28fef3=typeof _0x19db03['offset']===_0x6f41('0x21')&&typeof _0x19db03[_0x6f41('0x22')]===_0x6f41('0x21');var _0x2df3d4=_0x3b6af5[_0x6f41('0x23')];var _0x5a7408=_0x28fef3?0x0:_0x19db03['offset'];var _0x1497fb=_0x28fef3?_0x3b6af5[_0x6f41('0x23')]:_0x19db03[_0x6f41('0x24')]+_0x19db03[_0x6f41('0x22')];var _0x180714;if(_0x1497fb>=_0x2df3d4){_0x1497fb=_0x2df3d4;_0x180714=0xc8;}else{_0x180714=0xce;}_0x4c0102[_0x6f41('0x1f')](_0x180714);return _0x4c0102[_0x6f41('0x25')](_0x6f41('0x26'),_0x5a7408+'-'+_0x1497fb+'/'+_0x2df3d4)[_0x6f41('0x20')](_0x3b6af5);}return null;};}function patchUpdates(_0x1cff21){return function(_0x177a20){try{jsonpatch[_0x6f41('0x27')](_0x177a20,_0x1cff21,!![]);}catch(_0x2e2623){return BPromise[_0x6f41('0x28')](_0x2e2623);}return _0x177a20[_0x6f41('0x29')]();};}function saveUpdates(_0x135730,_0x42ad2c){return function(_0x801480){if(_0x801480){return _0x801480[_0x6f41('0x2a')](_0x135730)[_0x6f41('0x2b')](function(_0x5e29e2){return _0x5e29e2;});}return null;};}function removeEntity(_0x4f22c9,_0x32c730){return function(_0x36dd3c){if(_0x36dd3c){return _0x36dd3c[_0x6f41('0x2c')]()[_0x6f41('0x2b')](function(){_0x4f22c9[_0x6f41('0x1f')](0xcc)['end']();});}};}function handleEntityNotFound(_0x5bd0c9,_0x136993){return function(_0x25a620){if(!_0x25a620){_0x5bd0c9[_0x6f41('0x1e')](0x194);}return _0x25a620;};}function handleError(_0x492fd0,_0x1a5acc){_0x1a5acc=_0x1a5acc||0x1f4;return function(_0x55063f){logger[_0x6f41('0x2d')](_0x55063f['stack']);if(_0x55063f[_0x6f41('0x2e')]){delete _0x55063f[_0x6f41('0x2e')];}_0x492fd0['status'](_0x1a5acc)[_0x6f41('0x2f')](_0x55063f);};}exports['index']=function(_0x19be0a,_0x549a54){var _0x57b27a={},_0x3368f9={},_0x3023cb={'count':0x0,'rows':[]};var _0x5e15c6=_[_0x6f41('0x30')](db['ChatGroup'][_0x6f41('0x31')],function(_0x36ad4d){return{'name':_0x36ad4d[_0x6f41('0x32')],'type':_0x36ad4d['type'][_0x6f41('0x33')]};});_0x3368f9[_0x6f41('0x34')]=_['map'](_0x5e15c6,_0x6f41('0x2e'));_0x3368f9[_0x6f41('0x35')]=_[_0x6f41('0x36')](_0x19be0a[_0x6f41('0x35')]);_0x3368f9[_0x6f41('0x37')]=_[_0x6f41('0x38')](_0x3368f9[_0x6f41('0x34')],_0x3368f9['query']);_0x57b27a[_0x6f41('0x39')]=_['intersection'](_0x3368f9[_0x6f41('0x34')],qs[_0x6f41('0x3a')](_0x19be0a[_0x6f41('0x35')][_0x6f41('0x3a')]));_0x57b27a[_0x6f41('0x39')]=_0x57b27a[_0x6f41('0x39')]['length']?_0x57b27a[_0x6f41('0x39')]:_0x3368f9[_0x6f41('0x34')];if(!_0x19be0a[_0x6f41('0x35')]['hasOwnProperty']('nolimit')){_0x57b27a[_0x6f41('0x22')]=qs[_0x6f41('0x22')](_0x19be0a[_0x6f41('0x35')][_0x6f41('0x22')]);_0x57b27a['offset']=qs[_0x6f41('0x24')](_0x19be0a[_0x6f41('0x35')][_0x6f41('0x24')]);}_0x57b27a[_0x6f41('0x3b')]=qs[_0x6f41('0x3c')](_0x19be0a['query'][_0x6f41('0x3c')]);_0x57b27a[_0x6f41('0x3d')]=qs[_0x6f41('0x37')](_[_0x6f41('0x3e')](_0x19be0a[_0x6f41('0x35')],_0x3368f9[_0x6f41('0x37')]),_0x5e15c6);if(_0x19be0a['query']['filter']){_0x57b27a[_0x6f41('0x3d')]=_[_0x6f41('0x3f')](_0x57b27a['where'],{'$or':_[_0x6f41('0x30')](_0x5e15c6,function(_0x175fbf){if(_0x175fbf[_0x6f41('0x40')]!==_0x6f41('0x41')){var _0x4bb49b={};_0x4bb49b[_0x175fbf[_0x6f41('0x2e')]]={'$like':'%'+_0x19be0a['query'][_0x6f41('0x42')]+'%'};return _0x4bb49b;}})});}_0x57b27a=_[_0x6f41('0x3f')]({},_0x57b27a,_0x19be0a[_0x6f41('0x43')]);var _0x42b667={'where':_0x57b27a[_0x6f41('0x3d')]};return db[_0x6f41('0x44')]['count'](_0x42b667)[_0x6f41('0x2b')](function(_0x466528){_0x3023cb['count']=_0x466528;if(_0x19be0a[_0x6f41('0x35')][_0x6f41('0x45')]){_0x57b27a[_0x6f41('0x46')]=[{'all':!![]}];}return db['ChatGroup'][_0x6f41('0x47')](_0x57b27a);})[_0x6f41('0x2b')](function(_0x42e16f){_0x3023cb['rows']=_0x42e16f;return _0x3023cb;})[_0x6f41('0x2b')](respondWithFilteredResult(_0x549a54,_0x57b27a))[_0x6f41('0x48')](handleError(_0x549a54,null));};exports[_0x6f41('0x49')]=function(_0x38ce52,_0x2f46ff){var _0x1e66e9={'raw':!![],'where':{'id':_0x38ce52[_0x6f41('0x4a')]['id']}},_0x80aae0={};_0x80aae0[_0x6f41('0x34')]=_[_0x6f41('0x36')](db['ChatGroup'][_0x6f41('0x31')]);_0x80aae0['query']=_[_0x6f41('0x36')](_0x38ce52[_0x6f41('0x35')]);_0x80aae0[_0x6f41('0x37')]=_[_0x6f41('0x38')](_0x80aae0[_0x6f41('0x34')],_0x80aae0['query']);_0x1e66e9['attributes']=_['intersection'](_0x80aae0[_0x6f41('0x34')],qs[_0x6f41('0x3a')](_0x38ce52['query'][_0x6f41('0x3a')]));_0x1e66e9[_0x6f41('0x39')]=_0x1e66e9['attributes'][_0x6f41('0x4b')]?_0x1e66e9[_0x6f41('0x39')]:_0x80aae0[_0x6f41('0x34')];if(_0x38ce52[_0x6f41('0x35')][_0x6f41('0x45')]){_0x1e66e9['include']=[{'all':!![]}];}_0x1e66e9=_[_0x6f41('0x3f')]({},_0x1e66e9,_0x38ce52[_0x6f41('0x43')]);return db[_0x6f41('0x44')][_0x6f41('0x4c')](_0x1e66e9)['then'](handleEntityNotFound(_0x2f46ff,null))[_0x6f41('0x2b')](respondWithResult(_0x2f46ff,null))['catch'](handleError(_0x2f46ff,null));};exports[_0x6f41('0x4d')]=function(_0x15675a,_0x442bea){return db[_0x6f41('0x44')]['create'](_0x15675a[_0x6f41('0x4e')],{})[_0x6f41('0x2b')](respondWithResult(_0x442bea,0xc9))[_0x6f41('0x48')](handleError(_0x442bea,null));};exports['update']=function(_0xa76c41,_0x155c8e){if(_0xa76c41[_0x6f41('0x4e')]['id']){delete _0xa76c41[_0x6f41('0x4e')]['id'];}return db['ChatGroup']['find']({'where':{'id':_0xa76c41[_0x6f41('0x4a')]['id']}})[_0x6f41('0x2b')](handleEntityNotFound(_0x155c8e,null))[_0x6f41('0x2b')](saveUpdates(_0xa76c41[_0x6f41('0x4e')],null))[_0x6f41('0x2b')](respondWithResult(_0x155c8e,null))['catch'](handleError(_0x155c8e,null));};exports['destroy']=function(_0x11767d,_0x27d3cb){return db[_0x6f41('0x44')][_0x6f41('0x4c')]({'where':{'id':_0x11767d[_0x6f41('0x4a')]['id']}})[_0x6f41('0x2b')](handleEntityNotFound(_0x27d3cb,null))[_0x6f41('0x2b')](removeEntity(_0x27d3cb,null))[_0x6f41('0x48')](handleError(_0x27d3cb,null));};exports[_0x6f41('0x4f')]=function(_0x41a501,_0x44e96a){return db[_0x6f41('0x44')]['describe']()['then'](respondWithResult(_0x44e96a,null))[_0x6f41('0x48')](handleError(_0x44e96a,null));};exports['getUnread']=function(_0xbc86aa,_0x116010,_0x23f587){return db['ChatInternalMessage'][_0x6f41('0x23')]({'where':{'ChatGroupId':_0xbc86aa['params']['id'],'ToId':_0xbc86aa[_0x6f41('0x50')]['id'],'read':![]}})[_0x6f41('0x2b')](function(_0xa13500){return{'id':_[_0x6f41('0x51')](_0xbc86aa[_0x6f41('0x4a')]['id']),'count':_0xa13500};})[_0x6f41('0x2b')](respondWithResult(_0x116010,null))[_0x6f41('0x48')](handleError(_0x116010,null));};exports[_0x6f41('0x52')]=function(_0x35e999,_0x1313d5,_0x24e747){return db['ChatGroup'][_0x6f41('0x4c')]({'where':{'id':_0x35e999[_0x6f41('0x4a')]['id']}})['then'](handleEntityNotFound(_0x1313d5,null))[_0x6f41('0x2b')](function(_0x543ff9){if(_0x543ff9){return _0x543ff9[_0x6f41('0x52')](_0x35e999[_0x6f41('0x4e')][_0x6f41('0x53')],_[_0x6f41('0x54')](_0x35e999[_0x6f41('0x4e')],['ids','id'])||{});}})[_0x6f41('0x2b')](respondWithResult(_0x1313d5,null))[_0x6f41('0x48')](handleError(_0x1313d5,null));};exports[_0x6f41('0x55')]=function(_0x52e7b7,_0x399e56,_0x5362c4){var _0x65de2={};var _0x2afa43={};var _0x18a338;var _0x1c8dc4;return db['ChatGroup'][_0x6f41('0x56')]({'where':{'id':_0x52e7b7[_0x6f41('0x4a')]['id']}})[_0x6f41('0x2b')](handleEntityNotFound(_0x399e56,null))[_0x6f41('0x2b')](function(_0x2b06a7){if(_0x2b06a7){_0x18a338=_0x2b06a7;_0x2afa43[_0x6f41('0x34')]=_[_0x6f41('0x36')](db[_0x6f41('0x57')][_0x6f41('0x31')]);_0x2afa43['query']=_[_0x6f41('0x36')](_0x52e7b7[_0x6f41('0x35')]);_0x2afa43[_0x6f41('0x37')]=_['intersection'](_0x2afa43['model'],_0x2afa43['query']);_0x65de2['attributes']=_['intersection'](_0x2afa43['model'],qs[_0x6f41('0x3a')](_0x52e7b7[_0x6f41('0x35')][_0x6f41('0x3a')]));_0x65de2[_0x6f41('0x39')]=_0x65de2[_0x6f41('0x39')][_0x6f41('0x4b')]?_0x65de2[_0x6f41('0x39')]:_0x2afa43[_0x6f41('0x34')];_0x65de2[_0x6f41('0x3b')]=qs['sort'](_0x52e7b7[_0x6f41('0x35')][_0x6f41('0x3c')]);_0x65de2[_0x6f41('0x3d')]=qs['filters'](_[_0x6f41('0x3e')](_0x52e7b7[_0x6f41('0x35')],_0x2afa43['filters']));if(_0x52e7b7[_0x6f41('0x35')][_0x6f41('0x42')]){_0x65de2[_0x6f41('0x3d')]=_[_0x6f41('0x3f')](_0x65de2[_0x6f41('0x3d')],{'$or':_[_0x6f41('0x30')](_0x65de2['attributes'],function(_0x4fa1dd){var _0x4ef087={};_0x4ef087[_0x4fa1dd]={'$like':'%'+_0x52e7b7[_0x6f41('0x35')][_0x6f41('0x42')]+'%'};return _0x4ef087;})});}_0x65de2=_[_0x6f41('0x3f')]({},_0x65de2,_0x52e7b7['options']);return _0x18a338[_0x6f41('0x55')](_0x65de2);}})[_0x6f41('0x2b')](function(_0x5214e){if(_0x5214e){_0x1c8dc4=_0x5214e['length'];if(!_0x52e7b7[_0x6f41('0x35')]['hasOwnProperty'](_0x6f41('0x58'))){_0x65de2[_0x6f41('0x22')]=qs[_0x6f41('0x22')](_0x52e7b7['query'][_0x6f41('0x22')]);_0x65de2[_0x6f41('0x24')]=qs[_0x6f41('0x24')](_0x52e7b7[_0x6f41('0x35')][_0x6f41('0x24')]);}return _0x18a338[_0x6f41('0x55')](_0x65de2);}})[_0x6f41('0x2b')](function(_0x458685){if(_0x458685){return _0x458685?{'count':_0x1c8dc4,'rows':_0x458685}:null;}})[_0x6f41('0x2b')](respondWithResult(_0x399e56,null))['catch'](handleError(_0x399e56,null));};exports['removeMembers']=function(_0x427e2f,_0x139b53,_0x21c8ea){return db[_0x6f41('0x44')][_0x6f41('0x4c')]({'where':{'id':_0x427e2f[_0x6f41('0x4a')]['id']}})[_0x6f41('0x2b')](handleEntityNotFound(_0x139b53,null))[_0x6f41('0x2b')](function(_0x53e486){if(_0x53e486){return _0x53e486[_0x6f41('0x59')](_0x427e2f['query'][_0x6f41('0x53')]);}})['then'](respondWithStatusCode(_0x139b53,null))['catch'](handleError(_0x139b53,null));};exports[_0x6f41('0x5a')]=function(_0xa65d9e,_0x349dd8,_0x433c12){if(_0xa65d9e[_0x6f41('0x4e')]['id']){delete _0xa65d9e[_0x6f41('0x4e')]['id'];}return db[_0x6f41('0x44')][_0x6f41('0x4c')]({'where':{'id':_0xa65d9e[_0x6f41('0x4a')]['id']}})['then'](handleEntityNotFound(_0x349dd8,null))[_0x6f41('0x2b')](function(_0x3a8059){if(_0x3a8059){_0xa65d9e['body'][_0x6f41('0x5b')]=_0x3a8059['id'];return db['ChatInternalMessage'][_0x6f41('0x4d')](_0xa65d9e['body']);}})['then'](respondWithResult(_0x349dd8,null))[_0x6f41('0x48')](handleError(_0x349dd8,null));};exports['getMessages']=function(_0x4dbfea,_0xb3f9ec,_0x1f7926){var _0x578bf4={};var _0x3de8e8={};var _0x39add3;var _0x530734;return db[_0x6f41('0x44')][_0x6f41('0x56')]({'where':{'id':_0x4dbfea['params']['id']}})[_0x6f41('0x2b')](handleEntityNotFound(_0xb3f9ec,null))['then'](function(_0x4ff6cb){if(_0x4ff6cb){_0x39add3=_0x4ff6cb;_0x3de8e8['model']=_[_0x6f41('0x36')](db[_0x6f41('0x5c')][_0x6f41('0x31')]);_0x3de8e8[_0x6f41('0x35')]=_[_0x6f41('0x36')](_0x4dbfea['query']);_0x3de8e8['filters']=_[_0x6f41('0x38')](_0x3de8e8[_0x6f41('0x34')],_0x3de8e8['query']);_0x578bf4['attributes']=_[_0x6f41('0x38')](_0x3de8e8[_0x6f41('0x34')],qs[_0x6f41('0x3a')](_0x4dbfea[_0x6f41('0x35')][_0x6f41('0x3a')]));_0x578bf4[_0x6f41('0x39')]=_0x578bf4['attributes']['length']?_0x578bf4[_0x6f41('0x39')]:_0x3de8e8[_0x6f41('0x34')];_0x578bf4['order']=qs['sort'](_0x4dbfea[_0x6f41('0x35')][_0x6f41('0x3c')]);_0x578bf4[_0x6f41('0x3d')]=qs['filters'](_[_0x6f41('0x3e')](_0x4dbfea[_0x6f41('0x35')],_0x3de8e8[_0x6f41('0x37')]));if(_0x4dbfea[_0x6f41('0x35')][_0x6f41('0x42')]){_0x578bf4[_0x6f41('0x3d')]=_[_0x6f41('0x3f')](_0x578bf4['where'],{'$or':_['map'](_0x578bf4[_0x6f41('0x39')],function(_0x4eae2d){var _0x1297f5={};_0x1297f5[_0x4eae2d]={'$like':'%'+_0x4dbfea['query'][_0x6f41('0x42')]+'%'};return _0x1297f5;})});}if(_0x4dbfea['query']['$gte']){var _0x193d82=_0x4dbfea[_0x6f41('0x35')][_0x6f41('0x5d')][_0x6f41('0x5e')](',');var _0x4ff0db={};_0x4ff0db[_0x193d82[0x0]]={'$gte':moment(_0x193d82[0x1])['format'](_0x6f41('0x5f'))};_0x578bf4[_0x6f41('0x3d')]=_[_0x6f41('0x3f')](_0x578bf4['where'],_0x4ff0db);}_0x578bf4=_[_0x6f41('0x3f')]({},_0x578bf4,_0x4dbfea['options']);return _0x39add3[_0x6f41('0x60')](_0x578bf4);}})[_0x6f41('0x2b')](function(_0xce5b6){if(_0xce5b6){_0x530734=_0xce5b6[_0x6f41('0x4b')];if(!_0x4dbfea[_0x6f41('0x35')]['hasOwnProperty'](_0x6f41('0x58'))){_0x578bf4['limit']=qs[_0x6f41('0x22')](_0x4dbfea[_0x6f41('0x35')][_0x6f41('0x22')]);_0x578bf4[_0x6f41('0x24')]=qs[_0x6f41('0x24')](_0x4dbfea[_0x6f41('0x35')]['offset']);}return _0x39add3['getMessages'](_0x578bf4);}})[_0x6f41('0x2b')](function(_0x55a283){if(_0x55a283){return _0x55a283?{'count':_0x530734,'rows':_0x55a283}:null;}})['then'](respondWithResult(_0xb3f9ec,null))[_0x6f41('0x48')](handleError(_0xb3f9ec,null));};
\ No newline at end of file