Merge pull request #4137 from matrix-org/erikj/clean_up_events

Clean up event accesses and tests
This commit is contained in:
Erik Johnston 2018-11-02 14:12:49 +00:00 committed by GitHub
commit 90d713b8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 10 deletions

1
changelog.d/4137.misc Normal file
View File

@ -0,0 +1 @@
Clean up event accesses and tests

View File

@ -117,9 +117,6 @@ class Transaction(JsonEncodedObject):
"Require 'transaction_id' to construct a Transaction" "Require 'transaction_id' to construct a Transaction"
) )
for p in pdus:
p.transaction_id = kwargs["transaction_id"]
kwargs["pdus"] = [p.get_pdu_json() for p in pdus] kwargs["pdus"] = [p.get_pdu_json() for p in pdus]
return Transaction(**kwargs) return Transaction(**kwargs)

View File

@ -311,10 +311,10 @@ class HttpPusher(object):
] ]
} }
} }
if event.type == 'm.room.member': if event.type == 'm.room.member' and event.is_state():
d['notification']['membership'] = event.content['membership'] d['notification']['membership'] = event.content['membership']
d['notification']['user_is_target'] = event.state_key == self.user_id 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 and event.content:
d['notification']['content'] = event.content d['notification']['content'] = event.content
# We no longer send aliases separately, instead, we send the human # We no longer send aliases separately, instead, we send the human

View File

@ -124,7 +124,7 @@ class PushRuleEvaluatorForEvent(object):
# XXX: optimisation: cache our pattern regexps # XXX: optimisation: cache our pattern regexps
if condition['key'] == 'content.body': if condition['key'] == 'content.body':
body = self._event["content"].get("body", None) body = self._event.content.get("body", None)
if not body: if not body:
return False return False
@ -140,7 +140,7 @@ class PushRuleEvaluatorForEvent(object):
if not display_name: if not display_name:
return False return False
body = self._event["content"].get("body", None) body = self._event.content.get("body", None)
if not body: if not body:
return False return False

View File

@ -28,8 +28,8 @@ ROOM_ID = "!room:blue"
def dict_equals(self, other): def dict_equals(self, other):
me = encode_canonical_json(self._event_dict) me = encode_canonical_json(self.get_pdu_json())
them = encode_canonical_json(other._event_dict) them = encode_canonical_json(other.get_pdu_json())
return me == them return me == them

View File

@ -112,7 +112,7 @@ class MessageAcceptTests(unittest.TestCase):
"origin_server_ts": 1, "origin_server_ts": 1,
"type": "m.room.message", "type": "m.room.message",
"origin": "test.serv", "origin": "test.serv",
"content": "hewwo?", "content": {"body": "hewwo?"},
"auth_events": [], "auth_events": [],
"prev_events": [("two:test.serv", {}), (most_recent, {})], "prev_events": [("two:test.serv", {}), (most_recent, {})],
} }