Class ChangeEmail
- java.lang.Object
-
- com.google.gerrit.server.mail.send.OutgoingEmail
-
- com.google.gerrit.server.mail.send.NotificationEmail
-
- com.google.gerrit.server.mail.send.ChangeEmail
-
- Direct Known Subclasses:
NewChangeSender
,ReplyToChangeSender
,SetAssigneeSender
public abstract class ChangeEmail extends NotificationEmail
Sends an email to one or more interested parties.
-
-
Field Summary
Fields Modifier and Type Field Description protected Set<Account.Id>
authors
protected Change
change
protected ChangeData
changeData
protected String
changeMessage
protected boolean
emailOnlyAttentionSetIfEnabled
protected boolean
emailOnlyAuthors
protected PatchSet
patchSet
protected PatchSetInfo
patchSetInfo
protected ProjectState
projectState
protected com.google.common.collect.ListMultimap<Account.Id,String>
stars
protected Instant
timestamp
-
Fields inherited from class com.google.gerrit.server.mail.send.NotificationEmail
branch
-
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
add(RecipientType rt, Account.Id to)
Schedule delivery of this message to the given account.protected void
addWatcher(RecipientType rt, Account.Id to)
This bypasses the EmailStrategy.ATTENTION_SET_ONLY strategy when adding the recipient.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()
Find 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 ProjectWatch.Watchers
getWatchers(NotifyConfig.NotifyType type, boolean includeWatchersFromNotifyConfig)
Returns all watchers that are relevantprotected void
init()
Setup the message headers and envelope (TO, CC, BCC).protected boolean
isVisibleTo(Account.Id to)
Returns whether this email is visible to the given accountprotected 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)
protected void
rcptToAuthors(RecipientType rt)
TO or CC all vested parties (change owner, patch set uploader, author).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.NotificationEmail
add, getInstanceAndProjectName, getShortProjectName, getSshHost, includeWatchers, includeWatchers
-
Methods inherited from class com.google.gerrit.server.mail.send.OutgoingEmail
add, add, add, addByEmail, addByEmail, appendHtml, appendText, getFromLine, getGerritHost, getNameEmailFor, getNameFor, getSettingsUrl, 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
-
projectState
protected ProjectState projectState
-
authors
protected Set<Account.Id> authors
-
emailOnlyAuthors
protected boolean emailOnlyAuthors
-
emailOnlyAttentionSetIfEnabled
protected boolean emailOnlyAttentionSetIfEnabled
-
-
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 classNotificationEmail
- 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.
-
rcptToAuthors
protected void rcptToAuthors(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.
-
getWatchers
protected final ProjectWatch.Watchers getWatchers(NotifyConfig.NotifyType type, boolean includeWatchersFromNotifyConfig)
Description copied from class:NotificationEmail
Returns all watchers that are relevant- Specified by:
getWatchers
in classNotificationEmail
-
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.
-
add
protected void add(RecipientType rt, Account.Id to)
Description copied from class:OutgoingEmail
Schedule delivery of this message to the given account.- Overrides:
add
in classOutgoingEmail
-
addWatcher
protected void addWatcher(RecipientType rt, Account.Id to)
This bypasses the EmailStrategy.ATTENTION_SET_ONLY strategy when adding the recipient.- Specified by:
addWatcher
in classNotificationEmail
-
isVisibleTo
protected boolean isVisibleTo(Account.Id to) throws PermissionBackendException
Description copied from class:OutgoingEmail
Returns whether this email is visible to the given account- Overrides:
isVisibleTo
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()
Find all users who are authors of any part of this change.
-
setupSoyContext
protected void setupSoyContext()
- Overrides:
setupSoyContext
in classNotificationEmail
-
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.
-
-