mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 04:44:53 -04:00
Fix PushRuleEvaluator
and Filter
to work on frozendicts (#12100)
* Fix `PushRuleEvaluator` to work on frozendicts frozendicts do not (necessarily) inherit from dict, so this needs to handle them correctly. * Fix event filtering for frozen events Looks like this one was introduced by #11194.
This commit is contained in:
parent
5565f454e1
commit
6c0b44a3d7
5 changed files with 27 additions and 6 deletions
|
@ -15,12 +15,12 @@
|
|||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Dict, List, Optional, Pattern, Tuple, Union
|
||||
from typing import Any, Dict, List, Mapping, Optional, Pattern, Tuple, Union
|
||||
|
||||
from matrix_common.regex import glob_to_regex, to_word_pattern
|
||||
|
||||
from synapse.events import EventBase
|
||||
from synapse.types import JsonDict, UserID
|
||||
from synapse.types import UserID
|
||||
from synapse.util.caches.lrucache import LruCache
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -223,7 +223,7 @@ def _glob_matches(glob: str, value: str, word_boundary: bool = False) -> bool:
|
|||
|
||||
|
||||
def _flatten_dict(
|
||||
d: Union[EventBase, JsonDict],
|
||||
d: Union[EventBase, Mapping[str, Any]],
|
||||
prefix: Optional[List[str]] = None,
|
||||
result: Optional[Dict[str, str]] = None,
|
||||
) -> Dict[str, str]:
|
||||
|
@ -234,7 +234,7 @@ def _flatten_dict(
|
|||
for key, value in d.items():
|
||||
if isinstance(value, str):
|
||||
result[".".join(prefix + [key])] = value.lower()
|
||||
elif isinstance(value, dict):
|
||||
elif isinstance(value, Mapping):
|
||||
_flatten_dict(value, prefix=(prefix + [key]), result=result)
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue