From b8deaa077e82a1d1418f704659abaa609e6d400b Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 27 Nov 2018 10:32:30 +0000 Subject: Strip signatures and hashes on outgoing events --- synapse/federation/units.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'synapse/federation/units.py') diff --git a/synapse/federation/units.py b/synapse/federation/units.py index 025a79c022..d278475d9a 100644 --- a/synapse/federation/units.py +++ b/synapse/federation/units.py @@ -117,6 +117,26 @@ class Transaction(JsonEncodedObject): "Require 'transaction_id' to construct a Transaction" ) - kwargs["pdus"] = [p.get_pdu_json() for p in pdus] + kwargs["pdus"] = [ + _mangle_pdu(p.get_pdu_json()) + for p in pdus + ] return Transaction(**kwargs) + + +def _mangle_pdu(pdu_json): + pdu_json.pop("hashes", None) + pdu_json.pop("signatures", None) + + pdu_json["auth_events"] = list(_strip_hashes(pdu_json["auth_events"])) + pdu_json["prev_events"] = list(_strip_hashes(pdu_json["prev_events"])) + + return pdu_json + + +def _strip_hashes(iterable): + return ( + (e, {}) + for e, hashes in iterable + ) -- cgit 1.5.1