aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/juick/server')
-rw-r--r--juick-server/src/main/java/com/juick/server/MessengerManager.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/TelegramBotManager.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/WebsocketManager.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Post.java11
4 files changed, 10 insertions, 9 deletions
diff --git a/juick-server/src/main/java/com/juick/server/MessengerManager.java b/juick-server/src/main/java/com/juick/server/MessengerManager.java
index 1628afc0..9192288f 100644
--- a/juick-server/src/main/java/com/juick/server/MessengerManager.java
+++ b/juick-server/src/main/java/com/juick/server/MessengerManager.java
@@ -98,7 +98,7 @@ public class MessengerManager implements ApplicationListener<MessageEvent> {
logger.info("Received text message from '{}' at '{}' with content: {} (mid: {})",
senderId, timestamp, text, messageId);
try {
- commandsManager.processCommand(user_from, null, text, URI.create(StringUtils.EMPTY));
+ commandsManager.processCommand(user_from, text, URI.create(StringUtils.EMPTY));
} catch (Exception e) {
logger.warn("messenger error", e);
}
diff --git a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
index 17ad4630..b0803265 100644
--- a/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
+++ b/juick-server/src/main/java/com/juick/server/TelegramBotManager.java
@@ -185,7 +185,7 @@ public class TelegramBotManager implements NotificationListener {
int rid = Integer.valueOf(uriComponents.getFragment());
prefix = String.format("#%d/%d ", mid, rid);
}
- CommandResult result = commandsManager.processCommand(user_from, null,prefix + text, attachment);
+ CommandResult result = commandsManager.processCommand(user_from, prefix + text, attachment);
String messageTxt = StringUtils.isNotEmpty(result.getMarkdown()) ? result.getMarkdown()
: "Unknown error or unsupported command";
telegramNotify(message.from().id().longValue(), messageTxt, StringUtils.EMPTY);
@@ -204,7 +204,7 @@ public class TelegramBotManager implements NotificationListener {
"Can not reply to this message", replyMessage.messageId(), StringUtils.EMPTY);
}
} else {
- CommandResult result = commandsManager.processCommand(user_from, null, text, attachment);
+ CommandResult result = commandsManager.processCommand(user_from, text, attachment);
String messageTxt = StringUtils.isNotEmpty(result.getMarkdown()) ? result.getMarkdown()
: "Unknown error or unsupported command";
telegramNotify(message.from().id().longValue(), messageTxt, StringUtils.EMPTY);
diff --git a/juick-server/src/main/java/com/juick/server/WebsocketManager.java b/juick-server/src/main/java/com/juick/server/WebsocketManager.java
index 8475fd40..f55bd92b 100644
--- a/juick-server/src/main/java/com/juick/server/WebsocketManager.java
+++ b/juick-server/src/main/java/com/juick/server/WebsocketManager.java
@@ -151,7 +151,7 @@ public class WebsocketManager extends TextWebSocketHandler {
Message draft = jsonMapper.readValue(message.asBytes(), Message.class);
if (draft.getUser() != null && (draft.getText() != null || draft.getAttachment() != null)) {
String attachmentFileName = draft.getAttachment() == null ? "" : draft.getAttachment().getUrl();
- commandsManager.processCommand(draft.getUser(), null, draft.getText(), URI.create(attachmentFileName));
+ commandsManager.processCommand(draft.getUser(), draft.getText(), URI.create(attachmentFileName));
}
} catch (Exception e) {
throw new HttpBadRequestException();
diff --git a/juick-server/src/main/java/com/juick/server/api/Post.java b/juick-server/src/main/java/com/juick/server/api/Post.java
index eddd1dd6..68465de1 100644
--- a/juick-server/src/main/java/com/juick/server/api/Post.java
+++ b/juick-server/src/main/java/com/juick/server/api/Post.java
@@ -106,7 +106,7 @@ public class Post {
throw new HttpBadRequestException();
}
}
- commandsManager.processCommand(visitor, null, body, attachmentFName);
+ commandsManager.processCommand(visitor, body, attachmentFName);
}
@PostMapping("/upload")
public String doUploadFile(@RequestParam(required = true) MultipartFile attach) {
@@ -163,7 +163,7 @@ public class Post {
}
}
- return commandsManager.processCommand(visitor, null, body, attachmentFName).getNewMessage().get();
+ return commandsManager.processCommand(visitor, body, attachmentFName).getNewMessage().get();
}
Session session = Session.getDefaultInstance(new Properties());
@@ -227,7 +227,7 @@ public class Post {
}
URI attachmentUri = StringUtils.isNotEmpty(attachmentFName[0]) ? URI.create(String.format("juick://%s", attachmentFName[0]))
: URI.create(StringUtils.EMPTY);
- commandsManager.processCommand(visitor, null, body[0], attachmentUri);
+ commandsManager.processCommand(visitor, body[0], attachmentUri);
} else {
logger.info("not registered: {}", from);
}
@@ -237,7 +237,7 @@ public class Post {
}
@PostMapping("/like")
@ResponseStatus(value = HttpStatus.OK)
- public Status doPostRecomm(@RequestParam Integer mid) {
+ public Status doPostRecomm(@RequestParam Integer mid) throws Exception {
com.juick.User visitor = UserUtils.getCurrentUser();
if (visitor.getUid() == 0) {
throw new HttpForbiddenException();
@@ -249,7 +249,8 @@ public class Post {
if (msg.getUser().getUid() == visitor.getUid()) {
throw new HttpForbiddenException();
}
- CommandResult status = commandsManager.commandRecommend(visitor, null, null, String.valueOf(mid));
+ CommandResult status = commandsManager.processCommand(visitor, String.format("! #%d", mid),
+ URI.create(StringUtils.EMPTY));
return Status.getStatus(status.getText());
}
}