aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-24 17:17:19 +0300
committerGravatar Vitaly Takmazov2018-10-24 17:17:19 +0300
commit4b6e60929bcaf830bba3423d66bb1f325e73fcb6 (patch)
tree99f121e618754919992199ec5024b359811447c7 /juick-server/src/main/java/com
parent0886b0290dd35b01776856db40e960863f200c68 (diff)
AcitvityPub: fix Mention rendering
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r--juick-server/src/main/java/com/juick/server/ActivityPubManager.java33
-rw-r--r--juick-server/src/main/java/com/juick/server/SignatureManager.java2
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) {