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.
 
 
 
 
 
 

81 lines
3.5 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 ._base import Config
  16. class PushConfig(Config):
  17. section = "push"
  18. def read_config(self, config, **kwargs):
  19. push_config = config.get("push") or {}
  20. self.push_include_content = push_config.get("include_content", True)
  21. self.push_group_unread_count_by_room = push_config.get(
  22. "group_unread_count_by_room", True
  23. )
  24. # There was a a 'redact_content' setting but mistakenly read from the
  25. # 'email'section'. Check for the flag in the 'push' section, and log,
  26. # but do not honour it to avoid nasty surprises when people upgrade.
  27. if push_config.get("redact_content") is not None:
  28. print(
  29. "The push.redact_content content option has never worked. "
  30. "Please set push.include_content if you want this behaviour"
  31. )
  32. # Now check for the one in the 'email' section and honour it,
  33. # with a warning.
  34. push_config = config.get("email") or {}
  35. redact_content = push_config.get("redact_content")
  36. if redact_content is not None:
  37. print(
  38. "The 'email.redact_content' option is deprecated: "
  39. "please set push.include_content instead"
  40. )
  41. self.push_include_content = not redact_content
  42. def generate_config_section(self, config_dir_path, server_name, **kwargs):
  43. return """
  44. ## Push ##
  45. push:
  46. # Clients requesting push notifications can either have the body of
  47. # the message sent in the notification poke along with other details
  48. # like the sender, or just the event ID and room ID (`event_id_only`).
  49. # If clients choose the former, this option controls whether the
  50. # notification request includes the content of the event (other details
  51. # like the sender are still included). For `event_id_only` push, it
  52. # has no effect.
  53. #
  54. # For modern android devices the notification content will still appear
  55. # because it is loaded by the app. iPhone, however will send a
  56. # notification saying only that a message arrived and who it came from.
  57. #
  58. # The default value is "true" to include message details. Uncomment to only
  59. # include the event ID and room ID in push notification payloads.
  60. #
  61. #include_content: false
  62. # When a push notification is received, an unread count is also sent.
  63. # This number can either be calculated as the number of unread messages
  64. # for the user, or the number of *rooms* the user has unread messages in.
  65. #
  66. # The default value is "true", meaning push clients will see the number of
  67. # rooms with unread messages in them. Uncomment to instead send the number
  68. # of unread messages.
  69. #
  70. #group_unread_count_by_room: false
  71. """