diff options
author | Vitaly Takmazov | 2020-03-10 22:51:04 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2020-03-10 22:51:04 +0300 |
commit | 301275c432501d9709168e69bb685c073fb621de (patch) | |
tree | 249d7e42f61f0917e1f426ab281fa5310c531ee1 /src/main/java/com/juick/server/api/Service.java | |
parent | c28afe791bd1be6ba2999d688f4ea2b00925ad37 (diff) |
Mail unsubscribe API
Diffstat (limited to 'src/main/java/com/juick/server/api/Service.java')
-rw-r--r-- | src/main/java/com/juick/server/api/Service.java | 17 |
1 files changed, 17 insertions, 0 deletions
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)) |