Enable assignee e-mail notification (#2003)
* Enable assignee e-mail notification * Check assignee and doer to avoid self made comment notifications. * Assignee not always defined * New method to avoid error when assignee deleted * Assignee empty check
This commit is contained in:
		
							parent
							
								
									09cb999145
								
							
						
					
					
						commit
						f2afed3098
					
				|  | @ -131,6 +131,22 @@ func (issue *Issue) loadPoster(e Engine) (err error) { | ||||||
| 	return | 	return | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | func (issue *Issue) loadAssignee(e Engine) (err error) { | ||||||
|  | 	if issue.Assignee == nil { | ||||||
|  | 		issue.Assignee, err = getUserByID(e, issue.AssigneeID) | ||||||
|  | 		if err != nil { | ||||||
|  | 			issue.AssigneeID = -1 | ||||||
|  | 			issue.Assignee = NewGhostUser() | ||||||
|  | 			if !IsErrUserNotExist(err) { | ||||||
|  | 				return fmt.Errorf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err) | ||||||
|  | 			} | ||||||
|  | 			err = nil | ||||||
|  | 			return | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return | ||||||
|  | } | ||||||
|  | 
 | ||||||
| func (issue *Issue) loadAttributes(e Engine) (err error) { | func (issue *Issue) loadAttributes(e Engine) (err error) { | ||||||
| 	if err = issue.loadRepo(e); err != nil { | 	if err = issue.loadRepo(e); err != nil { | ||||||
| 		return | 		return | ||||||
|  | @ -151,11 +167,8 @@ func (issue *Issue) loadAttributes(e Engine) (err error) { | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if issue.Assignee == nil && issue.AssigneeID > 0 { | 	if err = issue.loadAssignee(e); err != nil { | ||||||
| 		issue.Assignee, err = getUserByID(e, issue.AssigneeID) | 		return | ||||||
| 		if err != nil { |  | ||||||
| 			return fmt.Errorf("getUserByID.(assignee) [%d]: %v", issue.AssigneeID, err) |  | ||||||
| 		} |  | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if issue.IsPull && issue.PullRequest == nil { | 	if issue.IsPull && issue.PullRequest == nil { | ||||||
|  |  | ||||||
|  | @ -42,6 +42,11 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, comment *Comment, | ||||||
| 		participants = append(participants, issue.Poster) | 		participants = append(participants, issue.Poster) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	// Assignee must receive any communications
 | ||||||
|  | 	if issue.Assignee != nil && issue.AssigneeID > 0 && issue.AssigneeID != doer.ID { | ||||||
|  | 		participants = append(participants, issue.Assignee) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	tos := make([]string, 0, len(watchers)) // List of email addresses.
 | 	tos := make([]string, 0, len(watchers)) // List of email addresses.
 | ||||||
| 	names := make([]string, 0, len(watchers)) | 	names := make([]string, 0, len(watchers)) | ||||||
| 	for i := range watchers { | 	for i := range watchers { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue