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

Convert Transation and Edu object to attrs #10542

Merged
merged 8 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions synapse/federation/sender/transaction_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ async def send_new_transaction(
len(edus),
)

transaction = Transaction.create_new(
transaction = Transaction(
origin_server_ts=int(self.clock.time_msec()),
transaction_id=txn_id,
origin=self._server_name,
destination=destination,
pdus=pdus,
edus=edus,
pdus=[p.get_pdu_json() for p in pdus],
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
edus=[edu.get_dict() for edu in edus],
)

self._next_txn_id += 1
Expand Down
14 changes: 0 additions & 14 deletions synapse/federation/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,3 @@ def __init__(self, transaction_id=None, pdus: Optional[list] = None, **kwargs):
del kwargs["edus"]

super().__init__(transaction_id=transaction_id, pdus=pdus or [], **kwargs)

@staticmethod
def create_new(pdus, **kwargs):
"""Used to create a new transaction. Will auto fill out
transaction_id and origin_server_ts keys.
"""
if "origin_server_ts" not in kwargs:
raise KeyError("Require 'origin_server_ts' to construct a Transaction")
if "transaction_id" not in kwargs:
raise KeyError("Require 'transaction_id' to construct a Transaction")

kwargs["pdus"] = [p.get_pdu_json() for p in pdus]

return Transaction(**kwargs)