Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

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

Sönke Werner Köster8c2224ae3903
diff --git a/server/memo.go b/server/memo.go
index 31560e507..94f0beda7 100644
--- a/server/memo.go
+++ b/server/memo.go
@@ -64,7 +64,18 @@ func (s *Server) registerMemoRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to unmarshal system setting").SetInternal(err)
}
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
+ }
}
}