aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/util/formatters
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/util/formatters')
-rw-r--r--src/main/java/com/juick/util/formatters/PlainTextFormatter.java21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/com/juick/util/formatters/PlainTextFormatter.java b/src/main/java/com/juick/util/formatters/PlainTextFormatter.java
index 83feb8a6..b1b1a44a 100644
--- a/src/main/java/com/juick/util/formatters/PlainTextFormatter.java
+++ b/src/main/java/com/juick/util/formatters/PlainTextFormatter.java
@@ -31,25 +31,20 @@ import java.util.Locale;
public class PlainTextFormatter {
static PrettyTime pt = new PrettyTime(new Locale("en"));
- public static String formatPost(Message jmsg) {
- return formatPost(jmsg, false);
+ public static String formatPost(Message jmsg, String domain) {
+ return formatPost(jmsg, false, domain);
}
- public static String formatPost(Message jmsg, boolean markdown) {
+ public static String formatPost(Message jmsg, boolean compatibleWithDurov, String domain) {
StringBuilder sb = new StringBuilder();
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.getMessageHashTags(jmsg) : MessageUtils.getTagsString(jmsg);
- sb.append(title).append(markdown ? MessageUtils.getMarkdownUser(jmsg.getUser()) : jmsg.getUser().getName()).append(":\n")
+ String subtitle = MessageUtils.isReply(jmsg) ? jmsg.getReplyQuote()
+ : compatibleWithDurov ? MessageUtils.getMessageHashTags(jmsg) : MessageUtils.getTagsString(jmsg);
+ sb.append(title).append(compatibleWithDurov ? MessageUtils.getUserHtmlLink(jmsg.getUser(), domain) : jmsg.getUser().getName()).append(":\n")
.append(subtitle).append("\n");
- if (markdown) {
- sb.append(MessageUtils.formatMarkdownText(jmsg));
- } else {
- sb.append(StringUtils.defaultString(jmsg.getText()));
- }
+ sb.append(compatibleWithDurov? MessageUtils.formatMessage(jmsg.getText(), true) : StringUtils.defaultString(jmsg.getText()));
sb.append("\n");
- if (!markdown && StringUtils.isNotEmpty(jmsg.getAttachmentType())) {
+ if (!compatibleWithDurov && StringUtils.isNotEmpty(jmsg.getAttachmentType())) {
sb.append(MessageUtils.attachmentUrl(jmsg));
}
return sb.toString();