aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src/main/java/com/juick/server/CommandsManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-common/src/main/java/com/juick/server/CommandsManager.java')
-rw-r--r--juick-common/src/main/java/com/juick/server/CommandsManager.java11
1 files changed, 5 insertions, 6 deletions
diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java
index 7dd372b1..a5484f75 100644
--- a/juick-common/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java
@@ -114,13 +114,12 @@ public class CommandsManager {
: HttpUtils.downloadImage(attachment.toURL(), tmpDir).getHost();
attachmentType = attachmentFName.substring(attachmentFName.length() - 3);
}
- int mid = messagesService.createMessage(user.getUid(), body, attachmentType, tags);
- subscriptionService.subscribeMessage(messagesService.getMessage(mid), user);
+ com.juick.Message msg = messagesService.createMessage(user, body, attachmentType, tags);
+ subscriptionService.subscribeMessage(msg, user);
if (haveAttachment) {
- String fname = String.format("%d.%s", mid, attachmentType);
+ String fname = String.format("%d.%s", msg.getMid(), attachmentType);
imagesService.saveImageWithPreviews(attachmentFName, fname);
}
- com.juick.Message msg = messagesService.getMessage(mid);
applicationEventPublisher.publishEvent(new MessageReadEvent(this, user, msg));
applicationEventPublisher.publishEvent(new MessageEvent(this, msg, subscriptionService.getSubscribedUsers(msg.getUser().getUid(), msg.getMid())));
return CommandResult.build(msg, "New message posted.\n#" + msg.getMid() + " https://juick.com/m/" + msg.getMid(), String.format("[New message](%s) posted", PlainTextFormatter.formatUrl(msg)));
@@ -145,7 +144,7 @@ public class CommandsManager {
@UserCommand(pattern = "^login$", patternFlags = Pattern.CASE_INSENSITIVE,
help = "LOGIN - log in to Juick website")
public CommandResult commandLogin(User user_from, URI attachment, String[] input) {
- return CommandResult.fromString("http://juick.com/login?hash=" + userService.getHashByUID(user_from.getUid()));
+ return CommandResult.fromString("http://juick.com/login?hash=" + userService.getHashForUser(user_from));
}
@UserCommand(pattern = "^\\@(\\S+)\\s+([\\s\\S]+)$", help = "@username message - send PM to username")
public CommandResult commandPM(User user_from, URI attachment, String... arguments) {
@@ -155,7 +154,7 @@ public class CommandsManager {
if (!user_to.isAnonymous()) {
if (!userService.isInBLAny(user_to.getUid(), user_from.getUid())) {
- if (pmQueriesService.createPM(user_from.getUid(), user_to.getUid(), body)) {
+ if (pmQueriesService.createPM(user_from, user_to, body)) {
com.juick.Message jmsg = new com.juick.Message();
jmsg.setUser(user_from);
jmsg.setTo(user_to);