mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Fix lint errors
This commit is contained in:
parent
706e5abbc9
commit
77f912721a
2 changed files with 6 additions and 61 deletions
|
@ -36,11 +36,11 @@ func (f *FederationInternalAPI) QueryEventAuthFromFederation(
|
||||||
}
|
}
|
||||||
|
|
||||||
tryHost := func(serverName gomatrixserverlib.ServerName) error {
|
tryHost := func(serverName gomatrixserverlib.ServerName) error {
|
||||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
reqctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
ires, err := f.doRequest(serverName, func() (interface{}, error) {
|
ires, err := f.doRequest(serverName, func() (interface{}, error) {
|
||||||
return f.federation.GetEventAuth(
|
return f.federation.GetEventAuth(
|
||||||
ctx,
|
reqctx,
|
||||||
serverName,
|
serverName,
|
||||||
request.RoomID,
|
request.RoomID,
|
||||||
request.EventID,
|
request.EventID,
|
||||||
|
@ -76,11 +76,11 @@ func (f *FederationInternalAPI) QueryStateIDsFromFederation(
|
||||||
}
|
}
|
||||||
|
|
||||||
tryHost := func(serverName gomatrixserverlib.ServerName) error {
|
tryHost := func(serverName gomatrixserverlib.ServerName) error {
|
||||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
reqctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
ires, err := f.doRequest(serverName, func() (interface{}, error) {
|
ires, err := f.doRequest(serverName, func() (interface{}, error) {
|
||||||
return f.federation.LookupStateIDs(
|
return f.federation.LookupStateIDs(
|
||||||
ctx,
|
reqctx,
|
||||||
serverName,
|
serverName,
|
||||||
request.RoomID,
|
request.RoomID,
|
||||||
request.EventID,
|
request.EventID,
|
||||||
|
@ -117,11 +117,11 @@ func (f *FederationInternalAPI) QueryStateFromFederation(
|
||||||
}
|
}
|
||||||
|
|
||||||
tryHost := func(serverName gomatrixserverlib.ServerName) error {
|
tryHost := func(serverName gomatrixserverlib.ServerName) error {
|
||||||
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
reqctx, cancel := context.WithTimeout(ctx, time.Second*30)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
ires, err := f.doRequest(serverName, func() (interface{}, error) {
|
ires, err := f.doRequest(serverName, func() (interface{}, error) {
|
||||||
return f.federation.LookupState(
|
return f.federation.LookupState(
|
||||||
ctx,
|
reqctx,
|
||||||
serverName,
|
serverName,
|
||||||
request.RoomID,
|
request.RoomID,
|
||||||
request.EventID,
|
request.EventID,
|
||||||
|
|
|
@ -697,61 +697,6 @@ func (t *txnReq) processEvent(ctx context.Context, e *gomatrixserverlib.Event) e
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *txnReq) retrieveMissingAuthEvents(
|
|
||||||
ctx context.Context, e *gomatrixserverlib.Event, stateResp *api.QueryMissingAuthPrevEventsResponse,
|
|
||||||
) error {
|
|
||||||
logger := util.GetLogger(ctx).WithField("event_id", e.EventID()).WithField("room_id", e.RoomID())
|
|
||||||
|
|
||||||
missingAuthEvents := make(map[string]struct{})
|
|
||||||
for _, missingAuthEventID := range stateResp.MissingAuthEventIDs {
|
|
||||||
missingAuthEvents[missingAuthEventID] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
withNextEvent:
|
|
||||||
for missingAuthEventID := range missingAuthEvents {
|
|
||||||
withNextServer:
|
|
||||||
for _, server := range t.getServers(ctx, e.RoomID(), e) {
|
|
||||||
logger.Infof("Retrieving missing auth event %q from %q", missingAuthEventID, server)
|
|
||||||
tx, err := t.federation.GetEvent(ctx, server, missingAuthEventID)
|
|
||||||
if err != nil {
|
|
||||||
logger.WithError(err).Warnf("Failed to retrieve auth event %q", missingAuthEventID)
|
|
||||||
if errors.Is(err, context.DeadlineExceeded) {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue withNextServer
|
|
||||||
}
|
|
||||||
ev, err := gomatrixserverlib.NewEventFromUntrustedJSON(tx.PDUs[0], stateResp.RoomVersion)
|
|
||||||
if err != nil {
|
|
||||||
logger.WithError(err).Warnf("Failed to unmarshal auth event %q", missingAuthEventID)
|
|
||||||
continue withNextServer
|
|
||||||
}
|
|
||||||
if err = api.SendInputRoomEvents(
|
|
||||||
context.Background(),
|
|
||||||
t.rsAPI,
|
|
||||||
[]api.InputRoomEvent{
|
|
||||||
{
|
|
||||||
Kind: api.KindOutlier,
|
|
||||||
Event: ev.Headered(stateResp.RoomVersion),
|
|
||||||
AuthEventIDs: ev.AuthEventIDs(),
|
|
||||||
SendAsServer: api.DoNotSendToOtherServers,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
); err != nil {
|
|
||||||
return fmt.Errorf("api.SendEvents: %w", err)
|
|
||||||
}
|
|
||||||
t.hadEvent(ev.EventID(), true) // if the roomserver didn't know about the event before, it does now
|
|
||||||
t.cacheAndReturn(ev.Headered(stateResp.RoomVersion))
|
|
||||||
delete(missingAuthEvents, missingAuthEventID)
|
|
||||||
continue withNextEvent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if missing := len(missingAuthEvents); missing > 0 {
|
|
||||||
return fmt.Errorf("event refers to %d auth_events which we failed to fetch", missing)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkAllowedByState(e *gomatrixserverlib.Event, stateEvents []*gomatrixserverlib.Event) error {
|
func checkAllowedByState(e *gomatrixserverlib.Event, stateEvents []*gomatrixserverlib.Event) error {
|
||||||
authUsingState := gomatrixserverlib.NewAuthEvents(nil)
|
authUsingState := gomatrixserverlib.NewAuthEvents(nil)
|
||||||
for i := range stateEvents {
|
for i := range stateEvents {
|
||||||
|
|
Loading…
Reference in a new issue