Skip to content

Commit 59ac541

Browse files
authored
Actually fix public rooms (#17184)
See #17177. I'm an idiot and moved them to the wrong store 🤦
1 parent a2e6f43 commit 59ac541

File tree

2 files changed

+55
-54
lines changed

2 files changed

+55
-54
lines changed

changelog.d/17184.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix bug where disabling room publication prevented public rooms being created on workers.

synapse/storage/databases/main/room.py

+54-54
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
from synapse.config.homeserver import HomeServerConfig
5252
from synapse.events import EventBase
5353
from synapse.replication.tcp.streams.partial_state import UnPartialStatedRoomStream
54-
from synapse.storage._base import SQLBaseStore, db_to_json, make_in_list_sql_clause
54+
from synapse.storage._base import db_to_json, make_in_list_sql_clause
5555
from synapse.storage.database import (
5656
DatabasePool,
5757
LoggingDatabaseConnection,
@@ -1682,6 +1682,58 @@ async def delete_event_report(self, report_id: int) -> bool:
16821682

16831683
return True
16841684

1685+
async def set_room_is_public(self, room_id: str, is_public: bool) -> None:
1686+
await self.db_pool.simple_update_one(
1687+
table="rooms",
1688+
keyvalues={"room_id": room_id},
1689+
updatevalues={"is_public": is_public},
1690+
desc="set_room_is_public",
1691+
)
1692+
1693+
async def set_room_is_public_appservice(
1694+
self, room_id: str, appservice_id: str, network_id: str, is_public: bool
1695+
) -> None:
1696+
"""Edit the appservice/network specific public room list.
1697+
1698+
Each appservice can have a number of published room lists associated
1699+
with them, keyed off of an appservice defined `network_id`, which
1700+
basically represents a single instance of a bridge to a third party
1701+
network.
1702+
1703+
Args:
1704+
room_id
1705+
appservice_id
1706+
network_id
1707+
is_public: Whether to publish or unpublish the room from the list.
1708+
"""
1709+
1710+
if is_public:
1711+
await self.db_pool.simple_upsert(
1712+
table="appservice_room_list",
1713+
keyvalues={
1714+
"appservice_id": appservice_id,
1715+
"network_id": network_id,
1716+
"room_id": room_id,
1717+
},
1718+
values={},
1719+
insertion_values={
1720+
"appservice_id": appservice_id,
1721+
"network_id": network_id,
1722+
"room_id": room_id,
1723+
},
1724+
desc="set_room_is_public_appservice_true",
1725+
)
1726+
else:
1727+
await self.db_pool.simple_delete(
1728+
table="appservice_room_list",
1729+
keyvalues={
1730+
"appservice_id": appservice_id,
1731+
"network_id": network_id,
1732+
"room_id": room_id,
1733+
},
1734+
desc="set_room_is_public_appservice_false",
1735+
)
1736+
16851737

16861738
class _BackgroundUpdates:
16871739
REMOVE_TOMESTONED_ROOMS_BG_UPDATE = "remove_tombstoned_rooms_from_directory"
@@ -1700,7 +1752,7 @@ class _BackgroundUpdates:
17001752
)
17011753

17021754

1703-
class RoomBackgroundUpdateStore(SQLBaseStore):
1755+
class RoomBackgroundUpdateStore(RoomWorkerStore):
17041756
def __init__(
17051757
self,
17061758
database: DatabasePool,
@@ -1933,58 +1985,6 @@ def _get_rooms(txn: LoggingTransaction) -> List[str]:
19331985

19341986
return len(rooms)
19351987

1936-
async def set_room_is_public(self, room_id: str, is_public: bool) -> None:
1937-
await self.db_pool.simple_update_one(
1938-
table="rooms",
1939-
keyvalues={"room_id": room_id},
1940-
updatevalues={"is_public": is_public},
1941-
desc="set_room_is_public",
1942-
)
1943-
1944-
async def set_room_is_public_appservice(
1945-
self, room_id: str, appservice_id: str, network_id: str, is_public: bool
1946-
) -> None:
1947-
"""Edit the appservice/network specific public room list.
1948-
1949-
Each appservice can have a number of published room lists associated
1950-
with them, keyed off of an appservice defined `network_id`, which
1951-
basically represents a single instance of a bridge to a third party
1952-
network.
1953-
1954-
Args:
1955-
room_id
1956-
appservice_id
1957-
network_id
1958-
is_public: Whether to publish or unpublish the room from the list.
1959-
"""
1960-
1961-
if is_public:
1962-
await self.db_pool.simple_upsert(
1963-
table="appservice_room_list",
1964-
keyvalues={
1965-
"appservice_id": appservice_id,
1966-
"network_id": network_id,
1967-
"room_id": room_id,
1968-
},
1969-
values={},
1970-
insertion_values={
1971-
"appservice_id": appservice_id,
1972-
"network_id": network_id,
1973-
"room_id": room_id,
1974-
},
1975-
desc="set_room_is_public_appservice_true",
1976-
)
1977-
else:
1978-
await self.db_pool.simple_delete(
1979-
table="appservice_room_list",
1980-
keyvalues={
1981-
"appservice_id": appservice_id,
1982-
"network_id": network_id,
1983-
"room_id": room_id,
1984-
},
1985-
desc="set_room_is_public_appservice_false",
1986-
)
1987-
19881988
async def has_auth_chain_index(self, room_id: str) -> bool:
19891989
"""Check if the room has (or can have) a chain cover index.
19901990

0 commit comments

Comments
 (0)