Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Clean up event accesses and tests #4137

Merged
merged 2 commits into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/4137.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean up event accesses and tests
3 changes: 0 additions & 3 deletions synapse/federation/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,6 @@ def create_new(pdus, **kwargs):
"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]

return Transaction(**kwargs)
4 changes: 2 additions & 2 deletions synapse/push/httppusher.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ def _build_notification_dict(self, event, tweaks, badge):
]
}
}
if event.type == 'm.room.member':
if event.type == 'm.room.member' and event.is_state():
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 and event.content:
d['notification']['content'] = event.content

# We no longer send aliases separately, instead, we send the human
Expand Down
4 changes: 2 additions & 2 deletions synapse/push/push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _event_match(self, condition, user_id):

# 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

Expand All @@ -140,7 +140,7 @@ def _contains_display_name(self, display_name):
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

Expand Down
4 changes: 2 additions & 2 deletions tests/replication/slave/storage/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@


def dict_equals(self, other):
me = encode_canonical_json(self._event_dict)
them = encode_canonical_json(other._event_dict)
me = encode_canonical_json(self.get_pdu_json())
them = encode_canonical_json(other.get_pdu_json())
return me == them


Expand Down
2 changes: 1 addition & 1 deletion tests/test_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def post_json(destination, path, data, headers=None, timeout=0):
"origin_server_ts": 1,
"type": "m.room.message",
"origin": "test.serv",
"content": "hewwo?",
"content": {"body": "hewwo?"},
"auth_events": [],
"prev_events": [("two:test.serv", {}), (most_recent, {})],
}
Expand Down