Don't construct synthetic objects

This commit is contained in:
Jack Kingsman
2026-03-11 19:04:57 -07:00
parent 15a8c637e4
commit bcde3bd9d5
2 changed files with 6 additions and 1 deletions
+4 -1
View File
@@ -286,7 +286,10 @@ async def create_contact(
if request.try_historical:
await start_historical_dm_decryption(background_tasks, lower_key, request.name)
return Contact(**contact_upsert.model_dump())
stored = await ContactRepository.get_by_key(lower_key)
if stored is None:
raise HTTPException(status_code=500, detail="Contact was created but could not be reloaded")
return stored
@router.get("/{public_key}/detail", response_model=ContactDetail)
+2
View File
@@ -117,11 +117,13 @@ class TestCreateContact:
data = response.json()
assert data["public_key"] == KEY_A
assert data["name"] == "NewContact"
assert data["last_seen"] is not None
# Verify in DB
contact = await ContactRepository.get_by_key(KEY_A)
assert contact is not None
assert contact.name == "NewContact"
assert data["last_seen"] == contact.last_seen
@pytest.mark.asyncio
async def test_create_invalid_hex(self, test_db, client):