diff options
author | 2019-01-20 14:52:45 +0300 | |
---|---|---|
committer | 2019-01-20 14:52:45 +0300 | |
commit | 8b474748883b9a4d780c7d696445126666c2094f (patch) | |
tree | 743a8cbb367788cde4eae9a4c10a7ef06c362174 /src/main/java/com/juick | |
parent | 0f83e951d1ca5185067cde9b73613b0371f1ba2b (diff) |
Set avatar in events
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r-- | src/main/java/com/juick/server/CommandsManager.java | 7 | ||||
-rw-r--r-- | src/main/java/com/juick/server/ServerManager.java | 3 | ||||
-rw-r--r-- | src/main/java/com/juick/server/api/PM.java | 1 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/main/java/com/juick/server/CommandsManager.java b/src/main/java/com/juick/server/CommandsManager.java index fa3c5537..087ba444 100644 --- a/src/main/java/com/juick/server/CommandsManager.java +++ b/src/main/java/com/juick/server/CommandsManager.java @@ -25,6 +25,7 @@ import com.juick.model.CommandResult; import com.juick.model.TagStats; import com.juick.server.helpers.annotation.UserCommand; import com.juick.server.util.HttpUtils; +import com.juick.server.www.WebApp; import com.juick.service.*; import com.juick.service.activities.DeleteMessageEvent; import com.juick.service.component.*; @@ -75,6 +76,8 @@ public class CommandsManager { private ApplicationEventPublisher applicationEventPublisher; @Inject private ImagesService imagesService; + @Inject + private WebApp webApp; public CommandResult processCommand(@Nonnull User user, String data, @Nonnull URI attachment) throws Exception { if (!user.isAnonymous()) { @@ -127,6 +130,7 @@ public class CommandsManager { imagesService.saveImageWithPreviews(attachmentFName, fname); } Message msg = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new); + msg.getUser().setAvatar(webApp.getAvatarWebPath(msg.getUser())); subscriptionService.subscribeMessage(msg, user); applicationEventPublisher.publishEvent(new MessageReadEvent(this, user, msg)); @@ -160,7 +164,7 @@ public class CommandsManager { String body = arguments[1]; User user_to = userService.getUserByName(arguments[0]); - + user_to.setAvatar(webApp.getAvatarWebPath(user_to)); if (!user_to.isAnonymous()) { if (!userService.isInBLAny(user_to.getUid(), user_from.getUid())) { if (pmQueriesService.createPM(user_from.getUid(), user_to.getUid(), body)) { @@ -537,6 +541,7 @@ public class CommandsManager { Message original = messagesService.getMessage(mid).orElseThrow(IllegalStateException::new); subscriptionService.subscribeMessage(original, user); Message reply = messagesService.getReply(mid, newrid); + reply.getUser().setAvatar(webApp.getAvatarWebPath(reply.getUser())); applicationEventPublisher.publishEvent(new MessageEvent(this, reply, subscriptionService.getUsersSubscribedToComments(original, reply))); return CommandResult.build(reply,"Reply posted.\n#" + mid + "/" + newrid + " " + "https://juick.com/m/" + mid + "#" + newrid, diff --git a/src/main/java/com/juick/server/ServerManager.java b/src/main/java/com/juick/server/ServerManager.java index be537409..5f96da08 100644 --- a/src/main/java/com/juick/server/ServerManager.java +++ b/src/main/java/com/juick/server/ServerManager.java @@ -94,8 +94,7 @@ public class ServerManager implements NotificationListener { if (MessageUtils.isPM(jmsg)) { onJuickPM(jmsg.getTo(), jmsg); } else if (!MessageUtils.isReply(jmsg)) { - // to get full message with attachment, etc. - onJuickMessagePost(messagesService.getMessage(jmsg.getMid()).orElseThrow(IllegalStateException::new), subscribedUsers); + onJuickMessagePost(jmsg, subscribedUsers); } else { // to get quote and attachment Message op = messagesService.getMessage(jmsg.getMid()).orElseThrow(IllegalStateException::new); diff --git a/src/main/java/com/juick/server/api/PM.java b/src/main/java/com/juick/server/api/PM.java index a80ad0dc..242cd31c 100644 --- a/src/main/java/com/juick/server/api/PM.java +++ b/src/main/java/com/juick/server/api/PM.java @@ -99,6 +99,7 @@ public class PM { jmsg.setUser(visitor); jmsg.setText(body); jmsg.setTo(userTo); + jmsg.getUser().setAvatar(webApp.getAvatarWebPath(jmsg.getUser())); applicationEventPublisher.publishEvent(new MessageEvent(this, jmsg, Collections.singletonList(jmsg.getTo()))); return jmsg; |