mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: allow instance moderators to post public via the API (#1464)
This commit is contained in:
committed by
GitHub
parent
6ff7cfddda
commit
8c2224ae39
@@ -64,7 +64,18 @@ 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 {
|
||||||
memoCreate.Visibility = api.Private
|
// 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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user