aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/server/www
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2020-03-07 13:20:45 +0300
committerGravatar Vitaly Takmazov2020-03-07 13:20:45 +0300
commitc9d67837cbcaae84a03b7bd14e508ca62880f87f (patch)
tree0f66e38f5b6aa48c66fae7d10c0b8b5ad6f7e7e2 /src/main/java/com/juick/server/www
parentad50d1090b303d3a71c354dd2922a982fda6a289 (diff)
Reorganize project layout
Diffstat (limited to 'src/main/java/com/juick/server/www')
-rw-r--r--src/main/java/com/juick/server/www/WebApp.java4
-rw-r--r--src/main/java/com/juick/server/www/controllers/Help.java2
-rw-r--r--src/main/java/com/juick/server/www/controllers/Login.java2
-rw-r--r--src/main/java/com/juick/server/www/controllers/MessagesWWW.java40
-rw-r--r--src/main/java/com/juick/server/www/controllers/Settings.java2
-rw-r--r--src/main/java/com/juick/server/www/controllers/SignUp.java2
-rw-r--r--src/main/java/com/juick/server/www/controllers/SocialLogin.java14
-rw-r--r--src/main/java/com/juick/server/www/filters/AnythingFilter.java7
8 files changed, 37 insertions, 36 deletions
diff --git a/src/main/java/com/juick/server/www/WebApp.java b/src/main/java/com/juick/server/www/WebApp.java
index 2bc2b596..8476224d 100644
--- a/src/main/java/com/juick/server/www/WebApp.java
+++ b/src/main/java/com/juick/server/www/WebApp.java
@@ -16,8 +16,8 @@
*/
package com.juick.server.www;
-import com.juick.Tag;
-import com.juick.User;
+import com.juick.model.Tag;
+import com.juick.model.User;
import com.juick.service.TagService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
diff --git a/src/main/java/com/juick/server/www/controllers/Help.java b/src/main/java/com/juick/server/www/controllers/Help.java
index d37a87de..8bb9aecd 100644
--- a/src/main/java/com/juick/server/www/controllers/Help.java
+++ b/src/main/java/com/juick/server/www/controllers/Help.java
@@ -17,7 +17,7 @@
package com.juick.server.www.controllers;
-import com.juick.User;
+import com.juick.model.User;
import com.juick.server.util.HttpNotFoundException;
import com.juick.server.www.HelpService;
import com.juick.server.www.WebApp;
diff --git a/src/main/java/com/juick/server/www/controllers/Login.java b/src/main/java/com/juick/server/www/controllers/Login.java
index 20ab45a4..e6d6904c 100644
--- a/src/main/java/com/juick/server/www/controllers/Login.java
+++ b/src/main/java/com/juick/server/www/controllers/Login.java
@@ -16,7 +16,7 @@
*/
package com.juick.server.www.controllers;
-import com.juick.User;
+import com.juick.model.User;
import com.juick.service.UserService;
import com.juick.service.security.annotation.Visitor;
import org.springframework.stereotype.Controller;
diff --git a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
index 946b13b3..a7e4c127 100644
--- a/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
+++ b/src/main/java/com/juick/server/www/controllers/MessagesWWW.java
@@ -16,9 +16,9 @@
*/
package com.juick.server.www.controllers;
-import com.juick.Message;
-import com.juick.Tag;
-import com.juick.User;
+import com.juick.model.Message;
+import com.juick.model.Tag;
+import com.juick.model.User;
import com.juick.formatters.PlainTextFormatter;
import com.juick.server.Utils;
import com.juick.server.util.HttpForbiddenException;
@@ -73,7 +73,7 @@ public class MessagesWWW {
@Inject
private WebApp webApp;
- private void fillUserModel(ModelMap model, com.juick.User user, com.juick.User visitor) {
+ private void fillUserModel(ModelMap model, User user, User visitor) {
user.setAvatar(webApp.getAvatarWebPath(user));
model.addAttribute("user", user);
model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
@@ -156,7 +156,7 @@ public class MessagesWWW {
model.addAttribute("headers", head);
model.addAttribute("visitor", visitor);
model.addAttribute("noindex", !(paramShow == null && paramBefore == 0));
- List<com.juick.Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(visitor, mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (!visitor.isAnonymous()) {
fillUserModel(model, visitor, visitor);
@@ -203,7 +203,7 @@ public class MessagesWWW {
@RequestParam(required = false, defaultValue = "0") Integer before,
@CookieValue(name = "sape_cookie", required = false, defaultValue = StringUtils.EMPTY) String sapeCookie,
ModelMap model) {
- com.juick.User user = userService.getUserByName(uname);
+ User user = userService.getUserByName(uname);
if (user.isBanned() || user.isAnonymous()) {
throw new HttpNotFoundException();
}
@@ -211,7 +211,7 @@ public class MessagesWWW {
List<Integer> mids;
- com.juick.Tag paramTag = null;
+ Tag paramTag = null;
if (paramTagStr != null) {
if (paramTagStr.length() < 64) {
paramTag = tagService.getTag(paramTagStr, false);
@@ -273,7 +273,7 @@ public class MessagesWWW {
model.addAttribute("noindex", paramShow == null && before == 0);
fillUserModel(model, user, visitor);
model.addAttribute("paramTag", paramTag);
- List<com.juick.Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(visitor, mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (!visitor.isAnonymous()) {
List<Integer> unread = messagesService.getUnread(visitor);
@@ -312,7 +312,7 @@ public class MessagesWWW {
protected String doGetTags(
@Visitor User visitor,
@PathVariable String uname, ModelMap model) {
- com.juick.User user = userService.getUserByName(uname);
+ User user = userService.getUserByName(uname);
if (visitor.isBanned()) {
throw new HttpNotFoundException();
}
@@ -332,7 +332,7 @@ public class MessagesWWW {
protected String doGetFriends(
@Visitor User visitor,
@PathVariable String uname, ModelMap model) {
- com.juick.User user = userService.getUserByName(uname);
+ User user = userService.getUserByName(uname);
if (visitor.isBanned()) {
throw new HttpNotFoundException();
}
@@ -350,7 +350,7 @@ public class MessagesWWW {
protected String doGetReaders(
@Visitor User visitor,
@PathVariable String uname, ModelMap model) {
- com.juick.User user = userService.getUserByName(uname);
+ User user = userService.getUserByName(uname);
visitor.setAvatar(webApp.getAvatarWebPath(visitor));
model.addAttribute("title", "Читатели " + user.getName());
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
@@ -365,7 +365,7 @@ public class MessagesWWW {
protected String doGetBL(
@Visitor User visitor,
@PathVariable String uname, ModelMap model) {
- com.juick.User user = userService.getUserByName(uname);
+ User user = userService.getUserByName(uname);
if (visitor.getUid() != user.getUid()) {
throw new HttpForbiddenException();
}
@@ -388,11 +388,11 @@ public class MessagesWWW {
ModelMap model) {
visitor.setAvatar(webApp.getAvatarWebPath(visitor));
String paramTagStr = StringEscapeUtils.unescapeHtml4(tagName);
- com.juick.Tag paramTag = tagService.getTag(paramTagStr, false);
+ Tag paramTag = tagService.getTag(paramTagStr, false);
if (paramTag == null) {
throw new HttpNotFoundException();
} else if (paramTag.SynonymID > 0 && paramTag.TID != paramTag.SynonymID) {
- com.juick.Tag synTag = tagService.getTag(paramTag.SynonymID);
+ Tag synTag = tagService.getTag(paramTag.SynonymID);
String url = "/tag/" + URLEncoder.encode(StringEscapeUtils.escapeHtml4(synTag.getName()), StandardCharsets.UTF_8);
if (request.getQueryString() != null) {
url += "?" + request.getQueryString();
@@ -409,7 +409,7 @@ public class MessagesWWW {
String title = "*" + StringEscapeUtils.escapeHtml4(paramTag.getName());
model.addAttribute("title", title);
List<Integer> mids = messagesService.getTag(paramTag.TID, visitor.getUid(), before, (visitor.isAnonymous()) ? 40 : 20);
- List<com.juick.Message> msgs = messagesService.getMessages(visitor, mids);
+ List<Message> msgs = messagesService.getMessages(visitor, mids);
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (!visitor.isAnonymous()) {
List<Integer> unread = messagesService.getUnread(visitor);
@@ -457,7 +457,7 @@ public class MessagesWWW {
}
visitor.setAvatar(webApp.getAvatarWebPath(visitor));
String title = "PM: Inbox";
- List<com.juick.Message> msgs = pmQueriesService.getLastPMInbox(visitor.getUid());
+ List<Message> msgs = pmQueriesService.getLastPMInbox(visitor.getUid());
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
fillUserModel(model, visitor, visitor);
model.addAttribute("title", title);
@@ -477,7 +477,7 @@ public class MessagesWWW {
}
visitor.setAvatar(webApp.getAvatarWebPath(visitor));
String title = "PM: Sent";
- List<com.juick.Message> msgs = pmQueriesService.getLastPMSent(visitor.getUid());
+ List<Message> msgs = pmQueriesService.getLastPMSent(visitor.getUid());
msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarWebPath(m.getUser())));
if (WebUtils.isNotUserName(uname)) {
uname = StringUtils.EMPTY;
@@ -501,7 +501,7 @@ public class MessagesWWW {
throw new HttpForbiddenException();
}
visitor.setAvatar(webApp.getAvatarWebPath(visitor));
- Optional<com.juick.Message> message = messagesService.getMessage(mid);
+ Optional<Message> message = messagesService.getMessage(mid);
if (message.isEmpty()) {
throw new HttpNotFoundException();
@@ -509,13 +509,13 @@ public class MessagesWWW {
Message msg = message.get();
- com.juick.User user = userService.getUserByName(uname);
+ User user = userService.getUserByName(uname);
if (user.isAnonymous() || !msg.getUser().equals(user)) {
return String.format("redirect:/%s/%d", msg.getUser().getName(), mid);
}
msg.VisitorCanComment = !visitor.isAnonymous();
msg.getUser().setAvatar(webApp.getAvatarWebPath(msg.getUser()));
- List<com.juick.Message> replies = messagesService.getReplies(visitor, msg.getMid());
+ List<Message> replies = messagesService.getReplies(visitor, msg.getMid());
// this should be after getReplies to mark thread as read
fillUserModel(model, user, visitor);
if (!visitor.isAnonymous()) {
diff --git a/src/main/java/com/juick/server/www/controllers/Settings.java b/src/main/java/com/juick/server/www/controllers/Settings.java
index 7e3e2514..e535eef0 100644
--- a/src/main/java/com/juick/server/www/controllers/Settings.java
+++ b/src/main/java/com/juick/server/www/controllers/Settings.java
@@ -16,7 +16,7 @@
*/
package com.juick.server.www.controllers;
-import com.juick.User;
+import com.juick.model.User;
import com.juick.model.NotifyOpts;
import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.HttpUtils;
diff --git a/src/main/java/com/juick/server/www/controllers/SignUp.java b/src/main/java/com/juick/server/www/controllers/SignUp.java
index 7332dc2e..cc2101a3 100644
--- a/src/main/java/com/juick/server/www/controllers/SignUp.java
+++ b/src/main/java/com/juick/server/www/controllers/SignUp.java
@@ -16,7 +16,7 @@
*/
package com.juick.server.www.controllers;
-import com.juick.User;
+import com.juick.model.User;
import com.juick.server.util.HttpBadRequestException;
import com.juick.server.util.HttpForbiddenException;
import com.juick.server.www.WebApp;
diff --git a/src/main/java/com/juick/server/www/controllers/SocialLogin.java b/src/main/java/com/juick/server/www/controllers/SocialLogin.java
index 710bae8e..e3b7a33b 100644
--- a/src/main/java/com/juick/server/www/controllers/SocialLogin.java
+++ b/src/main/java/com/juick/server/www/controllers/SocialLogin.java
@@ -22,8 +22,8 @@ import com.github.scribejava.core.builder.ServiceBuilder;
import com.github.scribejava.core.model.*;
import com.github.scribejava.core.oauth.OAuth10aService;
import com.github.scribejava.core.oauth.OAuth20Service;
-import com.juick.model.facebook.User;
-import com.juick.model.vk.UsersResponse;
+import com.juick.model.ext.facebook.User;
+import com.juick.model.ext.vk.UsersResponse;
import com.juick.server.Utils;
import com.juick.server.util.HttpBadRequestException;
import com.juick.service.CrosspostService;
@@ -193,7 +193,7 @@ public class SocialLogin {
}
@GetMapping("/_twitter")
protected void doTwitterLogin(
- @Visitor com.juick.User user,
+ @Visitor com.juick.model.User user,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ExecutionException, InterruptedException {
String hash = StringUtils.EMPTY, request_token = StringUtils.EMPTY, request_token_secret = StringUtils.EMPTY;
@@ -229,8 +229,8 @@ public class SocialLogin {
OAuth1AccessToken accessToken = oAuthService.getAccessToken(requestToken, verifier);
OAuthRequest oAuthRequest = new OAuthRequest(Verb.GET, TWITTER_VERIFY_URL);
oAuthService.signRequest(accessToken, oAuthRequest);
- com.juick.model.twitter.User twitterUser = jsonMapper.readValue(oAuthService.execute(oAuthRequest).getBody(),
- com.juick.model.twitter.User.class);
+ com.juick.model.ext.twitter.User twitterUser = jsonMapper.readValue(oAuthService.execute(oAuthRequest).getBody(),
+ com.juick.model.ext.twitter.User.class);
if (userService.linkTwitterAccount(user, accessToken.getToken(), accessToken.getTokenSecret(),
twitterUser.getScreenName())) {
response.setStatus(HttpServletResponse.SC_FOUND);
@@ -267,7 +267,7 @@ public class SocialLogin {
vkAuthService.signRequest(token, meRequest);
String graph = vkAuthService.execute(meRequest).getBody();
- com.juick.model.vk.User jsonUser = jsonMapper.readValue(graph, UsersResponse.class).getUsers().get(0);
+ com.juick.model.ext.vk.User jsonUser = jsonMapper.readValue(graph, UsersResponse.class).getUsers().get(0);
String vkName = jsonUser.getFirstName() + " " + jsonUser.getLastName();
String vkLink = jsonUser.getScreenName();
@@ -348,7 +348,7 @@ public class SocialLogin {
AppleSignInApi api = (AppleSignInApi) appleSignInService.getApi();
var email = api.validateToken(idToken);
if (email.isPresent()) {
- com.juick.User user = userService.getUserByEmail(email.get());
+ com.juick.model.User user = userService.getUserByEmail(email.get());
if (!user.isAnonymous()) {
Cookie c = new Cookie("hash", userService.getHashByUID(user.getUid()));
c.setMaxAge(50 * 24 * 60 * 60);
diff --git a/src/main/java/com/juick/server/www/filters/AnythingFilter.java b/src/main/java/com/juick/server/www/filters/AnythingFilter.java
index cf484357..9a012089 100644
--- a/src/main/java/com/juick/server/www/filters/AnythingFilter.java
+++ b/src/main/java/com/juick/server/www/filters/AnythingFilter.java
@@ -17,6 +17,7 @@
package com.juick.server.www.filters;
+import com.juick.model.User;
import com.juick.server.util.WebUtils;
import com.juick.service.MessagesService;
import com.juick.service.UserService;
@@ -59,7 +60,7 @@ public class AnythingFilter extends OncePerRequestFilter {
if (isPostNumber && anything.equals(Integer.toString(messageId))) {
if (messageId > 0) {
- com.juick.User author = messagesService.getMessageAuthor(messageId);
+ User author = messagesService.getMessageAuthor(messageId);
if (author != null) {
servletResponse.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
@@ -68,14 +69,14 @@ public class AnythingFilter extends OncePerRequestFilter {
}
}
}
- com.juick.User user = userService.getUserByName(anything);
+ User user = userService.getUserByName(anything);
if (user.getUid() > 0) {
servletResponse.sendRedirect("/" + user.getName() + "/");
} else {
filterChain.doFilter(servletRequest, servletResponse);
}
} else {
- com.juick.User user = userService.getUserByName(anything);
+ User user = userService.getUserByName(anything);
if (!user.isAnonymous()) {
servletResponse.sendRedirect("/" + user.getName() + "/?before=" + before);
} else {