From 8a0fbbd35c13054a947ea0d27ca117542bc452b9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 18 May 2018 15:33:38 +0300 Subject: JPA WIP --- juick-server/src/main/java/com/juick/server/api/PM.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'juick-server/src/main/java/com/juick/server/api/PM.java') diff --git a/juick-server/src/main/java/com/juick/server/api/PM.java b/juick-server/src/main/java/com/juick/server/api/PM.java index cbd70bed..0985e7c4 100644 --- a/juick-server/src/main/java/com/juick/server/api/PM.java +++ b/juick-server/src/main/java/com/juick/server/api/PM.java @@ -54,16 +54,16 @@ public class PM { if (visitor.isAnonymous()) { throw new HttpForbiddenException(); } - int uid = 0; + User user = AnonymousUser.INSTANCE; if (uname != null && uname.matches("^[a-zA-Z0-9\\-]{2,16}$")) { - uid = userService.getUIDbyName(uname); + user = userService.getUserByName(uname); } - if (uid == 0) { + if (user.getUid() == 0) { throw new HttpBadRequestException(); } - return pmQueriesService.getPMMessages(visitor.getUid(), uid); + return pmQueriesService.getPMMessages(visitor, user); } @RequestMapping(value = "/pm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @@ -87,7 +87,7 @@ public class PM { throw new HttpForbiddenException(); } - if (pmQueriesService.createPM(visitor.getUid(), userTo.getUid(), body)) { + if (pmQueriesService.createPM(visitor, userTo, body)) { com.juick.Message jmsg = new com.juick.Message(); jmsg.setUser(visitor); jmsg.setText(body); @@ -112,7 +112,7 @@ public class PM { cnt = 10; } - List lastconv = pmQueriesService.getPMLastConversationsUsers(visitor.getUid(), cnt); + List lastconv = pmQueriesService.getPMLastConversationsUsers(visitor, cnt); PrivateChats pms = new PrivateChats(); pms.setUsers(lastconv); return pms; -- cgit v1.2.3