Allow notify in /review to control email delivery
This may help automated systems to be less noisy. Tools can now choose which review updates should send email, and which categories of users on a change should get that email. For example when starting an automated build a CI system might want to use: notify: 'NONE' message: 'Starting build http://build-server/1234' to make an advisory message available on the review page without sending email to anyone. This feature is also good for aggressive linting tools that want to make lint information available on line comments, but don't need to email the results out. Later the build system can send build failures to only the owner: notify: 'OWNER' message: 'Build failed! Errors at http://build-server/1234/log' Some messages might need to go to the owner and reviewers: notify: 'OWNER_REVIEWERS' message: 'Change has been tested and is now ready for review.' The default behavior is to send to everyone, including users that have only starred the change, or subscribed to changes with watch filters: notify: 'ALL' message: 'Build passed!' If tools adopt this feature the emailReviewers capability could be deprecated, as the tool can make dynamic decisions on how widely spread its messages should go. Change-Id: If4bf81a9842151756af2d59453af56823e902566
This commit is contained in:
		 Shawn O. Pearce
					Shawn O. Pearce
				
			
				
					committed by
					
						 Shawn Pearce
						Shawn Pearce
					
				
			
			
				
	
			
			
			 Shawn Pearce
						Shawn Pearce
					
				
			
						parent
						
							ee720b8ab7
						
					
				
				
					commit
					477e4dd17a
				
			| @@ -22,6 +22,7 @@ import com.google.gerrit.reviewdb.client.PatchLineComment; | ||||
| import com.google.gerrit.reviewdb.client.PatchSet; | ||||
| import com.google.gerrit.reviewdb.server.ReviewDb; | ||||
| import com.google.gerrit.server.CurrentUser; | ||||
| import com.google.gerrit.server.change.PostReview.NotifyHandling; | ||||
| import com.google.gerrit.server.git.WorkQueue; | ||||
| import com.google.gerrit.server.mail.CommentSender; | ||||
| import com.google.gerrit.server.patch.PatchSetInfoFactory; | ||||
| @@ -46,6 +47,7 @@ class EmailReviewComments implements Runnable, RequestContext { | ||||
|  | ||||
|   interface Factory { | ||||
|     EmailReviewComments create( | ||||
|         NotifyHandling notify, | ||||
|         Change change, | ||||
|         PatchSet patchSet, | ||||
|         Account.Id authorId, | ||||
| @@ -59,6 +61,7 @@ class EmailReviewComments implements Runnable, RequestContext { | ||||
|   private final SchemaFactory<ReviewDb> schemaFactory; | ||||
|   private final ThreadLocalRequestContext requestContext; | ||||
|  | ||||
|   private final PostReview.NotifyHandling notify; | ||||
|   private final Change change; | ||||
|   private final PatchSet patchSet; | ||||
|   private final Account.Id authorId; | ||||
| @@ -73,6 +76,7 @@ class EmailReviewComments implements Runnable, RequestContext { | ||||
|       CommentSender.Factory commentSenderFactory, | ||||
|       SchemaFactory<ReviewDb> schemaFactory, | ||||
|       ThreadLocalRequestContext requestContext, | ||||
|       @Assisted NotifyHandling notify, | ||||
|       @Assisted Change change, | ||||
|       @Assisted PatchSet patchSet, | ||||
|       @Assisted Account.Id authorId, | ||||
| @@ -83,6 +87,7 @@ class EmailReviewComments implements Runnable, RequestContext { | ||||
|     this.commentSenderFactory = commentSenderFactory; | ||||
|     this.schemaFactory = schemaFactory; | ||||
|     this.requestContext = requestContext; | ||||
|     this.notify = notify; | ||||
|     this.change = change; | ||||
|     this.patchSet = patchSet; | ||||
|     this.authorId = authorId; | ||||
| @@ -122,7 +127,7 @@ class EmailReviewComments implements Runnable, RequestContext { | ||||
|         } | ||||
|       }); | ||||
|  | ||||
|       CommentSender cm = commentSenderFactory.create(change); | ||||
|       CommentSender cm = commentSenderFactory.create(notify, change); | ||||
|       cm.setFrom(authorId); | ||||
|       cm.setPatchSet(patchSet, patchSetInfoFactory.get(change, patchSet)); | ||||
|       cm.setChangeMessage(message); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user