0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-06-13 09:58:59 +02:00

Don't HTTP500 if a profile does't exist

This commit is contained in:
Till Faelligen 2023-07-14 14:24:31 +02:00
parent 6011ddc0a8
commit 33ff309572
No known key found for this signature in database
GPG key ID: ACCDC9606D472758

View file

@ -15,9 +15,11 @@
package routing
import (
"errors"
"fmt"
"net/http"
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
"github.com/matrix-org/dendrite/internal/eventutil"
"github.com/matrix-org/dendrite/setup/config"
userapi "github.com/matrix-org/dendrite/userapi/api"
@ -52,6 +54,12 @@ func GetProfile(
profile, err := userAPI.QueryProfile(httpReq.Context(), userID)
if err != nil {
if errors.Is(err, appserviceAPI.ErrProfileNotExists) {
return util.JSONResponse{
Code: http.StatusNotFound,
JSON: spec.NotFound("The user does not exist or does not have a profile."),
}
}
util.GetLogger(httpReq.Context()).WithError(err).Error("userAPI.QueryProfile failed")
return util.JSONResponse{
Code: http.StatusInternalServerError,