mattermost-mobile/app/actions/websocket/system.ts
Jason Frerich 9cb8cae8b5
[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
2022-02-10 08:16:25 -03:00

41 lines
1.3 KiB
TypeScript

// 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
}
}