aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java11
-rw-r--r--src/main/java/com/juick/ServerManager.java13
-rw-r--r--src/main/java/com/juick/TelegramBotManager.java8
-rw-r--r--src/main/java/com/juick/TopManager.java26
-rw-r--r--src/main/java/com/juick/XMPPManager.java5
-rw-r--r--src/main/java/com/juick/config/WebConfig.java13
-rw-r--r--src/main/java/com/juick/service/MessagesService.java6
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java52
-rw-r--r--src/main/java/com/juick/service/UserService.java2
-rw-r--r--src/main/java/com/juick/service/UserServiceImpl.java8
-rw-r--r--src/main/java/com/juick/www/api/Messages.java6
-rw-r--r--src/main/java/com/juick/www/api/Notifications.java10
-rw-r--r--src/main/java/com/juick/www/api/Service.java8
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java4
-rw-r--r--src/main/java/com/juick/www/controllers/Site.java4
-rw-r--r--src/main/java/com/juick/www/rss/Feeds.java2
-rw-r--r--src/main/resources/data-h2.sql1
17 files changed, 53 insertions, 126 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java
index 3b90530c..57110729 100644
--- a/src/main/java/com/juick/ActivityPubManager.java
+++ b/src/main/java/com/juick/ActivityPubManager.java
@@ -74,22 +74,11 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
@Inject
private SocialService socialService;
@Inject
- private UserService userService;
- @Inject
private MessagesService messagesService;
@Inject
private PebbleEngine pebbleEngine;
@Value("${ap_base_uri:http://localhost:8080/}")
private String baseUri;
- @Value("${service_user:juick}")
- private String serviceUsername;
-
- private User serviceUser;
-
- @PostConstruct
- public void init() {
- serviceUser = userService.getUserByName(serviceUsername);
- }
@Override
public void processFollowEvent(@Nonnull FollowEvent followEvent) {
diff --git a/src/main/java/com/juick/ServerManager.java b/src/main/java/com/juick/ServerManager.java
index f8f8b8c6..50389705 100644
--- a/src/main/java/com/juick/ServerManager.java
+++ b/src/main/java/com/juick/ServerManager.java
@@ -28,12 +28,10 @@ import com.juick.util.MessageUtils;
import org.apache.commons.collections4.ListUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.annotation.Nonnull;
-import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.Arrays;
@@ -55,18 +53,9 @@ public class ServerManager implements NotificationListener {
@Inject
private UserService userService;
private final CopyOnWriteArrayList<EventSession> sessions = new CopyOnWriteArrayList<>();
-
- @Value("${service_user:juick}")
- private String serviceUsername;
-
+ @Inject
private User serviceUser;
- @PostConstruct
- public void init() {
- serviceUser = userService.getUserByName(serviceUsername);
- }
-
-
private void onJuickPM(final User to, final Message jmsg) {
messageEvent(jmsg, Arrays.asList(to, jmsg.getUser()));
}
diff --git a/src/main/java/com/juick/TelegramBotManager.java b/src/main/java/com/juick/TelegramBotManager.java
index 3538a27b..33cac896 100644
--- a/src/main/java/com/juick/TelegramBotManager.java
+++ b/src/main/java/com/juick/TelegramBotManager.java
@@ -93,8 +93,8 @@ public class TelegramBotManager implements NotificationListener {
private ApplicationEventPublisher applicationEventPublisher;
@Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
private String tmpDir;
- @Value("${service_user:juick}")
- private String serviceUser;
+ @Inject
+ private User serviceUser;
private static final String MSG_LINK = "🔗";
@@ -397,7 +397,7 @@ public class TelegramBotManager implements NotificationListener {
if (type.equals(SystemActivity.ActivityType.message)) {
processMessage(activity.getMessage(), activity.getTo());
} else if (type.equals(SystemActivity.ActivityType.like)) {
- if (systemEvent.getActivity().getFrom().getName().equals(serviceUser)) {
+ if (systemEvent.getActivity().getFrom().equals(serviceUser)) {
processTop(systemEvent.getActivity().getMessage());
} else {
processLike(activity.getFrom(), activity.getMessage(), activity.getTo());
@@ -433,7 +433,7 @@ public class TelegramBotManager implements NotificationListener {
}
private void processLike(User liker, com.juick.model.Message message, List<User> subscribers) {
- if (!liker.getName().equals(serviceUser)) {
+ if (!liker.equals(serviceUser)) {
logger.info("Like received in tg listener");
if (!userService.isInBLAny(message.getUser().getUid(), liker.getUid())) {
telegramService.getTelegramIdentifiers(Collections.singletonList(message.getUser()))
diff --git a/src/main/java/com/juick/TopManager.java b/src/main/java/com/juick/TopManager.java
index ca3b3e84..c58af428 100644
--- a/src/main/java/com/juick/TopManager.java
+++ b/src/main/java/com/juick/TopManager.java
@@ -20,19 +20,12 @@ package com.juick;
import com.juick.model.Message;
import com.juick.model.Tag;
import com.juick.model.User;
-import com.juick.www.api.SystemActivity;
import com.juick.service.MessagesService;
-import com.juick.service.UserService;
-import com.juick.service.component.SystemEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationEventPublisher;
import org.springframework.scheduling.annotation.Scheduled;
-import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
@@ -41,30 +34,19 @@ public class TopManager {
@Inject
private MessagesService messagesService;
@Inject
- private UserService userService;
- @Inject
- private ApplicationEventPublisher applicationEventPublisher;
-
- @Value("${service_user:juick}")
- private String serviceUsername;
+ private CommandsManager commandsManager;
+ @Inject
private User serviceUser;
- @PostConstruct
- public void init() {
- serviceUser = userService.getUserByName(serviceUsername);
- }
-
@Scheduled(fixedRate = 3600000)
public void updateTop() {
messagesService.getPopularCandidates().forEach(m -> {
Message jmsg = messagesService.getMessage(m).orElseThrow(IllegalStateException::new);
- logger.info("added {} to popular", m);
- messagesService.setMessagePopular(m, 1);
List<String> tags = jmsg.getTags().stream().map(Tag::getName).map(String::toLowerCase).collect(Collectors.toList());
if (!tags.contains("juick")) {
- applicationEventPublisher.publishEvent(new SystemEvent(this,
- SystemActivity.like(serviceUser, jmsg, Collections.emptyList())));
+ logger.info("added {} to popular", m);
+ commandsManager.commandRecommend(serviceUser, null, String.valueOf(m));
}
});
}
diff --git a/src/main/java/com/juick/XMPPManager.java b/src/main/java/com/juick/XMPPManager.java
index 8b775495..b42b4b9f 100644
--- a/src/main/java/com/juick/XMPPManager.java
+++ b/src/main/java/com/juick/XMPPManager.java
@@ -115,11 +115,9 @@ public class XMPPManager implements NotificationListener {
private PMQueriesService pmQueriesService;
@Inject
private Executor applicationTaskExecutor;
- @Value("${service_user:juick}")
- private String serviceUsername;
@Inject
private WebApp webApp;
-
+ @Inject
private User serviceUser;
@PostConstruct
@@ -263,7 +261,6 @@ public class XMPPManager implements NotificationListener {
logger.warn("xmpp exception", e);
}
});
- serviceUser = userService.getUserByName(serviceUsername);
}
private void sendJuickMessage(com.juick.model.Message jmsg, List<User> users) {
diff --git a/src/main/java/com/juick/config/WebConfig.java b/src/main/java/com/juick/config/WebConfig.java
index ccfa5f1e..fcc61b72 100644
--- a/src/main/java/com/juick/config/WebConfig.java
+++ b/src/main/java/com/juick/config/WebConfig.java
@@ -18,7 +18,9 @@
package com.juick.config;
import com.juick.*;
+import com.juick.model.User;
import com.juick.service.HelpService;
+import com.juick.service.UserService;
import com.mitchellbosecke.pebble.PebbleEngine;
import com.mitchellbosecke.pebble.extension.FormatterExtension;
import com.mitchellbosecke.pebble.loader.ClasspathLoader;
@@ -52,6 +54,8 @@ import java.nio.file.Paths;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
+import javax.inject.Inject;
+
/**
* Created by aalexeev on 11/22/16.
*/
@@ -176,5 +180,14 @@ public class WebConfig implements WebMvcConfigurer {
e.printStackTrace();
}
}
+
+ @Inject
+ private UserService userService;
+ @Value("${service_user:juick}")
+ private String serviceUsername;
+ @Bean
+ public User serviceUser() {
+ return userService.getUserByName(serviceUsername);
+ }
}
diff --git a/src/main/java/com/juick/service/MessagesService.java b/src/main/java/com/juick/service/MessagesService.java
index bb12a61e..5e3a1e83 100644
--- a/src/main/java/com/juick/service/MessagesService.java
+++ b/src/main/java/com/juick/service/MessagesService.java
@@ -85,8 +85,6 @@ public interface MessagesService {
List<Integer> getRecommended(int uid, int before);
- List<Integer> getPopular(int visitorUid, int before);
-
List<Integer> getPhotos(int visitorUid, int before);
List<Integer> getSearch(User visitor, String search, int page);
@@ -97,7 +95,7 @@ public interface MessagesService {
List<Integer> getUserBlogAtDay(int uid, int privacy, int daysback);
- List<Integer> getUserBlogWithRecommendations(int uid, int privacy, int before);
+ List<Integer> getUserBlogWithRecommendations(User user, User visitor, int privacy, int before);
List<Integer> getUserRecommendations(int uid, int before);
@@ -111,8 +109,6 @@ public interface MessagesService {
List<Message> getReplies(User user, int mid);
- boolean setMessagePopular(int mid, int popular);
-
boolean setMessagePrivacy(int mid);
boolean deleteMessage(int uid, int mid);
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index c2e5d15d..0625716a 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -623,20 +623,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public List<Integer> getPopular(final int visitorUid, final int before) {
- SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("vid", visitorUid)
- .addValue("before", before);
-
- return getNamedParameterJdbcTemplate().queryForList("SELECT m.message_id FROM messages m WHERE m.privacy > 0 "
- + (before > 0 ? " AND m.message_id < :before " : StringUtils.EMPTY)
- + " AND m.popular > 0 AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = m.user_id) "
- + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN "
- + "(SELECT tag_id FROM messages_tags WHERE message_id = m.message_id) and :vid = bt.user_id)"
- + " ORDER BY m.message_id DESC LIMIT 20", sqlParameterSource, Integer.class);
- }
-
- @Transactional(readOnly = true)
- @Override
public List<Integer> getPhotos(final int visitorUid, final int before) {
SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("vid", visitorUid)
.addValue("before", before);
@@ -705,9 +691,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional(readOnly = true)
@Override
- public List<Integer> getUserBlogWithRecommendations(final int uid, final int privacy, final int before) {
- SqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("uid", uid)
- .addValue("privacy", privacy).addValue("before", before);
+ public List<Integer> getUserBlogWithRecommendations(final User user, final User visitor, final int privacy, final int before) {
+ SqlParameterSource sqlParameterSource = new MapSqlParameterSource()
+ .addValue("uid", user.getUid())
+ .addValue("vid", visitor.getUid())
+ .addValue("privacy", privacy).addValue("before", before);
return getNamedParameterJdbcTemplate()
.queryForList("SELECT message_id FROM " + "(SELECT message_id FROM favorites " + " INNER JOIN users"
@@ -716,6 +704,9 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ " ORDER BY message_id DESC LIMIT 20) as r" + " UNION ALL " + "SELECT message_id FROM "
+ "(SELECT message_id FROM messages" + " INNER JOIN users" + " ON messages.user_id = users.id"
+ " WHERE user_id = :uid AND users.banned = 0"
+ + " AND NOT EXISTS (SELECT 1 FROM bl_users b WHERE b.user_id = :vid and b.bl_user_id = messages.user_id) "
+ + " AND NOT EXISTS (SELECT 1 FROM bl_tags bt WHERE bt.tag_id IN "
+ + "(SELECT tag_id FROM messages_tags WHERE message_id = messages.message_id) and :vid = bt.user_id)"
+ (before > 0 ? " AND message_id < :before" : StringUtils.EMPTY)
+ " AND privacy >= :privacy ORDER BY message_id DESC LIMIT 20) as m "
+ "ORDER BY message_id DESC LIMIT 20", sqlParameterSource, Integer.class);
@@ -870,33 +861,6 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
@Transactional
@Override
- public boolean setMessagePopular(final int mid, final int popular) {
- int ret;
- MapSqlParameterSource sqlParameterSource = new MapSqlParameterSource().addValue("mid", mid).addValue("popular",
- popular);
-
- switch (popular) {
- case -2:
- ret = getNamedParameterJdbcTemplate().update("UPDATE messages SET hidden = 1 WHERE message_id = :mid",
- sqlParameterSource);
- break;
- case -1:
- sqlParameterSource.addValue("popular", 0);
- default:
- ret = getNamedParameterJdbcTemplate()
- .update("UPDATE messages SET popular = :popular WHERE message_id = :mid", sqlParameterSource);
- break;
- }
-
- if (popular == -1)
- ret = getNamedParameterJdbcTemplate().update("INSERT INTO top_ignore_messages VALUES (:mid)",
- sqlParameterSource);
-
- return ret > 0;
- }
-
- @Transactional
- @Override
public boolean setMessagePrivacy(final int mid) {
return getJdbcTemplate().update("UPDATE messages SET privacy=1 WHERE message_id=?", mid) > 0;
}
diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java
index dc879821..c0428169 100644
--- a/src/main/java/com/juick/service/UserService.java
+++ b/src/main/java/com/juick/service/UserService.java
@@ -131,8 +131,6 @@ public interface UserService {
boolean isAdminUser(User user);
- boolean isServiceUser(User user);
-
Optional<ExternalToken> getTwitterToken(int uid);
boolean deleteTwitterToken(Integer uid);
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java
index 9762802f..e73f4ea3 100644
--- a/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/src/main/java/com/juick/service/UserServiceImpl.java
@@ -60,9 +60,6 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Value("${juick.admin_users:}")
List<String> adminUsers;
- @Value("${service_user:juick}")
- private String serviceUser;
-
private class UserMapper implements RowMapper<User> {
@Override
public User mapRow(@Nonnull ResultSet rs, int rowNum) throws SQLException {
@@ -669,11 +666,6 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
public boolean isAdminUser(User user) {
return adminUsers.contains(user.getName());
}
-
- @Override
- public boolean isServiceUser(User user) {
- return user.getName().equals(serviceUser);
- }
@Transactional(readOnly = true)
@Override
diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java
index 7b003220..9608813d 100644
--- a/src/main/java/com/juick/www/api/Messages.java
+++ b/src/main/java/com/juick/www/api/Messages.java
@@ -65,6 +65,8 @@ public class Messages {
private WebApp webApp;
@Value("classpath:Transparent.gif")
private Resource invisiblePixel;
+ @Inject
+ private User serviceUser;
// TODO: serialize image urls
@@ -102,7 +104,7 @@ public class Messages {
throw new HttpNotFoundException();
}
} else if (StringUtils.hasText(withrecommended)) {
- mids = messagesService.getUserBlogWithRecommendations(user.getUid(), 0, before);
+ mids = messagesService.getUserBlogWithRecommendations(user, visitor, 0, before);
} else if (daysback > 0) {
mids = messagesService.getUserBlogAtDay(user.getUid(), 0, daysback);
} else if (StringUtils.hasText(search)) {
@@ -116,7 +118,7 @@ public class Messages {
}
} else {
if (StringUtils.hasText(popular)) {
- mids = messagesService.getPopular(visitor.getUid(), before);
+ mids = messagesService.getUserBlogWithRecommendations(serviceUser, visitor, 0, before);
} else if (StringUtils.hasText(media)) {
mids = messagesService.getPhotos(visitor.getUid(), before);
} else if (StringUtils.hasText(tag)) {
diff --git a/src/main/java/com/juick/www/api/Notifications.java b/src/main/java/com/juick/www/api/Notifications.java
index d00fe4ca..613e6cfc 100644
--- a/src/main/java/com/juick/www/api/Notifications.java
+++ b/src/main/java/com/juick/www/api/Notifications.java
@@ -63,8 +63,8 @@ public class Notifications {
private UserService userService;
@Inject
private TelegramService telegramService;
- @Value("${api_user:juick}")
- private String serviceUser;
+ @Inject
+ private User serviceUser;
private User collectTokens(Integer uid) {
User user = userService.getUserByUID(uid).orElse(AnonymousUser.INSTANCE);
@@ -90,7 +90,7 @@ public class Notifications {
@RequestParam(required = false, defaultValue = "0") int uid,
@RequestParam(required = false, defaultValue = "0") int mid,
@RequestParam(required = false, defaultValue = "0") int rid) {
- if (!(visitor.getName().equals(serviceUser))) {
+ if (!(visitor.equals(serviceUser))) {
throw new HttpForbiddenException();
}
if (uid > 0 && mid == 0) {
@@ -127,7 +127,7 @@ public class Notifications {
public Status doDelete(
@Visitor User visitor,
@RequestBody List<ExternalToken> list) {
- if (!visitor.getName().equals(serviceUser)) {
+ if (!visitor.equals(serviceUser)) {
throw new HttpForbiddenException();
}
list.forEach(t -> {
@@ -153,7 +153,7 @@ public class Notifications {
public Status doDeleteTokens(
@Visitor User visitor,
@RequestBody List<ExternalToken> list) {
- if (!visitor.getName().equals(serviceUser)) {
+ if (!visitor.equals(serviceUser)) {
throw new HttpForbiddenException();
}
list.forEach(t -> {
diff --git a/src/main/java/com/juick/www/api/Service.java b/src/main/java/com/juick/www/api/Service.java
index 3844d003..fc0132b1 100644
--- a/src/main/java/com/juick/www/api/Service.java
+++ b/src/main/java/com/juick/www/api/Service.java
@@ -75,8 +75,8 @@ public class Service {
private CommandsManager commandsManager;
@Inject
private ApplicationEventPublisher applicationEventPublisher;
- @Value("${api_user:juick}")
- private String serviceUser;
+ @Inject
+ private User serviceUser;
@Value("${upload_tmp_dir:#{systemEnvironment['TEMP'] ?: '/tmp'}}")
private String tmpDir;
@Value("${banned_emails:}")
@@ -90,7 +90,7 @@ public class Service {
@PostMapping("/api/mail")
@ResponseStatus(value = HttpStatus.OK)
public void processMail(@Visitor User current, InputStream data) throws Exception {
- if (current.getName().equals(serviceUser)) {
+ if (current.equals(serviceUser)) {
MimeMessage msg = new MimeMessage(session, data);
String[] returnPaths = msg.getHeader("Return-Path");
if (returnPaths != null) {
@@ -197,7 +197,7 @@ public class Service {
@PostMapping("/api/mail/unsubscribe")
@ResponseStatus(value = HttpStatus.OK)
public void processMailUnsubscribe(@Visitor User current, InputStream data) throws Exception {
- if (current.getName().equals(serviceUser)) {
+ if (current.equals(serviceUser)) {
MimeMessage msg = new MimeMessage(session, data);
String from = msg.getFrom() == null || msg.getFrom().length > 1
? ((InternetAddress) msg.getSender()).getAddress()
diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java
index 3dc717e9..045e919d 100644
--- a/src/main/java/com/juick/www/api/activity/Profile.java
+++ b/src/main/java/com/juick/www/api/activity/Profile.java
@@ -105,13 +105,15 @@ public class Profile {
private WebApp webApp;
@Inject
private Remark remarkConverter;
+ @Inject
+ private User serviceUser;
@GetMapping(value = "/u/{userName}", produces = { Context.LD_JSON_MEDIA_TYPE,
Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, Context.FALLBACK_JSON_MEDIA_TYPE })
public Actor getUser(@PathVariable String userName) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous()) {
- Actor profile = userService.isServiceUser(user) ? new Application() : new Person();
+ Actor profile = user.equals(serviceUser) ? new Application() : new Person();
profile.setId(activityPubManager.personUri(user));
profile.setUrl(activityPubManager.personWebUri(user));
profile.setName(userName);
diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java
index 682ed247..9eb4c917 100644
--- a/src/main/java/com/juick/www/controllers/Site.java
+++ b/src/main/java/com/juick/www/controllers/Site.java
@@ -69,6 +69,8 @@ public class Site {
private PMQueriesService pmQueriesService;
@Inject
private WebApp webApp;
+ @Inject
+ private User serviceUser;
private void fillUserModel(ModelMap model, User user, User visitor) {
user.setAvatar(webApp.getAvatarWebPath(user));
@@ -118,7 +120,7 @@ public class Site {
mids = messagesService.getDiscussions(visitor.getUid(), paramTo);
} else if (paramShow.equals("top")) {
title = ResourceBundle.getBundle("messages", locale).getString("link.popular");
- mids = messagesService.getPopular(visitor.getUid(), paramBefore);
+ mids = messagesService.getUserBlogWithRecommendations(serviceUser, visitor, 0, paramBefore);
model.addAttribute("discover", true);
} else if (paramShow.equals("my") && !visitor.isAnonymous()) {
title = ResourceBundle.getBundle("messages", locale).getString("link.my");
diff --git a/src/main/java/com/juick/www/rss/Feeds.java b/src/main/java/com/juick/www/rss/Feeds.java
index 34ad7e5e..8b396fd2 100644
--- a/src/main/java/com/juick/www/rss/Feeds.java
+++ b/src/main/java/com/juick/www/rss/Feeds.java
@@ -51,7 +51,7 @@ public class Feeds {
public ModelAndView getBlog(@Visitor User visitor, @PathVariable String userName, @PathVariable FeedType feedType) {
User user = userService.getUserByName(userName);
if (!user.isAnonymous() && !user.isBanned()) {
- List<Integer> mids = feedType == FeedType.blog ? messagesService.getUserBlog(user.getUid(), 0, 0) : messagesService.getUserBlogWithRecommendations(user.getUid(), 0, 0);
+ List<Integer> mids = feedType == FeedType.blog ? messagesService.getUserBlog(user.getUid(), 0, 0) : messagesService.getUserBlogWithRecommendations(user, visitor, 0, 0);
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("messagesView");
modelAndView.addObject("user", user);
diff --git a/src/main/resources/data-h2.sql b/src/main/resources/data-h2.sql
index aff3e286..e279e524 100644
--- a/src/main/resources/data-h2.sql
+++ b/src/main/resources/data-h2.sql
@@ -1,4 +1,5 @@
INSERT INTO users(id, nick, passw) VALUES(0, 'Anonymous', 'password');
+INSERT INTO users(id, nick, passw) VALUES(2, 'juick', 'password');
INSERT INTO tags(tag_id, name) VALUES(2, 'juick');
INSERT INTO reactions (like_id, description) VALUES (1, 'like');
INSERT INTO reactions (like_id, description) VALUES (2, 'love');