diff options
author | Vitaly Takmazov | 2019-07-06 14:31:16 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2019-07-06 14:31:16 +0300 |
commit | 3188babc5e9acb46816a6d4a917c31340af11298 (patch) | |
tree | 4831b7f8a1d64fc4d904bffc24a36c9cd6c3dd48 /src | |
parent | 0c644d5b1c8a744252642e9950156c5ca81a597e (diff) |
ActivityPub contexts already have type, no need to duplicate
Diffstat (limited to 'src')
3 files changed, 10 insertions, 9 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 687848cc..d617f99b 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 @@ -60,10 +60,6 @@ public abstract class Context { this.id = id; } - public String getType() { - return getClass().getSimpleName(); - } - @JsonProperty("@context") @JsonFormat(with = JsonFormat.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY) public List<Object> getContext() { diff --git a/src/main/java/com/juick/server/api/activity/model/objects/Person.java b/src/main/java/com/juick/server/api/activity/model/objects/Person.java index 2d3a45d7..a6fd9a76 100644 --- a/src/main/java/com/juick/server/api/activity/model/objects/Person.java +++ b/src/main/java/com/juick/server/api/activity/model/objects/Person.java @@ -14,11 +14,6 @@ public class Person extends Context { private String followers; private Key publicKey; - @Override - public String getType() { - return "Person"; - } - public String getName() { return name; } diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index de742447..53fbbf1d 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -37,6 +37,7 @@ import com.juick.server.*; import com.juick.server.api.activity.Profile; import com.juick.server.api.activity.model.Context; import com.juick.server.api.activity.model.activities.*; +import com.juick.server.api.activity.model.objects.Mention; import com.juick.server.api.activity.model.objects.Note; import com.juick.server.api.activity.model.objects.Person; import com.juick.server.api.webfinger.model.Account; @@ -2153,4 +2154,13 @@ public class ServerTests { .orElseThrow(); assertThat(htmlPM, is(getSnapshot(testPrivateHtmlEmail))); } + @Test + public void mentionShouldNotDuplicateType() throws Exception { + Mention mention = new Mention("http://localhost/u/ugnich", "ugnich"); + String mentionStr = jsonMapper.writeValueAsString(mention); + Context mentionFromString = jsonMapper.readValue(mentionStr, Context.class); + assertThat(mention, is(samePropertyValuesAs(mentionFromString))); + JsonNode mentionNode = jsonMapper.readTree(mentionStr); + assertThat(mentionNode.findValues("type").size(), is(1)); + } } |