From b664517144d3a82fc1b7951f83751cec1174959d Mon Sep 17 00:00:00 2001
From: Vitaly Takmazov
Date: Tue, 9 Oct 2018 12:28:11 +0300
Subject: fix message format filter for pms
---
.../pebble/extension/filters/FormatMessageFilter.java | 16 ++++++++++------
1 file 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("@%s",
- msg.getTo().getUri().toASCIIString(), msg.getTo().getName()) : String.format("@%s", 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("@%s",
+ msg.getTo().getUri().toASCIIString(), msg.getTo().getName()) : String.format("@%s", 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");
}
--
cgit v1.2.3