aboutsummaryrefslogtreecommitdiff
path: root/juick-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'juick-common/src')
-rw-r--r--juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java10
-rw-r--r--juick-common/src/main/java/com/juick/util/MessageUtils.java6
2 files changed, 11 insertions, 5 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 a47a6113..0e7569ab 100644
--- a/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java
+++ b/juick-common/src/main/java/com/juick/formatters/PlainTextFormatter.java
@@ -37,10 +37,8 @@ public class PlainTextFormatter {
public static String formatPost(Message jmsg, boolean markdown) {
StringBuilder sb = new StringBuilder();
- boolean isPM = jmsg.getMid() == 0;
- boolean isReply = jmsg.getRid() > 0;
- String title = isReply ? "Reply by @" : isPM ? "Private message from @" : "@";
- String subtitle = isReply ? markdown ? MessageUtils.escapeMarkdown(StringUtils.defaultString(jmsg.getReplyQuote()))
+ String title = MessageUtils.isReply(jmsg) ? "Reply by @" : MessageUtils.isPM(jmsg) ? "Private message from @" : "@";
+ String subtitle = MessageUtils.isReply(jmsg) ? markdown ? MessageUtils.escapeMarkdown(StringUtils.defaultString(jmsg.getReplyQuote()))
: jmsg.getReplyQuote()
: markdown ? MessageUtils.getMarkdownTags(jmsg) : MessageUtils.getTagsString(jmsg);
sb.append(title).append(markdown ? MessageUtils.getMarkdownUser(jmsg.getUser()) : jmsg.getUser().getName()).append(":\n")
@@ -78,8 +76,10 @@ public class PlainTextFormatter {
}
public static String formatUrl(com.juick.Message jmsg) {
- if (jmsg.getRid() > 0) {
+ if (MessageUtils.isReply(jmsg)) {
return String.format("https://juick.com/%d#%d", jmsg.getMid(), jmsg.getRid());
+ } else if (MessageUtils.isPM(jmsg)) {
+ return "https://juick.com/pm/inbox";
}
return "https://juick.com/" + jmsg.getMid();
}
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 10314bb0..bb7edfc3 100644
--- a/juick-common/src/main/java/com/juick/util/MessageUtils.java
+++ b/juick-common/src/main/java/com/juick/util/MessageUtils.java
@@ -262,4 +262,10 @@ public class MessageUtils {
}
return builder.toString();
}
+ public static boolean isPM(Message message) {
+ return message.getMid() == 0;
+ }
+ public static boolean isReply(Message message) {
+ return message.getRid() > 0;
+ }
}