From 8c2224ae390374f245d5e2bdbb4446dec6f448d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Werner=20K=C3=B6ster?= <30159582+cubuzz@users.noreply.github.com> Date: Tue, 4 Apr 2023 16:28:20 +0200 Subject: [PATCH] feat: allow instance moderators to post public via the API (#1464) --- server/memo.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 + } } }