__init__.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. # Copyright 2017 New Vector Ltd
  2. # Copyright 2020 The Matrix.org Foundation C.I.C.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. import email.utils
  16. import logging
  17. from typing import (
  18. TYPE_CHECKING,
  19. Any,
  20. Callable,
  21. Dict,
  22. Generator,
  23. Iterable,
  24. List,
  25. Optional,
  26. Tuple,
  27. )
  28. import jinja2
  29. from twisted.internet import defer
  30. from twisted.web.resource import IResource
  31. from synapse.events import EventBase
  32. from synapse.events.presence_router import PresenceRouter
  33. from synapse.http.client import SimpleHttpClient
  34. from synapse.http.server import (
  35. DirectServeHtmlResource,
  36. DirectServeJsonResource,
  37. respond_with_html,
  38. )
  39. from synapse.http.servlet import parse_json_object_from_request
  40. from synapse.http.site import SynapseRequest
  41. from synapse.logging.context import make_deferred_yieldable, run_in_background
  42. from synapse.metrics.background_process_metrics import run_as_background_process
  43. from synapse.storage.database import DatabasePool, LoggingTransaction
  44. from synapse.storage.databases.main.roommember import ProfileInfo
  45. from synapse.storage.state import StateFilter
  46. from synapse.types import JsonDict, Requester, UserID, UserInfo, create_requester
  47. from synapse.util import Clock
  48. from synapse.util.caches.descriptors import cached
  49. if TYPE_CHECKING:
  50. from synapse.server import HomeServer
  51. """
  52. This package defines the 'stable' API which can be used by extension modules which
  53. are loaded into Synapse.
  54. """
  55. PRESENCE_ALL_USERS = PresenceRouter.ALL_USERS
  56. __all__ = [
  57. "errors",
  58. "make_deferred_yieldable",
  59. "parse_json_object_from_request",
  60. "respond_with_html",
  61. "run_in_background",
  62. "cached",
  63. "UserID",
  64. "DatabasePool",
  65. "LoggingTransaction",
  66. "DirectServeHtmlResource",
  67. "DirectServeJsonResource",
  68. "ModuleApi",
  69. "PRESENCE_ALL_USERS",
  70. ]
  71. logger = logging.getLogger(__name__)
  72. class ModuleApi:
  73. """A proxy object that gets passed to various plugin modules so they
  74. can register new users etc if necessary.
  75. """
  76. def __init__(self, hs: "HomeServer", auth_handler):
  77. self._hs = hs
  78. self._store = hs.get_datastore()
  79. self._auth = hs.get_auth()
  80. self._auth_handler = auth_handler
  81. self._server_name = hs.hostname
  82. self._presence_stream = hs.get_event_sources().sources["presence"]
  83. self._state = hs.get_state_handler()
  84. self._clock: Clock = hs.get_clock()
  85. self._send_email_handler = hs.get_send_email_handler()
  86. try:
  87. app_name = self._hs.config.email_app_name
  88. self._from_string = self._hs.config.email_notif_from % {"app": app_name}
  89. except (KeyError, TypeError):
  90. # If substitution failed (which can happen if the string contains
  91. # placeholders other than just "app", or if the type of the placeholder is
  92. # not a string), fall back to the bare strings.
  93. self._from_string = self._hs.config.email_notif_from
  94. self._raw_from = email.utils.parseaddr(self._from_string)[1]
  95. # We expose these as properties below in order to attach a helpful docstring.
  96. self._http_client: SimpleHttpClient = hs.get_simple_http_client()
  97. self._public_room_list_manager = PublicRoomListManager(hs)
  98. self._spam_checker = hs.get_spam_checker()
  99. self._account_validity_handler = hs.get_account_validity_handler()
  100. self._third_party_event_rules = hs.get_third_party_event_rules()
  101. self._presence_router = hs.get_presence_router()
  102. #################################################################################
  103. # The following methods should only be called during the module's initialisation.
  104. @property
  105. def register_spam_checker_callbacks(self):
  106. """Registers callbacks for spam checking capabilities."""
  107. return self._spam_checker.register_callbacks
  108. @property
  109. def register_account_validity_callbacks(self):
  110. """Registers callbacks for account validity capabilities."""
  111. return self._account_validity_handler.register_account_validity_callbacks
  112. @property
  113. def register_third_party_rules_callbacks(self):
  114. """Registers callbacks for third party event rules capabilities."""
  115. return self._third_party_event_rules.register_third_party_rules_callbacks
  116. @property
  117. def register_presence_router_callbacks(self):
  118. """Registers callbacks for presence router capabilities."""
  119. return self._presence_router.register_presence_router_callbacks
  120. def register_web_resource(self, path: str, resource: IResource):
  121. """Registers a web resource to be served at the given path.
  122. This function should be called during initialisation of the module.
  123. If multiple modules register a resource for the same path, the module that
  124. appears the highest in the configuration file takes priority.
  125. Args:
  126. path: The path to register the resource for.
  127. resource: The resource to attach to this path.
  128. """
  129. self._hs.register_module_web_resource(path, resource)
  130. #########################################################################
  131. # The following methods can be called by the module at any point in time.
  132. @property
  133. def http_client(self):
  134. """Allows making outbound HTTP requests to remote resources.
  135. An instance of synapse.http.client.SimpleHttpClient
  136. """
  137. return self._http_client
  138. @property
  139. def public_room_list_manager(self):
  140. """Allows adding to, removing from and checking the status of rooms in the
  141. public room list.
  142. An instance of synapse.module_api.PublicRoomListManager
  143. """
  144. return self._public_room_list_manager
  145. @property
  146. def public_baseurl(self) -> str:
  147. """The configured public base URL for this homeserver."""
  148. return self._hs.config.public_baseurl
  149. @property
  150. def email_app_name(self) -> str:
  151. """The application name configured in the homeserver's configuration."""
  152. return self._hs.config.email.email_app_name
  153. async def get_userinfo_by_id(self, user_id: str) -> Optional[UserInfo]:
  154. """Get user info by user_id
  155. Args:
  156. user_id: Fully qualified user id.
  157. Returns:
  158. UserInfo object if a user was found, otherwise None
  159. """
  160. return await self._store.get_userinfo_by_id(user_id)
  161. async def get_user_by_req(
  162. self,
  163. req: SynapseRequest,
  164. allow_guest: bool = False,
  165. allow_expired: bool = False,
  166. ) -> Requester:
  167. """Check the access_token provided for a request
  168. Args:
  169. req: Incoming HTTP request
  170. allow_guest: True if guest users should be allowed. If this
  171. is False, and the access token is for a guest user, an
  172. AuthError will be thrown
  173. allow_expired: True if expired users should be allowed. If this
  174. is False, and the access token is for an expired user, an
  175. AuthError will be thrown
  176. Returns:
  177. The requester for this request
  178. Raises:
  179. InvalidClientCredentialsError: if no user by that token exists,
  180. or the token is invalid.
  181. """
  182. return await self._auth.get_user_by_req(
  183. req,
  184. allow_guest,
  185. allow_expired=allow_expired,
  186. )
  187. async def is_user_admin(self, user_id: str) -> bool:
  188. """Checks if a user is a server admin.
  189. Args:
  190. user_id: The Matrix ID of the user to check.
  191. Returns:
  192. True if the user is a server admin, False otherwise.
  193. """
  194. return await self._store.is_server_admin(UserID.from_string(user_id))
  195. def get_qualified_user_id(self, username):
  196. """Qualify a user id, if necessary
  197. Takes a user id provided by the user and adds the @ and :domain to
  198. qualify it, if necessary
  199. Args:
  200. username (str): provided user id
  201. Returns:
  202. str: qualified @user:id
  203. """
  204. if username.startswith("@"):
  205. return username
  206. return UserID(username, self._hs.hostname).to_string()
  207. async def get_profile_for_user(self, localpart: str) -> ProfileInfo:
  208. """Look up the profile info for the user with the given localpart.
  209. Args:
  210. localpart: The localpart to look up profile information for.
  211. Returns:
  212. The profile information (i.e. display name and avatar URL).
  213. """
  214. return await self._store.get_profileinfo(localpart)
  215. async def get_threepids_for_user(self, user_id: str) -> List[Dict[str, str]]:
  216. """Look up the threepids (email addresses and phone numbers) associated with the
  217. given Matrix user ID.
  218. Args:
  219. user_id: The Matrix user ID to look up threepids for.
  220. Returns:
  221. A list of threepids, each threepid being represented by a dictionary
  222. containing a "medium" key which value is "email" for email addresses and
  223. "msisdn" for phone numbers, and an "address" key which value is the
  224. threepid's address.
  225. """
  226. return await self._store.user_get_threepids(user_id)
  227. def check_user_exists(self, user_id):
  228. """Check if user exists.
  229. Args:
  230. user_id (str): Complete @user:id
  231. Returns:
  232. Deferred[str|None]: Canonical (case-corrected) user_id, or None
  233. if the user is not registered.
  234. """
  235. return defer.ensureDeferred(self._auth_handler.check_user_exists(user_id))
  236. @defer.inlineCallbacks
  237. def register(self, localpart, displayname=None, emails: Optional[List[str]] = None):
  238. """Registers a new user with given localpart and optional displayname, emails.
  239. Also returns an access token for the new user.
  240. Deprecated: avoid this, as it generates a new device with no way to
  241. return that device to the user. Prefer separate calls to register_user and
  242. register_device.
  243. Args:
  244. localpart (str): The localpart of the new user.
  245. displayname (str|None): The displayname of the new user.
  246. emails (List[str]): Emails to bind to the new user.
  247. Returns:
  248. Deferred[tuple[str, str]]: a 2-tuple of (user_id, access_token)
  249. """
  250. logger.warning(
  251. "Using deprecated ModuleApi.register which creates a dummy user device."
  252. )
  253. user_id = yield self.register_user(localpart, displayname, emails or [])
  254. _, access_token, _, _ = yield self.register_device(user_id)
  255. return user_id, access_token
  256. def register_user(
  257. self, localpart, displayname=None, emails: Optional[List[str]] = None
  258. ):
  259. """Registers a new user with given localpart and optional displayname, emails.
  260. Args:
  261. localpart (str): The localpart of the new user.
  262. displayname (str|None): The displayname of the new user.
  263. emails (List[str]): Emails to bind to the new user.
  264. Raises:
  265. SynapseError if there is an error performing the registration. Check the
  266. 'errcode' property for more information on the reason for failure
  267. Returns:
  268. defer.Deferred[str]: user_id
  269. """
  270. return defer.ensureDeferred(
  271. self._hs.get_registration_handler().register_user(
  272. localpart=localpart,
  273. default_display_name=displayname,
  274. bind_emails=emails or [],
  275. )
  276. )
  277. def register_device(self, user_id, device_id=None, initial_display_name=None):
  278. """Register a device for a user and generate an access token.
  279. Args:
  280. user_id (str): full canonical @user:id
  281. device_id (str|None): The device ID to check, or None to generate
  282. a new one.
  283. initial_display_name (str|None): An optional display name for the
  284. device.
  285. Returns:
  286. defer.Deferred[tuple[str, str]]: Tuple of device ID and access token
  287. """
  288. return defer.ensureDeferred(
  289. self._hs.get_registration_handler().register_device(
  290. user_id=user_id,
  291. device_id=device_id,
  292. initial_display_name=initial_display_name,
  293. )
  294. )
  295. def record_user_external_id(
  296. self, auth_provider_id: str, remote_user_id: str, registered_user_id: str
  297. ) -> defer.Deferred:
  298. """Record a mapping from an external user id to a mxid
  299. Args:
  300. auth_provider: identifier for the remote auth provider
  301. external_id: id on that system
  302. user_id: complete mxid that it is mapped to
  303. """
  304. return defer.ensureDeferred(
  305. self._store.record_user_external_id(
  306. auth_provider_id, remote_user_id, registered_user_id
  307. )
  308. )
  309. def generate_short_term_login_token(
  310. self,
  311. user_id: str,
  312. duration_in_ms: int = (2 * 60 * 1000),
  313. auth_provider_id: str = "",
  314. ) -> str:
  315. """Generate a login token suitable for m.login.token authentication
  316. Args:
  317. user_id: gives the ID of the user that the token is for
  318. duration_in_ms: the time that the token will be valid for
  319. auth_provider_id: the ID of the SSO IdP that the user used to authenticate
  320. to get this token, if any. This is encoded in the token so that
  321. /login can report stats on number of successful logins by IdP.
  322. """
  323. return self._hs.get_macaroon_generator().generate_short_term_login_token(
  324. user_id,
  325. auth_provider_id,
  326. duration_in_ms,
  327. )
  328. @defer.inlineCallbacks
  329. def invalidate_access_token(self, access_token):
  330. """Invalidate an access token for a user
  331. Args:
  332. access_token(str): access token
  333. Returns:
  334. twisted.internet.defer.Deferred - resolves once the access token
  335. has been removed.
  336. Raises:
  337. synapse.api.errors.AuthError: the access token is invalid
  338. """
  339. # see if the access token corresponds to a device
  340. user_info = yield defer.ensureDeferred(
  341. self._auth.get_user_by_access_token(access_token)
  342. )
  343. device_id = user_info.get("device_id")
  344. user_id = user_info["user"].to_string()
  345. if device_id:
  346. # delete the device, which will also delete its access tokens
  347. yield defer.ensureDeferred(
  348. self._hs.get_device_handler().delete_device(user_id, device_id)
  349. )
  350. else:
  351. # no associated device. Just delete the access token.
  352. yield defer.ensureDeferred(
  353. self._auth_handler.delete_access_token(access_token)
  354. )
  355. def run_db_interaction(self, desc, func, *args, **kwargs):
  356. """Run a function with a database connection
  357. Args:
  358. desc (str): description for the transaction, for metrics etc
  359. func (func): function to be run. Passed a database cursor object
  360. as well as *args and **kwargs
  361. *args: positional args to be passed to func
  362. **kwargs: named args to be passed to func
  363. Returns:
  364. Deferred[object]: result of func
  365. """
  366. return defer.ensureDeferred(
  367. self._store.db_pool.runInteraction(desc, func, *args, **kwargs)
  368. )
  369. def complete_sso_login(
  370. self, registered_user_id: str, request: SynapseRequest, client_redirect_url: str
  371. ):
  372. """Complete a SSO login by redirecting the user to a page to confirm whether they
  373. want their access token sent to `client_redirect_url`, or redirect them to that
  374. URL with a token directly if the URL matches with one of the whitelisted clients.
  375. This is deprecated in favor of complete_sso_login_async.
  376. Args:
  377. registered_user_id: The MXID that has been registered as a previous step of
  378. of this SSO login.
  379. request: The request to respond to.
  380. client_redirect_url: The URL to which to offer to redirect the user (or to
  381. redirect them directly if whitelisted).
  382. """
  383. self._auth_handler._complete_sso_login(
  384. registered_user_id,
  385. "<unknown>",
  386. request,
  387. client_redirect_url,
  388. )
  389. async def complete_sso_login_async(
  390. self,
  391. registered_user_id: str,
  392. request: SynapseRequest,
  393. client_redirect_url: str,
  394. new_user: bool = False,
  395. auth_provider_id: str = "<unknown>",
  396. ):
  397. """Complete a SSO login by redirecting the user to a page to confirm whether they
  398. want their access token sent to `client_redirect_url`, or redirect them to that
  399. URL with a token directly if the URL matches with one of the whitelisted clients.
  400. Args:
  401. registered_user_id: The MXID that has been registered as a previous step of
  402. of this SSO login.
  403. request: The request to respond to.
  404. client_redirect_url: The URL to which to offer to redirect the user (or to
  405. redirect them directly if whitelisted).
  406. new_user: set to true to use wording for the consent appropriate to a user
  407. who has just registered.
  408. auth_provider_id: the ID of the SSO IdP which was used to log in. This
  409. is used to track counts of sucessful logins by IdP.
  410. """
  411. await self._auth_handler.complete_sso_login(
  412. registered_user_id,
  413. auth_provider_id,
  414. request,
  415. client_redirect_url,
  416. new_user=new_user,
  417. )
  418. @defer.inlineCallbacks
  419. def get_state_events_in_room(
  420. self, room_id: str, types: Iterable[Tuple[str, Optional[str]]]
  421. ) -> Generator[defer.Deferred, Any, Iterable[EventBase]]:
  422. """Gets current state events for the given room.
  423. (This is exposed for compatibility with the old SpamCheckerApi. We should
  424. probably deprecate it and replace it with an async method in a subclass.)
  425. Args:
  426. room_id: The room ID to get state events in.
  427. types: The event type and state key (using None
  428. to represent 'any') of the room state to acquire.
  429. Returns:
  430. twisted.internet.defer.Deferred[list(synapse.events.FrozenEvent)]:
  431. The filtered state events in the room.
  432. """
  433. state_ids = yield defer.ensureDeferred(
  434. self._store.get_filtered_current_state_ids(
  435. room_id=room_id, state_filter=StateFilter.from_types(types)
  436. )
  437. )
  438. state = yield defer.ensureDeferred(self._store.get_events(state_ids.values()))
  439. return state.values()
  440. async def create_and_send_event_into_room(self, event_dict: JsonDict) -> EventBase:
  441. """Create and send an event into a room. Membership events are currently not supported.
  442. Args:
  443. event_dict: A dictionary representing the event to send.
  444. Required keys are `type`, `room_id`, `sender` and `content`.
  445. Returns:
  446. The event that was sent. If state event deduplication happened, then
  447. the previous, duplicate event instead.
  448. Raises:
  449. SynapseError if the event was not allowed.
  450. """
  451. # Create a requester object
  452. requester = create_requester(
  453. event_dict["sender"], authenticated_entity=self._server_name
  454. )
  455. # Create and send the event
  456. (
  457. event,
  458. _,
  459. ) = await self._hs.get_event_creation_handler().create_and_send_nonmember_event(
  460. requester,
  461. event_dict,
  462. ratelimit=False,
  463. ignore_shadow_ban=True,
  464. )
  465. return event
  466. async def send_local_online_presence_to(self, users: Iterable[str]) -> None:
  467. """
  468. Forces the equivalent of a presence initial_sync for a set of local or remote
  469. users. The users will receive presence for all currently online users that they
  470. are considered interested in.
  471. Updates to remote users will be sent immediately, whereas local users will receive
  472. them on their next sync attempt.
  473. Note that this method can only be run on the process that is configured to write to the
  474. presence stream. By default this is the main process.
  475. """
  476. if self._hs._instance_name not in self._hs.config.worker.writers.presence:
  477. raise Exception(
  478. "send_local_online_presence_to can only be run "
  479. "on the process that is configured to write to the "
  480. "presence stream (by default this is the main process)",
  481. )
  482. local_users = set()
  483. remote_users = set()
  484. for user in users:
  485. if self._hs.is_mine_id(user):
  486. local_users.add(user)
  487. else:
  488. remote_users.add(user)
  489. # We pull out the presence handler here to break a cyclic
  490. # dependency between the presence router and module API.
  491. presence_handler = self._hs.get_presence_handler()
  492. if local_users:
  493. # Force a presence initial_sync for these users next time they sync.
  494. await presence_handler.send_full_presence_to_users(local_users)
  495. for user in remote_users:
  496. # Retrieve presence state for currently online users that this user
  497. # is considered interested in.
  498. presence_events, _ = await self._presence_stream.get_new_events(
  499. UserID.from_string(user), from_key=None, include_offline=False
  500. )
  501. # Send to remote destinations.
  502. destination = UserID.from_string(user).domain
  503. presence_handler.get_federation_queue().send_presence_to_destinations(
  504. presence_events, destination
  505. )
  506. def looping_background_call(
  507. self,
  508. f: Callable,
  509. msec: float,
  510. *args,
  511. desc: Optional[str] = None,
  512. **kwargs,
  513. ):
  514. """Wraps a function as a background process and calls it repeatedly.
  515. Waits `msec` initially before calling `f` for the first time.
  516. Args:
  517. f: The function to call repeatedly. f can be either synchronous or
  518. asynchronous, and must follow Synapse's logcontext rules.
  519. More info about logcontexts is available at
  520. https://matrix-org.github.io/synapse/latest/log_contexts.html
  521. msec: How long to wait between calls in milliseconds.
  522. *args: Positional arguments to pass to function.
  523. desc: The background task's description. Default to the function's name.
  524. **kwargs: Key arguments to pass to function.
  525. """
  526. if desc is None:
  527. desc = f.__name__
  528. if self._hs.config.run_background_tasks:
  529. self._clock.looping_call(
  530. run_as_background_process,
  531. msec,
  532. desc,
  533. f,
  534. *args,
  535. **kwargs,
  536. )
  537. else:
  538. logger.warning(
  539. "Not running looping call %s as the configuration forbids it",
  540. f,
  541. )
  542. async def send_mail(
  543. self,
  544. recipient: str,
  545. subject: str,
  546. html: str,
  547. text: str,
  548. ):
  549. """Send an email on behalf of the homeserver.
  550. Args:
  551. recipient: The email address for the recipient.
  552. subject: The email's subject.
  553. html: The email's HTML content.
  554. text: The email's text content.
  555. """
  556. await self._send_email_handler.send_email(
  557. email_address=recipient,
  558. subject=subject,
  559. app_name=self.email_app_name,
  560. html=html,
  561. text=text,
  562. )
  563. def read_templates(
  564. self,
  565. filenames: List[str],
  566. custom_template_directory: Optional[str] = None,
  567. ) -> List[jinja2.Template]:
  568. """Read and load the content of the template files at the given location.
  569. By default, Synapse will look for these templates in its configured template
  570. directory, but another directory to search in can be provided.
  571. Args:
  572. filenames: The name of the template files to look for.
  573. custom_template_directory: An additional directory to look for the files in.
  574. Returns:
  575. A list containing the loaded templates, with the orders matching the one of
  576. the filenames parameter.
  577. """
  578. return self._hs.config.read_templates(
  579. filenames,
  580. (td for td in (custom_template_directory,) if td),
  581. )
  582. class PublicRoomListManager:
  583. """Contains methods for adding to, removing from and querying whether a room
  584. is in the public room list.
  585. """
  586. def __init__(self, hs: "HomeServer"):
  587. self._store = hs.get_datastore()
  588. async def room_is_in_public_room_list(self, room_id: str) -> bool:
  589. """Checks whether a room is in the public room list.
  590. Args:
  591. room_id: The ID of the room.
  592. Returns:
  593. Whether the room is in the public room list. Returns False if the room does
  594. not exist.
  595. """
  596. room = await self._store.get_room(room_id)
  597. if not room:
  598. return False
  599. return room.get("is_public", False)
  600. async def add_room_to_public_room_list(self, room_id: str) -> None:
  601. """Publishes a room to the public room list.
  602. Args:
  603. room_id: The ID of the room.
  604. """
  605. await self._store.set_room_is_public(room_id, True)
  606. async def remove_room_from_public_room_list(self, room_id: str) -> None:
  607. """Removes a room from the public room list.
  608. Args:
  609. room_id: The ID of the room.
  610. """
  611. await self._store.set_room_is_public(room_id, False)