From 0a67254245046236f82733c95e84a23ffcfdc45c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 5 Oct 2018 11:22:33 +0300 Subject: ActivityPub: change Note uri --- .../src/main/java/com/juick/server/ActivityPubManager.java | 4 ++-- .../src/main/java/com/juick/server/api/activity/Profile.java | 7 ++++--- .../com/juick/server/configuration/WwwAppConfiguration.java | 1 - .../src/test/java/com/juick/server/tests/ServerTests.java | 11 ----------- 4 files changed, 6 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 f08754c6..cc63a4ce 100644 --- a/juick-server/src/main/java/com/juick/server/ActivityPubManager.java +++ b/juick-server/src/main/java/com/juick/server/ActivityPubManager.java @@ -161,7 +161,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene } public String messageUri(Message msg) { UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); - uri.replacePath(String.format("/m/%d", msg.getMid())); + uri.replacePath(String.format("/n/%d", msg.getMid())); if (MessageUtils.isReply(msg)) { uri.fragment(String.valueOf(msg.getRid())); } @@ -169,7 +169,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene } public String messageUri(int mid, int rid) { UriComponentsBuilder uri = UriComponentsBuilder.fromUriString(baseUri); - uri.replacePath(String.format("/m/%d", mid)); + uri.replacePath(String.format("/n/%d", mid)); if (rid > 0) { uri.fragment(String.valueOf(rid)); } diff --git a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java index a21601db..160270f4 100644 --- a/juick-server/src/main/java/com/juick/server/api/activity/Profile.java +++ b/juick-server/src/main/java/com/juick/server/api/activity/Profile.java @@ -2,6 +2,7 @@ package com.juick.server.api.activity; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.juick.Message; import com.juick.User; import com.juick.server.ActivityPubManager; import com.juick.server.KeystoreManager; @@ -227,12 +228,12 @@ public class Profile { } throw new HttpNotFoundException(); } - /* - @GetMapping(value = "/m/{mid}", produces = {Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_JSON_MEDIA_TYPE}) + + @GetMapping(value = "/n/{mid}", produces = {Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_JSON_MEDIA_TYPE}) public Context showNote(@PathVariable int mid) { Message message = messagesService.getMessage(mid); return Context.build(activityPubManager.makeNote(message)); - }*/ + } @PostMapping(value = "/api/inbox", consumes = {Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_JSON_MEDIA_TYPE}) public ResponseEntity processInbox(@RequestBody Activity activity, diff --git a/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java index e4612a84..72889f96 100644 --- a/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java +++ b/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java @@ -117,5 +117,4 @@ public class WwwAppConfiguration implements WebMvcConfigurer { viewResolver.setCharacterEncoding(CharEncoding.UTF_8); return viewResolver; } - } diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index 92fc0678..38845cd7 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -1706,15 +1706,4 @@ public class ServerTests { .andExpect(status().isOk()).andReturn(); String xrd = result.getResponse().getContentAsString(); } - @Test - public void contentNegotiationTest() throws Exception { - int mid = messagesService.createMessage(ugnich.getUid(),"TXT", null, Collections.emptyList()); - mockMvc.perform(get("/m/" + mid) - .header("Accept", "text/html")).andExpect(status().is3xxRedirection()); - mockMvc.perform(get("/m/" + mid) - .header("Accept", "application/activity+json")).andExpect(status().isOk()); - mockMvc.perform(get("/m/" + mid) - .header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")) - .andExpect(status().is3xxRedirection()); - } } -- cgit v1.2.3