Class ChangeEmail
- java.lang.Object
-
- com.google.gerrit.server.mail.send.OutgoingEmail
-
- com.google.gerrit.server.mail.send.ChangeEmail
-
- Direct Known Subclasses:
NewChangeSender
,ReplyToChangeSender
public abstract class ChangeEmail extends OutgoingEmail
Sends an email to one or more interested parties.
-
-
Field Summary
Fields Modifier and Type Field Description protected BranchNameKey
branch
protected Change
change
protected ChangeData
changeData
protected String
changeMessage
protected boolean
emailOnlyAttentionSetIfEnabled
protected PatchSet
patchSet
protected PatchSetInfo
patchSetInfo
protected ProjectState
projectState
protected com.google.common.collect.ListMultimap<Account.Id,String>
stars
protected Instant
timestamp
protected Set<Account.Id>
watcherAccounts
protected Set<Address>
watcherEmails
-
Fields inherited from class com.google.gerrit.server.mail.send.OutgoingEmail
args, footers, fromId, messageClass, notify, soyContext, soyContextEmailData
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ChangeEmail(EmailArguments args, String messageClass, ChangeData changeData)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addAuthors(RecipientType rt)
TO or CC all vested parties (change owner, patch set uploader, author).protected void
bccStarredBy()
BCC any user who has starred this change.protected void
ccAllApprovals()
Any user who has published comments on this change.protected void
ccExistingReviewers()
Users who were added as reviewers to this change.protected void
format()
Format the message body by callingOutgoingEmail.appendText(String)
.protected abstract void
formatChange()
Format the message body by callingOutgoingEmail.appendText(String)
.protected void
formatFooter()
Format the message footer by callingOutgoingEmail.appendText(String)
.protected Set<Account.Id>
getAuthors()
Lazily finds all users who are authors of any part of this change.String
getChangeDetail()
Create the change message and the affected file list.String
getChangeMessageThreadId()
String
getChangeUrl()
Get a link to the change; null if the server doesn't know its own address or if the address is malformed.String
getCoverLetter()
Get the text of the "cover letter".protected static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableMap<String,String>>
getDiffTemplateData(String sourceDiff)
Generate a list of maps representing each line of the unified diff.boolean
getIncludeDiff()
protected ProjectState
getProjectState()
Get the project entity the change is in; null if its been deleted.String
getUnifiedDiff()
Show patch set as unified difference.protected void
includeWatchers(NotifyConfig.NotifyType type)
Include users and groups that want notification of events.protected void
includeWatchers(NotifyConfig.NotifyType type, boolean includeWatchersFromNotifyConfig)
Include users and groups that want notification of events.protected void
init()
Setup the message headers and envelope (TO, CC, BCC).protected boolean
isRecipientAllowed(Account.Id to)
Returns whether this email is allowed to be sent to the given accountprotected boolean
isRecipientAllowed(Address addr)
Returns whether this email is allowed to be sent to the given addressprotected Map<String,FileDiffOutput>
listModifiedFiles()
Get the patch list corresponding to this patch set.protected Map<String,FileDiffOutput>
listModifiedFiles(int patchSetId)
Get the patch list corresponding to patch set patchSetId of this change.protected static ChangeData
newChangeData(EmailArguments ea, Project.NameKey project, Change.Id id)
protected static ChangeData
newChangeData(EmailArguments ea, Project.NameKey project, Change.Id id, org.eclipse.jgit.lib.ObjectId metaId)
void
setChangeMessage(String cm, Instant t)
void
setFrom(Account.Id id)
void
setPatchSet(PatchSet ps)
void
setPatchSet(PatchSet ps, PatchSetInfo psi)
protected void
setupSoyContext()
-
Methods inherited from class com.google.gerrit.server.mail.send.OutgoingEmail
addByAccountId, addByAccountId, addByEmail, addByEmail, addFooter, appendHtml, appendText, getFromLine, getGerritHost, getNameEmailFor, getNameFor, getSettingsUrl, getSoyContext, getSoyContextEmailData, getUserNameEmailFor, removeHeader, removeUser, send, setHeader, setHeader, setMessageId, setNotify, shouldSendMessage, soyHtmlTemplate, textTemplate, useHtml
-
-
-
-
Field Detail
-
change
protected final Change change
-
changeData
protected final ChangeData changeData
-
stars
protected com.google.common.collect.ListMultimap<Account.Id,String> stars
-
patchSet
protected PatchSet patchSet
-
patchSetInfo
protected PatchSetInfo patchSetInfo
-
changeMessage
protected String changeMessage
-
timestamp
protected Instant timestamp
-
branch
protected BranchNameKey branch
-
projectState
protected ProjectState projectState
-
emailOnlyAttentionSetIfEnabled
protected boolean emailOnlyAttentionSetIfEnabled
-
watcherAccounts
protected Set<Account.Id> watcherAccounts
-
-
Constructor Detail
-
ChangeEmail
protected ChangeEmail(EmailArguments args, String messageClass, ChangeData changeData)
-
-
Method Detail
-
newChangeData
protected static ChangeData newChangeData(EmailArguments ea, Project.NameKey project, Change.Id id)
-
newChangeData
protected static ChangeData newChangeData(EmailArguments ea, Project.NameKey project, Change.Id id, org.eclipse.jgit.lib.ObjectId metaId)
-
setFrom
public void setFrom(Account.Id id)
- Overrides:
setFrom
in classOutgoingEmail
-
setPatchSet
public void setPatchSet(PatchSet ps)
-
setPatchSet
public void setPatchSet(PatchSet ps, PatchSetInfo psi)
-
format
protected void format() throws com.google.gerrit.exceptions.EmailException
Format the message body by callingOutgoingEmail.appendText(String)
.- Specified by:
format
in classOutgoingEmail
- Throws:
com.google.gerrit.exceptions.EmailException
-
formatChange
protected abstract void formatChange() throws com.google.gerrit.exceptions.EmailException
Format the message body by callingOutgoingEmail.appendText(String)
.- Throws:
com.google.gerrit.exceptions.EmailException
-
formatFooter
protected void formatFooter() throws com.google.gerrit.exceptions.EmailException
Format the message footer by callingOutgoingEmail.appendText(String)
.- Throws:
com.google.gerrit.exceptions.EmailException
- if an error occurred.
-
init
protected void init() throws com.google.gerrit.exceptions.EmailException
Setup the message headers and envelope (TO, CC, BCC).- Overrides:
init
in classOutgoingEmail
- Throws:
com.google.gerrit.exceptions.EmailException
- if an error occurred.
-
getChangeUrl
public String getChangeUrl()
Get a link to the change; null if the server doesn't know its own address or if the address is malformed. The link will contain a usp parameter set to "email" to inform the frontend on clickthroughs where the link came from.
-
getChangeMessageThreadId
public String getChangeMessageThreadId()
-
getCoverLetter
public String getCoverLetter()
Get the text of the "cover letter".
-
getChangeDetail
public String getChangeDetail()
Create the change message and the affected file list.
-
listModifiedFiles
protected Map<String,FileDiffOutput> listModifiedFiles(int patchSetId)
Get the patch list corresponding to patch set patchSetId of this change.
-
listModifiedFiles
protected Map<String,FileDiffOutput> listModifiedFiles()
Get the patch list corresponding to this patch set.
-
getProjectState
protected ProjectState getProjectState()
Get the project entity the change is in; null if its been deleted.
-
addAuthors
protected void addAuthors(RecipientType rt)
TO or CC all vested parties (change owner, patch set uploader, author).
-
bccStarredBy
protected void bccStarredBy()
BCC any user who has starred this change.
-
includeWatchers
protected void includeWatchers(NotifyConfig.NotifyType type)
Include users and groups that want notification of events.
-
includeWatchers
protected void includeWatchers(NotifyConfig.NotifyType type, boolean includeWatchersFromNotifyConfig)
Include users and groups that want notification of events.
-
ccAllApprovals
protected void ccAllApprovals()
Any user who has published comments on this change.
-
ccExistingReviewers
protected void ccExistingReviewers()
Users who were added as reviewers to this change.
-
isRecipientAllowed
protected boolean isRecipientAllowed(Address addr) throws PermissionBackendException
Description copied from class:OutgoingEmail
Returns whether this email is allowed to be sent to the given address- Overrides:
isRecipientAllowed
in classOutgoingEmail
- Parameters:
addr
- email address of recipient.- Throws:
PermissionBackendException
- thrown if checking a permission fails due to an error in the permission backend
-
isRecipientAllowed
protected boolean isRecipientAllowed(Account.Id to) throws PermissionBackendException
Description copied from class:OutgoingEmail
Returns whether this email is allowed to be sent to the given account- Overrides:
isRecipientAllowed
in classOutgoingEmail
- Parameters:
to
- account.- Throws:
PermissionBackendException
- thrown if checking a permission fails due to an error in the permission backend
-
getAuthors
protected Set<Account.Id> getAuthors()
Lazily finds all users who are authors of any part of this change.
-
setupSoyContext
protected void setupSoyContext()
- Overrides:
setupSoyContext
in classOutgoingEmail
-
getIncludeDiff
public boolean getIncludeDiff()
-
getUnifiedDiff
public String getUnifiedDiff()
Show patch set as unified difference.
-
getDiffTemplateData
protected static com.google.common.collect.ImmutableList<com.google.common.collect.ImmutableMap<String,String>> getDiffTemplateData(String sourceDiff)
Generate a list of maps representing each line of the unified diff. The line maps will have a 'type' key which maps to one of 'common', 'add' or 'remove' and a 'text' key which maps to the line's content.- Parameters:
sourceDiff
- the unified diff that we're converting to the map.- Returns:
- map of 'type' to a line's content.
-
-