diff options
Diffstat (limited to 'juick-api/src/main/java/com/juick/api/controllers')
-rw-r--r-- | juick-api/src/main/java/com/juick/api/controllers/Messages.java | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/juick-api/src/main/java/com/juick/api/controllers/Messages.java b/juick-api/src/main/java/com/juick/api/controllers/Messages.java index 414e9ba1..78c8ecc6 100644 --- a/juick-api/src/main/java/com/juick/api/controllers/Messages.java +++ b/juick-api/src/main/java/com/juick/api/controllers/Messages.java @@ -10,7 +10,6 @@ import com.juick.service.MessagesService; import com.juick.service.TagService; import com.juick.service.UserService; import com.juick.util.UserUtils; -import org.apache.commons.lang3.math.NumberUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; @@ -136,7 +135,8 @@ public class Messages { @RequestMapping("/thread") public ResponseEntity<List<com.juick.Message>> getThread( - HttpServletRequest request) { + HttpServletRequest request, + @RequestParam(defaultValue = "0") int mid) { // TODO: use spring-security String auth = request.getHeader("Authorization"); int vuid = userService.getUIDByHttpAuth(auth); @@ -149,7 +149,6 @@ public class Messages { vuid = userService.getUIDbyHash(hash); } } - int mid = NumberUtils.toInt(request.getParameter("mid"), 0); com.juick.Message msg = messagesService.getMessage(mid); if (msg != null) { if (!messagesService.canViewThread(mid, vuid)) { @@ -164,7 +163,9 @@ public class Messages { } @RequestMapping("/messages/recommended") - public ResponseEntity<List<com.juick.Message>> doGetRecommended(HttpServletRequest request) { + public ResponseEntity<List<com.juick.Message>> doGetRecommended( + HttpServletRequest request, + @RequestParam(defaultValue = "0") int before_mid) { // TODO: use spring-security String auth = request.getHeader("Authorization"); int vuid = userService.getUIDByHttpAuth(auth); @@ -180,8 +181,6 @@ public class Messages { if (vuid == 0) { return FORBIDDEN; } - int before_mid = NumberUtils.toInt(request.getParameter("before_mid"), 0); - List<Integer> mids = messagesService.getUserRecommendations(vuid, before_mid); if (mids != null && !mids.isEmpty()) { List<com.juick.Message> msgs = messagesService.getMessages(mids); @@ -196,7 +195,9 @@ public class Messages { @RequestMapping("/messages/set_privacy") @ResponseBody - public Status doSetPrivacy(HttpServletRequest request) { + public Status doSetPrivacy( + HttpServletRequest request, + @RequestParam(defaultValue = "0") int mid) { // TODO: use spring-security String auth = request.getHeader("Authorization"); int vuid = userService.getUIDByHttpAuth(auth); @@ -212,20 +213,17 @@ public class Messages { if (vuid == 0) { throw new HttpForbiddenException(); } - int mid = NumberUtils.toInt(request.getParameter("mid"), 0); com.juick.User user = messagesService.getMessageAuthor(mid); if (user != null && user.getUid() == vuid && messagesService.setMessagePrivacy(mid)) { return Status.OK; - } else { - throw new HttpBadRequestException(); } + throw new HttpBadRequestException(); } @RequestMapping("/messages/set_popular") - public Status doSetPopular(HttpServletRequest request) { - int mid = NumberUtils.toInt(request.getParameter("mid"), 0); - int popular = NumberUtils.toInt(request.getParameter("popular"), 0); - + public Status doSetPopular( + @RequestParam(defaultValue = "0") int mid, + @RequestParam(defaultValue = "0") int popular) { if (mid > 0) { boolean ret = messagesService.setMessagePopular(mid, popular); |