Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api types: Update InitialDataRealm and RealmDataForUpdate to FL 237 #5806

Merged
merged 3 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/__tests__/lib/exampleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { randString, randInt } from '../../utils/misc';
import { makeUserId } from '../../api/idTypes';
import type { InitialData } from '../../api/apiTypes';
import { EventTypes, type UpdateMessageEvent } from '../../api/eventTypes';
import { CreateWebPublicStreamPolicy, EmailAddressVisibility } from '../../api/permissionsTypes';
import { CreateWebPublicStreamPolicy } from '../../api/permissionsTypes';
import type {
AccountSwitchAction,
LoginSuccessAction,
Expand Down Expand Up @@ -764,7 +764,6 @@ export const action = Object.freeze({
realm_avatar_changes_disabled: false,
realm_bot_creation_policy: 3,
realm_bot_domain: 'example.com',
realm_community_topic_editing_limit_seconds: 600,
realm_create_private_stream_policy: 3,
realm_create_public_stream_policy: 3,
realm_create_web_public_stream_policy: CreateWebPublicStreamPolicy.ModeratorOrAbove,
Expand All @@ -784,7 +783,6 @@ export const action = Object.freeze({
realm_digest_weekday: 2,
realm_disallow_disposable_email_addresses: true,
realm_edit_topic_policy: 3,
realm_email_address_visibility: EmailAddressVisibility.Admins,
realm_email_auth_enabled: true,
realm_email_changes_disabled: true,
realm_emails_restricted_to_domains: false,
Expand Down
66 changes: 53 additions & 13 deletions src/api/initialDataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
EmailAddressVisibility,
} from './permissionsTypes';
import type { ZulipVersion } from '../utils/zulipVersion';
import type { JSONableDict } from '../utils/jsonable';

/*
The types in this file are organized by which `fetch_event_types` values
Expand Down Expand Up @@ -61,14 +62,6 @@ export type RawInitialDataBase = $ReadOnly<{|
* `zulip_feature_level`, above.
*/
zulip_version: string,

/** New in FL 164; use 60 when absent. */
// TODO(server-7.0): simplify to always-present
server_presence_ping_interval_seconds?: number,

/** New in FL 164; use 140 when absent. */
// TODO(server-7.0): simplify to always-present
server_presence_offline_threshold_seconds?: number,
|}>;

/**
Expand Down Expand Up @@ -117,7 +110,7 @@ export type AvailableVideoChatProviders = $ReadOnly<{|
[providerName: string]: $ReadOnly<{| name: string, id: number |}>,
|}>;

// This is current to feature level 140.
// This is current to feature level 237.
export type InitialDataRealm = $ReadOnly<{|
//
// Keep alphabetical order. When changing this, also change our type for
Expand All @@ -129,7 +122,7 @@ export type InitialDataRealm = $ReadOnly<{|
// TODO(server-5.0): Added, at feat. 74.
event_queue_longpoll_timeout_seconds?: number,

jitsi_server_url?: string, // TODO: Really optional?
jitsi_server_url?: string, // deprecated
max_avatar_file_size_mib: number,
max_file_upload_size_mib: number,

Expand Down Expand Up @@ -181,8 +174,11 @@ export type InitialDataRealm = $ReadOnly<{|
realm_bot_creation_policy: number,
realm_bot_domain: string,

// TODO(server-3.0): Added in feat. 11
realm_community_topic_editing_limit_seconds?: number,
// TODO(server-8.0): Added in feat. 225
realm_can_access_all_users_group?: boolean,
Comment on lines +177 to +178
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO(server-8.0): Added in feat. 225
realm_can_access_all_users_group?: boolean,
// TODO(server-8.0): Added in feat. 225
realm_can_access_all_users_group_id?: boolean,

Right?

… Oh huh, the changelog and the /api/register-queue page disagree. The latter says …_group, so I guess that's what it actually is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, interesting, yeah.


// TODO(server-8.0): Added in feat. 209
realm_create_multiuse_invite_group?: number,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading through the changelog, here's a small other item at FL 195:

GET /events, POST /register: The default_code_block_language realm setting is now consistently an empty string when no default pygments language code is set. Previously, the server had a bug that meant it might represent no default for this realm setting as either null or an empty string. Clients supporting older server versions should treat either value (null or "") as no default being set.

So the line realm_default_code_block_language: string | null, should get a TODO(server-8.0) comment saying it's just string in current versions.

// TODO(server-5.0): Added in feat. 102, replacing
// realm_create_stream_policy for private streams
Expand All @@ -202,6 +198,7 @@ export type InitialDataRealm = $ReadOnly<{|
// CreateWebPublicStreamPolicy.Nobody.
realm_create_web_public_stream_policy?: CreateWebPublicStreamPolicy,

// TODO(server-8.0): In feat. 195+, just `string`, not `string | null`.
realm_default_code_block_language: string | null,

// TODO(server-2.1): Added in commit 2.1.0-rc1~1382.
Expand Down Expand Up @@ -231,11 +228,16 @@ export type InitialDataRealm = $ReadOnly<{|
// TODO(server-5.0): Added in feat. 75, replacing realm_allow_community_topic_editing
realm_edit_topic_policy?: number,

realm_email_address_visibility: EmailAddressVisibility,
// TODO(server-7.0): Removed in feat. 163
realm_email_address_visibility?: EmailAddressVisibility,

realm_email_auth_enabled: boolean,
realm_email_changes_disabled: boolean,
realm_emails_restricted_to_domains: boolean,

// TODO(server-8.0): Added in feat. 216
realm_enable_guest_user_indicator?: boolean,

// TODO(server-6.0): Added in feat. 137; if absent, treat as false.
realm_enable_read_receipts?: boolean,

Expand All @@ -260,6 +262,10 @@ export type InitialDataRealm = $ReadOnly<{|

realm_invite_to_stream_policy: number,
realm_is_zephyr_mirror_realm: boolean,

// TODO(server-8.0): Added in feat. 212
realm_jitsi_server_url?: string | null,

realm_logo_source: 'D' | 'U',
realm_logo_url: string,
realm_mandatory_topics: boolean,
Expand All @@ -280,6 +286,12 @@ export type InitialDataRealm = $ReadOnly<{|
// TODO(server-4.0): Added in feat. 56
realm_move_messages_between_streams_policy?: number,

// TODO(server-7.0): Added in feat. 162
realm_move_messages_between_streams_limit_seconds?: number | null,

// TODO(server-7.0): Added in feat. 162
realm_move_messages_within_stream_limit_seconds?: number | null,

realm_name: string,
realm_name_changes_disabled: boolean,
realm_night_logo_source: 'D' | 'U',
Expand All @@ -294,6 +306,10 @@ export type InitialDataRealm = $ReadOnly<{|
realm_presence_disabled: boolean,
realm_private_message_policy: number,
realm_push_notifications_enabled: boolean,

// TODO(server-8.0): Added in feat. 231
realm_push_notifications_enabled_end_timestamp?: number | null,

realm_send_welcome_emails: boolean,
realm_signup_notifications_stream_id: number,

Expand Down Expand Up @@ -324,11 +340,35 @@ export type InitialDataRealm = $ReadOnly<{|
server_generation: number,
server_inline_image_preview: boolean,
server_inline_url_embed_preview: boolean,

// TODO(server-8.0): Added in feat. 212
server_jitsi_server_url?: string | null,

server_name_changes_disabled: boolean,

// TODO(server-5.0): Added in feat. 74
server_needs_upgrade?: boolean,

// Use 140 when absent.
// TODO(server-7.0): Added in feat. 164. (Remove comment about using 140.)
server_presence_offline_threshold_seconds?: number,

// Use 60 when absent.
// TODO(server-7.0): Added in feat. 164. (Remove comment about using 60.)
server_presence_ping_interval_seconds?: number,

// TODO(server-8.0): Added in feat. 221
server_supported_permission_settings?: JSONableDict, // unstable

// TODO(server-8.0): Added in feat. 204
server_typing_started_expiry_period_milliseconds?: number,

// TODO(server-8.0): Added in feat. 204
server_typing_started_wait_period_milliseconds?: number,

// TODO(server-8.0): Added in feat. 204
server_typing_stopped_wait_period_milliseconds?: number,

// TODO(server-5.0): Added in feat. 110; if absent, treat as false.
server_web_public_streams_enabled?: boolean,

Expand Down
24 changes: 20 additions & 4 deletions src/api/realmDataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { InitialDataRealm } from './initialDataTypes';
* start with "realm_"). But we expect the values to be typed the same.
*/
/* prettier-ignore */
// Current to FL 140.
// Current to FL 237.
export type RealmDataForUpdate = $ReadOnly<{
//
// Keep alphabetical by the InitialDataRealm property. So by
Expand All @@ -35,8 +35,10 @@ export type RealmDataForUpdate = $ReadOnly<{
InitialDataRealm['realm_authentication_methods'],
bot_creation_policy:
InitialDataRealm['realm_bot_creation_policy'],
community_topic_editing_limit_seconds:
InitialDataRealm['realm_community_topic_editing_limit_seconds'],
can_access_all_users_group:
InitialDataRealm['realm_can_access_all_users_group'],
create_multiuse_invite_group:
InitialDataRealm['realm_create_multiuse_invite_group'],
create_private_stream_policy:
InitialDataRealm['realm_create_private_stream_policy'],
create_public_stream_policy:
Expand All @@ -59,12 +61,14 @@ export type RealmDataForUpdate = $ReadOnly<{
InitialDataRealm['realm_disallow_disposable_email_addresses'],
edit_topic_policy:
InitialDataRealm['realm_edit_topic_policy'],
email_address_visibility:
email_address_visibility: // removed in feat. 163
InitialDataRealm['realm_email_address_visibility'],
email_changes_disabled:
InitialDataRealm['realm_email_changes_disabled'],
emails_restricted_to_domains:
InitialDataRealm['realm_emails_restricted_to_domains'],
enable_guest_user_indicator:
InitialDataRealm['realm_enable_guest_user_indicator'],
enable_read_receipts:
InitialDataRealm['realm_enable_read_receipts'],
enable_spectator_access:
Expand All @@ -87,6 +91,8 @@ export type RealmDataForUpdate = $ReadOnly<{
InitialDataRealm['realm_invite_to_realm_policy'],
invite_to_stream_policy:
InitialDataRealm['realm_invite_to_stream_policy'],
jitsi_server_url:
InitialDataRealm['realm_jitsi_server_url'],
logo_source:
InitialDataRealm['realm_logo_source'],
logo_url:
Expand All @@ -101,6 +107,10 @@ export type RealmDataForUpdate = $ReadOnly<{
InitialDataRealm['realm_message_content_edit_limit_seconds'],
move_messages_between_streams_policy:
InitialDataRealm['realm_move_messages_between_streams_policy'],
move_messages_between_streams_limit_seconds:
InitialDataRealm['realm_move_messages_between_streams_limit_seconds'],
move_messages_within_stream_limit_seconds:
InitialDataRealm['realm_move_messages_within_stream_limit_seconds'],
name:
InitialDataRealm['realm_name'],
name_changes_disabled:
Expand All @@ -111,12 +121,18 @@ export type RealmDataForUpdate = $ReadOnly<{
InitialDataRealm['realm_night_logo_url'],
notifications_stream_id:
InitialDataRealm['realm_notifications_stream_id'],
org_type:
InitialDataRealm['realm_org_type'],
plan_type:
InitialDataRealm['realm_plan_type'],
presence_disabled:
InitialDataRealm['realm_presence_disabled'],
private_message_policy:
InitialDataRealm['realm_private_message_policy'],
push_notifications_enabled:
InitialDataRealm['realm_push_notifications_enabled'],
push_notifications_enabled_end_timestamp:
InitialDataRealm['realm_push_notifications_enabled_end_timestamp'],
send_welcome_emails:
InitialDataRealm['realm_send_welcome_emails'],
signup_notifications_stream_id:
Expand Down
2 changes: 1 addition & 1 deletion src/realm/__tests__/realmReducer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('realmReducer', () => {
waitingPeriodThreshold: action.data.realm_waiting_period_threshold,
allowEditHistory: action.data.realm_allow_edit_history,
enableReadReceipts: action.data.realm_enable_read_receipts,
emailAddressVisibility: action.data.realm_email_address_visibility,
emailAddressVisibility: null,

//
// InitialDataRealmUser
Expand Down
5 changes: 2 additions & 3 deletions src/realm/realmReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {
import {
CreatePublicOrPrivateStreamPolicy,
CreateWebPublicStreamPolicy,
EmailAddressVisibility,
} from '../api/permissionsTypes';
import { EventTypes } from '../api/eventTypes';
import {
Expand Down Expand Up @@ -53,7 +52,7 @@ const initialState = {
waitingPeriodThreshold: 90,
allowEditHistory: false,
enableReadReceipts: false,
emailAddressVisibility: EmailAddressVisibility.Admins,
emailAddressVisibility: null,

//
// InitialDataRealmUser
Expand Down Expand Up @@ -165,7 +164,7 @@ export default (
waitingPeriodThreshold: action.data.realm_waiting_period_threshold,
allowEditHistory: action.data.realm_allow_edit_history,
enableReadReceipts: action.data.realm_enable_read_receipts ?? false,
emailAddressVisibility: action.data.realm_email_address_visibility,
emailAddressVisibility: action.data.realm_email_address_visibility ?? null,

//
// InitialDataRealmUser
Expand Down
2 changes: 1 addition & 1 deletion src/reduxTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export type RealmState = {|
+waitingPeriodThreshold: number,
+allowEditHistory: boolean,
+enableReadReceipts: boolean,
+emailAddressVisibility: EmailAddressVisibility,
+emailAddressVisibility: EmailAddressVisibility | null,

//
// InitialDataRealmUser
Expand Down
6 changes: 3 additions & 3 deletions src/storage/__tests__/migrations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('migrations', () => {
// What `base` becomes after all migrations.
const endBase = {
...base52,
migrations: { version: 60 },
migrations: { version: 61 },
};

for (const [desc, before, after] of [
Expand All @@ -128,9 +128,9 @@ describe('migrations', () => {
// redundant with this one, because none of the migration steps notice
// whether any properties outside `storeKeys` are present or not.
[
'check dropCache at 60',
'check dropCache at 61',
// Just before the `dropCache`, plus a `cacheKeys` property, plus junk.
{ ...base52, migrations: { version: 59 }, mute: [], nonsense: [1, 2, 3] },
{ ...base52, migrations: { version: 60 }, mute: [], nonsense: [1, 2, 3] },
// Should wind up with the same result as without the extra properties.
endBase,
],
Expand Down
3 changes: 3 additions & 0 deletions src/storage/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,9 @@ const migrationsInner: {| [string]: (LessPartialState) => LessPartialState |} =
// Discard invalid enum values from `state.mute`.
'60': dropCache,

// Fix emailAddressVisibility accidentally being undefined/dropped
'61': dropCache,

// TIP: When adding a migration, consider just using `dropCache`.
// (See its jsdoc for guidance on when that's the right answer.)
};
Expand Down
4 changes: 1 addition & 3 deletions src/users/userSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,7 @@ export function getDisplayEmailForUser(realm: RealmState, user: UserOrBot): stri
if (user.delivery_email !== undefined) {
return user.delivery_email;
} else if (realm.emailAddressVisibility === EmailAddressVisibility.Everyone) {
// On future servers, we expect this case will never happen: we'll always include
// a delivery_email when you have access, including when the visibility is Everyone
// https://github.com/zulip/zulip-mobile/pull/5515#discussion_r997731727
// TODO(server-7.0): Not reached on FL 163+, where delivery_email is always present.
return user.email;
} else {
return null;
Expand Down
Loading