From f0e4119c3271b55a4adf4471f23d8e84d6b2bd8a Mon Sep 17 00:00:00 2001 From: floss4good Date: Tue, 1 Apr 2025 02:16:23 +0300 Subject: [PATCH] log warning and return custom error also when trying to report users/orgs that are not visible --- services/moderation/reporting.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/moderation/reporting.go b/services/moderation/reporting.go index bd278c30d7..e01156dc11 100644 --- a/services/moderation/reporting.go +++ b/services/moderation/reporting.go @@ -45,6 +45,10 @@ func CanReport(ctx context.Context, doer *user.User, contentType moderation.Repo } hasAccess = user.IsUserVisibleToViewer(ctx, reportedUser, ctx.Doer) + if !hasAccess { + log.Warn("User #%d wanted to report user/org #%d but they are not able to see that profile.", doer.ID, contentID) + return false, ErrDoerNotAllowed + } } else { // for comments and issues/pulls we need to get the parent repository switch contentType {