log warning and return custom error also when trying to report users/orgs that are not visible

This commit is contained in:
floss4good 2025-04-01 02:16:23 +03:00
parent 9aa5624872
commit f0e4119c32
No known key found for this signature in database
GPG key ID: 5B948B4F4DAF819D

View file

@ -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 {