fix(user): allow unblocking users promoted to admin (#39192)

Fixes #39189.

`IsUserBlockedBy` intentionally treats admin users as not blocked, but
`CanUnblockUser` was also using it to determine whether a blocking
relationship exists. If a previously blocked user is later promoted to
admin, the existing `user_blocking` record remains but can no longer be
removed.

This change separates those two concerns by adding `HasBlocking` for
checking the persisted blocking relationship. `CanUnblockUser` uses that
relationship check while `IsUserBlockedBy` keeps its existing admin-user
behavior.

A regression test verifies that an admin is still not considered blocked
while an existing blocking relationship can still be unblocked.
This commit is contained in:
Even authored and GitHub committed 2026-09-23 16:54:12 +00:00
1 parent 191287d8be
commit 06e334121f
3 files changed
+15 -6

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@ func CanUnblockUser(ctx context.Context, doer, blocker, blockee *user_model.User
return false
}
if !user_model.IsUserBlockedBy(ctx, blockee, blocker.ID) {
if !user_model.HasBlocking(ctx, blockee.ID, blocker.ID) {
return false
}