public class MailAttachmentsManagerImpl extends Object implements MailAttachmentsManager
CID_PREFIX
Modifier and Type | Method and Description |
---|---|
String |
addAttachmentAndReturnCid(MailAttachment mailAttachment)
Adds an attachment to the mail attachments manager's collection of attachments.
|
Iterable<javax.mail.BodyPart> |
buildAttachmentsBodyParts()
Builds bodyPart for each image (including avatars) added to this manager
|
protected String |
getAbsoluteUrl(String path) |
int |
getAttachmentsCount()
Returns the number of attachments added to this manager
|
String |
getAvatarUrl(ApplicationUser user)
Returns a link to access user avatar in email message.
|
String |
getAvatarUrl(Avatar avatar,
Avatar.Size size,
String avatarOwnerDescription)
Returns a link to access
Avatar (icon for project or some other entity in Jira) in email message. |
String |
getAvatarUrl(String username)
Returns a link to access user avatar in email message.
|
String |
getAvatarUrl(TemplateUser templateUser)
Returns a link to access user avatar in email message.
|
String |
getExternalImageUrl(String path)
If the path is a relative url tries to add the image specified as an attachment.
|
String |
getImageUrl(String path)
Tries to inline image specified by path and add it to email attachments or add JWT token
|
String |
getIssueTypeIconUrl(IssueType issueType) |
boolean |
hasSecuredImage()
Needed to attach/or not
Use only after
MailAttachmentsManager.inlineImages(String) as it will count found images in rendered html. |
String |
inlineImages(String html) |
String |
processImages(String html)
- Looks for tags and tries to inline image if it's an internal resource.
|
String |
removeBaseUrl(String url)
Tries to remove the baseUrl (eg: http://example.com/jira) or the basePath (/jira) from an URL, and return the
result.
|
static MailAttachmentsManagerImpl |
withJwtTokens(AvatarService avatarService,
AvatarTranscoder avatarTranscoder,
UserManager userManager,
AvatarManager avatarManager,
ApplicationProperties applicationProperties,
ImageAttachmentJwtTokenService imageAttachmentJwtTokenService,
ImageAttachmentAltAttributeService imageAttachmentAltAttributeService,
String recipientUserName)
Created this way it will try to add JWT tokens to secured image paths.
|
static MailAttachmentsManagerImpl |
withoutJwtTokens(AvatarService avatarService,
AvatarTranscoder avatarTranscoder,
UserManager userManager,
AvatarManager avatarManager,
ApplicationProperties applicationProperties,
ImageAttachmentJwtTokenService imageAttachmentJwtTokenService,
ImageAttachmentAltAttributeService imageAttachmentAltAttributeService)
Created this way it won't try to add JWT tokens to secured image paths.
|
public static MailAttachmentsManagerImpl withoutJwtTokens(AvatarService avatarService, AvatarTranscoder avatarTranscoder, UserManager userManager, AvatarManager avatarManager, ApplicationProperties applicationProperties, ImageAttachmentJwtTokenService imageAttachmentJwtTokenService, ImageAttachmentAltAttributeService imageAttachmentAltAttributeService)
public static MailAttachmentsManagerImpl withJwtTokens(AvatarService avatarService, AvatarTranscoder avatarTranscoder, UserManager userManager, AvatarManager avatarManager, ApplicationProperties applicationProperties, ImageAttachmentJwtTokenService imageAttachmentJwtTokenService, ImageAttachmentAltAttributeService imageAttachmentAltAttributeService, String recipientUserName)
public String getAvatarUrl(String username)
MailAttachmentsManager
getAvatarUrl
in interface MailAttachmentsManager
public String getAvatarUrl(TemplateUser templateUser)
MailAttachmentsManager
getAvatarUrl
in interface MailAttachmentsManager
public String getAvatarUrl(ApplicationUser user)
MailAttachmentsManager
getAvatarUrl
in interface MailAttachmentsManager
public String getAvatarUrl(@Nonnull Avatar avatar, @Nonnull Avatar.Size size, String avatarOwnerDescription)
MailAttachmentsManager
Avatar
(icon for project or some other entity in Jira) in email message.getAvatarUrl
in interface MailAttachmentsManager
avatar
- Avatar
to display in emailsize
- avatar sizeavatarOwnerDescription
- Description of avatarpublic String addAttachmentAndReturnCid(MailAttachment mailAttachment)
MailAttachmentsManager
addAttachmentAndReturnCid
in interface MailAttachmentsManager
public String getImageUrl(String path)
MailAttachmentsManager
getImageUrl
in interface MailAttachmentsManager
public String processImages(String html)
MailAttachmentsManager
- Looks for tags and tries to inline image if it's an internal resource. Otherwise adds JWT token for every /secure/* image or leaves unchanged for other paths.
- Counts how many images there are that start with /secure/* so MailAttachmentsManager.hasSecuredImage()
can calculate the result needed to construct email footer
- Adds default 'alt' attribute which is an attachment file name in case img has none
processImages
in interface MailAttachmentsManager
html
- HTML to change.public String inlineImages(String html)
inlineImages
in interface MailAttachmentsManager
public boolean hasSecuredImage()
MailAttachmentsManager
MailAttachmentsManager.inlineImages(String)
as it will count found images in rendered html.hasSecuredImage
in interface MailAttachmentsManager
public String removeBaseUrl(String url)
MailAttachmentsManager
removeBaseUrl
in interface MailAttachmentsManager
url
- the url to remove the baseUrl frompublic String getExternalImageUrl(String path)
MailAttachmentsManager
getExternalImageUrl
in interface MailAttachmentsManager
public int getAttachmentsCount()
MailAttachmentsManager
getAttachmentsCount
in interface MailAttachmentsManager
public Iterable<javax.mail.BodyPart> buildAttachmentsBodyParts()
MailAttachmentsManager
buildAttachmentsBodyParts
in interface MailAttachmentsManager
Copyright © 2002-2021 Atlassian. All Rights Reserved.