aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/ActivityPubManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/ActivityPubManager.java')
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java
index db8a1acb..b62be93a 100644
--- a/src/main/java/com/juick/ActivityPubManager.java
+++ b/src/main/java/com/juick/ActivityPubManager.java
@@ -283,6 +283,21 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
});
}
+ public String htmlLayout(Message msg, String baseUri) {
+ PebbleTemplate noteTemplate = pebbleEngine.getTemplate("layouts/note");
+ Map<String, Object> context = new HashMap<>();
+ context.put("msg", msg);
+ context.put("baseUri", profileUriBuilder.baseUri());
+ try {
+ Writer writer = new StringWriter();
+ noteTemplate.evaluate(writer, context);
+ return writer.toString();
+ } catch (IOException e) {
+ logger.warn("template not rendered, falling back");
+ return MessageUtils.formatMessage(StringUtils.defaultString(msg.getText()));
+ }
+ }
+
public Note makeNote(Message msg) {
Note note = new Note();
note.setId(profileUriBuilder.messageUri(msg));
@@ -345,18 +360,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
if (msg.isHtml()) {
note.setContent(msg.getText());
} else {
- PebbleTemplate noteTemplate = pebbleEngine.getTemplate("layouts/note");
- Map<String, Object> context = new HashMap<>();
- context.put("msg", msg);
- context.put("baseUri", profileUriBuilder.baseUri());
- try {
- Writer writer = new StringWriter();
- noteTemplate.evaluate(writer, context);
- note.setContent(writer.toString());
- } catch (IOException e) {
- logger.warn("template not rendered, falling back");
- note.setContent(MessageUtils.formatMessage(StringUtils.defaultString(msg.getText())));
- }
+ note.setContent(htmlLayout(msg, profileUriBuilder.baseUri()));
}
return note;
}