Allow InternalUsers to see drafts
According to the documentation, InternalUsers should have full read access. This is not true, since InternalUsers cannot see drafts. This also means plugins utilizing the PluginUser cannot react to events from newly created drafts. This fix allows InternalUsers to also see draft changes and patchsets. Change-Id: Ibc36c3373f795cbc36535b1566a97b00dc3700ac
This commit is contained in:
		 Gustaf Lundh
					Gustaf Lundh
				
			
				
					committed by
					
						 David Pursehouse
						David Pursehouse
					
				
			
			
				
	
			
			
			 David Pursehouse
						David Pursehouse
					
				
			
						parent
						
							9e221da881
						
					
				
				
					commit
					e63e609b3c
				
			| @@ -100,4 +100,9 @@ public abstract class CurrentUser { | ||||
|   public boolean isIdentifiedUser() { | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   /** Check if the CurrentUser is an InternalUser. */ | ||||
|   public boolean isInternalUser() { | ||||
|     return false; | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -61,6 +61,11 @@ public class InternalUser extends CurrentUser { | ||||
|     return Collections.emptySet(); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public boolean isInternalUser() { | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public String toString() { | ||||
|     return "InternalUser"; | ||||
|   | ||||
| @@ -28,6 +28,7 @@ import com.google.gerrit.reviewdb.client.Project; | ||||
| import com.google.gerrit.reviewdb.server.ReviewDb; | ||||
| import com.google.gerrit.server.CurrentUser; | ||||
| import com.google.gerrit.server.IdentifiedUser; | ||||
| import com.google.gerrit.server.InternalUser; | ||||
| import com.google.gerrit.server.notedb.ChangeNotes; | ||||
| import com.google.gerrit.server.query.change.ChangeData; | ||||
| import com.google.gwtorm.server.OrmException; | ||||
| @@ -352,6 +353,7 @@ public class ChangeControl { | ||||
|  | ||||
|   public boolean isDraftVisible(ReviewDb db, ChangeData cd) | ||||
|       throws OrmException { | ||||
|     return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts(); | ||||
|     return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts() | ||||
|         || getCurrentUser().isInternalUser(); | ||||
|   } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user