refactor(room): Move validateTimer() out of getLobbyState()/getLobbyTimer() getters#17810
Merged
Merged
Conversation
cbdac8f to
d094467
Compare
d094467 to
20e762a
Compare
…imer() getters getLobbyState() and getLobbyTimer() previously triggered a database write as a side effect when called — if the lobby timer had expired, they would silently reset the lobby state in the DB and fire events. This is incompatible with Entity's assumption that getters are pure. - Make getLobbyState() and getLobbyTimer() pure getters (remove bool $validateTime parameter) - Extract the timer check into RoomService::validateLobbyTimer(Room $room) using proper constructor DI - Call it explicitly at the three entry points that gate interactive user flows: RoomFormatter::formatRoomV4(), InjectionMiddleware::checkLobbyState(), and RoomPropertiesHelper::getPropertiesForSignaling() - ITimeFactory is no longer needed in Room's constructor The remaining callers (Chat/Notifier, Dashboard, search, background jobs) only read lobby state for display or notification decisions — not to gate access. All interactive flows (join, send message, API responses) go through InjectionMiddleware or RoomFormatter first, which validates the timer before any secondary callers are reached. Making getLobbyState() always auto-validate is not feasible: it would cause infinite recursion in setLobby() (which reads getLobbyState() to get the old state), and would break the federation sync comparison in syncProperties() which intentionally reads the raw stored value. AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Anna Larch <anna@nextcloud.com>
93fe18d to
e394740
Compare
nickvergessen
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Make
getLobbyState()andgetLobbyTimer()pure getters by moving the timer-expiry side effect into an explicitRoomService::validateLobbyTimer()method called at the three entry points that gate all interactive user flows.What changed
getLobbyState()andgetLobbyTimer()are now pure getters (removedbool $validateTimeparameter)RoomService::validateLobbyTimer(Room $room)with proper constructor DIRoomFormatter::formatRoomV4(),InjectionMiddleware::checkLobbyState(), andRoomPropertiesHelper::getPropertiesForSignaling()ITimeFactoryis no longer needed inRoom's constructorOn the secondary callers
cc @nickvergessen
Some callers (
Chat/Notifier,Dashboard/TalkWidget,Search, background jobs) readgetLobbyState()without an explicitvalidateLobbyTimer()call. These callers only use the lobby state for display or notification decisions — not to gate access. Every interactive user flow (joining a room, sending a message, any API response) goes throughInjectionMiddlewareorRoomFormatterfirst, which validates the timer before the secondary callers are reached.Making
getLobbyState()auto-validate on every call is not feasible:getLobbyState()→validateLobbyTimer()→setLobby()→getLobbyState()(which reads old state before updating)syncProperties(), which intentionally reads the raw stored value to diff against the hostA background job running every minute was investigated but rejected — the documented recommendation is a 5-minute cron interval, which is too coarse for lobby timer precision.
AI (if applicable)
🛠️ API Checklist
🏁 Checklist
docs/has been updated or is not required