diff --git a/clientapi/routing/send_pdus.go b/clientapi/routing/send_pdus.go index 422882638..f50601ca3 100644 --- a/clientapi/routing/send_pdus.go +++ b/clientapi/routing/send_pdus.go @@ -43,6 +43,7 @@ type sendPDUsRequest struct { } // SendPDUs implements /sendPDUs +// nolint:gocyclo func SendPDUs( req *http.Request, device *api.Device, cfg *config.ClientAPI, @@ -195,17 +196,17 @@ func SendPDUs( JSON: spec.Forbidden("invalid state_key for membership event"), } } - userID, err := rsAPI.QueryUserIDForSender(req.Context(), pdu.RoomID(), spec.SenderID(*stateKey)) - if err != nil || userID == nil { + invitedUserID, err := rsAPI.QueryUserIDForSender(req.Context(), pdu.RoomID(), spec.SenderID(*stateKey)) + if err != nil || invitedUserID == nil { return util.JSONResponse{ Code: http.StatusNotFound, JSON: spec.NotFound("cannot find userID for invite event"), } } - if !cfg.Matrix.IsLocalServerName(spec.ServerName(userID.Domain())) { + if !cfg.Matrix.IsLocalServerName(spec.ServerName(invitedUserID.Domain())) { inviteReq := roomserverAPI.PerformInviteRequestCryptoIDs{ RoomID: pdu.RoomID().String(), - UserID: *userID, + UserID: *invitedUserID, InviteEvent: pdu, } err := rsAPI.PerformSendInviteCryptoIDs(req.Context(), &inviteReq) diff --git a/clientapi/routing/sendevent.go b/clientapi/routing/sendevent.go index 9f71bb593..094f3d286 100644 --- a/clientapi/routing/sendevent.go +++ b/clientapi/routing/sendevent.go @@ -535,8 +535,8 @@ func generateSendEvent( var identity fclient.SigningIdentity if !cryptoIDs { - id, err := rsAPI.SigningIdentityFor(ctx, *validRoomID, *fullUserID) - if err != nil { + id, idErr := rsAPI.SigningIdentityFor(ctx, *validRoomID, *fullUserID) + if idErr != nil { return nil, &util.JSONResponse{ Code: http.StatusInternalServerError, JSON: spec.InternalServerError{}, diff --git a/clientapi/routing/state.go b/clientapi/routing/state.go index 471294921..6041f14c9 100644 --- a/clientapi/routing/state.go +++ b/clientapi/routing/state.go @@ -198,6 +198,7 @@ func OnIncomingStateRequest(ctx context.Context, device *userapi.Device, rsAPI a // state to see if there is an event with that type and state key, if there // is then (by default) we return the content, otherwise a 404. // If eventFormat=true, sends the whole event else just the content. +// nolint:gocyclo func OnIncomingStateTypeRequest( ctx context.Context, device *userapi.Device, rsAPI api.ClientRoomserverAPI, roomID, evType, stateKey string, eventFormat bool, diff --git a/federationapi/internal/perform.go b/federationapi/internal/perform.go index 4a2609eb2..b5b734da9 100644 --- a/federationapi/internal/perform.go +++ b/federationapi/internal/perform.go @@ -310,7 +310,7 @@ func (r *FederationInternalAPI) PerformMakeJoin( WrappedError: nil, Message: "Unknown HTTP error", } - if lastError != nil { + if lastErr != nil { lastError.Message = lastErr.Error() } } @@ -451,7 +451,7 @@ func (r *FederationInternalAPI) PerformSendJoin( WrappedError: nil, Message: "Unknown HTTP error", } - if lastError != nil { + if lastErr != nil { lastError.Message = lastErr.Error() } } @@ -460,7 +460,6 @@ func (r *FederationInternalAPI) PerformSendJoin( "failed to join user %q to room %q through %d server(s): last error %s", request.UserID, request.RoomID, len(request.ServerNames), lastError, ) - return } func (r *FederationInternalAPI) performSendJoinUsingServer( diff --git a/roomserver/internal/perform/perform_join.go b/roomserver/internal/perform/perform_join.go index 3b847d510..a1aa1565c 100644 --- a/roomserver/internal/perform/perform_join.go +++ b/roomserver/internal/perform/perform_join.go @@ -663,8 +663,8 @@ func (r *Joiner) performJoinRoomByIDCryptoIDs( // If we should do a forced federated join then do that. if forceFederatedJoin { - joinEvent, version, serverName, err := r.performFederatedMakeJoinByIDCryptoIDs(ctx, req) - return joinEvent, req.RoomIDOrAlias, version, serverName, err + joinEvent, version, serverName, federatedJoinErr := r.performFederatedMakeJoinByIDCryptoIDs(ctx, req) + return joinEvent, req.RoomIDOrAlias, version, serverName, federatedJoinErr } // Try to construct an actual join event from the template. @@ -746,8 +746,8 @@ func (r *Joiner) performJoinRoomByIDCryptoIDs( } // Perform a federated room join. - joinEvent, version, serverName, err := r.performFederatedMakeJoinByIDCryptoIDs(ctx, req) - return joinEvent, req.RoomIDOrAlias, version, serverName, err + joinEvent, version, serverName, federatedJoinErr := r.performFederatedMakeJoinByIDCryptoIDs(ctx, req) + return joinEvent, req.RoomIDOrAlias, version, serverName, federatedJoinErr default: // Something else went wrong.