event_schema: Rename "presence" event to "legacy_presence".

This commit is contained in:
Vector73
2025-08-12 06:24:58 +00:00
committed by Tim Abbott
parent 58427f8ed1
commit 88761f70a2
3 changed files with 18 additions and 18 deletions

View File

@@ -37,6 +37,7 @@ from zerver.lib.event_types import (
EventHasZoomToken,
EventHeartbeat,
EventInvitesChanged,
EventLegacyPresence,
EventMessage,
EventMutedTopics,
EventMutedUsers,
@@ -44,7 +45,6 @@ from zerver.lib.event_types import (
EventNavigationViewRemove,
EventNavigationViewUpdate,
EventOnboardingSteps,
EventPresence,
EventPushDevice,
EventReactionAdd,
EventReactionRemove,
@@ -246,8 +246,8 @@ check_web_reload_client_event = make_checker(EventWebReloadClient)
_check_channel_folder_update = make_checker(EventChannelFolderUpdate)
_check_delete_message = make_checker(EventDeleteMessage)
_check_has_zoom_token = make_checker(EventHasZoomToken)
_check_legacy_presence = make_checker(EventLegacyPresence)
_check_muted_topics = make_checker(EventMutedTopics)
_check_presence = make_checker(EventPresence)
_check_realm_bot_add = make_checker(EventRealmBotAdd)
_check_realm_bot_update = make_checker(EventRealmBotUpdate)
_check_realm_default_update = make_checker(EventRealmUserSettingsDefaultsUpdate)
@@ -338,14 +338,14 @@ def check_muted_topics(
assert list(map(type, muted_topic_tuple)) == [str, str, int]
def check_presence(
def check_legacy_presence(
var_name: str,
event: dict[str, object],
has_email: bool,
presence_key: str,
status: str,
) -> None:
_check_presence(var_name, event)
_check_legacy_presence(var_name, event)
assert ("email" in event) == has_email

View File

@@ -326,21 +326,21 @@ class EventNavigationViewUpdate(BaseEvent):
data: NavigationViewFieldsForUpdate
class Presence(BaseModel):
class LegacyPresence(BaseModel):
status: Literal["active", "idle"]
timestamp: int
client: str
pushable: bool
class EventPresenceCore(BaseEvent):
class EventLegacyPresenceCore(BaseEvent):
type: Literal["presence"]
user_id: int
server_timestamp: float | int
presence: dict[str, Presence]
presence: dict[str, LegacyPresence]
class EventPresence(EventPresenceCore):
class EventLegacyPresence(EventLegacyPresenceCore):
# TODO: fix types to avoid optional fields
email: str | None = None

View File

@@ -183,6 +183,7 @@ from zerver.lib.event_schema import (
check_has_zoom_token,
check_heartbeat,
check_invites_changed,
check_legacy_presence,
check_message,
check_muted_topics,
check_muted_users,
@@ -190,7 +191,6 @@ from zerver.lib.event_schema import (
check_navigation_view_remove,
check_navigation_view_update,
check_onboarding_steps,
check_presence,
check_push_device,
check_reaction_add,
check_reaction_remove,
@@ -1820,7 +1820,7 @@ class NormalActionsTest(BaseAction):
check_navigation_view_remove("events[0]", events[0])
self.assertEqual(events[0]["fragment"], "inbox")
def test_presence_events(self) -> None:
def test_legacy_presence_events(self) -> None:
with self.verify_action(slim_presence=False) as events:
do_update_user_presence(
self.user_profile,
@@ -1829,7 +1829,7 @@ class NormalActionsTest(BaseAction):
UserPresence.LEGACY_STATUS_ACTIVE_INT,
)
check_presence(
check_legacy_presence(
"events[0]",
events[0],
has_email=True,
@@ -1845,7 +1845,7 @@ class NormalActionsTest(BaseAction):
UserPresence.LEGACY_STATUS_ACTIVE_INT,
)
check_presence(
check_legacy_presence(
"events[0]",
events[0],
has_email=False,
@@ -1891,7 +1891,7 @@ class NormalActionsTest(BaseAction):
UserPresence.LEGACY_STATUS_ACTIVE_INT,
)
check_presence(
check_legacy_presence(
"events[0]",
events[0],
has_email=True,
@@ -2040,7 +2040,7 @@ class NormalActionsTest(BaseAction):
events[2],
{"away", "status_text", "emoji_name", "emoji_code", "reaction_type"},
)
check_presence(
check_legacy_presence(
"events[3]",
events[3],
has_email=True,
@@ -2068,7 +2068,7 @@ class NormalActionsTest(BaseAction):
events[2],
{"away", "status_text", "emoji_name", "emoji_code", "reaction_type"},
)
check_presence(
check_legacy_presence(
"events[3]",
events[3],
has_email=True,
@@ -2092,7 +2092,7 @@ class NormalActionsTest(BaseAction):
check_user_settings_update("events[0]", events[0])
check_update_global_notifications("events[1]", events[1], not away_val)
check_user_status("events[2]", events[2], {"away"})
check_presence(
check_legacy_presence(
"events[3]",
events[3],
has_email=True,
@@ -2149,7 +2149,7 @@ class NormalActionsTest(BaseAction):
reaction_type=None,
client_id=client.id,
)
check_presence(
check_legacy_presence(
"events[0]",
events[0],
has_email=True,
@@ -3178,7 +3178,7 @@ class NormalActionsTest(BaseAction):
)
check_user_settings_update("events[0]", events[0])
check_update_global_notifications("events[1]", events[1], val)
check_presence(
check_legacy_presence(
"events[2]", events[2], has_email=True, presence_key="website", status="active"
)