Skip to content

Commit

Permalink
Selectively handle EDUs
Browse files Browse the repository at this point in the history
  • Loading branch information
turt2live committed Oct 6, 2022
1 parent dc5069d commit f3eb2b2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions synapse/federation/transport/server/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,32 @@ async def on_PUT(

logger.debug("Decoded %s: %s", transaction_id, str(transaction_data))

edus_before_filter = len(transaction_data.get("edus", []))

filtered_edus = []
for edu in transaction_data.get("edus", []):
edu_type = edu.get('edu_type', 'io.t2bot.ignored')
if edu_type == 'io.t2bot.ignored':
continue
if edu_type == 'm.presence':
continue
if edu_type == 'm.receipt':
continue
if edu_type == 'm.typing':
continue
filtered_edus.append(edu)

logger.info(
"Received txn %s from %s. (PDUs: %d, EDUs: %d)",
"Received txn %s from %s. (PDUs: %d, Accepted EDUs: %d, Ignored EDUs: %d)",
transaction_id,
origin,
len(transaction_data.get("pdus", [])),
len(transaction_data.get("edus", [])),
len(filtered_edus),
edus_before_filter - len(filtered_edus),
)

transaction_data["edus"] = filtered_edus

if issue_8631_logger.isEnabledFor(logging.DEBUG):
DEVICE_UPDATE_EDUS = [
EduTypes.DEVICE_LIST_UPDATE,
Expand Down

0 comments on commit f3eb2b2

Please sign in to comment.