diff --git a/roomserver/api/perform.go b/roomserver/api/perform.go index 20931f807..249e6bdff 100644 --- a/roomserver/api/perform.go +++ b/roomserver/api/perform.go @@ -57,6 +57,11 @@ func (p *PerformError) JSONResponse() util.JSONResponse { // TODO: Should we assert this is in fact JSON? E.g gjson parse? JSON: json.RawMessage(p.Msg), } + case PerformErrorNotFound: + return util.JSONResponse{ + Code: http.StatusNotFound, + JSON: jsonerror.NotFound(p.Msg), + } default: return util.ErrorResponse(p) } @@ -73,6 +78,8 @@ const ( PerformErrorNoOperation PerformErrorCode = 4 // PerformErrRemote means that the request failed and the PerformError.Msg is the raw remote JSON error response PerformErrRemote PerformErrorCode = 5 + // PerformErrorNotFound means the thing they were trying to do was not found. + PerformErrorNotFound PerformErrorCode = 6 ) type PerformJoinRequest struct { diff --git a/roomserver/internal/perform/perform_invite.go b/roomserver/internal/perform/perform_invite.go index 08b1035fa..39f48a4a5 100644 --- a/roomserver/internal/perform/perform_invite.go +++ b/roomserver/internal/perform/perform_invite.go @@ -92,7 +92,7 @@ func (r *Inviter) PerformInvite( } if userRes.Available { res.Error = &api.PerformError{ - Code: api.PerformErrorBadRequest, + Code: api.PerformErrorNotFound, Msg: fmt.Sprintf("The user ID %q does not exist!", targetUserID), } return nil, nil