Files
gitea/services
e3a43af379 fix(user): allow unblocking users promoted to admin (#39192) (#39402)
Backport #39192 by @loveulvu

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.

Tests:
- `go test ./models/user ./services/user -count=1`

Co-authored-by: Even <412401474@qq.com>
2026-09-23 20:26:48 +02:00
..
2026-06-08 16:58:42 +08:00