Fix linter errors

This commit is contained in:
Devon Hudson 2023-05-23 13:29:11 -06:00
parent e573010cd2
commit b426961d84
No known key found for this signature in database
GPG key ID: CD06B18E77F6A628

View file

@ -61,17 +61,17 @@ func InviteV2(
} }
} }
invitedUser, err := spec.NewUserID(*inviteReq.Event().StateKey(), true) invitedUser, userErr := spec.NewUserID(*inviteReq.Event().StateKey(), true)
if err != nil { if userErr != nil {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: spec.InvalidParam(fmt.Sprintf("The user ID is invalid")), JSON: spec.InvalidParam("The user ID is invalid"),
} }
} }
if !cfg.Matrix.IsLocalServerName(invitedUser.Domain()) { if !cfg.Matrix.IsLocalServerName(invitedUser.Domain()) {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: spec.InvalidParam(fmt.Sprintf("The invited user domain does not belong to this server")), JSON: spec.InvalidParam("The invited user domain does not belong to this server"),
} }
} }
@ -134,7 +134,7 @@ func InviteV1(
} }
} }
var strippedState []gomatrixserverlib.InviteStrippedState var strippedState []gomatrixserverlib.InviteStrippedState
if err := json.Unmarshal(event.Unsigned(), &strippedState); err != nil { if jsonErr := json.Unmarshal(event.Unsigned(), &strippedState); jsonErr != nil {
// just warn, they may not have added any. // just warn, they may not have added any.
util.GetLogger(httpReq.Context()).Warnf("failed to extract stripped state from invite event") util.GetLogger(httpReq.Context()).Warnf("failed to extract stripped state from invite event")
} }
@ -150,13 +150,13 @@ func InviteV1(
if err != nil { if err != nil {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: spec.InvalidParam(fmt.Sprintf("The user ID is invalid")), JSON: spec.InvalidParam("The user ID is invalid"),
} }
} }
if !cfg.Matrix.IsLocalServerName(invitedUser.Domain()) { if !cfg.Matrix.IsLocalServerName(invitedUser.Domain()) {
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusBadRequest, Code: http.StatusBadRequest,
JSON: spec.InvalidParam(fmt.Sprintf("The invited user domain does not belong to this server")), JSON: spec.InvalidParam("The invited user domain does not belong to this server"),
} }
} }