From 71c29cc99d1b3f71247b81bc42d30f8b52dad240 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 4 Apr 2018 22:20:52 +0300 Subject: server: PMs in email * also introduces MessageUtils.isReply and MessageUtils.isPM --- .../src/main/java/com/juick/formatters/PlainTextFormatter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'juick-common/src/main/java/com/juick/formatters') 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(); } -- cgit v1.2.3