Skip to content

Commit

Permalink
Add walletpasses to email (#448)
Browse files Browse the repository at this point in the history
* Add name to passes

* Add wallet passes to email
  • Loading branch information
JoepdeJong authored Oct 2, 2023
1 parent 7eb7b9c commit 27d2184
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import javax.mail.internet.MimeMessage;
import javax.validation.constraints.NotNull;

import ch.wisv.events.core.service.ticket.TicketService;
import ch.wisv.events.core.util.QrCode;
import com.google.zxing.WriterException;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -45,6 +46,9 @@ public class MailServiceImpl implements MailService {
/** SpringTemplateEngine. */
private final SpringTemplateEngine templateEngine;

/** TicketService. */
private final TicketService ticketService;

/** Link to GTC. */
@Value("${links.gtc}")
@NotNull
Expand All @@ -57,9 +61,10 @@ public class MailServiceImpl implements MailService {
* @param templateEngine of type templateEngine
*/
@Autowired
public MailServiceImpl(JavaMailSender mailSender, SpringTemplateEngine templateEngine) {
public MailServiceImpl(JavaMailSender mailSender, SpringTemplateEngine templateEngine, TicketService ticketService) {
this.mailSender = mailSender;
this.templateEngine = templateEngine;
this.ticketService = ticketService;
}

/**
Expand Down Expand Up @@ -181,6 +186,14 @@ private void sendMailWithContent(String recipientEmail, String subject, String c
BufferedImage qrCode = QrCode.generateQrCode(uniqueCode);
byte[] bytes = QrCode.bufferedImageToBytes(qrCode);
message.addInline("ch-" + uniqueCode + ".png", new ByteArrayResource(bytes), "image/png");

// Get wallet passes
try {
byte[] walletPass = ticketService.getApplePass(ticket);
message.addAttachment("ch-" + uniqueCode + ".pkpass", new ByteArrayResource(walletPass), "application/vnd.apple.pkpass");
} catch (Exception e) {
// Do nothing
}
}
}
}
Expand Down

0 comments on commit 27d2184

Please sign in to comment.