Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
morguldir committed Nov 7, 2024
1 parent f55e645 commit 464e9cf
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,14 @@ async def _handle_pdus_in_txn(
# v1/v2 events, then it's invalid and we should reject it.
if possible_event_id != _UNKNOWN_EVENT_ID:
if room_version.event_format != EventFormatVersions.ROOM_V1_V2:
logger.info(f"Rejecting event {possible_event_id} from {origin} "
f"because the event was made for a v1 room, "
f"while {room_id} is a v{room_version.identifier} room")
pdu_results[possible_event_id] = {"error": "Event ID should not be supplied in non-v1/v2 room"}
logger.info(
f"Rejecting event {possible_event_id} from {origin} "
f"because the event was made for a v1 room, "
f"while {room_id} is a v{room_version.identifier} room"
)
pdu_results[possible_event_id] = {
"error": "Event ID should not be supplied in non-v1/v2 room"
}
continue

try:
Expand All @@ -497,8 +501,12 @@ async def _handle_pdus_in_txn(
# but since we we failed to parse the event, we can't derive the `event_id` so there is nothing
# to use as the `pdu_results` key. Best we can do is just log for our own record and move on.
if possible_event_id != _UNKNOWN_EVENT_ID:
pdu_results[possible_event_id] = {"error": f"Failed to convert json into event, {e}"}
logger.warning("Failed to parse event {possible_event_id} in transaction from {origin}, due to {e}")
pdu_results[possible_event_id] = {
"error": f"Failed to convert json into event, {e}"
}
logger.warning(
"Failed to parse event {possible_event_id} in transaction from {origin}, due to {e}"
)
continue

pdus_by_room.setdefault(room_id, []).append(event)
Expand Down

0 comments on commit 464e9cf

Please sign in to comment.