diff options
author | Erik Johnston <erik@matrix.org> | 2016-01-18 15:42:23 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-01-18 15:42:23 +0000 |
commit | 7dd14e5d1c8950f50279efccce83b9ff30f0bcfb (patch) | |
tree | 2dc57276ecdce5df6a0b6692ebb57f571ccb91b6 /synapse | |
parent | Do for loop once at start (diff) | |
download | synapse-7dd14e5d1c8950f50279efccce83b9ff30f0bcfb.tar.xz |
Add comments and remove dead code
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/push/push_rule_evaluator.py | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/synapse/push/push_rule_evaluator.py b/synapse/push/push_rule_evaluator.py index 9332fe5c5e..eab7fc7d5c 100644 --- a/synapse/push/push_rule_evaluator.py +++ b/synapse/push/push_rule_evaluator.py @@ -184,9 +184,14 @@ class PushRuleEvaluatorForEvent(object): def __init__(self, event, body_parts, room_member_count): self._event = event + + # This is a list of words of the content.body (if event has one). Each + # word has been converted to lower case. self._body_parts = body_parts + self._room_member_count = room_member_count + # Maps strings of e.g. 'content.body' -> event["content"]["body"] self._value_cache = _flatten_dict(event) @staticmethod @@ -264,19 +269,13 @@ class PushRuleEvaluatorForEvent(object): return self._value_cache.get(dotted_key, None) -def _value_for_dotted_key(dotted_key, event): - parts = dotted_key.split(".") - val = event - while len(parts) > 0: - if parts[0] not in val: - return None - val = val[parts[0]] - parts = parts[1:] - - return val - - def _glob_to_matcher(glob): + """Takes a glob and returns a `func(string) -> bool`, which returns if the + string matches the glob. Assumes given string is lower case. + + The matcher returned is either a simple string comparison for globs without + wildcards, or a regex matcher for globs with wildcards. + """ glob = glob.lower() if not IS_GLOB.search(glob): |