feat(notifications): honor chat mute in web realtime alerts
Some checks failed
CI / test (push) Failing after 1m30s

This commit is contained in:
2026-03-08 20:37:54 +03:00
parent 6c039ae94f
commit 418c9e6044
7 changed files with 41 additions and 1 deletions

View File

@@ -135,6 +135,37 @@ async def test_delete_saved_messages_chat_clears_messages_but_keeps_chat(client,
assert messages_after_delete.json() == []
async def test_chat_list_includes_notification_muted_flag(client, db_session):
u1 = await _create_verified_user(client, db_session, "muted_flag_u1@example.com", "muted_flag_u1", "strongpass123")
u2 = await _create_verified_user(client, db_session, "muted_flag_u2@example.com", "muted_flag_u2", "strongpass123")
me_u2 = await client.get("/api/v1/auth/me", headers={"Authorization": f"Bearer {u2['access_token']}"})
u2_id = me_u2.json()["id"]
create_chat_response = await client.post(
"/api/v1/chats",
headers={"Authorization": f"Bearer {u1['access_token']}"},
json={"type": ChatType.PRIVATE.value, "title": None, "member_ids": [u2_id]},
)
assert create_chat_response.status_code == 200
chat_id = create_chat_response.json()["id"]
mute_response = await client.put(
f"/api/v1/chats/{chat_id}/notifications",
headers={"Authorization": f"Bearer {u1['access_token']}"},
json={"muted": True},
)
assert mute_response.status_code == 200
assert mute_response.json()["muted"] is True
chats_response = await client.get("/api/v1/chats", headers={"Authorization": f"Bearer {u1['access_token']}"})
assert chats_response.status_code == 200
rows = chats_response.json()
row = next((item for item in rows if item["id"] == chat_id), None)
assert row is not None
assert row["muted"] is True
async def test_private_chat_respects_contacts_only_policy(client, db_session):
u1 = await _create_verified_user(client, db_session, "pm_u1@example.com", "pm_user_one", "strongpass123")
u2 = await _create_verified_user(client, db_session, "pm_u2@example.com", "pm_user_two", "strongpass123")