aboutsummaryrefslogtreecommitdiff
path: root/juick-www/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-www/src/main/java')
-rw-r--r--juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java2
-rw-r--r--juick-www/src/main/java/com/juick/www/controllers/User.java75
2 files changed, 36 insertions, 41 deletions
diff --git a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
index 12960cfb..23bec18b 100644
--- a/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
+++ b/juick-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
@@ -70,7 +70,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.addFilterAfter(hashParamAuthenticationFilter(), BasicAuthenticationFilter.class);
http
.authorizeRequests()
- .antMatchers("/settings", "/pm/**").authenticated()
+ .antMatchers("/settings", "/pm/**", "/**/bl").authenticated()
.anyRequest().permitAll()
.and()
.anonymous().principal(JuickUser.ANONYMOUS_USER).authorities(JuickUser.ANONYMOUS_AUTHORITY)
diff --git a/juick-www/src/main/java/com/juick/www/controllers/User.java b/juick-www/src/main/java/com/juick/www/controllers/User.java
index 443f7b08..532e0caa 100644
--- a/juick-www/src/main/java/com/juick/www/controllers/User.java
+++ b/juick-www/src/main/java/com/juick/www/controllers/User.java
@@ -62,6 +62,20 @@ public class User {
@Inject
private Sape sape;
+ void fillUserModel(ModelMap model, com.juick.User user, com.juick.User visitor) {
+ model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
+ model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
+ model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
+ model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
+ model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
+ model.addAttribute("statsMyBL", userService.getUserBLUsers(user.getUid()).size());
+ model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
+ model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
+ model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
+ model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
+ .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ }
+
@GetMapping("/{uname}/")
protected String doGetBlog(
@RequestParam(required = false, name = "show") String paramShow,
@@ -138,16 +152,7 @@ public class User {
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
model.addAttribute("noindex", paramShow == null && before == 0);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("paramTag", paramTag);
List<com.juick.Message> msgs = messagesService.getMessages(mids);
@@ -199,16 +204,7 @@ public class User {
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex,nofollow\"/>");
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("tags", tagService.getUserTagStats(user.getUid()).stream()
.sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).map(t -> t.getTag().getName()).collect(Collectors.toList()));
@@ -226,16 +222,7 @@ public class User {
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("users", userService.getUserFriends(user.getUid()));
return "views/users";
@@ -252,18 +239,26 @@ public class User {
model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
model.addAttribute("visitor", visitor);
model.addAttribute("user", user);
- model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBL", userService.isInBL(visitor.getUid(), user.getUid()));
- model.addAttribute("isInBLAny", userService.isInBLAny(user.getUid(), visitor.getUid()));
- model.addAttribute("statsIRead", userService.getStatsIRead(user.getUid()));
- model.addAttribute("statsMyReaders", userService.getStatsMyReaders(user.getUid()));
- model.addAttribute("statsMessages", userService.getStatsMessages(user.getUid()));
- model.addAttribute("statsReplies", userService.getStatsReplies(user.getUid()));
- model.addAttribute("iread", userService.getUserReadLeastPopular(user.getUid(), 8));
- model.addAttribute("tagStats", tagService.getUserTagStats(user.getUid())
- .stream().sorted((e1, e2) -> Integer.compare(e2.getUsageCount(), e1.getUsageCount())).limit(20).map(t -> t.getTag().getName()).collect(Collectors.toList()));
+ fillUserModel(model, user, visitor);
model.addAttribute("users", userService.getUserReaders(user.getUid()));
return "views/users";
}
+
+ @GetMapping("/{uname}/bl")
+ protected String doGetBL(@PathVariable String uname, ModelMap model) throws IOException {
+ com.juick.User user = userService.getUserByName(uname);
+ com.juick.User visitor = UserUtils.getCurrentUser();
+ if (visitor.isBanned() || visitor.getUid() != user.getUid()) {
+ throw new HttpForbiddenException();
+ }
+ model.addAttribute("title", "Черный список " + user.getName());
+ model.addAttribute("headers", "<meta name=\"robots\" content=\"noindex\"/>");
+ model.addAttribute("visitor", visitor);
+ model.addAttribute("user", user);
+ fillUserModel(model, user, visitor);
+ model.addAttribute("users", userService.getUserBLUsers(user.getUid()));
+
+ return "views/users";
+ }
}