This commit is contained in:
Neil Alexander 2020-05-04 13:16:43 +01:00
parent 56e980782b
commit 68ef3b5502
2 changed files with 8 additions and 15 deletions

View file

@ -130,8 +130,8 @@ func MakeJoin(
} }
// SendJoin implements the /send_join API // SendJoin implements the /send_join API
// TODO: Is there a way to break this function up in a way that actually // The make-join send-join dance makes much more sense as a single
// makes sense? // flow so the cyclomatic complexity is high:
// nolint:gocyclo // nolint:gocyclo
func SendJoin( func SendJoin(
httpReq *http.Request, httpReq *http.Request,

View file

@ -49,7 +49,6 @@ func (r *FederationSenderInternalAPI) PerformJoin(
// Try each server that we were provided until we land on one that // Try each server that we were provided until we land on one that
// successfully completes the make-join send-join dance. // successfully completes the make-join send-join dance.
succeeded := false
for _, serverName := range request.ServerNames { for _, serverName := range request.ServerNames {
// Try to perform a make_join using the information supplied in the // Try to perform a make_join using the information supplied in the
// request. // request.
@ -138,20 +137,14 @@ func (r *FederationSenderInternalAPI) PerformJoin(
} }
// We're all good. // We're all good.
succeeded = true return nil
break
} }
if succeeded { // If we reach here then we didn't complete a join for some reason.
// Everything went to plan.
return nil
} else {
// We didn't complete a join for some reason.
return fmt.Errorf( return fmt.Errorf(
"failed to join user %q to room %q through %d server(s)", "failed to join user %q to room %q through %d server(s)",
request.UserID, request.RoomID, len(request.ServerNames), request.UserID, request.RoomID, len(request.ServerNames),
) )
}
} }
// PerformLeaveRequest implements api.FederationSenderInternalAPI // PerformLeaveRequest implements api.FederationSenderInternalAPI