feat: update memo visibility in frontend

This commit is contained in:
boojack
2022-07-08 23:38:24 +08:00
parent 697d01e306
commit 1afc183458
11 changed files with 72 additions and 19 deletions

View File

@ -63,12 +63,14 @@ func (s *Server) registerUserRoutes(g *echo.Group) {
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch user").SetInternal(err)
}
if user == nil {
return echo.NewHTTPError(http.StatusNotFound, "User not found")
username := ""
if user != nil {
username = user.Name
}
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(user.Name)); err != nil {
if err := json.NewEncoder(c.Response().Writer).Encode(composeResponse(username)); err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to encode user response").SetInternal(err)
}
return nil