aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-24 00:31:28 +0300
committerGravatar Vitaly Takmazov2018-10-24 00:34:42 +0300
commit5b88a7355c554e500199d6c233ae891459b602ac (patch)
treecca19bfa8fa75e06debf1b072e979be68035fab7 /juick-server/src/main/java
parent8e6d764d6bb4391532e5376c795f634ee3898872 (diff)
Fix deserialisation and tests
Diffstat (limited to 'juick-server/src/main/java')
-rw-r--r--juick-server/src/main/java/com/juick/server/ActivityPubManager.java4
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/model/Context.java2
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java6
-rw-r--r--juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java8
4 files changed, 14 insertions, 6 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 4a6ed7be..6cfcf377 100644
--- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
+++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java
@@ -214,7 +214,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
attachment.setId(msg.getAttachment().getMedium().getUrl());
attachment.setUrl(msg.getAttachment().getMedium().getUrl());
attachment.setMediaType(HttpUtils.mediaType(msg.getAttachmentType()));
- note.setAttachment(attachment);
+ note.setAttachment(Collections.singletonList(attachment));
}
note.setTags(msg.getTags().stream().map(t -> {
Hashtag hashtag = new Hashtag();
@@ -222,7 +222,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
hashtag.setName("#" + t.getName());
return hashtag;
}).collect(Collectors.toList()));
- if (msg.getReplyToUri().toASCIIString().length() > 0) {
+ if (msg.getReplyToUri() != null && msg.getReplyToUri().toASCIIString().length() > 0) {
Optional<Context> createContext = signatureManager.getContext(msg.getReplyToUri());
if (createContext.isPresent()) {
Create activity = (Create) createContext.get();
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java b/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java
index dd67fa64..544f1aa2 100644
--- a/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java
+++ b/juick-server/src/main/java/com/juick/server/api/activity/model/Context.java
@@ -28,6 +28,8 @@ import java.util.List;
@JsonSubTypes.Type(value = Image.class, name = "Image"),
@JsonSubTypes.Type(value = Key.class, name = "Key"),
@JsonSubTypes.Type(value = Link.class, name = "Link"),
+ @JsonSubTypes.Type(value = Hashtag.class, name = "Hashtag"),
+ @JsonSubTypes.Type(value = Mention.class, name = "Mention"),
@JsonSubTypes.Type(value = Note.class, name = "Note"),
@JsonSubTypes.Type(value = OrderedCollection.class, name = "OrderedCollection"),
@JsonSubTypes.Type(value = OrderedCollectionPage.class, name = "OrderedCollectionPage"),
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java
index dbf3bec9..bcb52d37 100644
--- a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java
+++ b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Mention.java
@@ -1,7 +1,11 @@
package com.juick.server.api.activity.model.objects;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
public class Mention extends Link {
- public Mention(String href, String name) {
+ @JsonCreator
+ public Mention(@JsonProperty("href") String href, @JsonProperty("name") String name) {
this.setHref(href);
this.setName(name);
}
diff --git a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java
index 458b925c..baad2d3b 100644
--- a/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java
+++ b/juick-server/src/main/java/com/juick/server/api/activity/model/objects/Note.java
@@ -1,5 +1,6 @@
package com.juick.server.api.activity.model.objects;
+import com.fasterxml.jackson.annotation.JsonFormat;
import com.juick.server.api.activity.model.Context;
import java.util.List;
@@ -8,7 +9,7 @@ public class Note extends Context {
private String content;
private String attributedTo;
private String inReplyTo;
- private Image attachment;
+ private List<Image> attachment;
private List<String> to;
private List<String> cc;
@@ -28,11 +29,12 @@ public class Note extends Context {
this.attributedTo = attributedTo;
}
- public Image getAttachment() {
+ @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
+ public List<Image> getAttachment() {
return attachment;
}
- public void setAttachment(Image attachment) {
+ public void setAttachment(List<Image> attachment) {
this.attachment = attachment;
}