push.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2015, 2016 OpenMarket Ltd
  3. # Copyright 2017 New Vector Ltd
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. from ._base import Config
  17. class PushConfig(Config):
  18. def read_config(self, config):
  19. push_config = config.get("push", {})
  20. self.push_include_content = push_config.get("include_content", True)
  21. # There was a a 'redact_content' setting but mistakenly read from the
  22. # 'email'section'. Check for the flag in the 'push' section, and log,
  23. # but do not honour it to avoid nasty surprises when people upgrade.
  24. if push_config.get("redact_content") is not None:
  25. print(
  26. "The push.redact_content content option has never worked. "
  27. "Please set push.include_content if you want this behaviour"
  28. )
  29. # Now check for the one in the 'email' section and honour it,
  30. # with a warning.
  31. push_config = config.get("email", {})
  32. redact_content = push_config.get("redact_content")
  33. if redact_content is not None:
  34. print(
  35. "The 'email.redact_content' option is deprecated: "
  36. "please set push.include_content instead"
  37. )
  38. self.push_include_content = not redact_content
  39. def default_config(self, config_dir_path, server_name, **kwargs):
  40. return """
  41. # Clients requesting push notifications can either have the body of
  42. # the message sent in the notification poke along with other details
  43. # like the sender, or just the event ID and room ID (`event_id_only`).
  44. # If clients choose the former, this option controls whether the
  45. # notification request includes the content of the event (other details
  46. # like the sender are still included). For `event_id_only` push, it
  47. # has no effect.
  48. # For modern android devices the notification content will still appear
  49. # because it is loaded by the app. iPhone, however will send a
  50. # notification saying only that a message arrived and who it came from.
  51. #
  52. #push:
  53. # include_content: true
  54. """