From 29c0732ab7a74f789d27553fb5019c28a402fdff Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 23 Mar 2021 19:08:55 +0300 Subject: Fix email processing flow --- src/main/java/com/juick/www/api/Service.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/juick/www/api/Service.java b/src/main/java/com/juick/www/api/Service.java index 8b18b125..c3ce1242 100644 --- a/src/main/java/com/juick/www/api/Service.java +++ b/src/main/java/com/juick/www/api/Service.java @@ -98,8 +98,11 @@ public class Service { return; } } - String from = msg.getFrom() == null || msg.getFrom().length > 1 ? ((InternetAddress) msg.getSender()).getAddress() - : ((InternetAddress) msg.getFrom()[0]).getAddress(); + if (msg.getFrom() == null || msg.getFrom().length == 0) { + logger.info("Missing from/sender headers"); + return; + } + String from = ((InternetAddress) msg.getFrom()[0]).getAddress(); User visitor = userService.getUserByEmail(from); if (!visitor.isAnonymous()) { -- cgit v1.2.3