diff options
Diffstat (limited to 'juick-common/src/main/java/com/juick')
4 files changed, 59 insertions, 3 deletions
diff --git a/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java b/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java index c599d33b..68799b83 100644 --- a/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java +++ b/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java @@ -42,7 +42,7 @@ public class PlainTextFormatter { String subtitle = isReply ? markdown ? MessageUtils.escapeMarkdown(StringUtils.defaultString(jmsg.getReplyQuote())) : jmsg.getReplyQuote() : markdown ? MessageUtils.getMarkdownTags(jmsg) : MessageUtils.getTagsString(jmsg); - sb.append(title).append(markdown ? MessageUtils.getMarkdownUser(jmsg) : jmsg.getUser().getName()).append(":\n") + sb.append(title).append(markdown ? MessageUtils.getMarkdownUser(jmsg.getUser()) : jmsg.getUser().getName()).append(":\n") .append(subtitle).append("\n"); if (markdown) { sb.append(MessageUtils.escapeMarkdown(StringUtils.defaultString(jmsg.getText()))); diff --git a/juick-common/src/main/java/com/juick/server/component/LikeEvent.java b/juick-common/src/main/java/com/juick/server/component/LikeEvent.java new file mode 100644 index 00000000..8ff0a184 --- /dev/null +++ b/juick-common/src/main/java/com/juick/server/component/LikeEvent.java @@ -0,0 +1,28 @@ +package com.juick.server.component; + +import com.juick.Message; +import com.juick.User; +import org.springframework.context.ApplicationEvent; + +public class LikeEvent extends ApplicationEvent { + private User user; + private Message message; + /** + * Create a new ApplicationEvent. + * + * @param source the object on which the event initially occurred (never {@code null}) + */ + public LikeEvent(Object source, User user, Message message) { + super(source); + this.message = message; + this.user = user; + } + + public User getUser() { + return user; + } + + public Message getMessage() { + return message; + } +} diff --git a/juick-common/src/main/java/com/juick/server/component/SubscribeEvent.java b/juick-common/src/main/java/com/juick/server/component/SubscribeEvent.java new file mode 100644 index 00000000..2d3ceddb --- /dev/null +++ b/juick-common/src/main/java/com/juick/server/component/SubscribeEvent.java @@ -0,0 +1,27 @@ +package com.juick.server.component; + +import com.juick.User; +import org.springframework.context.ApplicationEvent; + +public class SubscribeEvent extends ApplicationEvent { + private User user; + private User toUser; + /** + * Create a new ApplicationEvent. + * + * @param source the object on which the event initially occurred (never {@code null}) + */ + public SubscribeEvent(Object source, User user, User toUser) { + super(source); + this.user = user; + this.toUser = toUser; + } + + public User getUser() { + return user; + } + + public User getToUser() { + return toUser; + } +} diff --git a/juick-common/src/main/java/com/juick/util/MessageUtils.java b/juick-common/src/main/java/com/juick/util/MessageUtils.java index 87a10351..10314bb0 100644 --- a/juick-common/src/main/java/com/juick/util/MessageUtils.java +++ b/juick-common/src/main/java/com/juick/util/MessageUtils.java @@ -19,6 +19,7 @@ package com.juick.util; import com.juick.Message; import com.juick.Tag; +import com.juick.User; import org.apache.commons.codec.CharEncoding; import org.apache.commons.lang3.StringUtils; @@ -188,8 +189,8 @@ public class MessageUtils { .collect(Collectors.joining(", ")); } - public static String getMarkdownUser(final Message jmsg) { - return String.format("[%s](https://juick.com/%s/)", jmsg.getUser().getName(), jmsg.getUser().getName()); + public static String getMarkdownUser(final User user) { + return String.format("[%s](https://juick.com/%s/)", user.getName(), user.getName()); } // TODO: check if it is really needed |