diff options
Diffstat (limited to 'juick-server/src/main')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/ActivityPubManager.java | 33 | ||||
-rw-r--r-- | juick-server/src/main/java/com/juick/server/SignatureManager.java | 2 |
2 files changed, 18 insertions, 17 deletions
diff --git a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java index bd837eb8..aa329b0a 100644 --- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java +++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java @@ -215,22 +215,6 @@ public class ActivityPubManager implements ActivityListener, NotificationListene note.setCc(Collections.singletonList(followersUri(msg.getUser()))); } note.setPublished(msg.getTimestamp()); - 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", 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()))); - } - } if (StringUtils.isNotBlank(msg.getAttachmentType())) { Image attachment = new Image(); attachment.setId(msg.getAttachment().getMedium().getUrl()); @@ -252,11 +236,28 @@ public class ActivityPubManager implements ActivityListener, NotificationListene if (personContext.isPresent()) { Person person = (Person) personContext.get(); note.getTags().add(new Mention(person.getUrl(), person.getPreferredUsername())); + msg.getTo().setName(person.getPreferredUsername()); } } } else if (MessageUtils.isReply(msg)) { note.getTags().add(new Mention(personWebUri(msg.getTo()), msg.getTo().getName())); } + 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", 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()))); + } + } return note; } diff --git a/juick-server/src/main/java/com/juick/server/SignatureManager.java b/juick-server/src/main/java/com/juick/server/SignatureManager.java index 4fa6c5ff..f152796c 100644 --- a/juick-server/src/main/java/com/juick/server/SignatureManager.java +++ b/juick-server/src/main/java/com/juick/server/SignatureManager.java @@ -64,7 +64,7 @@ public class SignatureManager { //boolean valid = verifySignature(Signature.fromString(requestHeaders.getFirst("Signature")), // keystoreManager.getPublicKey(), "POST", inbox.getPath(), headers); logger.info("Sending context: {}", jsonMapper.writeValueAsString(data)); - ResponseEntity<Void> response = new RestTemplate().postForEntity(inbox, request, Void.class); + ResponseEntity<Void> response = apClient.postForEntity(inbox, request, Void.class); logger.info("accepted follower: {}", response.getStatusCodeValue()); } public boolean verifySignature(String signatureString, URI actor, String method, String path, Map<String, String> headers) { |