Browse Source

Minor fix for PR #3822

pull/3781/merge
Unknwon 8 years ago
parent
commit
c1e53cdc72
No known key found for this signature in database
GPG Key ID: FB9F411CDD69BEC1
  1. 14
      models/issue.go
  2. 8
      models/issue_comment.go
  3. 2
      models/issue_mail.go
  4. 9
      models/org.go

14
models/issue.go

@ -1024,9 +1024,9 @@ func GetIssueUserPairsByMode(uid, rid int64, isClosed bool, page, filterMode int
return ius, err return ius, err
} }
// UpdateIssueMentions extracts mentioned people from content and // updateIssueMentions extracts mentioned people from content and
// updates issue-user relations for them. // updates issue-user relations for them.
func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error { func updateIssueMentions(e Engine, issueID int64, mentions []string) error {
if len(mentions) == 0 { if len(mentions) == 0 {
return nil return nil
} }
@ -1048,9 +1048,9 @@ func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error {
} }
memberIDs := make([]int64, 0, user.NumMembers) memberIDs := make([]int64, 0, user.NumMembers)
orgUsers, err := GetOrgUsersByOrgID(user.ID) orgUsers, err := getOrgUsersByOrgID(e, user.ID)
if err != nil { if err != nil {
return fmt.Errorf("GetOrgUsersByOrgID [%d]: %v", user.ID, err) return fmt.Errorf("getOrgUsersByOrgID [%d]: %v", user.ID, err)
} }
for _, orgUser := range orgUsers { for _, orgUser := range orgUsers {
@ -1060,7 +1060,7 @@ func UpdateIssueMentions(e Engine, issueID int64, mentions []string) error {
ids = append(ids, memberIDs...) ids = append(ids, memberIDs...)
} }
if err := UpdateIssueUsersByMentions(e, issueID, ids); err != nil { if err := updateIssueUsersByMentions(e, issueID, ids); err != nil {
return fmt.Errorf("UpdateIssueUsersByMentions: %v", err) return fmt.Errorf("UpdateIssueUsersByMentions: %v", err)
} }
@ -1292,8 +1292,8 @@ func UpdateIssueUserByRead(uid, issueID int64) error {
return err return err
} }
// UpdateIssueUsersByMentions updates issue-user pairs by mentioning. // updateIssueUsersByMentions updates issue-user pairs by mentioning.
func UpdateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error { func updateIssueUsersByMentions(e Engine, issueID int64, uids []int64) error {
for _, uid := range uids { for _, uid := range uids {
iu := &IssueUser{ iu := &IssueUser{
UID: uid, UID: uid,

8
models/issue_comment.go

@ -160,11 +160,11 @@ func (c *Comment) EventTag() string {
return "event-" + com.ToStr(c.ID) return "event-" + com.ToStr(c.ID)
} }
// MailParticipants sends new comment emails to repository watchers // mailParticipants sends new comment emails to repository watchers
// and mentioned people. // and mentioned people.
func (cmt *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) { func (cmt *Comment) mailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
mentions := markdown.FindAllMentions(cmt.Content) mentions := markdown.FindAllMentions(cmt.Content)
if err = UpdateIssueMentions(e, cmt.IssueID, mentions); err != nil { if err = updateIssueMentions(e, cmt.IssueID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", cmt.IssueID, err) return fmt.Errorf("UpdateIssueMentions [%d]: %v", cmt.IssueID, err)
} }
@ -278,7 +278,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
if err = notifyWatchers(e, act); err != nil { if err = notifyWatchers(e, act); err != nil {
log.Error(4, "notifyWatchers: %v", err) log.Error(4, "notifyWatchers: %v", err)
} }
if err = comment.MailParticipants(e, act.OpType, opts.Issue); err != nil { if err = comment.mailParticipants(e, act.OpType, opts.Issue); err != nil {
log.Error(4, "MailParticipants: %v", err) log.Error(4, "MailParticipants: %v", err)
} }
} }

2
models/issue_mail.go

@ -69,7 +69,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string)
// and mentioned people. // and mentioned people.
func (issue *Issue) MailParticipants() (err error) { func (issue *Issue) MailParticipants() (err error) {
mentions := markdown.FindAllMentions(issue.Content) mentions := markdown.FindAllMentions(issue.Content)
if err = UpdateIssueMentions(x, issue.ID, mentions); err != nil { if err = updateIssueMentions(x, issue.ID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err) return fmt.Errorf("UpdateIssueMentions [%d]: %v", issue.ID, err)
} }

9
models/org.go

@ -311,11 +311,14 @@ func GetOrgUsersByUserID(uid int64, all bool) ([]*OrgUser, error) {
return ous, err return ous, err
} }
func getOrgUsersByOrgID(e Engine, orgID int64) ([]*OrgUser, error) {
orgUsers := make([]*OrgUser, 0, 10)
return orgUsers, e.Where("org_id=?", orgID).Find(&orgUsers)
}
// GetOrgUsersByOrgID returns all organization-user relations by organization ID. // GetOrgUsersByOrgID returns all organization-user relations by organization ID.
func GetOrgUsersByOrgID(orgID int64) ([]*OrgUser, error) { func GetOrgUsersByOrgID(orgID int64) ([]*OrgUser, error) {
ous := make([]*OrgUser, 0, 10) return getOrgUsersByOrgID(x, orgID)
err := x.Where("org_id=?", orgID).Find(&ous)
return ous, err
} }
// ChangeOrgUserStatus changes public or private membership status. // ChangeOrgUserStatus changes public or private membership status.

Loading…
Cancel
Save