Skip to content

Commit

Permalink
server settings: Make ServerSettings a bit more "cooked"
Browse files Browse the repository at this point in the history
We don't currently use these three properties of the response, but
if we do, we'd want them in these more convenient forms for passing
around. (We will want to use zulip_version soon, though, for zulip#5102,
"Don't allow connecting to ancient servers.")

Not marking as NFC just because this will cause fresh errors if
zulip_version doesn't parse. There's no reason to suspect it
wouldn't parse, though.
  • Loading branch information
chrisbobbe committed Dec 7, 2022
1 parent 100c871 commit 984de23
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/settings/getServerSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { ApiResponseSuccess } from '../transportTypes';
import { apiGet } from '../apiFetch';
import { ApiError } from '../apiErrors';
import { ZulipVersion } from '../../utils/zulipVersion';

// This corresponds to AUTHENTICATION_FLAGS in zulip/zulip:zerver/models.py .
export type AuthenticationMethods = {
Expand Down Expand Up @@ -71,8 +72,11 @@ type ApiResponseServerSettings = {|

export type ServerSettings = $ReadOnly<{|
...ApiResponseServerSettings,
+zulip_feature_level: number,
+zulip_version: ZulipVersion,
+realm_uri: URL,
+realm_name: string,
+realm_web_public_access_enabled: boolean,
|}>;

/**
Expand All @@ -96,8 +100,11 @@ function transform(raw: ApiResponseServerSettings): ServerSettings {

return {
...raw,
zulip_feature_level: raw.zulip_feature_level ?? 0,
zulip_version: new ZulipVersion(raw.zulip_version),
realm_uri: new URL(raw.realm_uri),
realm_name,
realm_web_public_access_enabled: raw.realm_web_public_access_enabled ?? false,
};
}

Expand Down

0 comments on commit 984de23

Please sign in to comment.