Exclude cancelled runs from failure-only email notifications (#36569)

The default configuration of `failure-only` added in
https://github.com/go-gitea/gitea/pull/34982 included sending mails for
cancelled runs which is not what one would expect from a option named
like that because a cancelled run is not a failure.

This change makes it omit mails for cancelled runs:

| Run Status | `failure-only` before | `failure-only` after |
|------------|-----------------------|----------------------|
| Success    | no                    | no                   |
| Failure    | mail                  | mail                 |
| Cancelled  | mail                  | no                   |

The first commit in this PR is the fix, and there are a few more
refactor commits afterwards.

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
silverwind
2026-02-16 00:47:02 +01:00
committed by GitHub
parent 692ef9eca6
commit 88752bc159
2 changed files with 21 additions and 20 deletions

View File

@@ -496,10 +496,10 @@ func (u *User) ShortName(length int) string {
return util.EllipsisDisplayString(u.Name, length)
}
// IsMailable checks if a user is eligible
// to receive emails.
// IsMailable checks if a user is eligible to receive emails.
// System users like Ghost and Gitea Actions are excluded.
func (u *User) IsMailable() bool {
return u.IsActive
return u.IsActive && !u.IsGiteaActions() && !u.IsGhost()
}
// IsUserExist checks if given username exist,