aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/api/PM.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-04-29 14:06:24 +0300
committerGravatar Vitaly Takmazov2019-04-29 14:06:24 +0300
commitc3a9365645ec94d5b7c9778ab32c93e5eb4be5f6 (patch)
treed853fc7df61fdc18a20a52c93291853796e9a60f /src/main/java/com/juick/server/api/PM.java
parent409ef92da23f4b650340197e7383ba8b528999e4 (diff)
UserUtils -> @Visitor
Diffstat (limited to 'src/main/java/com/juick/server/api/PM.java')
-rw-r--r--src/main/java/com/juick/server/api/PM.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java
index 06dc9733..b65841c0 100644
--- a/src/main/java/com/juick/server/api/PM.java
+++ b/src/main/java/com/juick/server/api/PM.java
@@ -20,13 +20,16 @@ package com.juick.server.api;
import com.juick.Chat;
import com.juick.Message;
import com.juick.User;
-import com.juick.server.www.WebApp;
-import com.juick.service.component.MessageEvent;
import com.juick.model.AnonymousUser;
import com.juick.model.PrivateChats;
-import com.juick.server.util.*;
+import com.juick.server.util.HttpBadRequestException;
+import com.juick.server.util.HttpForbiddenException;
+import com.juick.server.util.WebUtils;
+import com.juick.server.www.WebApp;
import com.juick.service.PMQueriesService;
import com.juick.service.UserService;
+import com.juick.service.component.MessageEvent;
+import com.juick.service.security.annotation.Visitor;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -54,8 +57,8 @@ public class PM {
@RequestMapping(value = "/api/pm", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<com.juick.Message> doGetPM(
+ @Visitor User visitor,
@RequestParam(required = false) String uname) {
- User visitor = UserUtils.getCurrentUser();
int uid = 0;
if (uname != null && uname.matches("^[a-zA-Z0-9\\-]{2,16}$")) {
uid = userService.getUIDbyName(uname);
@@ -72,9 +75,9 @@ public class PM {
@RequestMapping(value = "/api/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public com.juick.Message doPostPM(
+ @Visitor User visitor,
@RequestParam String uname,
@RequestParam String body) {
- User visitor = UserUtils.getCurrentUser();
User userTo = AnonymousUser.INSTANCE;
if (WebUtils.isUserName(uname)) {
userTo = userService.getUserByName(uname);
@@ -102,8 +105,8 @@ public class PM {
}
@RequestMapping(value = "/api/groups_pms", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public PrivateChats doGetGroupsPMs(
+ @Visitor User visitor,
@RequestParam(defaultValue = "5") int cnt) {
- User visitor = UserUtils.getCurrentUser();
// TODO: ignore cnt param for now but make sure paging param will not be cnt
List<Chat> lastconv = pmQueriesService.getLastChats(visitor);