Built motion from commit 753c950e.|2.5.42
[motion2.git] / server / api / chatGroup / chatGroup.controller.js
index cd2d024..8dda5be 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xdbcd=['ChatGroup','rawAttributes','fieldName','type','key','model','map','name','query','keys','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','limit','sort','where','pick','filter','options','include','findAll','rows','catch','params','includeAll','merge','find','create','body','destroy','describe','getUnread','user','toInteger','addMembers','omit','findOne','User','order','getMembers','removeMembers','addMessage','ChatGroupId','ChatInternalMessage','getMessages','$gte','html-pdf','eml-format','fast-json-patch','request-promise','moment','mustache','util','ejs','desk.js','to-csv','querystring','papaparse','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','redis','defaults','localhost','socket.io-emitter','./chatGroup.socket','client','http','then','debug','request\x20sent','stringify','error','code','message','ChatGroup,\x20%s,\x20%s','info','result','sendStatus','status','end','json','count','offset','set','Content-Range','apply','save','update','stack'];(function(_0x470279,_0x32ee22){var _0x5f5de0=function(_0x5291ec){while(--_0x5291ec){_0x470279['push'](_0x470279['shift']());}};_0x5f5de0(++_0x32ee22);}(_0xdbcd,0x1ba));var _0xddbc=function(_0x50504f,_0x26c8f8){_0x50504f=_0x50504f-0x0;var _0x309023=_0xdbcd[_0x50504f];return _0x309023;};'use strict';var pdf=require(_0xddbc('0x0'));var emlformat=require(_0xddbc('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xddbc('0x2'));var rp=require(_0xddbc('0x3'));var moment=require(_0xddbc('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xddbc('0x5'));var util=require(_0xddbc('0x6'));var path=require('path');var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xddbc('0x7'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require('crypto');var jsforce=require('jsforce');var deskjs=require(_0xddbc('0x8'));var toCsv=require(_0xddbc('0x9'));var querystring=require(_0xddbc('0xa'));var Papa=require(_0xddbc('0xb'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0xddbc('0xc'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xddbc('0xd'));var logger=require('../../config/logger')(_0xddbc('0xe'));var utils=require(_0xddbc('0xf'));var config=require(_0xddbc('0x10'));var licenseUtil=require(_0xddbc('0x11'));var db=require(_0xddbc('0x12'))['db'];config[_0xddbc('0x13')]=_[_0xddbc('0x14')](config[_0xddbc('0x13')],{'host':_0xddbc('0x15'),'port':0x18eb});var socket=require(_0xddbc('0x16'))(new Redis(config[_0xddbc('0x13')]));require(_0xddbc('0x17'))['register'](socket);var jayson=require('jayson/promise');var client=jayson[_0xddbc('0x18')][_0xddbc('0x19')]({'port':0x232a});function respondWithRpcPromise(_0x4ecb2e,_0x5c1d50,_0x464f3d,_0x2d4a9b){return new BPromise(function(_0x2d366d,_0x19f977){var _0x5427b0=_0x2d4a9b||client;return _0x5427b0['request'](_0x4ecb2e,_0x464f3d)[_0xddbc('0x1a')](function(_0x193c84){logger['info']('ChatGroup,\x20%s,\x20%s',_0x5c1d50,'request\x20sent');logger[_0xddbc('0x1b')]('ChatGroup,\x20%s,\x20%s,\x20%s',_0x5c1d50,_0xddbc('0x1c'),JSON[_0xddbc('0x1d')](_0x193c84));if(_0x193c84[_0xddbc('0x1e')]){if(_0x193c84[_0xddbc('0x1e')][_0xddbc('0x1f')]===0x1f4){logger[_0xddbc('0x1e')]('ChatGroup,\x20%s,\x20%s',_0x5c1d50,_0x193c84[_0xddbc('0x1e')]['message']);return _0x19f977(_0x193c84['error'][_0xddbc('0x20')]);}logger['error'](_0xddbc('0x21'),_0x5c1d50,_0x193c84[_0xddbc('0x1e')][_0xddbc('0x20')]);return _0x2d366d(_0x193c84[_0xddbc('0x1e')]['message']);}else{logger[_0xddbc('0x22')](_0xddbc('0x21'),_0x5c1d50,_0xddbc('0x1c'));_0x2d366d(_0x193c84[_0xddbc('0x23')][_0xddbc('0x20')]);}})['catch'](function(_0x4bccd1){logger['error'](_0xddbc('0x21'),_0x5c1d50,_0x4bccd1);_0x19f977(_0x4bccd1);});});}function respondWithStatusCode(_0x2f58cd,_0x2db65f){_0x2db65f=_0x2db65f||0xcc;return function(_0x37c6f5){if(_0x37c6f5){return _0x2f58cd[_0xddbc('0x24')](_0x2db65f);}return _0x2f58cd[_0xddbc('0x25')](_0x2db65f)[_0xddbc('0x26')]();};}function respondWithResult(_0x58f1af,_0x2a7e0b){_0x2a7e0b=_0x2a7e0b||0xc8;return function(_0x136f64){if(_0x136f64){return _0x58f1af[_0xddbc('0x25')](_0x2a7e0b)[_0xddbc('0x27')](_0x136f64);}};}function respondWithFilteredResult(_0x3b1f06,_0xb4f6f5){return function(_0x16a720){if(_0x16a720){var _0x56e8a0=_0x16a720[_0xddbc('0x28')],_0xbd82d9=_0xb4f6f5['offset'],_0x158cc0=_0xb4f6f5[_0xddbc('0x29')]+_0xb4f6f5['limit'],_0x10ec5b;if(_0x158cc0>=_0x56e8a0){_0x158cc0=_0x56e8a0;_0x10ec5b=0xc8;}else{_0x10ec5b=0xce;}_0x3b1f06[_0xddbc('0x25')](_0x10ec5b);return _0x3b1f06[_0xddbc('0x2a')](_0xddbc('0x2b'),_0xbd82d9+'-'+_0x158cc0+'/'+_0x56e8a0)[_0xddbc('0x27')](_0x16a720);}return null;};}function patchUpdates(_0x2e261e){return function(_0x3c4eb6){try{jsonpatch[_0xddbc('0x2c')](_0x3c4eb6,_0x2e261e,!![]);}catch(_0x4296ae){return BPromise['reject'](_0x4296ae);}return _0x3c4eb6[_0xddbc('0x2d')]();};}function saveUpdates(_0x5934a2,_0x3286f1){return function(_0x35cf8e){if(_0x35cf8e){return _0x35cf8e[_0xddbc('0x2e')](_0x5934a2)[_0xddbc('0x1a')](function(_0x2f542e){return _0x2f542e;});}return null;};}function removeEntity(_0x3d723d,_0x3f6e1f){return function(_0xa6b4be){if(_0xa6b4be){return _0xa6b4be['destroy']()[_0xddbc('0x1a')](function(){_0x3d723d[_0xddbc('0x25')](0xcc)[_0xddbc('0x26')]();});}};}function handleEntityNotFound(_0x5528da,_0x4717da){return function(_0x4a5f35){if(!_0x4a5f35){_0x5528da[_0xddbc('0x24')](0x194);}return _0x4a5f35;};}function handleError(_0x3426ca,_0x5ba5f4){_0x5ba5f4=_0x5ba5f4||0x1f4;return function(_0x6e2420){logger['error'](_0x6e2420[_0xddbc('0x2f')]);if(_0x6e2420['name']){delete _0x6e2420['name'];}_0x3426ca[_0xddbc('0x25')](_0x5ba5f4)['send'](_0x6e2420);};}exports['index']=function(_0x457fe8,_0x8d2fbd){var _0x1fab0c={},_0x4cd505={},_0x4f7399={'count':0x0,'rows':[]};var _0x31663f=_['map'](db[_0xddbc('0x30')][_0xddbc('0x31')],function(_0x44a022){return{'name':_0x44a022[_0xddbc('0x32')],'type':_0x44a022[_0xddbc('0x33')][_0xddbc('0x34')]};});_0x4cd505[_0xddbc('0x35')]=_[_0xddbc('0x36')](_0x31663f,_0xddbc('0x37'));_0x4cd505[_0xddbc('0x38')]=_[_0xddbc('0x39')](_0x457fe8[_0xddbc('0x38')]);_0x4cd505[_0xddbc('0x3a')]=_[_0xddbc('0x3b')](_0x4cd505['model'],_0x4cd505[_0xddbc('0x38')]);_0x1fab0c[_0xddbc('0x3c')]=_[_0xddbc('0x3b')](_0x4cd505[_0xddbc('0x35')],qs[_0xddbc('0x3d')](_0x457fe8['query']['fields']));_0x1fab0c[_0xddbc('0x3c')]=_0x1fab0c[_0xddbc('0x3c')][_0xddbc('0x3e')]?_0x1fab0c[_0xddbc('0x3c')]:_0x4cd505['model'];if(!_0x457fe8[_0xddbc('0x38')][_0xddbc('0x3f')](_0xddbc('0x40'))){_0x1fab0c[_0xddbc('0x41')]=qs[_0xddbc('0x41')](_0x457fe8[_0xddbc('0x38')][_0xddbc('0x41')]);_0x1fab0c[_0xddbc('0x29')]=qs['offset'](_0x457fe8[_0xddbc('0x38')][_0xddbc('0x29')]);}_0x1fab0c['order']=qs['sort'](_0x457fe8[_0xddbc('0x38')][_0xddbc('0x42')]);_0x1fab0c[_0xddbc('0x43')]=qs[_0xddbc('0x3a')](_[_0xddbc('0x44')](_0x457fe8['query'],_0x4cd505[_0xddbc('0x3a')]),_0x31663f);if(_0x457fe8['query'][_0xddbc('0x45')]){_0x1fab0c[_0xddbc('0x43')]=_['merge'](_0x1fab0c[_0xddbc('0x43')],{'$or':_[_0xddbc('0x36')](_0x31663f,function(_0x3dcfee){if(_0x3dcfee['type']!=='VIRTUAL'){var _0x521074={};_0x521074[_0x3dcfee[_0xddbc('0x37')]]={'$like':'%'+_0x457fe8['query']['filter']+'%'};return _0x521074;}})});}_0x1fab0c=_['merge']({},_0x1fab0c,_0x457fe8[_0xddbc('0x46')]);var _0xe8c572={'where':_0x1fab0c[_0xddbc('0x43')]};return db[_0xddbc('0x30')][_0xddbc('0x28')](_0xe8c572)[_0xddbc('0x1a')](function(_0x198e84){_0x4f7399[_0xddbc('0x28')]=_0x198e84;if(_0x457fe8[_0xddbc('0x38')]['includeAll']){_0x1fab0c[_0xddbc('0x47')]=[{'all':!![]}];}return db[_0xddbc('0x30')][_0xddbc('0x48')](_0x1fab0c);})[_0xddbc('0x1a')](function(_0x4c2254){_0x4f7399[_0xddbc('0x49')]=_0x4c2254;return _0x4f7399;})[_0xddbc('0x1a')](respondWithFilteredResult(_0x8d2fbd,_0x1fab0c))[_0xddbc('0x4a')](handleError(_0x8d2fbd,null));};exports['show']=function(_0x2115ea,_0x1fa0bd){var _0x2325c4={'raw':!![],'where':{'id':_0x2115ea[_0xddbc('0x4b')]['id']}},_0x3daea4={};_0x3daea4['model']=_[_0xddbc('0x39')](db[_0xddbc('0x30')][_0xddbc('0x31')]);_0x3daea4['query']=_[_0xddbc('0x39')](_0x2115ea[_0xddbc('0x38')]);_0x3daea4[_0xddbc('0x3a')]=_[_0xddbc('0x3b')](_0x3daea4[_0xddbc('0x35')],_0x3daea4[_0xddbc('0x38')]);_0x2325c4['attributes']=_['intersection'](_0x3daea4[_0xddbc('0x35')],qs['fields'](_0x2115ea[_0xddbc('0x38')][_0xddbc('0x3d')]));_0x2325c4[_0xddbc('0x3c')]=_0x2325c4[_0xddbc('0x3c')]['length']?_0x2325c4[_0xddbc('0x3c')]:_0x3daea4[_0xddbc('0x35')];if(_0x2115ea[_0xddbc('0x38')][_0xddbc('0x4c')]){_0x2325c4['include']=[{'all':!![]}];}_0x2325c4=_[_0xddbc('0x4d')]({},_0x2325c4,_0x2115ea[_0xddbc('0x46')]);return db[_0xddbc('0x30')][_0xddbc('0x4e')](_0x2325c4)[_0xddbc('0x1a')](handleEntityNotFound(_0x1fa0bd,null))[_0xddbc('0x1a')](respondWithResult(_0x1fa0bd,null))[_0xddbc('0x4a')](handleError(_0x1fa0bd,null));};exports['create']=function(_0x1df983,_0x41aaae){return db[_0xddbc('0x30')][_0xddbc('0x4f')](_0x1df983['body'],{})[_0xddbc('0x1a')](respondWithResult(_0x41aaae,0xc9))[_0xddbc('0x4a')](handleError(_0x41aaae,null));};exports['update']=function(_0x5281a8,_0x34a513){if(_0x5281a8[_0xddbc('0x50')]['id']){delete _0x5281a8[_0xddbc('0x50')]['id'];}return db[_0xddbc('0x30')][_0xddbc('0x4e')]({'where':{'id':_0x5281a8['params']['id']}})[_0xddbc('0x1a')](handleEntityNotFound(_0x34a513,null))[_0xddbc('0x1a')](saveUpdates(_0x5281a8['body'],null))[_0xddbc('0x1a')](respondWithResult(_0x34a513,null))[_0xddbc('0x4a')](handleError(_0x34a513,null));};exports[_0xddbc('0x51')]=function(_0x221039,_0x376950){return db['ChatGroup'][_0xddbc('0x4e')]({'where':{'id':_0x221039[_0xddbc('0x4b')]['id']}})[_0xddbc('0x1a')](handleEntityNotFound(_0x376950,null))[_0xddbc('0x1a')](removeEntity(_0x376950,null))[_0xddbc('0x4a')](handleError(_0x376950,null));};exports['describe']=function(_0x59d625,_0xfca5d1){return db[_0xddbc('0x30')][_0xddbc('0x52')]()[_0xddbc('0x1a')](respondWithResult(_0xfca5d1,null))['catch'](handleError(_0xfca5d1,null));};exports[_0xddbc('0x53')]=function(_0x47d0ab,_0x125c95,_0x5806a1){return db['ChatInternalMessage'][_0xddbc('0x28')]({'where':{'ChatGroupId':_0x47d0ab[_0xddbc('0x4b')]['id'],'ToId':_0x47d0ab[_0xddbc('0x54')]['id'],'read':![]}})[_0xddbc('0x1a')](function(_0x39b689){return{'id':_[_0xddbc('0x55')](_0x47d0ab['params']['id']),'count':_0x39b689};})[_0xddbc('0x1a')](respondWithResult(_0x125c95,null))[_0xddbc('0x4a')](handleError(_0x125c95,null));};exports[_0xddbc('0x56')]=function(_0x1883da,_0x54db01,_0x59421a){return db[_0xddbc('0x30')][_0xddbc('0x4e')]({'where':{'id':_0x1883da[_0xddbc('0x4b')]['id']}})[_0xddbc('0x1a')](handleEntityNotFound(_0x54db01,null))['then'](function(_0x1d3d68){if(_0x1d3d68){return _0x1d3d68[_0xddbc('0x56')](_0x1883da[_0xddbc('0x50')]['ids'],_[_0xddbc('0x57')](_0x1883da[_0xddbc('0x50')],['ids','id'])||{});}})[_0xddbc('0x1a')](respondWithResult(_0x54db01,null))[_0xddbc('0x4a')](handleError(_0x54db01,null));};exports['getMembers']=function(_0x589679,_0x5b1dae,_0x305add){var _0x1959e0={};var _0x5b67b2={};var _0x13f139;var _0x2d3f66;return db[_0xddbc('0x30')][_0xddbc('0x58')]({'where':{'id':_0x589679[_0xddbc('0x4b')]['id']}})['then'](handleEntityNotFound(_0x5b1dae,null))[_0xddbc('0x1a')](function(_0x59d3a3){if(_0x59d3a3){_0x13f139=_0x59d3a3;_0x5b67b2[_0xddbc('0x35')]=_[_0xddbc('0x39')](db[_0xddbc('0x59')][_0xddbc('0x31')]);_0x5b67b2['query']=_[_0xddbc('0x39')](_0x589679[_0xddbc('0x38')]);_0x5b67b2[_0xddbc('0x3a')]=_[_0xddbc('0x3b')](_0x5b67b2[_0xddbc('0x35')],_0x5b67b2[_0xddbc('0x38')]);_0x1959e0['attributes']=_[_0xddbc('0x3b')](_0x5b67b2['model'],qs['fields'](_0x589679[_0xddbc('0x38')][_0xddbc('0x3d')]));_0x1959e0[_0xddbc('0x3c')]=_0x1959e0[_0xddbc('0x3c')][_0xddbc('0x3e')]?_0x1959e0[_0xddbc('0x3c')]:_0x5b67b2[_0xddbc('0x35')];_0x1959e0[_0xddbc('0x5a')]=qs[_0xddbc('0x42')](_0x589679[_0xddbc('0x38')][_0xddbc('0x42')]);_0x1959e0[_0xddbc('0x43')]=qs[_0xddbc('0x3a')](_[_0xddbc('0x44')](_0x589679['query'],_0x5b67b2[_0xddbc('0x3a')]));if(_0x589679['query'][_0xddbc('0x45')]){_0x1959e0[_0xddbc('0x43')]=_[_0xddbc('0x4d')](_0x1959e0[_0xddbc('0x43')],{'$or':_[_0xddbc('0x36')](_0x1959e0['attributes'],function(_0x5b63e3){var _0x358c10={};_0x358c10[_0x5b63e3]={'$like':'%'+_0x589679[_0xddbc('0x38')][_0xddbc('0x45')]+'%'};return _0x358c10;})});}_0x1959e0=_[_0xddbc('0x4d')]({},_0x1959e0,_0x589679[_0xddbc('0x46')]);return _0x13f139[_0xddbc('0x5b')](_0x1959e0);}})[_0xddbc('0x1a')](function(_0x257c6b){if(_0x257c6b){_0x2d3f66=_0x257c6b[_0xddbc('0x3e')];if(!_0x589679['query'][_0xddbc('0x3f')](_0xddbc('0x40'))){_0x1959e0[_0xddbc('0x41')]=qs[_0xddbc('0x41')](_0x589679['query'][_0xddbc('0x41')]);_0x1959e0[_0xddbc('0x29')]=qs[_0xddbc('0x29')](_0x589679[_0xddbc('0x38')][_0xddbc('0x29')]);}return _0x13f139['getMembers'](_0x1959e0);}})[_0xddbc('0x1a')](function(_0x1533e6){if(_0x1533e6){return _0x1533e6?{'count':_0x2d3f66,'rows':_0x1533e6}:null;}})[_0xddbc('0x1a')](respondWithResult(_0x5b1dae,null))['catch'](handleError(_0x5b1dae,null));};exports[_0xddbc('0x5c')]=function(_0x5c1b76,_0x59da73,_0x65190f){return db[_0xddbc('0x30')][_0xddbc('0x4e')]({'where':{'id':_0x5c1b76['params']['id']}})[_0xddbc('0x1a')](handleEntityNotFound(_0x59da73,null))['then'](function(_0x3c1522){if(_0x3c1522){return _0x3c1522[_0xddbc('0x5c')](_0x5c1b76[_0xddbc('0x38')]['ids']);}})[_0xddbc('0x1a')](respondWithStatusCode(_0x59da73,null))[_0xddbc('0x4a')](handleError(_0x59da73,null));};exports[_0xddbc('0x5d')]=function(_0x294b6d,_0x34fd1f,_0x3583e4){if(_0x294b6d[_0xddbc('0x50')]['id']){delete _0x294b6d[_0xddbc('0x50')]['id'];}return db['ChatGroup'][_0xddbc('0x4e')]({'where':{'id':_0x294b6d[_0xddbc('0x4b')]['id']}})[_0xddbc('0x1a')](handleEntityNotFound(_0x34fd1f,null))[_0xddbc('0x1a')](function(_0x53c660){if(_0x53c660){_0x294b6d['body'][_0xddbc('0x5e')]=_0x53c660['id'];return db[_0xddbc('0x5f')][_0xddbc('0x4f')](_0x294b6d[_0xddbc('0x50')]);}})[_0xddbc('0x1a')](respondWithResult(_0x34fd1f,null))[_0xddbc('0x4a')](handleError(_0x34fd1f,null));};exports[_0xddbc('0x60')]=function(_0x39b39c,_0x4a6f14,_0x38f66b){var _0x141ee5={};var _0x3bed88={};var _0x4612c2;var _0x1774b9;return db[_0xddbc('0x30')][_0xddbc('0x58')]({'where':{'id':_0x39b39c[_0xddbc('0x4b')]['id']}})[_0xddbc('0x1a')](handleEntityNotFound(_0x4a6f14,null))[_0xddbc('0x1a')](function(_0xffc01){if(_0xffc01){_0x4612c2=_0xffc01;_0x3bed88['model']=_['keys'](db[_0xddbc('0x5f')]['rawAttributes']);_0x3bed88['query']=_['keys'](_0x39b39c[_0xddbc('0x38')]);_0x3bed88[_0xddbc('0x3a')]=_[_0xddbc('0x3b')](_0x3bed88[_0xddbc('0x35')],_0x3bed88[_0xddbc('0x38')]);_0x141ee5['attributes']=_[_0xddbc('0x3b')](_0x3bed88[_0xddbc('0x35')],qs['fields'](_0x39b39c[_0xddbc('0x38')]['fields']));_0x141ee5[_0xddbc('0x3c')]=_0x141ee5['attributes'][_0xddbc('0x3e')]?_0x141ee5['attributes']:_0x3bed88[_0xddbc('0x35')];_0x141ee5['order']=qs['sort'](_0x39b39c[_0xddbc('0x38')][_0xddbc('0x42')]);_0x141ee5[_0xddbc('0x43')]=qs['filters'](_[_0xddbc('0x44')](_0x39b39c[_0xddbc('0x38')],_0x3bed88[_0xddbc('0x3a')]));if(_0x39b39c[_0xddbc('0x38')][_0xddbc('0x45')]){_0x141ee5['where']=_[_0xddbc('0x4d')](_0x141ee5[_0xddbc('0x43')],{'$or':_[_0xddbc('0x36')](_0x141ee5['attributes'],function(_0x5ad362){var _0x58c68f={};_0x58c68f[_0x5ad362]={'$like':'%'+_0x39b39c['query']['filter']+'%'};return _0x58c68f;})});}if(_0x39b39c[_0xddbc('0x38')][_0xddbc('0x61')]){var _0x20a360=_0x39b39c[_0xddbc('0x38')][_0xddbc('0x61')]['split'](',');var _0x2b8b4c={};_0x2b8b4c[_0x20a360[0x0]]={'$gte':moment(_0x20a360[0x1])['format']('YYYY-MM-DD\x20HH:mm:ss')};_0x141ee5[_0xddbc('0x43')]=_[_0xddbc('0x4d')](_0x141ee5[_0xddbc('0x43')],_0x2b8b4c);}_0x141ee5=_[_0xddbc('0x4d')]({},_0x141ee5,_0x39b39c[_0xddbc('0x46')]);return _0x4612c2[_0xddbc('0x60')](_0x141ee5);}})[_0xddbc('0x1a')](function(_0x4d469d){if(_0x4d469d){_0x1774b9=_0x4d469d[_0xddbc('0x3e')];if(!_0x39b39c['query']['hasOwnProperty'](_0xddbc('0x40'))){_0x141ee5[_0xddbc('0x41')]=qs['limit'](_0x39b39c[_0xddbc('0x38')][_0xddbc('0x41')]);_0x141ee5[_0xddbc('0x29')]=qs[_0xddbc('0x29')](_0x39b39c['query'][_0xddbc('0x29')]);}return _0x4612c2['getMessages'](_0x141ee5);}})[_0xddbc('0x1a')](function(_0x1c8af4){if(_0x1c8af4){return _0x1c8af4?{'count':_0x1774b9,'rows':_0x1c8af4}:null;}})[_0xddbc('0x1a')](respondWithResult(_0x4a6f14,null))['catch'](handleError(_0x4a6f14,null));};
\ No newline at end of file
+var _0xc631=['update','destroy','then','sendStatus','stack','name','send','index','map','ChatGroup','rawAttributes','fieldName','type','key','keys','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','filter','where','merge','VIRTUAL','options','includeAll','include','findAll','rows','show','params','create','body','find','catch','describe','ChatInternalMessage','user','toInteger','ids','omit','getMembers','findOne','User','order','pick','removeMembers','addMessage','ChatGroupId','getMessages','$gte','split','format','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','path','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./chatGroup.socket','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject'];(function(_0x39e84d,_0x11931d){var _0x1991bc=function(_0xc81e32){while(--_0xc81e32){_0x39e84d['push'](_0x39e84d['shift']());}};_0x1991bc(++_0x11931d);}(_0xc631,0x163));var _0x1c63=function(_0x3bc326,_0x3e5ab9){_0x3bc326=_0x3bc326-0x0;var _0x5c6973=_0xc631[_0x3bc326];return _0x5c6973;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x1c63('0x0'));var zipdir=require(_0x1c63('0x1'));var jsonpatch=require(_0x1c63('0x2'));var rp=require(_0x1c63('0x3'));var moment=require(_0x1c63('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x1c63('0x5'));var util=require('util');var path=require(_0x1c63('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x1c63('0x7'));var fs=require('fs');var fs_extra=require(_0x1c63('0x8'));var _=require(_0x1c63('0x9'));var squel=require(_0x1c63('0xa'));var crypto=require(_0x1c63('0xb'));var jsforce=require(_0x1c63('0xc'));var deskjs=require(_0x1c63('0xd'));var toCsv=require(_0x1c63('0xe'));var querystring=require(_0x1c63('0xf'));var Papa=require(_0x1c63('0x10'));var Redis=require('ioredis');var authService=require(_0x1c63('0x11'));var qs=require(_0x1c63('0x12'));var as=require(_0x1c63('0x13'));var hardwareService=require(_0x1c63('0x14'));var logger=require(_0x1c63('0x15'))(_0x1c63('0x16'));var utils=require('../../config/utils');var config=require(_0x1c63('0x17'));var licenseUtil=require(_0x1c63('0x18'));var db=require(_0x1c63('0x19'))['db'];config['redis']=_['defaults'](config[_0x1c63('0x1a')],{'host':_0x1c63('0x1b'),'port':0x18eb});var socket=require(_0x1c63('0x1c'))(new Redis(config[_0x1c63('0x1a')]));require(_0x1c63('0x1d'))['register'](socket);function respondWithStatusCode(_0x3d832d,_0x52e7c5){_0x52e7c5=_0x52e7c5||0xcc;return function(_0x359a52){if(_0x359a52){return _0x3d832d['sendStatus'](_0x52e7c5);}return _0x3d832d[_0x1c63('0x1e')](_0x52e7c5)[_0x1c63('0x1f')]();};}function respondWithResult(_0x4f7aa0,_0x33b3b7){_0x33b3b7=_0x33b3b7||0xc8;return function(_0x893b04){if(_0x893b04){return _0x4f7aa0[_0x1c63('0x1e')](_0x33b3b7)[_0x1c63('0x20')](_0x893b04);}};}function respondWithFilteredResult(_0x5b567b,_0x32d23f){return function(_0xbcf985){if(_0xbcf985){var _0x599a75=typeof _0x32d23f['offset']===_0x1c63('0x21')&&typeof _0x32d23f[_0x1c63('0x22')]===_0x1c63('0x21');var _0x4ce014=_0xbcf985[_0x1c63('0x23')];var _0x53b7ad=_0x599a75?0x0:_0x32d23f[_0x1c63('0x24')];var _0xfa6bcc=_0x599a75?_0xbcf985[_0x1c63('0x23')]:_0x32d23f['offset']+_0x32d23f[_0x1c63('0x22')];var _0x3cda60;if(_0xfa6bcc>=_0x4ce014){_0xfa6bcc=_0x4ce014;_0x3cda60=0xc8;}else{_0x3cda60=0xce;}_0x5b567b['status'](_0x3cda60);return _0x5b567b[_0x1c63('0x25')](_0x1c63('0x26'),_0x53b7ad+'-'+_0xfa6bcc+'/'+_0x4ce014)[_0x1c63('0x20')](_0xbcf985);}return null;};}function patchUpdates(_0x3c1c75){return function(_0x293e16){try{jsonpatch[_0x1c63('0x27')](_0x293e16,_0x3c1c75,!![]);}catch(_0x35671a){return BPromise[_0x1c63('0x28')](_0x35671a);}return _0x293e16['save']();};}function saveUpdates(_0x5d396d,_0x4226f9){return function(_0x8356f6){if(_0x8356f6){return _0x8356f6[_0x1c63('0x29')](_0x5d396d)['then'](function(_0x1b6a74){return _0x1b6a74;});}return null;};}function removeEntity(_0x55d049,_0x1c69a3){return function(_0x1641c2){if(_0x1641c2){return _0x1641c2[_0x1c63('0x2a')]()[_0x1c63('0x2b')](function(){_0x55d049[_0x1c63('0x1e')](0xcc)[_0x1c63('0x1f')]();});}};}function handleEntityNotFound(_0x461aff,_0x285bc6){return function(_0x3c0351){if(!_0x3c0351){_0x461aff[_0x1c63('0x2c')](0x194);}return _0x3c0351;};}function handleError(_0x25a23a,_0x5d3696){_0x5d3696=_0x5d3696||0x1f4;return function(_0x24d824){logger['error'](_0x24d824[_0x1c63('0x2d')]);if(_0x24d824[_0x1c63('0x2e')]){delete _0x24d824[_0x1c63('0x2e')];}_0x25a23a[_0x1c63('0x1e')](_0x5d3696)[_0x1c63('0x2f')](_0x24d824);};}exports[_0x1c63('0x30')]=function(_0xd4f8f9,_0x1fe4be){var _0xa2b2b6={},_0xce5092={},_0x19e344={'count':0x0,'rows':[]};var _0x372d15=_[_0x1c63('0x31')](db[_0x1c63('0x32')][_0x1c63('0x33')],function(_0x310085){return{'name':_0x310085[_0x1c63('0x34')],'type':_0x310085[_0x1c63('0x35')][_0x1c63('0x36')]};});_0xce5092['model']=_['map'](_0x372d15,'name');_0xce5092['query']=_[_0x1c63('0x37')](_0xd4f8f9[_0x1c63('0x38')]);_0xce5092[_0x1c63('0x39')]=_[_0x1c63('0x3a')](_0xce5092[_0x1c63('0x3b')],_0xce5092[_0x1c63('0x38')]);_0xa2b2b6[_0x1c63('0x3c')]=_[_0x1c63('0x3a')](_0xce5092[_0x1c63('0x3b')],qs[_0x1c63('0x3d')](_0xd4f8f9['query']['fields']));_0xa2b2b6[_0x1c63('0x3c')]=_0xa2b2b6[_0x1c63('0x3c')][_0x1c63('0x3e')]?_0xa2b2b6[_0x1c63('0x3c')]:_0xce5092[_0x1c63('0x3b')];if(!_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x3f')](_0x1c63('0x40'))){_0xa2b2b6[_0x1c63('0x22')]=qs[_0x1c63('0x22')](_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x22')]);_0xa2b2b6[_0x1c63('0x24')]=qs[_0x1c63('0x24')](_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x24')]);}_0xa2b2b6['order']=qs['sort'](_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x41')]);_0xa2b2b6['where']=qs[_0x1c63('0x39')](_['pick'](_0xd4f8f9['query'],_0xce5092['filters']),_0x372d15);if(_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x42')]){_0xa2b2b6[_0x1c63('0x43')]=_[_0x1c63('0x44')](_0xa2b2b6[_0x1c63('0x43')],{'$or':_[_0x1c63('0x31')](_0x372d15,function(_0x33355b){if(_0x33355b['type']!==_0x1c63('0x45')){var _0x3e96ce={};_0x3e96ce[_0x33355b[_0x1c63('0x2e')]]={'$like':'%'+_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x42')]+'%'};return _0x3e96ce;}})});}_0xa2b2b6=_['merge']({},_0xa2b2b6,_0xd4f8f9[_0x1c63('0x46')]);var _0x4d4ef2={'where':_0xa2b2b6['where']};return db['ChatGroup']['count'](_0x4d4ef2)['then'](function(_0x10eb4e){_0x19e344[_0x1c63('0x23')]=_0x10eb4e;if(_0xd4f8f9[_0x1c63('0x38')][_0x1c63('0x47')]){_0xa2b2b6[_0x1c63('0x48')]=[{'all':!![]}];}return db[_0x1c63('0x32')][_0x1c63('0x49')](_0xa2b2b6);})['then'](function(_0xceff6e){_0x19e344[_0x1c63('0x4a')]=_0xceff6e;return _0x19e344;})['then'](respondWithFilteredResult(_0x1fe4be,_0xa2b2b6))['catch'](handleError(_0x1fe4be,null));};exports[_0x1c63('0x4b')]=function(_0x28fc88,_0x137ead){var _0x2a9214={'raw':!![],'where':{'id':_0x28fc88[_0x1c63('0x4c')]['id']}},_0xc7ef66={};_0xc7ef66[_0x1c63('0x3b')]=_['keys'](db[_0x1c63('0x32')][_0x1c63('0x33')]);_0xc7ef66[_0x1c63('0x38')]=_[_0x1c63('0x37')](_0x28fc88['query']);_0xc7ef66['filters']=_[_0x1c63('0x3a')](_0xc7ef66[_0x1c63('0x3b')],_0xc7ef66['query']);_0x2a9214[_0x1c63('0x3c')]=_[_0x1c63('0x3a')](_0xc7ef66['model'],qs['fields'](_0x28fc88[_0x1c63('0x38')][_0x1c63('0x3d')]));_0x2a9214[_0x1c63('0x3c')]=_0x2a9214[_0x1c63('0x3c')][_0x1c63('0x3e')]?_0x2a9214['attributes']:_0xc7ef66['model'];if(_0x28fc88['query'][_0x1c63('0x47')]){_0x2a9214[_0x1c63('0x48')]=[{'all':!![]}];}_0x2a9214=_[_0x1c63('0x44')]({},_0x2a9214,_0x28fc88[_0x1c63('0x46')]);return db[_0x1c63('0x32')]['find'](_0x2a9214)[_0x1c63('0x2b')](handleEntityNotFound(_0x137ead,null))[_0x1c63('0x2b')](respondWithResult(_0x137ead,null))['catch'](handleError(_0x137ead,null));};exports['create']=function(_0x1e2c55,_0x32254c){return db[_0x1c63('0x32')][_0x1c63('0x4d')](_0x1e2c55[_0x1c63('0x4e')],{})['then'](respondWithResult(_0x32254c,0xc9))['catch'](handleError(_0x32254c,null));};exports[_0x1c63('0x29')]=function(_0x19dc79,_0x5e1edf){if(_0x19dc79[_0x1c63('0x4e')]['id']){delete _0x19dc79[_0x1c63('0x4e')]['id'];}return db[_0x1c63('0x32')][_0x1c63('0x4f')]({'where':{'id':_0x19dc79['params']['id']}})[_0x1c63('0x2b')](handleEntityNotFound(_0x5e1edf,null))[_0x1c63('0x2b')](saveUpdates(_0x19dc79[_0x1c63('0x4e')],null))['then'](respondWithResult(_0x5e1edf,null))[_0x1c63('0x50')](handleError(_0x5e1edf,null));};exports[_0x1c63('0x2a')]=function(_0x814df0,_0x47ba6b){return db[_0x1c63('0x32')][_0x1c63('0x4f')]({'where':{'id':_0x814df0[_0x1c63('0x4c')]['id']}})[_0x1c63('0x2b')](handleEntityNotFound(_0x47ba6b,null))[_0x1c63('0x2b')](removeEntity(_0x47ba6b,null))['catch'](handleError(_0x47ba6b,null));};exports[_0x1c63('0x51')]=function(_0x4dae2f,_0x2e2af0){return db[_0x1c63('0x32')][_0x1c63('0x51')]()[_0x1c63('0x2b')](respondWithResult(_0x2e2af0,null))[_0x1c63('0x50')](handleError(_0x2e2af0,null));};exports['getUnread']=function(_0x437648,_0x2711d3,_0x4b32a0){return db[_0x1c63('0x52')][_0x1c63('0x23')]({'where':{'ChatGroupId':_0x437648[_0x1c63('0x4c')]['id'],'ToId':_0x437648[_0x1c63('0x53')]['id'],'read':![]}})[_0x1c63('0x2b')](function(_0x368cee){return{'id':_[_0x1c63('0x54')](_0x437648[_0x1c63('0x4c')]['id']),'count':_0x368cee};})[_0x1c63('0x2b')](respondWithResult(_0x2711d3,null))[_0x1c63('0x50')](handleError(_0x2711d3,null));};exports['addMembers']=function(_0x8265eb,_0x235fd9,_0x43e1bc){return db[_0x1c63('0x32')][_0x1c63('0x4f')]({'where':{'id':_0x8265eb[_0x1c63('0x4c')]['id']}})[_0x1c63('0x2b')](handleEntityNotFound(_0x235fd9,null))['then'](function(_0x82d5cb){if(_0x82d5cb){return _0x82d5cb['addMembers'](_0x8265eb['body'][_0x1c63('0x55')],_[_0x1c63('0x56')](_0x8265eb[_0x1c63('0x4e')],[_0x1c63('0x55'),'id'])||{});}})[_0x1c63('0x2b')](respondWithResult(_0x235fd9,null))[_0x1c63('0x50')](handleError(_0x235fd9,null));};exports[_0x1c63('0x57')]=function(_0x431a41,_0x18e782,_0x3c1530){var _0x344f95={};var _0x338b9e={};var _0x106bad;var _0x525e0f;return db['ChatGroup'][_0x1c63('0x58')]({'where':{'id':_0x431a41[_0x1c63('0x4c')]['id']}})[_0x1c63('0x2b')](handleEntityNotFound(_0x18e782,null))[_0x1c63('0x2b')](function(_0x2f01bb){if(_0x2f01bb){_0x106bad=_0x2f01bb;_0x338b9e['model']=_['keys'](db[_0x1c63('0x59')][_0x1c63('0x33')]);_0x338b9e[_0x1c63('0x38')]=_[_0x1c63('0x37')](_0x431a41['query']);_0x338b9e['filters']=_[_0x1c63('0x3a')](_0x338b9e[_0x1c63('0x3b')],_0x338b9e['query']);_0x344f95[_0x1c63('0x3c')]=_[_0x1c63('0x3a')](_0x338b9e[_0x1c63('0x3b')],qs[_0x1c63('0x3d')](_0x431a41[_0x1c63('0x38')][_0x1c63('0x3d')]));_0x344f95[_0x1c63('0x3c')]=_0x344f95[_0x1c63('0x3c')][_0x1c63('0x3e')]?_0x344f95[_0x1c63('0x3c')]:_0x338b9e[_0x1c63('0x3b')];_0x344f95[_0x1c63('0x5a')]=qs[_0x1c63('0x41')](_0x431a41[_0x1c63('0x38')][_0x1c63('0x41')]);_0x344f95[_0x1c63('0x43')]=qs[_0x1c63('0x39')](_[_0x1c63('0x5b')](_0x431a41[_0x1c63('0x38')],_0x338b9e[_0x1c63('0x39')]));if(_0x431a41['query']['filter']){_0x344f95[_0x1c63('0x43')]=_[_0x1c63('0x44')](_0x344f95[_0x1c63('0x43')],{'$or':_[_0x1c63('0x31')](_0x344f95[_0x1c63('0x3c')],function(_0x3b19a7){var _0x5ca7c1={};_0x5ca7c1[_0x3b19a7]={'$like':'%'+_0x431a41[_0x1c63('0x38')][_0x1c63('0x42')]+'%'};return _0x5ca7c1;})});}_0x344f95=_['merge']({},_0x344f95,_0x431a41['options']);return _0x106bad[_0x1c63('0x57')](_0x344f95);}})['then'](function(_0x7e0baa){if(_0x7e0baa){_0x525e0f=_0x7e0baa[_0x1c63('0x3e')];if(!_0x431a41[_0x1c63('0x38')][_0x1c63('0x3f')](_0x1c63('0x40'))){_0x344f95[_0x1c63('0x22')]=qs[_0x1c63('0x22')](_0x431a41['query']['limit']);_0x344f95[_0x1c63('0x24')]=qs[_0x1c63('0x24')](_0x431a41[_0x1c63('0x38')][_0x1c63('0x24')]);}return _0x106bad[_0x1c63('0x57')](_0x344f95);}})[_0x1c63('0x2b')](function(_0x23a08e){if(_0x23a08e){return _0x23a08e?{'count':_0x525e0f,'rows':_0x23a08e}:null;}})[_0x1c63('0x2b')](respondWithResult(_0x18e782,null))[_0x1c63('0x50')](handleError(_0x18e782,null));};exports[_0x1c63('0x5c')]=function(_0x4fa46c,_0x5bc2c1,_0x56b14e){return db[_0x1c63('0x32')][_0x1c63('0x4f')]({'where':{'id':_0x4fa46c['params']['id']}})[_0x1c63('0x2b')](handleEntityNotFound(_0x5bc2c1,null))[_0x1c63('0x2b')](function(_0x4237cf){if(_0x4237cf){return _0x4237cf[_0x1c63('0x5c')](_0x4fa46c[_0x1c63('0x38')][_0x1c63('0x55')]);}})[_0x1c63('0x2b')](respondWithStatusCode(_0x5bc2c1,null))[_0x1c63('0x50')](handleError(_0x5bc2c1,null));};exports[_0x1c63('0x5d')]=function(_0x1ca6c7,_0x50b632,_0x2f5d2d){if(_0x1ca6c7[_0x1c63('0x4e')]['id']){delete _0x1ca6c7[_0x1c63('0x4e')]['id'];}return db[_0x1c63('0x32')][_0x1c63('0x4f')]({'where':{'id':_0x1ca6c7[_0x1c63('0x4c')]['id']}})[_0x1c63('0x2b')](handleEntityNotFound(_0x50b632,null))[_0x1c63('0x2b')](function(_0x3a9693){if(_0x3a9693){_0x1ca6c7['body'][_0x1c63('0x5e')]=_0x3a9693['id'];return db[_0x1c63('0x52')]['create'](_0x1ca6c7['body']);}})[_0x1c63('0x2b')](respondWithResult(_0x50b632,null))[_0x1c63('0x50')](handleError(_0x50b632,null));};exports[_0x1c63('0x5f')]=function(_0x437a84,_0x1d0e94,_0x22cb21){var _0x4d69b2={};var _0x282de9={};var _0x22d759;var _0x9cd1b3;return db[_0x1c63('0x32')][_0x1c63('0x58')]({'where':{'id':_0x437a84[_0x1c63('0x4c')]['id']}})['then'](handleEntityNotFound(_0x1d0e94,null))['then'](function(_0x3fb669){if(_0x3fb669){_0x22d759=_0x3fb669;_0x282de9['model']=_['keys'](db[_0x1c63('0x52')][_0x1c63('0x33')]);_0x282de9[_0x1c63('0x38')]=_['keys'](_0x437a84[_0x1c63('0x38')]);_0x282de9[_0x1c63('0x39')]=_[_0x1c63('0x3a')](_0x282de9[_0x1c63('0x3b')],_0x282de9[_0x1c63('0x38')]);_0x4d69b2['attributes']=_[_0x1c63('0x3a')](_0x282de9[_0x1c63('0x3b')],qs[_0x1c63('0x3d')](_0x437a84['query'][_0x1c63('0x3d')]));_0x4d69b2[_0x1c63('0x3c')]=_0x4d69b2[_0x1c63('0x3c')]['length']?_0x4d69b2[_0x1c63('0x3c')]:_0x282de9[_0x1c63('0x3b')];_0x4d69b2['order']=qs[_0x1c63('0x41')](_0x437a84[_0x1c63('0x38')][_0x1c63('0x41')]);_0x4d69b2['where']=qs[_0x1c63('0x39')](_[_0x1c63('0x5b')](_0x437a84[_0x1c63('0x38')],_0x282de9['filters']));if(_0x437a84[_0x1c63('0x38')]['filter']){_0x4d69b2['where']=_['merge'](_0x4d69b2[_0x1c63('0x43')],{'$or':_[_0x1c63('0x31')](_0x4d69b2[_0x1c63('0x3c')],function(_0x42df26){var _0x378427={};_0x378427[_0x42df26]={'$like':'%'+_0x437a84['query'][_0x1c63('0x42')]+'%'};return _0x378427;})});}if(_0x437a84[_0x1c63('0x38')]['$gte']){var _0x24ab99=_0x437a84[_0x1c63('0x38')][_0x1c63('0x60')][_0x1c63('0x61')](',');var _0x29dca5={};_0x29dca5[_0x24ab99[0x0]]={'$gte':moment(_0x24ab99[0x1])[_0x1c63('0x62')]('YYYY-MM-DD\x20HH:mm:ss')};_0x4d69b2['where']=_['merge'](_0x4d69b2[_0x1c63('0x43')],_0x29dca5);}_0x4d69b2=_[_0x1c63('0x44')]({},_0x4d69b2,_0x437a84[_0x1c63('0x46')]);return _0x22d759[_0x1c63('0x5f')](_0x4d69b2);}})[_0x1c63('0x2b')](function(_0xd59ae8){if(_0xd59ae8){_0x9cd1b3=_0xd59ae8[_0x1c63('0x3e')];if(!_0x437a84[_0x1c63('0x38')][_0x1c63('0x3f')]('nolimit')){_0x4d69b2[_0x1c63('0x22')]=qs[_0x1c63('0x22')](_0x437a84[_0x1c63('0x38')][_0x1c63('0x22')]);_0x4d69b2[_0x1c63('0x24')]=qs[_0x1c63('0x24')](_0x437a84['query'][_0x1c63('0x24')]);}return _0x22d759['getMessages'](_0x4d69b2);}})[_0x1c63('0x2b')](function(_0x1e5e1c){if(_0x1e5e1c){return _0x1e5e1c?{'count':_0x9cd1b3,'rows':_0x1e5e1c}:null;}})['then'](respondWithResult(_0x1d0e94,null))['catch'](handleError(_0x1d0e94,null));};
\ No newline at end of file