You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 line
2.3 KiB

  1. # Copyright 2018 New Vector Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from typing import Any, Optional
  15. from synapse.types import JsonDict, UserID
  16. from ._base import Config
  17. class ServerNoticesConfig(Config):
  18. """Configuration for the server notices room.
  19. Attributes:
  20. server_notices_mxid (str|None):
  21. The MXID to use for server notices.
  22. None if server notices are not enabled.
  23. server_notices_mxid_display_name (str|None):
  24. The display name to use for the server notices user.
  25. None if server notices are not enabled.
  26. server_notices_mxid_avatar_url (str|None):
  27. The MXC URL for the avatar of the server notices user.
  28. None if server notices are not enabled.
  29. server_notices_room_name (str|None):
  30. The name to use for the server notices room.
  31. None if server notices are not enabled.
  32. """
  33. section = "servernotices"
  34. def __init__(self, *args: Any):
  35. super().__init__(*args)
  36. self.server_notices_mxid: Optional[str] = None
  37. self.server_notices_mxid_display_name: Optional[str] = None
  38. self.server_notices_mxid_avatar_url: Optional[str] = None
  39. self.server_notices_room_name: Optional[str] = None
  40. def read_config(self, config: JsonDict, **kwargs: Any) -> None:
  41. c = config.get("server_notices")
  42. if c is None:
  43. return
  44. mxid_localpart = c["system_mxid_localpart"]
  45. self.server_notices_mxid = UserID(
  46. mxid_localpart, self.root.server.server_name
  47. ).to_string()
  48. self.server_notices_mxid_display_name = c.get("system_mxid_display_name", None)
  49. self.server_notices_mxid_avatar_url = c.get("system_mxid_avatar_url", None)
  50. # todo: i18n
  51. self.server_notices_room_name = c.get("room_name", "Server Notices")