Skip to content

Commit b792652

Browse files
chrisbobbegnprice
authored andcommitted
api: Make ServerSettings a bit more "cooked"
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 #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.
1 parent 814bf18 commit b792652

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/api/settings/getServerSettings.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { ApiResponseSuccess } from '../transportTypes';
33
import { apiGet } from '../apiFetch';
44
import { ApiError } from '../apiErrors';
5+
import { ZulipVersion } from '../../utils/zulipVersion';
56

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

7273
export type ServerSettings = $ReadOnly<{|
7374
...ApiResponseServerSettings,
75+
+zulip_feature_level: number,
76+
+zulip_version: ZulipVersion,
7477
+realm_uri: URL,
7578
+realm_name: string,
79+
+realm_web_public_access_enabled: boolean,
7680
|}>;
7781

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

97101
return {
98102
...raw,
103+
zulip_feature_level: raw.zulip_feature_level ?? 0,
104+
zulip_version: new ZulipVersion(raw.zulip_version),
99105
realm_uri: new URL(raw.realm_uri),
100106
realm_name,
107+
realm_web_public_access_enabled: raw.realm_web_public_access_enabled ?? false,
101108
};
102109
}
103110

0 commit comments

Comments
 (0)