mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-09-10 00:41:32 +02:00
fix mail notification when close/reopen issue (#6581)
This commit is contained in:
parent
48cdd90d4e
commit
2f53b5f88c
|
@ -118,17 +118,25 @@ func mailIssueCommentToParticipants(e Engine, issue *Issue, doer *User, content
|
||||||
|
|
||||||
// MailParticipants sends new issue thread created emails to repository watchers
|
// MailParticipants sends new issue thread created emails to repository watchers
|
||||||
// and mentioned people.
|
// and mentioned people.
|
||||||
func (issue *Issue) MailParticipants() (err error) {
|
func (issue *Issue) MailParticipants(opType ActionType) (err error) {
|
||||||
return issue.mailParticipants(x)
|
return issue.mailParticipants(x, opType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (issue *Issue) mailParticipants(e Engine) (err error) {
|
func (issue *Issue) mailParticipants(e Engine, opType ActionType) (err error) {
|
||||||
mentions := markup.FindAllMentions(issue.Content)
|
mentions := markup.FindAllMentions(issue.Content)
|
||||||
if err = UpdateIssueMentions(e, issue.ID, mentions); err != nil {
|
if err = UpdateIssueMentions(e, issue.ID, mentions); err != nil {
|
||||||
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
|
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = mailIssueCommentToParticipants(e, issue, issue.Poster, issue.Content, nil, mentions); err != nil {
|
var content = issue.Content
|
||||||
|
switch opType {
|
||||||
|
case ActionCloseIssue, ActionClosePullRequest:
|
||||||
|
content = fmt.Sprintf("Closed #%d", issue.Index)
|
||||||
|
case ActionReopenIssue, ActionReopenPullRequest:
|
||||||
|
content = fmt.Sprintf("Reopened #%d", issue.Index)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = mailIssueCommentToParticipants(e, issue, issue.Poster, content, nil, mentions); err != nil {
|
||||||
log.Error("mailIssueCommentToParticipants: %v", err)
|
log.Error("mailIssueCommentToParticipants: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,19 +42,34 @@ func (m *mailNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) {
|
func (m *mailNotifier) NotifyNewIssue(issue *models.Issue) {
|
||||||
if err := issue.MailParticipants(); err != nil {
|
if err := issue.MailParticipants(models.ActionCreateIssue); err != nil {
|
||||||
log.Error("MailParticipants: %v", err)
|
log.Error("MailParticipants: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, isClosed bool) {
|
func (m *mailNotifier) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, isClosed bool) {
|
||||||
if err := issue.MailParticipants(); err != nil {
|
var actionType models.ActionType
|
||||||
|
if issue.IsPull {
|
||||||
|
if isClosed {
|
||||||
|
actionType = models.ActionClosePullRequest
|
||||||
|
} else {
|
||||||
|
actionType = models.ActionReopenPullRequest
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if isClosed {
|
||||||
|
actionType = models.ActionCloseIssue
|
||||||
|
} else {
|
||||||
|
actionType = models.ActionReopenIssue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := issue.MailParticipants(actionType); err != nil {
|
||||||
log.Error("MailParticipants: %v", err)
|
log.Error("MailParticipants: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest) {
|
func (m *mailNotifier) NotifyNewPullRequest(pr *models.PullRequest) {
|
||||||
if err := pr.Issue.MailParticipants(); err != nil {
|
if err := pr.Issue.MailParticipants(models.ActionCreatePullRequest); err != nil {
|
||||||
log.Error("MailParticipants: %v", err)
|
log.Error("MailParticipants: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue