From 5f5cfa9ee18d5d590404096ae9c55086e4b08304 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 30 Jan 2018 12:33:05 +0300 Subject: xmpp: drop broken paging from user blog command, refactoring --- .../src/main/java/com/juick/components/JuickBot.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'juick-xmpp/src') diff --git a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java index bbe693a1..7a25f5d5 100644 --- a/juick-xmpp/src/main/java/com/juick/components/JuickBot.java +++ b/juick-xmpp/src/main/java/com/juick/components/JuickBot.java @@ -524,11 +524,7 @@ public class JuickBot implements StanzaListener, AutoCloseable { public String commandFavorites(User currentUser, Jid from, String... args) { List mids = messagesService.getUserRecommendations(currentUser.getUid(), 0); if (mids.size() > 0) { - List messages = messagesService.getMessages(mids); - return "Favorite messages: \n" + String.join("\n", messages.stream() - .sorted(Collections.reverseOrder()) - .map(PlainTextFormatter::formatPost) - .collect(Collectors.toList())); + return "Favorite messages: \n" + printMessages(mids, false); } return "No favorite messages, try to \"like\" something ;)"; } @@ -588,16 +584,14 @@ public class JuickBot implements StanzaListener, AutoCloseable { } } @UserCommand(pattern = "^\\@([^\\s\\n\\+]+)(\\+?)$", - help = "@username+ - Show user's info and last 10 messages (@username++ - second page, ..)") + help = "@username+ - Show user's info and last 20 messages") public String commandUser(User user, Jid from, String... arguments) { User blogUser = userService.getUserByName(arguments[0]); int page = arguments[1].length(); if (blogUser.getUid() > 0) { - List mids = messagesService.getUserBlog(blogUser.getUid(), 0, page); - List messages = messagesService.getMessages(mids); + List mids = messagesService.getUserBlog(blogUser.getUid(), 0, 0); return String.format("Last messages from @%s:\n%s", arguments[0], - String.join("\n", messages.stream() - .map(PlainTextFormatter::formatPostSummary).collect(Collectors.toList()))); + printMessages(mids, false)); } return "User not found"; } -- cgit v1.2.3