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

pull/1475/head
Sönke Werner Köster 2 years ago committed by GitHub
parent 6ff7cfddda
commit 8c2224ae39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -64,9 +64,20 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting").SetInternal(err)
}
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
}
}
}
if len(memoCreate.Content) > api.MaxContentLength {
return echo.NewHTTPError(http.StatusBadRequest, "Content size overflow, up to 1MB").SetInternal(err)

Loading…
Cancel
Save