[MM-50485] Implement ServerManager, introduce id concept for identifying servers/views (#2654)

* Implement ServerManager, introduce id concept for identifying servers/views

* REVERT ME (eventually): Move back to old logging

* PR feedback

* PR feedback

* Revert "REVERT ME (eventually): Move back to old logging"

This reverts commit 46954a5bbed4dd29e89ca9d5217bb75af2837bb3.

* Merge'd

* Use the correct method for Logger in ServerManager
This commit is contained in:
Devin Binnie
2023-04-05 16:30:50 -04:00
committed by GitHub
parent 862287edff
commit 53fb8c8fd3
19 changed files with 818 additions and 57 deletions

View File

@@ -1,14 +1,30 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {v4 as uuid} from 'uuid';
import {Team} from 'types/config';
import urlUtils from 'common/utils/url';
export class MattermostServer {
id: string;
name: string;
url: URL;
constructor(name: string, serverUrl: string) {
this.name = name;
this.url = urlUtils.parseURL(serverUrl)!;
url!: URL;
isPredefined: boolean;
constructor(server: Team, isPredefined = false) {
this.id = uuid();
this.name = server.name;
this.updateURL(server.url);
this.isPredefined = isPredefined;
if (!this.url) {
throw new Error('Invalid url for creating a server');
}
}
updateURL = (url: string) => {
this.url = urlUtils.parseURL(url)!;
if (!this.url) {
throw new Error('Invalid url for creating a server');
}