mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-26 15:08:28 +00:00
Don't HTTP500 if a profile does't exist
This commit is contained in:
parent
6011ddc0a8
commit
33ff309572
1 changed files with 8 additions and 0 deletions
|
@ -15,9 +15,11 @@
|
||||||
package routing
|
package routing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
||||||
"github.com/matrix-org/dendrite/internal/eventutil"
|
"github.com/matrix-org/dendrite/internal/eventutil"
|
||||||
"github.com/matrix-org/dendrite/setup/config"
|
"github.com/matrix-org/dendrite/setup/config"
|
||||||
userapi "github.com/matrix-org/dendrite/userapi/api"
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
||||||
|
@ -52,6 +54,12 @@ func GetProfile(
|
||||||
|
|
||||||
profile, err := userAPI.QueryProfile(httpReq.Context(), userID)
|
profile, err := userAPI.QueryProfile(httpReq.Context(), userID)
|
||||||
if err != nil {
|
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")
|
util.GetLogger(httpReq.Context()).WithError(err).Error("userAPI.QueryProfile failed")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
|
Loading…
Reference in a new issue