[Gekidou MM-39729] Websocket Events - hello, license, config (#5926)
* handle license changed * move inside trycatch * handle config changed * remove hello WS handler. Not needed for V2. https://community.mattermost.com/core/pl/9tom9ck3cty1pk9ft64m3jzj9w
This commit is contained in:
parent
3ea065b845
commit
9cb8cae8b5
2 changed files with 44 additions and 6 deletions
|
|
@ -24,6 +24,7 @@ import {handleNewPostEvent, handlePostDeleted, handlePostEdited, handlePostUnrea
|
|||
import {handlePreferenceChangedEvent, handlePreferencesChangedEvent, handlePreferencesDeletedEvent} from './preferences';
|
||||
import {handleAddCustomEmoji, handleReactionRemovedFromPostEvent, handleReactionAddedToPostEvent} from './reactions';
|
||||
import {handleUserRoleUpdatedEvent, handleTeamMemberRoleUpdatedEvent, handleRoleUpdatedEvent} from './roles';
|
||||
import {handleLicenseChangedEvent, handleConfigChangedEvent} from './system';
|
||||
import {handleLeaveTeamEvent, handleUserAddedToTeamEvent, handleUpdateTeamEvent} from './teams';
|
||||
import {handleUserUpdatedEvent, handleUserTypingEvent} from './users';
|
||||
|
||||
|
|
@ -294,11 +295,7 @@ export async function handleEvent(serverUrl: string, msg: WebSocketMessage) {
|
|||
case WebsocketEvents.TYPING:
|
||||
handleUserTypingEvent(serverUrl, msg);
|
||||
break;
|
||||
case WebsocketEvents.HELLO:
|
||||
break;
|
||||
|
||||
// handleHelloEvent(msg);
|
||||
// break;
|
||||
case WebsocketEvents.REACTION_ADDED:
|
||||
handleReactionAddedToPostEvent(serverUrl, msg);
|
||||
break;
|
||||
|
|
@ -312,13 +309,13 @@ export async function handleEvent(serverUrl: string, msg: WebSocketMessage) {
|
|||
break;
|
||||
|
||||
case WebsocketEvents.LICENSE_CHANGED:
|
||||
handleLicenseChangedEvent(serverUrl, msg);
|
||||
break;
|
||||
|
||||
// return dispatch(handleLicenseChangedEvent(msg));
|
||||
case WebsocketEvents.CONFIG_CHANGED:
|
||||
handleConfigChangedEvent(serverUrl, msg);
|
||||
break;
|
||||
|
||||
// return dispatch(handleConfigChangedEvent(msg));
|
||||
case WebsocketEvents.OPEN_DIALOG:
|
||||
break;
|
||||
|
||||
|
|
|
|||
41
app/actions/websocket/system.ts
Normal file
41
app/actions/websocket/system.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import {SYSTEM_IDENTIFIERS} from '@app/constants/database';
|
||||
import DatabaseManager from '@database/manager';
|
||||
|
||||
export async function handleLicenseChangedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
|
||||
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
|
||||
if (!operator) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const license = msg.data.license;
|
||||
const systems: IdValue[] = [{
|
||||
id: SYSTEM_IDENTIFIERS.LICENSE,
|
||||
value: JSON.stringify(license),
|
||||
}];
|
||||
await operator.handleSystem({systems, prepareRecordsOnly: false});
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleConfigChangedEvent(serverUrl: string, msg: WebSocketMessage): Promise<void> {
|
||||
const operator = DatabaseManager.serverDatabases[serverUrl]?.operator;
|
||||
if (!operator) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const config = msg.data.config;
|
||||
const systems: IdValue[] = [{
|
||||
id: SYSTEM_IDENTIFIERS.CONFIG,
|
||||
value: JSON.stringify(config),
|
||||
}];
|
||||
await operator.handleSystem({systems, prepareRecordsOnly: false});
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue