diff options
author | Vitaly Takmazov | 2019-04-29 14:06:24 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-04-29 14:06:24 +0300 |
commit | c3a9365645ec94d5b7c9778ab32c93e5eb4be5f6 (patch) | |
tree | d853fc7df61fdc18a20a52c93291853796e9a60f /src/main/java/com/juick/server/api/Service.java | |
parent | 409ef92da23f4b650340197e7383ba8b528999e4 (diff) |
UserUtils -> @Visitor
Diffstat (limited to 'src/main/java/com/juick/server/api/Service.java')
-rw-r--r-- | src/main/java/com/juick/server/api/Service.java | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/main/java/com/juick/server/api/Service.java b/src/main/java/com/juick/server/api/Service.java index 27316d91..791e09ce 100644 --- a/src/main/java/com/juick/server/api/Service.java +++ b/src/main/java/com/juick/server/api/Service.java @@ -1,14 +1,13 @@ package com.juick.server.api; -import com.juick.Message; import com.juick.User; import com.juick.server.CommandsManager; import com.juick.server.EmailManager; import com.juick.server.ServerManager; import com.juick.server.util.HttpForbiddenException; -import com.juick.server.util.UserUtils; import com.juick.service.EmailService; import com.juick.service.UserService; +import com.juick.service.security.annotation.Visitor; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -64,8 +63,8 @@ public class Service { @ApiIgnore @PostMapping("/api/mail") @ResponseStatus(value = HttpStatus.OK) - public void processMail(InputStream data) throws Exception { - if (UserUtils.getCurrentUser().getName().equals(serviceUser)) { + public void processMail(@Visitor User current, InputStream data) throws Exception { + if (current.getName().equals(serviceUser)) { MimeMessage msg = new MimeMessage(session, data); String[] returnPaths = msg.getHeader("Return-Path"); if (returnPaths != null) { @@ -90,7 +89,7 @@ public class Service { body[0] = IOUtils.toString(a.getInputStream(), StandardCharsets.UTF_8); logger.info("got text: {}", body[0]); } catch (IOException e) { - logger.info("attachment error: {}", e); + logger.info("attachment error", e); } }); } @@ -145,8 +144,7 @@ public class Service { .forEach(session -> serverManager.getSessions().remove(session)); } @GetMapping("/api/events") - public SseEmitter handle() throws IOException { - User visitor = UserUtils.getCurrentUser(); + public SseEmitter handle(@Visitor User visitor) throws IOException { logger.info("{} connected", visitor.getName()); if (!visitor.isAnonymous()) { userService.updateLastSeen(visitor); |