aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-common/src/main/java/com/juick/server/protocol/JuickProtocol.java22
-rw-r--r--juick-server/src/main/java/com/juick/server/XMPPBot.java10
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java2
3 files changed, 11 insertions, 23 deletions
diff --git a/juick-common/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-common/src/main/java/com/juick/server/protocol/JuickProtocol.java
index 1be34a3f..5206e1e8 100644
--- a/juick-common/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ b/juick-common/src/main/java/com/juick/server/protocol/JuickProtocol.java
@@ -108,28 +108,6 @@ public class JuickProtocol {
-
- @UserCommand(pattern = "^d\\s*\\#([0-9]+)$", patternFlags = Pattern.CASE_INSENSITIVE,
- help = "D #12345 - delete the message")
- public String commandDel(User user, String... args) {
- int mid = NumberUtils.toInt(args[0], 0);
- if (messagesService.deleteMessage(user.getUid(), mid)) {
- return String.format("Message %s deleted", mid);
- }
- return "Error";
- }
-
-
- @UserCommand(pattern = "^(#+)$", help = "# - Show last messages from your feed (## - second page, ...)")
- public String commandMyFeed(User user, String... arguments) {
- // number of # is the page count
- int page = arguments[0].length() - 1;
- List<Integer> mids = messagesService.getMyFeed(user.getUid(), page, false);
- List<Message> messages = messagesService.getMessages(mids);
- // TODO: add instructions for empty feed
- return "Your feed: \n" + String.join("\n",
- messages.stream().map(PlainTextFormatter::formatPost).collect(Collectors.toList()));
- }
@UserCommand(pattern = "^(#|\\.)(\\d+)((\\.|\\-|\\/)(\\d+))?\\s([\\s\\S]+)",
help = "#1234 *tag *tag2 - edit tags\n#1234 text - reply to message")
public String EditOrReply(User user, String... args) {
diff --git a/juick-server/src/main/java/com/juick/server/XMPPBot.java b/juick-server/src/main/java/com/juick/server/XMPPBot.java
index 9b6b5fe4..b8789276 100644
--- a/juick-server/src/main/java/com/juick/server/XMPPBot.java
+++ b/juick-server/src/main/java/com/juick/server/XMPPBot.java
@@ -689,6 +689,16 @@ public class XMPPBot implements StanzaListener, AutoCloseable {
public String commandSearchAll(User user, Jid from, String... args) {
return "Temporarily unavailable";
}
+ @UserCommand(pattern = "^(#+)$", help = "# - Show last messages from your feed (## - second page, ...)")
+ public String commandMyFeed(User user, String... arguments) {
+ // number of # is the page count
+ int page = arguments[0].length() - 1;
+ List<Integer> mids = messagesService.getMyFeed(user.getUid(), page, false);
+ if (mids.size() > 0) {
+ return "Your feed: \n" + printMessages(mids, true);
+ }
+ return "Your feed is empty";
+ }
void sendReply(Jid jidTo, String txt) {
Message reply = new Message();
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index dac0be22..1d76ca42 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -371,7 +371,7 @@ public class ServerTests extends AbstractJUnit4SpringContextTests {
public void botCommandsTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "PING").get(), is("PONG"));
// subscription commands have two lines, others have 1
- assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(28));
+ assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(29));
}
@Test