Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ func GetIssueUserPairsByMode(uid, rid int64, isClosed bool, page, filterMode int

// UpdateIssueMentions extracts mentioned people from content and
// updates issue-user relations for them.
func UpdateIssueMentions(issueID int64, mentions []string) error {
func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error {
if len(mentions) == 0 {
return nil
}
Expand All @@ -1092,7 +1092,7 @@ func UpdateIssueMentions(issueID int64, mentions []string) error {
}
users := make([]*User, 0, len(mentions))

if err := x.In("lower_name", mentions).Asc("lower_name").Find(&users); err != nil {
if err := e.In("lower_name", mentions).Asc("lower_name").Find(&users); err != nil {
return fmt.Errorf("find mentioned users: %v", err)
}

Expand All @@ -1116,7 +1116,7 @@ func UpdateIssueMentions(issueID int64, mentions []string) error {
ids = append(ids, memberIDs...)
}

if err := UpdateIssueUsersByMentions(issueID, ids); err != nil {
if err := UpdateIssueUsersByMentions(e, issueID, ids); err != nil {
return fmt.Errorf("UpdateIssueUsersByMentions: %v", err)
}

Expand Down Expand Up @@ -1357,22 +1357,22 @@ func UpdateIssueUserByRead(uid, issueID int64) error {
}

// UpdateIssueUsersByMentions updates issue-user pairs by mentioning.
func UpdateIssueUsersByMentions(issueID int64, uids []int64) error {
func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error {
for _, uid := range uids {
iu := &IssueUser{
UID: uid,
IssueID: issueID,
}
has, err := x.Get(iu)
has, err := e.Get(iu)
if err != nil {
return err
}

iu.IsMentioned = true
if has {
_, err = x.Id(iu.ID).AllCols().Update(iu)
_, err = e.Id(iu.ID).AllCols().Update(iu)
} else {
_, err = x.Insert(iu)
_, err = e.Insert(iu)
}
if err != nil {
return err
Expand Down
8 changes: 5 additions & 3 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ func (c *Comment) EventTag() string {

// MailParticipants sends new comment emails to repository watchers
// and mentioned people.
func (c *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
func (c *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
mentions := markdown.FindAllMentions(c.Content)
if err = UpdateIssueMentions(c.IssueID, mentions); err != nil {
if err = UpdateIssueMentions(e, c.IssueID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", c.IssueID, err)
}

Expand Down Expand Up @@ -262,7 +262,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
if err = notifyWatchers(e, act); err != nil {
log.Error(4, "notifyWatchers: %v", err)
}
comment.MailParticipants(act.OpType, opts.Issue)
if err = comment.MailParticipants(e, act.OpType, opts.Issue); err != nil {
log.Error(4, "MailParticipants: %v", err)
}
}

return comment, nil
Expand Down
2 changes: 1 addition & 1 deletion models/issue_mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string)
// and mentioned people.
func (issue *Issue) MailParticipants() (err error) {
mentions := markdown.FindAllMentions(issue.Content)
if err = UpdateIssueMentions(issue.ID, mentions); err != nil {
if err = UpdateIssueMentions(x, issue.ID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
}

Expand Down