Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

59 строки
2.3 KiB

  1. # Copyright 2015, 2016 OpenMarket Ltd
  2. # Copyright 2017 New Vector Ltd
  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. from typing import Any
  16. from synapse.types import JsonDict
  17. from ._base import Config
  18. class PushConfig(Config):
  19. section = "push"
  20. def read_config(self, config: JsonDict, **kwargs: Any) -> None:
  21. push_config = config.get("push") or {}
  22. self.push_include_content = push_config.get("include_content", True)
  23. self.enable_push = push_config.get("enabled", True)
  24. self.push_group_unread_count_by_room = push_config.get(
  25. "group_unread_count_by_room", True
  26. )
  27. # There was a a 'redact_content' setting but mistakenly read from the
  28. # 'email'section'. Check for the flag in the 'push' section, and log,
  29. # but do not honour it to avoid nasty surprises when people upgrade.
  30. if push_config.get("redact_content") is not None:
  31. print(
  32. "The push.redact_content content option has never worked. "
  33. "Please set push.include_content if you want this behaviour"
  34. )
  35. # Now check for the one in the 'email' section and honour it,
  36. # with a warning.
  37. email_push_config = config.get("email") or {}
  38. redact_content = email_push_config.get("redact_content")
  39. if redact_content is not None:
  40. print(
  41. "The 'email.redact_content' option is deprecated: "
  42. "please set push.include_content instead"
  43. )
  44. self.push_include_content = not redact_content
  45. # Whether to apply a random delay to outbound push.
  46. self.push_jitter_delay_ms = None
  47. push_jitter_delay = push_config.get("jitter_delay", None)
  48. if push_jitter_delay:
  49. self.push_jitter_delay_ms = self.parse_duration(push_jitter_delay)