Unverified Commit 8c2224ae authored by Sönke Werner Köster's avatar Sönke Werner Köster Committed by GitHub

feat: allow instance moderators to post public via the API (#1464)

parent 6ff7cfdd
...@@ -64,9 +64,20 @@ func (s *Server) registerMemoRoutes(g *echo.Group) { ...@@ -64,9 +64,20 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting").SetInternal(err) return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting").SetInternal(err)
} }
if disablePublicMemos { if disablePublicMemos {
// Allow if the user is an admin.
user, err := s.Store.FindUser(ctx, &api.UserFind{
ID: &userID,
})
if err != nil {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to find user").SetInternal(err)
}
// Only enforce private if you're a regular user.
// Admins should know what they're doing.
if user.Role == "USER" {
memoCreate.Visibility = api.Private memoCreate.Visibility = api.Private
} }
} }
}
if len(memoCreate.Content) > api.MaxContentLength { if len(memoCreate.Content) > api.MaxContentLength {
return echo.NewHTTPError(http.StatusBadRequest, "Content size overflow, up to 1MB").SetInternal(err) return echo.NewHTTPError(http.StatusBadRequest, "Content size overflow, up to 1MB").SetInternal(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment