Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve changes to sendgrid.java that served only graas report #98

Merged
merged 1 commit into from
Feb 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions gtfu/src/main/java/gtfu/tools/SendGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public class SendGrid {
private String[] tos;
private String subject;
private String body;
private Map<String, byte[]> blobMap;
private Map<String, byte[]> imageMap;

public SendGrid(String[] recipients, String emailSubject, String body, Map<String, byte[]> images) {
public SendGrid(String[] recipients, String emailSubject, String body, Map<String, byte[]> imageMap) {
this.tos = recipients;
this.subject = emailSubject;
this.body = escape(body);
this.blobMap = images;
this.imageMap = imageMap;
}

private String escape(String s) {
Expand Down Expand Up @@ -54,8 +54,8 @@ private String makeTos() {
private String makeAttachments() {
StringBuffer sb = new StringBuffer();

for (String key : blobMap.keySet()) {
byte[] buf = blobMap.get(key);
for (String key : imageMap.keySet()) {
byte[] buf = imageMap.get(key);

if (sb.length() > 0) {
sb.append(',');
Expand All @@ -74,11 +74,12 @@ private String makeAttachments() {

public int send() {
String attach = "";

if (blobMap.size() > 0) {
attach = String.format(",\"attachments\": [%s]", makeAttachments());
} else{
body = "There are no files in today's GRaaS report";
if(imageMap != null){
if (imageMap.size() > 0) {
attach = String.format(",\"attachments\": [%s]", makeAttachments());
} else{
body = "There are no images attached";
}
}

String from = "[email protected]";
Expand Down