Persist canonical prototype user state
This commit is contained in:
parent
083be77404
commit
19c85db89a
2 changed files with 4 additions and 1 deletions
|
|
@ -42,7 +42,9 @@ class PrototypeStateStore:
|
||||||
key = f"{platform}:{external_id}"
|
key = f"{platform}:{external_id}"
|
||||||
existing = self._users.get(key)
|
existing = self._users.get(key)
|
||||||
if existing is not None:
|
if existing is not None:
|
||||||
return existing.model_copy(update={"is_new": False})
|
stored = existing.model_copy(update={"is_new": False})
|
||||||
|
self._users[key] = stored
|
||||||
|
return stored
|
||||||
|
|
||||||
user = User(
|
user = User(
|
||||||
user_id=f"usr-{platform}-{external_id}",
|
user_id=f"usr-{platform}-{external_id}",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ async def test_get_or_create_user_is_stable_per_surface_identity():
|
||||||
assert second.user_id == first.user_id
|
assert second.user_id == first.user_id
|
||||||
assert second.is_new is False
|
assert second.is_new is False
|
||||||
assert second.display_name == "Alice"
|
assert second.display_name == "Alice"
|
||||||
|
assert store._users["matrix:@alice:example.org"].is_new is False
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue