diff options
author | Vitaly Takmazov | 2018-10-09 12:28:11 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-10-09 12:28:11 +0300 |
commit | b664517144d3a82fc1b7951f83751cec1174959d (patch) | |
tree | 8a5e80ec677997598253fefdd2b7a9ec277ba0cf /juick-server/src/main/java/com/mitchellbosecke/pebble | |
parent | fb1802e6400ee7f2c65a1d74f243e56bf27be326 (diff) |
fix message format filter for pms
Diffstat (limited to 'juick-server/src/main/java/com/mitchellbosecke/pebble')
-rw-r--r-- | juick-server/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/juick-server/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java b/juick-server/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java index f347c1c3..1b75727e 100644 --- a/juick-server/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java +++ b/juick-server/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java @@ -42,14 +42,18 @@ public class FormatMessageFilter implements Filter { return new SafeString(msg.getText()); } boolean isCode = msg.getTags().stream().anyMatch(t -> t.getName().equals("code")); - String toUserString = msg.getTo().getUid() == 0 ? String.format("<a href=\"%s\" data-user-uri=\"1\">@%s</a>", - msg.getTo().getUri().toASCIIString(), msg.getTo().getName()) : String.format("<a href=\"https://juick.com/%s/\">@%s</a>", msg.getTo().getName(), msg.getTo().getName()); - String formatString = MessageUtils.replyStartsWithQuote(msg) ? "%s,\n%s" : "%s, %s"; String formattedMessage = isCode ? MessageUtils.formatMessageCode(StringUtils.defaultString(msg.getText())) : MessageUtils.formatMessage(StringUtils.defaultString(msg.getText())); - String msgTxt = msg.getRid() > 0 ? String.format(formatString, toUserString, formattedMessage) - : formattedMessage; - return new SafeString(msgTxt); + if (MessageUtils.isPM(msg)) { + return new SafeString(formattedMessage); + } else { + String toUserString = msg.getTo().getUid() == 0 ? String.format("<a href=\"%s\" data-user-uri=\"1\">@%s</a>", + msg.getTo().getUri().toASCIIString(), msg.getTo().getName()) : String.format("<a href=\"https://juick.com/%s/\">@%s</a>", msg.getTo().getName(), msg.getTo().getName()); + String formatString = MessageUtils.replyStartsWithQuote(msg) ? "%s,\n%s" : "%s, %s"; + String msgTxt = msg.getRid() > 0 ? String.format(formatString, toUserString, formattedMessage) + : formattedMessage; + return new SafeString(msgTxt); + } } throw new IllegalArgumentException("invalid input"); } |