mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-26 10:09:21 -05:00
Fold _do_request_for_transaction into the methods that called it since it was a trivial wrapper around client.get_json
This commit is contained in:
parent
602684eac5
commit
2408c4b0a4
@ -29,7 +29,7 @@ class TransportLayerClient(object):
|
|||||||
"""Sends federation HTTP requests to other servers"""
|
"""Sends federation HTTP requests to other servers"""
|
||||||
|
|
||||||
@log_function
|
@log_function
|
||||||
def get_context_state(self, destination, context, event_id=None):
|
def get_context_state(self, destination, context, event_id):
|
||||||
""" Requests all state for a given context (i.e. room) from the
|
""" Requests all state for a given context (i.e. room) from the
|
||||||
given server.
|
given server.
|
||||||
|
|
||||||
@ -37,6 +37,7 @@ class TransportLayerClient(object):
|
|||||||
destination (str): The host name of the remote home server we want
|
destination (str): The host name of the remote home server we want
|
||||||
to get the state from.
|
to get the state from.
|
||||||
context (str): The name of the context we want the state of
|
context (str): The name of the context we want the state of
|
||||||
|
event_id (str): The event we want the context at.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Deferred: Results in a dict received from the remote homeserver.
|
Deferred: Results in a dict received from the remote homeserver.
|
||||||
@ -44,14 +45,9 @@ class TransportLayerClient(object):
|
|||||||
logger.debug("get_context_state dest=%s, context=%s",
|
logger.debug("get_context_state dest=%s, context=%s",
|
||||||
destination, context)
|
destination, context)
|
||||||
|
|
||||||
subpath = "/state/%s/" % context
|
path = PREFIX + "/state/%s/" % context
|
||||||
|
return self.client.get_json(
|
||||||
args = {}
|
destination, path=path, args={"event_id": event_id},
|
||||||
if event_id:
|
|
||||||
args["event_id"] = event_id
|
|
||||||
|
|
||||||
return self._do_request_for_transaction(
|
|
||||||
destination, subpath, args=args
|
|
||||||
)
|
)
|
||||||
|
|
||||||
@log_function
|
@log_function
|
||||||
@ -69,9 +65,8 @@ class TransportLayerClient(object):
|
|||||||
logger.debug("get_pdu dest=%s, event_id=%s",
|
logger.debug("get_pdu dest=%s, event_id=%s",
|
||||||
destination, event_id)
|
destination, event_id)
|
||||||
|
|
||||||
subpath = "/event/%s/" % (event_id, )
|
path = PREFIX + "/event/%s/" % (event_id, )
|
||||||
|
return self.client.get_json(destination, path=path)
|
||||||
return self._do_request_for_transaction(destination, subpath)
|
|
||||||
|
|
||||||
@log_function
|
@log_function
|
||||||
def backfill(self, dest, context, event_tuples, limit):
|
def backfill(self, dest, context, event_tuples, limit):
|
||||||
@ -96,16 +91,16 @@ class TransportLayerClient(object):
|
|||||||
# TODO: raise?
|
# TODO: raise?
|
||||||
return
|
return
|
||||||
|
|
||||||
subpath = "/backfill/%s/" % (context,)
|
path = PREFIX + "/backfill/%s/" % (context,)
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
"v": event_tuples,
|
"v": event_tuples,
|
||||||
"limit": [str(limit)],
|
"limit": [str(limit)],
|
||||||
}
|
}
|
||||||
|
|
||||||
return self._do_request_for_transaction(
|
return self.client.get_json(
|
||||||
dest,
|
destination,
|
||||||
subpath,
|
path=path,
|
||||||
args=args,
|
args=args,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -227,31 +222,3 @@ class TransportLayerClient(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
defer.returnValue(response)
|
defer.returnValue(response)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
|
||||||
@log_function
|
|
||||||
def _do_request_for_transaction(self, destination, subpath, args={}):
|
|
||||||
"""
|
|
||||||
Args:
|
|
||||||
destination (str)
|
|
||||||
path (str)
|
|
||||||
args (dict): This is parsed directly to the HttpClient.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Deferred: Results in a dict.
|
|
||||||
"""
|
|
||||||
|
|
||||||
data = yield self.client.get_json(
|
|
||||||
destination,
|
|
||||||
path=PREFIX + subpath,
|
|
||||||
args=args,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Add certain keys to the JSON, ready for decoding as a Transaction
|
|
||||||
data.update(
|
|
||||||
origin=destination,
|
|
||||||
destination=self.server_name,
|
|
||||||
transaction_id=None
|
|
||||||
)
|
|
||||||
|
|
||||||
defer.returnValue(data)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user