mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-20 14:00:04 +02:00
Mail assignee when issue/pull request is assigned (#8546)
* Send email to assigned user * Only send mail if enabled * Mail also when assigned through API * Need to refactor functions from models to issue service * Refer to issue index rather than ID * Disable email notifications completly at initalization if global disable * Check of user enbled mail shall be in mail notification function only * Initialize notifications from routers init function. * Use the assigned comment when sending assigned mail * Refactor so that assignees always added as separate step when new issue/pr. * Check error from AddAssignees * Check if user can be assiged to issue or pull request * Missing return * Refactor of CanBeAssigned check. CanBeAssigned shall have same check as UI. * Clarify function names (toggle rather than update/change), and clean up. * Fix review comments. * Flash error if assignees was not added when creating issue/pr * Generate error if assignee users doesn't exist
This commit is contained in:
parent
c34e58fc00
commit
6aa3f8bc29
23 changed files with 333 additions and 216 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/notification/mail"
|
||||
"code.gitea.io/gitea/modules/notification/ui"
|
||||
"code.gitea.io/gitea/modules/notification/webhook"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -24,9 +25,12 @@ func RegisterNotifier(notifier base.Notifier) {
|
|||
notifiers = append(notifiers, notifier)
|
||||
}
|
||||
|
||||
func init() {
|
||||
// NewContext registers notification handlers
|
||||
func NewContext() {
|
||||
RegisterNotifier(ui.NewNotifier())
|
||||
RegisterNotifier(mail.NewNotifier())
|
||||
if setting.Service.EnableNotifyMail {
|
||||
RegisterNotifier(mail.NewNotifier())
|
||||
}
|
||||
RegisterNotifier(indexer.NewNotifier())
|
||||
RegisterNotifier(webhook.NewNotifier())
|
||||
}
|
||||
|
@ -138,9 +142,9 @@ func NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent
|
|||
}
|
||||
|
||||
// NotifyIssueChangeAssignee notifies change content to notifiers
|
||||
func NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, removed bool) {
|
||||
func NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment) {
|
||||
for _, notifier := range notifiers {
|
||||
notifier.NotifyIssueChangeAssignee(doer, issue, removed)
|
||||
notifier.NotifyIssueChangeAssignee(doer, issue, assignee, removed, comment)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue