|
66 | 66 | event_from_pdu_json,
|
67 | 67 | )
|
68 | 68 | from synapse.federation.persistence import TransactionActions
|
69 |
| -from synapse.federation.units import Edu, Transaction |
| 69 | +from synapse.federation.units import Edu, Transaction, serialize_and_filter_pdus |
70 | 70 | from synapse.handlers.worker_lock import NEW_EVENT_DURING_PURGE_LOCK_NAME
|
71 | 71 | from synapse.http.servlet import assert_params_in_dict
|
72 | 72 | from synapse.logging.context import (
|
@@ -469,7 +469,12 @@ async def _handle_pdus_in_txn(
|
469 | 469 | logger.info("Ignoring PDU: %s", e)
|
470 | 470 | continue
|
471 | 471 |
|
472 |
| - event = event_from_pdu_json(p, room_version) |
| 472 | + try: |
| 473 | + event = event_from_pdu_json(p, room_version) |
| 474 | + except SynapseError as e: |
| 475 | + logger.info("Ignoring PDU for failing to deserialize: %s", e) |
| 476 | + continue |
| 477 | + |
473 | 478 | pdus_by_room.setdefault(room_id, []).append(event)
|
474 | 479 |
|
475 | 480 | if event.origin_server_ts > newest_pdu_ts:
|
@@ -636,8 +641,8 @@ async def _on_context_state_request_compute(
|
636 | 641 | )
|
637 | 642 |
|
638 | 643 | return {
|
639 |
| - "pdus": [pdu.get_pdu_json() for pdu in pdus], |
640 |
| - "auth_chain": [pdu.get_pdu_json() for pdu in auth_chain], |
| 644 | + "pdus": serialize_and_filter_pdus(pdus), |
| 645 | + "auth_chain": serialize_and_filter_pdus(auth_chain), |
641 | 646 | }
|
642 | 647 |
|
643 | 648 | async def on_pdu_request(
|
@@ -761,8 +766,8 @@ async def on_send_join_request(
|
761 | 766 | event_json = event.get_pdu_json(time_now)
|
762 | 767 | resp = {
|
763 | 768 | "event": event_json,
|
764 |
| - "state": [p.get_pdu_json(time_now) for p in state_events], |
765 |
| - "auth_chain": [p.get_pdu_json(time_now) for p in auth_chain_events], |
| 769 | + "state": serialize_and_filter_pdus(state_events, time_now), |
| 770 | + "auth_chain": serialize_and_filter_pdus(auth_chain_events, time_now), |
766 | 771 | "members_omitted": caller_supports_partial_state,
|
767 | 772 | }
|
768 | 773 |
|
@@ -1005,7 +1010,7 @@ async def on_event_auth(
|
1005 | 1010 |
|
1006 | 1011 | time_now = self._clock.time_msec()
|
1007 | 1012 | auth_pdus = await self.handler.on_event_auth(event_id)
|
1008 |
| - res = {"auth_chain": [a.get_pdu_json(time_now) for a in auth_pdus]} |
| 1013 | + res = {"auth_chain": serialize_and_filter_pdus(auth_pdus, time_now)} |
1009 | 1014 | return 200, res
|
1010 | 1015 |
|
1011 | 1016 | async def on_query_client_keys(
|
@@ -1090,7 +1095,7 @@ async def on_get_missing_events(
|
1090 | 1095 |
|
1091 | 1096 | time_now = self._clock.time_msec()
|
1092 | 1097 |
|
1093 |
| - return {"events": [ev.get_pdu_json(time_now) for ev in missing_events]} |
| 1098 | + return {"events": serialize_and_filter_pdus(missing_events, time_now)} |
1094 | 1099 |
|
1095 | 1100 | async def on_openid_userinfo(self, token: str) -> Optional[str]:
|
1096 | 1101 | ts_now_ms = self._clock.time_msec()
|
|
0 commit comments