mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Merge pull request #1063 from matrix-org/erikj/pull_out_ids_only
Only pull out IDs from DB for /state_ids/ request
This commit is contained in:
commit
1ffe9578d1
@ -223,16 +223,14 @@ class FederationServer(FederationBase):
|
|||||||
if not in_room:
|
if not in_room:
|
||||||
raise AuthError(403, "Host not in room.")
|
raise AuthError(403, "Host not in room.")
|
||||||
|
|
||||||
pdus = yield self.handler.get_state_for_pdu(
|
state_ids = yield self.handler.get_state_ids_for_pdu(
|
||||||
room_id, event_id,
|
room_id, event_id,
|
||||||
)
|
)
|
||||||
auth_chain = yield self.store.get_auth_chain(
|
auth_chain_ids = yield self.store.get_auth_chain_ids(state_ids)
|
||||||
[pdu.event_id for pdu in pdus]
|
|
||||||
)
|
|
||||||
|
|
||||||
defer.returnValue((200, {
|
defer.returnValue((200, {
|
||||||
"pdu_ids": [pdu.event_id for pdu in pdus],
|
"pdu_ids": state_ids,
|
||||||
"auth_chain_ids": [pdu.event_id for pdu in auth_chain],
|
"auth_chain_ids": auth_chain_ids,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
@ -1102,6 +1102,32 @@ class FederationHandler(BaseHandler):
|
|||||||
else:
|
else:
|
||||||
defer.returnValue([])
|
defer.returnValue([])
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def get_state_ids_for_pdu(self, room_id, event_id):
|
||||||
|
yield run_on_reactor()
|
||||||
|
|
||||||
|
state_groups = yield self.store.get_state_groups_ids(
|
||||||
|
room_id, [event_id]
|
||||||
|
)
|
||||||
|
|
||||||
|
if state_groups:
|
||||||
|
_, state = state_groups.items().pop()
|
||||||
|
results = state
|
||||||
|
|
||||||
|
event = yield self.store.get_event(event_id)
|
||||||
|
if event and event.is_state():
|
||||||
|
# Get previous state
|
||||||
|
if "replaces_state" in event.unsigned:
|
||||||
|
prev_id = event.unsigned["replaces_state"]
|
||||||
|
if prev_id != event.event_id:
|
||||||
|
results[(event.type, event.state_key)] = prev_id
|
||||||
|
else:
|
||||||
|
del results[(event.type, event.state_key)]
|
||||||
|
|
||||||
|
defer.returnValue(results.values())
|
||||||
|
else:
|
||||||
|
defer.returnValue([])
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
@log_function
|
@log_function
|
||||||
def on_backfill_request(self, origin, room_id, pdu_list, limit):
|
def on_backfill_request(self, origin, room_id, pdu_list, limit):
|
||||||
|
Loading…
Reference in New Issue
Block a user