Backport https://github.com/go-gitea/gitea/pull/29621 <img width="430" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/9cf7b0a3-406b-4dd6-ab3d-d31a96b9335a"> (cherry picked from commit b6a2b9594af06698b29ea4c649b85e40c7f4b82d)