Fix admin List Room API return type on sqlite (#13509)

This commit is contained in:
David Robertson 2022-08-31 11:38:16 +01:00 committed by GitHub
parent b9924df264
commit a160406d24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 7 deletions

1
changelog.d/13509.bugfix Normal file
View File

@ -0,0 +1 @@
Fix a bug introduced in Synapse 1.13 where the [List Rooms admin API](https://matrix-org.github.io/synapse/develop/admin_api/rooms.html#list-room-api) would return integers instead of booleans for the `federatable` and `public` fields when using a Sqlite database.

View File

@ -641,8 +641,10 @@ class RoomWorkerStore(CacheInvalidationWorkerStore):
"version": room[5], "version": room[5],
"creator": room[6], "creator": room[6],
"encryption": room[7], "encryption": room[7],
"federatable": room[8], # room_stats_state.federatable is an integer on sqlite.
"public": room[9], "federatable": bool(room[8]),
# rooms.is_public is an integer on sqlite.
"public": bool(room[9]),
"join_rules": room[10], "join_rules": room[10],
"guest_access": room[11], "guest_access": room[11],
"history_visibility": room[12], "history_visibility": room[12],

View File

@ -1080,7 +1080,9 @@ class RoomTestCase(unittest.HomeserverTestCase):
room_ids = [] room_ids = []
for _ in range(total_rooms): for _ in range(total_rooms):
room_id = self.helper.create_room_as( room_id = self.helper.create_room_as(
self.admin_user, tok=self.admin_user_tok self.admin_user,
tok=self.admin_user_tok,
is_public=True,
) )
room_ids.append(room_id) room_ids.append(room_id)
@ -1119,8 +1121,8 @@ class RoomTestCase(unittest.HomeserverTestCase):
self.assertIn("version", r) self.assertIn("version", r)
self.assertIn("creator", r) self.assertIn("creator", r)
self.assertIn("encryption", r) self.assertIn("encryption", r)
self.assertIn("federatable", r) self.assertIs(r["federatable"], True)
self.assertIn("public", r) self.assertIs(r["public"], True)
self.assertIn("join_rules", r) self.assertIn("join_rules", r)
self.assertIn("guest_access", r) self.assertIn("guest_access", r)
self.assertIn("history_visibility", r) self.assertIn("history_visibility", r)
@ -1587,8 +1589,12 @@ class RoomTestCase(unittest.HomeserverTestCase):
def test_single_room(self) -> None: def test_single_room(self) -> None:
"""Test that a single room can be requested correctly""" """Test that a single room can be requested correctly"""
# Create two test rooms # Create two test rooms
room_id_1 = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok) room_id_1 = self.helper.create_room_as(
room_id_2 = self.helper.create_room_as(self.admin_user, tok=self.admin_user_tok) self.admin_user, tok=self.admin_user_tok, is_public=True
)
room_id_2 = self.helper.create_room_as(
self.admin_user, tok=self.admin_user_tok, is_public=False
)
room_name_1 = "something" room_name_1 = "something"
room_name_2 = "else" room_name_2 = "else"
@ -1634,7 +1640,10 @@ class RoomTestCase(unittest.HomeserverTestCase):
self.assertIn("state_events", channel.json_body) self.assertIn("state_events", channel.json_body)
self.assertIn("room_type", channel.json_body) self.assertIn("room_type", channel.json_body)
self.assertIn("forgotten", channel.json_body) self.assertIn("forgotten", channel.json_body)
self.assertEqual(room_id_1, channel.json_body["room_id"]) self.assertEqual(room_id_1, channel.json_body["room_id"])
self.assertIs(True, channel.json_body["federatable"])
self.assertIs(True, channel.json_body["public"])
def test_single_room_devices(self) -> None: def test_single_room_devices(self) -> None:
"""Test that `joined_local_devices` can be requested correctly""" """Test that `joined_local_devices` can be requested correctly"""