aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/mitchellbosecke
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/main/java/com/mitchellbosecke')
-rw-r--r--juick-server/src/main/java/com/mitchellbosecke/pebble/extension/filters/FormatMessageFilter.java16
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 5b5291f1..93f9fccb 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
@@ -18,6 +18,7 @@
package com.mitchellbosecke.pebble.extension.filters;
import com.juick.Message;
+import com.juick.model.AnonymousUser;
import com.juick.util.MessageUtils;
import com.mitchellbosecke.pebble.extension.Filter;
import com.mitchellbosecke.pebble.extension.escaper.SafeString;
@@ -27,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
/**
* Created by vitalyster on 04.05.2017.
@@ -37,12 +39,14 @@ public class FormatMessageFilter implements Filter {
if (input instanceof Message) {
Message msg = (Message) input;
boolean isCode = msg.getTags().stream().anyMatch(t -> t.getName().equals("code"));
- String formatString = MessageUtils.replyStartsWithQuote(msg) ? "@%s,\n%s" : "@%s, %s";
- String msgTxt = msg.getRid() > 0 ? String.format(formatString, msg.getTo().getName(), StringUtils.defaultString(msg.getText()))
- : StringUtils.defaultString(msg.getText());
- String formattedMessage = isCode ? MessageUtils.formatMessageCode(msgTxt)
- : MessageUtils.formatMessage(msgTxt);
- return new SafeString(formattedMessage);
+ 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);
}
throw new IllegalArgumentException("invalid input");
}