mirror of
https://github.com/rommapp/romm.git
synced 2026-11-29 01:58:41 +01:00
fix(streaming): name the ended claim's stamp in a termination notice
A re-claim of the same container keeps its key, so the container alone cannot tell the tab that lost its claim from the tab holding the next one.
This commit is contained in:
@@ -54,6 +54,7 @@ class SessionTerminationSchema(BaseModel):
|
||||
rom_id: int | None = None
|
||||
rom_name: str | None = None
|
||||
container: str | None = None
|
||||
claimed_at: str | None = None
|
||||
desktop: bool = False
|
||||
|
||||
|
||||
|
||||
@@ -593,6 +593,8 @@ async def record_termination(
|
||||
# Which claim ended: a user can hold one per container, plus a desktop,
|
||||
# and only the tab that holds this one should act on the notice.
|
||||
"container": session_key,
|
||||
# A re-claim of the container keeps its key, so the stamp names the claim.
|
||||
"claimed_at": session.get("claimed_at"),
|
||||
"desktop": session_is_desktop(session),
|
||||
}
|
||||
await async_cache.set(
|
||||
|
||||
@@ -3053,6 +3053,26 @@ def test_a_termination_notice_names_the_container_it_ended(
|
||||
assert notice["desktop"] is False
|
||||
|
||||
|
||||
def test_a_termination_notice_names_the_claim_it_ended(
|
||||
client, access_token, viewer_access_token, rom: Rom
|
||||
):
|
||||
"""A re-claim of the same container keeps its key, so only the stamp tells
|
||||
the tab that lost its claim from the one holding the next."""
|
||||
with _streaming(_container_for(rom)):
|
||||
claimed_at = _claim_ok(client, viewer_access_token, rom.id).json()[
|
||||
"claimed_at"
|
||||
]
|
||||
client.delete(
|
||||
f"/api/streaming/sessions/{rom.platform_slug}",
|
||||
headers=_auth(access_token),
|
||||
)
|
||||
r = client.get(
|
||||
f"/api/streaming/sessions/{rom.platform_slug}/status",
|
||||
headers=_auth(viewer_access_token),
|
||||
)
|
||||
assert r.json()["termination"]["claimed_at"] == claimed_at
|
||||
|
||||
|
||||
def test_a_termination_notice_lands_before_the_drain(
|
||||
client, access_token, viewer_access_token, rom: Rom
|
||||
):
|
||||
|
||||
@@ -16,6 +16,7 @@ export type SessionTerminationSchema = {
|
||||
rom_id?: (number | null);
|
||||
rom_name?: (string | null);
|
||||
container?: (string | null);
|
||||
claimed_at?: (string | null);
|
||||
desktop?: boolean;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user