Skip to content
Snippets Groups Projects
Unverified Commit 436e0eb3 authored by Erik Johnston's avatar Erik Johnston Committed by GitHub
Browse files

Fix breaking event sending due to bad push rule (#13547)

Broke by #13522

It looks like we have some rules in the DB with a priority class less
than 0 that don't override the base rules. Before these were just
dropped, but #13522 made that a hard error.
parent ba8938b0
No related branches found
No related tags found
No related merge requests found
Improve performance of sending messages in rooms with thousands of local users.
...@@ -49,6 +49,7 @@ kind, etc, etc. ...@@ -49,6 +49,7 @@ kind, etc, etc.
""" """
import itertools import itertools
import logging
from typing import Dict, Iterator, List, Mapping, Sequence, Tuple, Union from typing import Dict, Iterator, List, Mapping, Sequence, Tuple, Union
import attr import attr
...@@ -56,6 +57,8 @@ import attr ...@@ -56,6 +57,8 @@ import attr
from synapse.config.experimental import ExperimentalConfig from synapse.config.experimental import ExperimentalConfig
from synapse.push.rulekinds import PRIORITY_CLASS_MAP from synapse.push.rulekinds import PRIORITY_CLASS_MAP
logger = logging.getLogger(__name__)
@attr.s(auto_attribs=True, slots=True, frozen=True) @attr.s(auto_attribs=True, slots=True, frozen=True)
class PushRule: class PushRule:
...@@ -199,8 +202,16 @@ def compile_push_rules(rawrules: List[PushRule]) -> PushRules: ...@@ -199,8 +202,16 @@ def compile_push_rules(rawrules: List[PushRule]) -> PushRules:
collection = rules.sender collection = rules.sender
elif rule.priority_class == 1: elif rule.priority_class == 1:
collection = rules.underride collection = rules.underride
elif rule.priority_class <= 0:
logger.info(
"Got rule with priority class less than zero, but doesn't override a base rule: %s",
rule,
)
continue
else: else:
raise Exception(f"Unknown priority class: {rule.priority_class}") # We log and continue here so as not to break event sending
logger.error("Unknown priority class: %", rule.priority_class)
continue
collection.append(rule) collection.append(rule)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment