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.
 
 
 
 
 
 

78 lines
2.5 KiB

  1. # Copyright 2022 The Matrix.org Foundation C.I.C.
  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, Collection, Dict, Mapping, Optional, Sequence, Set, Tuple, Union
  15. from synapse.types import JsonDict
  16. class PushRule:
  17. @property
  18. def rule_id(self) -> str: ...
  19. @property
  20. def priority_class(self) -> int: ...
  21. @property
  22. def conditions(self) -> Sequence[Mapping[str, str]]: ...
  23. @property
  24. def actions(self) -> Sequence[Union[Mapping[str, Any], str]]: ...
  25. @property
  26. def default(self) -> bool: ...
  27. @property
  28. def default_enabled(self) -> bool: ...
  29. @staticmethod
  30. def from_db(
  31. rule_id: str, priority_class: int, conditions: str, actions: str
  32. ) -> "PushRule": ...
  33. class PushRules:
  34. def __init__(self, rules: Collection[PushRule]): ...
  35. def rules(self) -> Collection[PushRule]: ...
  36. class FilteredPushRules:
  37. def __init__(
  38. self,
  39. push_rules: PushRules,
  40. enabled_map: Dict[str, bool],
  41. msc1767_enabled: bool,
  42. msc3381_polls_enabled: bool,
  43. msc3664_enabled: bool,
  44. msc3952_intentional_mentions: bool,
  45. ): ...
  46. def rules(self) -> Collection[Tuple[PushRule, bool]]: ...
  47. def get_base_rule_ids() -> Collection[str]: ...
  48. class PushRuleEvaluator:
  49. def __init__(
  50. self,
  51. flattened_keys: Mapping[str, str],
  52. user_mentions: Set[str],
  53. room_mention: bool,
  54. room_member_count: int,
  55. sender_power_level: Optional[int],
  56. notification_power_levels: Mapping[str, int],
  57. related_events_flattened: Mapping[str, Mapping[str, str]],
  58. related_event_match_enabled: bool,
  59. room_version_feature_flags: Tuple[str, ...],
  60. msc3931_enabled: bool,
  61. ): ...
  62. def run(
  63. self,
  64. push_rules: FilteredPushRules,
  65. user_id: Optional[str],
  66. display_name: Optional[str],
  67. ) -> Collection[Union[Mapping, str]]: ...
  68. def matches(
  69. self, condition: JsonDict, user_id: Optional[str], display_name: Optional[str]
  70. ) -> bool: ...