From 75ca54cd52a036c334746e38757fecdcd0df3422 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Mon, 26 Feb 2018 16:00:36 +0000 Subject: [PATCH] Remove __getitem__ and __contains__ from EventBase --- synapse/events/__init__.py | 6 ------ synapse/push/httppusher.py | 2 +- synapse/push/push_rule_evaluator.py | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/synapse/events/__init__.py b/synapse/events/__init__.py index e673e96cc0..79bbdfcf2c 100644 --- a/synapse/events/__init__.py +++ b/synapse/events/__init__.py @@ -127,12 +127,6 @@ class EventBase(object): def __set__(self, instance, value): raise AttributeError("Unrecognized attribute %s" % (instance,)) - def __getitem__(self, field): - return self._event_dict[field] - - def __contains__(self, field): - return field in self._event_dict - def items(self): return self._event_dict.items() diff --git a/synapse/push/httppusher.py b/synapse/push/httppusher.py index 2cbac571b8..eb8987855e 100644 --- a/synapse/push/httppusher.py +++ b/synapse/push/httppusher.py @@ -313,7 +313,7 @@ class HttpPusher(object): if event.type == 'm.room.member': d['notification']['membership'] = event.content['membership'] d['notification']['user_is_target'] = event.state_key == self.user_id - if self.hs.config.push_include_content and 'content' in event: + if self.hs.config.push_include_content: d['notification']['content'] = event.content # We no longer send aliases separately, instead, we send the human diff --git a/synapse/push/push_rule_evaluator.py b/synapse/push/push_rule_evaluator.py index 3601f2d365..ad24167d15 100644 --- a/synapse/push/push_rule_evaluator.py +++ b/synapse/push/push_rule_evaluator.py @@ -122,7 +122,7 @@ class PushRuleEvaluatorForEvent(object): # XXX: optimisation: cache our pattern regexps if condition['key'] == 'content.body': - body = self._event["content"].get("body", None) + body = self._event.content.get("body", None) if not body: return False @@ -138,7 +138,7 @@ class PushRuleEvaluatorForEvent(object): if not display_name: return False - body = self._event["content"].get("body", None) + body = self._event.content.get("body", None) if not body: return False