diff --git a/clientapi/routing/directory.go b/clientapi/routing/directory.go index 5eda03912..034296f45 100644 --- a/clientapi/routing/directory.go +++ b/clientapi/routing/directory.go @@ -339,7 +339,7 @@ func SetVisibility( // NOTSPEC: Check if the user's power is greater than power required to change m.room.canonical_alias event power, _ := gomatrixserverlib.NewPowerLevelContentFromEvent(queryEventsRes.StateEvents[0].PDU) fullUserID, err := spec.NewUserID(dev.UserID, true) - if err != nil || fullUserID == nil { + if err != nil { return util.JSONResponse{ Code: http.StatusForbidden, JSON: spec.Forbidden("userID doesn't have power level to change visibility"), diff --git a/clientapi/routing/membership.go b/clientapi/routing/membership.go index a8044fdf6..78829bec9 100644 --- a/clientapi/routing/membership.go +++ b/clientapi/routing/membership.go @@ -67,7 +67,7 @@ func SendBan( return *errRes } fullUserID, err := spec.NewUserID(device.UserID, true) - if err != nil || fullUserID == nil { + if err != nil { return util.JSONResponse{ Code: http.StatusForbidden, JSON: spec.Forbidden("You don't have permission to ban this user, bad userID"), @@ -157,7 +157,7 @@ func SendKick( return *errRes } fullUserID, err := spec.NewUserID(device.UserID, true) - if err != nil || fullUserID == nil { + if err != nil { return util.JSONResponse{ Code: http.StatusForbidden, JSON: spec.Forbidden("You don't have permission to kick this user, bad userID"), diff --git a/clientapi/routing/redaction.go b/clientapi/routing/redaction.go index 914712a78..22474fc08 100644 --- a/clientapi/routing/redaction.go +++ b/clientapi/routing/redaction.go @@ -74,7 +74,7 @@ func SendRedaction( } fullUserID, userIDErr := spec.NewUserID(device.UserID, true) - if userIDErr != nil || fullUserID == nil { + if userIDErr != nil { return util.JSONResponse{ Code: http.StatusForbidden, JSON: spec.Forbidden("userID doesn't have power level to redact"), diff --git a/clientapi/routing/sendevent.go b/clientapi/routing/sendevent.go index 8788949d5..4d0a9f24a 100644 --- a/clientapi/routing/sendevent.go +++ b/clientapi/routing/sendevent.go @@ -267,7 +267,7 @@ func generateSendEvent( ) (gomatrixserverlib.PDU, *util.JSONResponse) { // parse the incoming http request fullUserID, err := spec.NewUserID(device.UserID, true) - if err != nil || fullUserID == nil { + if err != nil { return nil, &util.JSONResponse{ Code: http.StatusBadRequest, JSON: spec.BadJSON("Bad userID"), diff --git a/federationapi/internal/perform.go b/federationapi/internal/perform.go index 5f4dc682a..485b79a03 100644 --- a/federationapi/internal/perform.go +++ b/federationapi/internal/perform.go @@ -147,7 +147,7 @@ func (r *FederationInternalAPI) performJoinUsingServer( } user, err := spec.NewUserID(userID, true) - if err != nil || user == nil { + if err != nil { return err } room, err := spec.NewRoomID(roomID) diff --git a/roomserver/internal/perform/perform_admin.go b/roomserver/internal/perform/perform_admin.go index f8e3e577f..eeb1ac406 100644 --- a/roomserver/internal/perform/perform_admin.go +++ b/roomserver/internal/perform/perform_admin.go @@ -235,7 +235,7 @@ func (r *Admin) PerformAdminDownloadState( roomID, userID string, serverName spec.ServerName, ) error { fullUserID, err := spec.NewUserID(userID, true) - if err != nil || fullUserID == nil { + if err != nil { return err } senderDomain := fullUserID.Domain()