Skip to content

Commit

Permalink
Java: Give attachments some attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed Aug 26, 2024
1 parent ba78122 commit 8d0fa91
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public static enum AttachmentType {

public static Attachment ofImage(String imageSrc, String alt, @Nullable Donation donation) {
String html = String.format(
"<img src=\"%s\" alt=\"%s\" style=\"border-radius: 0.25rem; height: auto; max-height: 2.5em; max-width: 2.5em;\"/>",
"<img data-rich-attachment-type=\"image\" src=\"%s\" alt=\"%s\" style=\"border-radius: 0.25rem; height: auto; max-height: 2.5em; max-width: 2.5em;\"/>",
HtmlEscape.escapeHtml5(imageSrc),
HtmlEscape.escapeHtml5(alt)
);

if (donation != null) {
html += String.format("x%d", donation.count);
html += String.format("<span data-rich-attachment-type=\"image-donation-count\">x%d</span>", donation.count);
}

return new Attachment(
Expand All @@ -56,7 +56,7 @@ public static Attachment ofInteractive(String url, String title) {
AttachmentType.INTERACTIVE,
new AttachmentContent(url, title),
String.format(
"<iframe src=\"%s\" title=\"%s\" style=\"width: 8em; height: 8em;\"></iframe>",
"<iframe data-rich-attachment-type=\"interactive\" src=\"%s\" title=\"%s\" style=\"width: 8em; height: 8em;\"></iframe>",
HtmlEscape.escapeHtml5(url),
HtmlEscape.escapeHtml5(title)
),
Expand Down

0 comments on commit 8d0fa91

Please sign in to comment.