|
21 | 21 | #
|
22 | 22 |
|
23 | 23 | import logging
|
24 |
| -from abc import abstractmethod |
25 | 24 | from enum import Enum
|
26 | 25 | from typing import (
|
27 | 26 | TYPE_CHECKING,
|
28 | 27 | AbstractSet,
|
29 | 28 | Any,
|
30 |
| - Awaitable, |
31 | 29 | Collection,
|
32 | 30 | Dict,
|
33 | 31 | List,
|
@@ -1935,13 +1933,57 @@ def _get_rooms(txn: LoggingTransaction) -> List[str]:
|
1935 | 1933 |
|
1936 | 1934 | return len(rooms)
|
1937 | 1935 |
|
1938 |
| - @abstractmethod |
1939 |
| - def set_room_is_public(self, room_id: str, is_public: bool) -> Awaitable[None]: |
1940 |
| - # this will need to be implemented if a background update is performed with |
1941 |
| - # existing (tombstoned, public) rooms in the database. |
1942 |
| - # |
1943 |
| - # It's overridden by RoomStore for the synapse master. |
1944 |
| - raise NotImplementedError() |
| 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 | + ) |
1945 | 1987 |
|
1946 | 1988 | async def has_auth_chain_index(self, room_id: str) -> bool:
|
1947 | 1989 | """Check if the room has (or can have) a chain cover index.
|
@@ -2349,62 +2391,6 @@ async def maybe_store_room_on_outlier_membership(
|
2349 | 2391 | },
|
2350 | 2392 | )
|
2351 | 2393 |
|
2352 |
| - async def set_room_is_public(self, room_id: str, is_public: bool) -> None: |
2353 |
| - await self.db_pool.simple_update_one( |
2354 |
| - table="rooms", |
2355 |
| - keyvalues={"room_id": room_id}, |
2356 |
| - updatevalues={"is_public": is_public}, |
2357 |
| - desc="set_room_is_public", |
2358 |
| - ) |
2359 |
| - |
2360 |
| - self.hs.get_notifier().on_new_replication_data() |
2361 |
| - |
2362 |
| - async def set_room_is_public_appservice( |
2363 |
| - self, room_id: str, appservice_id: str, network_id: str, is_public: bool |
2364 |
| - ) -> None: |
2365 |
| - """Edit the appservice/network specific public room list. |
2366 |
| -
|
2367 |
| - Each appservice can have a number of published room lists associated |
2368 |
| - with them, keyed off of an appservice defined `network_id`, which |
2369 |
| - basically represents a single instance of a bridge to a third party |
2370 |
| - network. |
2371 |
| -
|
2372 |
| - Args: |
2373 |
| - room_id |
2374 |
| - appservice_id |
2375 |
| - network_id |
2376 |
| - is_public: Whether to publish or unpublish the room from the list. |
2377 |
| - """ |
2378 |
| - |
2379 |
| - if is_public: |
2380 |
| - await self.db_pool.simple_upsert( |
2381 |
| - table="appservice_room_list", |
2382 |
| - keyvalues={ |
2383 |
| - "appservice_id": appservice_id, |
2384 |
| - "network_id": network_id, |
2385 |
| - "room_id": room_id, |
2386 |
| - }, |
2387 |
| - values={}, |
2388 |
| - insertion_values={ |
2389 |
| - "appservice_id": appservice_id, |
2390 |
| - "network_id": network_id, |
2391 |
| - "room_id": room_id, |
2392 |
| - }, |
2393 |
| - desc="set_room_is_public_appservice_true", |
2394 |
| - ) |
2395 |
| - else: |
2396 |
| - await self.db_pool.simple_delete( |
2397 |
| - table="appservice_room_list", |
2398 |
| - keyvalues={ |
2399 |
| - "appservice_id": appservice_id, |
2400 |
| - "network_id": network_id, |
2401 |
| - "room_id": room_id, |
2402 |
| - }, |
2403 |
| - desc="set_room_is_public_appservice_false", |
2404 |
| - ) |
2405 |
| - |
2406 |
| - self.hs.get_notifier().on_new_replication_data() |
2407 |
| - |
2408 | 2394 | async def add_event_report(
|
2409 | 2395 | self,
|
2410 | 2396 | room_id: str,
|
|
0 commit comments