From 8f5441d43dcb9a7851ec3c79f1714eb47aa25a6f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 28 May 2019 19:57:18 +0300 Subject: PROTOCOL CHANGES in mastodon 2.8(?) --- src/main/java/com/juick/server/api/activity/Profile.java | 7 +++++++ src/test/java/com/juick/server/tests/ServerTests.java | 2 ++ src/test/resources/delete_v3.json | 1 + 3 files changed, 10 insertions(+) create mode 100644 src/test/resources/delete_v3.json diff --git a/src/main/java/com/juick/server/api/activity/Profile.java b/src/main/java/com/juick/server/api/activity/Profile.java index a7ba65a5..7ec3f228 100644 --- a/src/main/java/com/juick/server/api/activity/Profile.java +++ b/src/main/java/com/juick/server/api/activity/Profile.java @@ -353,6 +353,13 @@ public class Profile { } } if (activity instanceof Delete) { + if (activity.getObject() instanceof String) { + // Delete gone user + // TODO: check if it is really deleted and remove copy-paste + if (activity.getActor().equals(activity.getObject())) { + return new ResponseEntity<>(CommandResult.fromString("Delete request accepted"), HttpStatus.ACCEPTED); + } + } Map tombstone = (Map) activity.getObject(); if (tombstone.get("type").equals("Tombstone")) { URI actor = URI.create(activity.getActor()); diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index a140e9f0..5d13095b 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -1708,6 +1708,8 @@ public class ServerTests { 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"); + String deletev3JsonStr = IOUtils.toString(new ClassPathResource("delete_v3.json").getURI(), StandardCharsets.UTF_8); + Delete deleteObject = jsonMapper.readValue(deletev3JsonStr, Delete.class); } @Test public void activitySerialization() throws Exception { diff --git a/src/test/resources/delete_v3.json b/src/test/resources/delete_v3.json new file mode 100644 index 00000000..1dfb0dbf --- /dev/null +++ b/src/test/resources/delete_v3.json @@ -0,0 +1 @@ +{"@context":"https://www.w3.org/ns/activitystreams","id":"https://rspod.dns-cloud.net/users/kreastr#delete","type":"Delete","actor":"https://rspod.dns-cloud.net/users/kreastr","to":["https://www.w3.org/ns/activitystreams#Public"],"object":"https://rspod.dns-cloud.net/users/kreastr","signature":{"type":"RsaSignature2017","creator":"https://rspod.dns-cloud.net/users/kreastr#main-key","created":"2019-05-17T09:26:22Z","signatureValue":"RmavUUPR0xn2Mb3INUelMNGgn4bf103s29lAJyGp/Eg9NdDGc+QMwyxVaosJUeTazpt/VF46aKiVz0EsRxdBlPhaplyvrss6CZBQHwb7+tKnZNLx0qLZpL1M3dIIBNEHod8FU33ZP8uAVX2HoOs7/WS2T2Lh4nfBYZ9f53dcC3ZiKayuiKn3wVwuZepvnLRLfyF5FC/3AWkPw9MsFHMly2hwp/K6PHkFUilgjbir63d3M5HZYsTXbUVjqjvgSH2Wp+SscSDnNTHrERDLbuUYqEukS9xjTp32bq0Ok4mgM024++helxMYcWJujPhyJLI4vkbQYj5HEBmknXGCxw6tQg=="}} \ No newline at end of file -- cgit v1.2.3