mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 00:03:09 -06:00
Add auth chain to federated response
This commit is contained in:
parent
4b4ff74103
commit
04e879b581
|
|
@ -198,6 +198,30 @@ func federatedEventRelationship(
|
|||
if resErr != nil {
|
||||
return *resErr
|
||||
}
|
||||
// add auth chain information
|
||||
requiredAuthEventsSet := make(map[string]bool)
|
||||
var requiredAuthEvents []string
|
||||
for _, ev := range res.Events {
|
||||
for _, a := range ev.AuthEventIDs() {
|
||||
if requiredAuthEventsSet[a] {
|
||||
continue
|
||||
}
|
||||
requiredAuthEvents = append(requiredAuthEvents, a)
|
||||
requiredAuthEventsSet[a] = true
|
||||
}
|
||||
}
|
||||
var queryRes roomserver.QueryAuthChainResponse
|
||||
err = rsAPI.QueryAuthChain(ctx, &roomserver.QueryAuthChainRequest{
|
||||
EventIDs: requiredAuthEvents,
|
||||
}, &queryRes)
|
||||
if err != nil {
|
||||
// they may already have the auth events so don't fail this request
|
||||
util.GetLogger(ctx).WithError(err).Error("Failed to QueryAuthChain")
|
||||
}
|
||||
res.AuthChain = make([]*gomatrixserverlib.Event, len(queryRes.AuthChain))
|
||||
for i := range queryRes.AuthChain {
|
||||
res.AuthChain[i] = queryRes.AuthChain[i].Unwrap()
|
||||
}
|
||||
|
||||
return util.JSONResponse{
|
||||
Code: 200,
|
||||
|
|
|
|||
|
|
@ -127,7 +127,8 @@ type RoomserverInternalAPI interface {
|
|||
) error
|
||||
|
||||
// QueryAuthChain returns the entire auth chain for the event IDs given.
|
||||
// Omits without error any missing auth events.
|
||||
// The response includes the events in the request.
|
||||
// Omits without error for any missing auth events. There will be no duplicates.
|
||||
QueryAuthChain(
|
||||
ctx context.Context,
|
||||
request *QueryAuthChainRequest,
|
||||
|
|
|
|||
Loading…
Reference in a new issue