aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-05-27 14:19:05 +0300
committerGravatar Vitaly Takmazov2019-05-27 14:19:05 +0300
commit852ee6a66a7aa7ae96b94defcd44494b0e71b02f (patch)
tree5117674deba53a9e8e3a8781c4d10a0deea71ae3 /src
parent26d7c249eec88a6977f74756d628a85282ebe644 (diff)
ActivityPub: deserialize activities with single context
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/server/api/activity/model/Context.java6
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java3
-rw-r--r--src/test/resources/undo_pleroma.json1
3 files changed, 6 insertions, 4 deletions
diff --git a/src/main/java/com/juick/server/api/activity/model/Context.java b/src/main/java/com/juick/server/api/activity/model/Context.java
index 2ba4606e..1d3f238c 100644
--- a/src/main/java/com/juick/server/api/activity/model/Context.java
+++ b/src/main/java/com/juick/server/api/activity/model/Context.java
@@ -1,9 +1,6 @@
package com.juick.server.api.activity.model;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonSubTypes;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.juick.server.api.activity.helpers.LinkValueDeserializer;
import com.juick.server.api.activity.model.activities.*;
@@ -68,6 +65,7 @@ public abstract class Context {
}
@JsonProperty("@context")
+ @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
public List<Object> getContext() {
return context;
}
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 322d4de7..a140e9f0 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -1705,6 +1705,9 @@ public class ServerTests {
NodeInfo info = jsonMapper.readValue(IOUtils.toString(new ClassPathResource("xnodeinfo2.json").getURI(), StandardCharsets.UTF_8), NodeInfo.class);
assertThat(info.getUsage().getUsers().getActiveHalfyear(), is(42));
Like like = jsonMapper.readValue(IOUtils.toString(new ClassPathResource("like.json").getURI(), StandardCharsets.UTF_8), Like.class);
+ String undoPleromaStr = IOUtils.toString(new ClassPathResource("undo_pleroma.json").getURI(), StandardCharsets.UTF_8);
+ Undo undoPleroma = jsonMapper.readValue(undoPleromaStr, Undo.class);
+ String undoPleromaFollower = (String)((Map)undoPleroma.getObject()).get("object");
}
@Test
public void activitySerialization() throws Exception {
diff --git a/src/test/resources/undo_pleroma.json b/src/test/resources/undo_pleroma.json
new file mode 100644
index 00000000..2ef67bc2
--- /dev/null
+++ b/src/test/resources/undo_pleroma.json
@@ -0,0 +1 @@
+{"@context":"https://www.w3.org/ns/activitystreams","id":"https://mastodon.social/users/chest_i_razym#follows/4510327/undo","type":"Undo","actor":"https://mastodon.social/users/chest_i_razym","object":{"id":"https://mastodon.social/1a4824f6-b5d0-415b-a7ef-62d7637d83c9","type":"Follow","actor":"https://mastodon.social/users/chest_i_razym","object":"https://juick.com/u/WP8"}} \ No newline at end of file