51
51
from synapse .config .homeserver import HomeServerConfig
52
52
from synapse .events import EventBase
53
53
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
55
55
from synapse .storage .database import (
56
56
DatabasePool ,
57
57
LoggingDatabaseConnection ,
@@ -1682,6 +1682,58 @@ async def delete_event_report(self, report_id: int) -> bool:
1682
1682
1683
1683
return True
1684
1684
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
+
1685
1737
1686
1738
class _BackgroundUpdates :
1687
1739
REMOVE_TOMESTONED_ROOMS_BG_UPDATE = "remove_tombstoned_rooms_from_directory"
@@ -1700,7 +1752,7 @@ class _BackgroundUpdates:
1700
1752
)
1701
1753
1702
1754
1703
- class RoomBackgroundUpdateStore (SQLBaseStore ):
1755
+ class RoomBackgroundUpdateStore (RoomWorkerStore ):
1704
1756
def __init__ (
1705
1757
self ,
1706
1758
database : DatabasePool ,
@@ -1933,58 +1985,6 @@ def _get_rooms(txn: LoggingTransaction) -> List[str]:
1933
1985
1934
1986
return len (rooms )
1935
1987
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
-
1988
1988
async def has_auth_chain_index (self , room_id : str ) -> bool :
1989
1989
"""Check if the room has (or can have) a chain cover index.
1990
1990
0 commit comments