mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-22 03:31:41 +00:00
Don't HTTP500 if a profile does't exist
This commit is contained in:
parent
6011ddc0a8
commit
33ff309572
@ -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 New Issue
Block a user