From 301275c432501d9709168e69bb685c073fb621de Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 10 Mar 2020 22:51:04 +0300 Subject: Mail unsubscribe API --- src/main/java/com/juick/server/api/Service.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/main/java/com/juick/server') diff --git a/src/main/java/com/juick/server/api/Service.java b/src/main/java/com/juick/server/api/Service.java index 4474e4f0..12a9167f 100644 --- a/src/main/java/com/juick/server/api/Service.java +++ b/src/main/java/com/juick/server/api/Service.java @@ -177,6 +177,23 @@ public class Service { throw new HttpForbiddenException(); } } + @ApiIgnore + @PostMapping("/api/mail/unsubscribe") + @ResponseStatus(value = HttpStatus.OK) + public void processMailUnsubscribe(@Visitor User current, InputStream data) throws Exception { + if (current.getName().equals(serviceUser)) { + MimeMessage msg = new MimeMessage(session, data); + String from = msg.getFrom() == null || msg.getFrom().length > 1 ? ((InternetAddress) msg.getSender()).getAddress() + : ((InternetAddress) msg.getFrom()[0]).getAddress(); + + User visitor = userService.getUserByEmail(from); + if (!visitor.isAnonymous()) { + + } + } else { + throw new HttpForbiddenException(); + } + } private void endSession(SseEmitter emitter) { serverManager.getSessions().stream() .filter(s -> s.getEmitter().equals(emitter)) -- cgit v1.2.3