-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various fixes for issue mail notifications #7165
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,26 +118,41 @@ func mailIssueCommentToParticipants(e Engine, issue *Issue, doer *User, content | |
|
||
// MailParticipants sends new issue thread created emails to repository watchers | ||
// and mentioned people. | ||
func (issue *Issue) MailParticipants(opType ActionType) (err error) { | ||
return issue.mailParticipants(x, opType) | ||
func (issue *Issue) MailParticipants(doer *User, opType ActionType) (err error) { | ||
return issue.mailParticipants(x, doer, opType) | ||
} | ||
|
||
func (issue *Issue) mailParticipants(e Engine, opType ActionType) (err error) { | ||
func (issue *Issue) mailParticipants(e Engine, doer *User, opType ActionType) (err error) { | ||
mentions := markup.FindAllMentions(issue.Content) | ||
|
||
if err = UpdateIssueMentions(e, issue.ID, mentions); err != nil { | ||
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err) | ||
} | ||
|
||
var content = issue.Content | ||
if len(issue.Content) > 0 { | ||
if err = mailIssueCommentToParticipants(e, issue, doer, issue.Content, nil, mentions); err != nil { | ||
log.Error("mailIssueCommentToParticipants: %v", err) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, it's intended. |
||
} | ||
|
||
switch opType { | ||
case ActionCreateIssue, ActionCreatePullRequest: | ||
if len(issue.Content) == 0 { | ||
ct := fmt.Sprintf("Created #%d.", issue.Index) | ||
if err = mailIssueCommentToParticipants(e, issue, doer, ct, nil, mentions); err != nil { | ||
log.Error("mailIssueCommentToParticipants: %v", err) | ||
} | ||
} | ||
case ActionCloseIssue, ActionClosePullRequest: | ||
content = fmt.Sprintf("Closed #%d", issue.Index) | ||
ct := fmt.Sprintf("Closed #%d.", issue.Index) | ||
if err = mailIssueCommentToParticipants(e, issue, doer, ct, nil, mentions); err != nil { | ||
log.Error("mailIssueCommentToParticipants: %v", err) | ||
} | ||
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) | ||
ct := fmt.Sprintf("Reopened #%d.", issue.Index) | ||
if err = mailIssueCommentToParticipants(e, issue, doer, ct, nil, mentions); err != nil { | ||
log.Error("mailIssueCommentToParticipants: %v", err) | ||
} | ||
} | ||
|
||
return nil | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, sending two mails is intended. One for each action (comment and close/reopen).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's just a comment, the
switch
below will not hit a case and only 1 mail is sent.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One action sending two mails is annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. It's not one action after all if a user clicks "comment and close". Also it does match GitHub's behaviour, they also send two mails on "comment and close".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of GitHub sending two mails for "comment and close":