From 9f7150aa4419380bdc75d7c0edaa2c6ff7d86ba9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 4 Oct 2018 22:48:13 +0300 Subject: ActivityPub: log unknown activities --- .../src/main/java/com/juick/server/api/activity/Profile.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'juick-server/src/main/java/com/juick') 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 115ca89a..146e78f0 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 @@ -1,6 +1,7 @@ package com.juick.server.api.activity; -import com.juick.Message; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.juick.User; import com.juick.server.ActivityPubManager; import com.juick.server.KeystoreManager; @@ -17,6 +18,8 @@ import com.juick.service.UserService; import com.juick.service.activities.DeleteUserEvent; import com.juick.service.activities.FollowEvent; import com.juick.service.activities.UndoFollowEvent; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; import org.springframework.http.HttpStatus; @@ -36,6 +39,7 @@ import java.util.stream.Stream; @RestController public class Profile { + private static final Logger logger = LoggerFactory.getLogger(Profile.class); @Inject private UserService userService; @Inject @@ -54,6 +58,8 @@ public class Profile { private String baseUri; @Value("${img_url:http://localhost:8080/i/}") private String baseImagesUri; + @Inject + private ObjectMapper jsonMapper; @GetMapping(value = "/u/{userName}", produces = {Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_JSON_MEDIA_TYPE}) public Person getUser(@PathVariable String userName) { @@ -236,7 +242,7 @@ public class Profile { @RequestHeader(name = "Content-Type") String contentType, @RequestHeader(name = "User-Agent", required = false) String userAgent, @RequestHeader(name = "Accept-Encoding", required = false) String acceptEncoding, - @RequestHeader(name = "Signature", required = false) String signature) { + @RequestHeader(name = "Signature", required = false) String signature) throws JsonProcessingException { UriComponents componentsBuilder = ServletUriComponentsBuilder.fromCurrentRequestUri().build(); Map headers = new HashMap<>(); headers.put("host", host); @@ -265,6 +271,7 @@ public class Profile { applicationEventPublisher.publishEvent(new DeleteUserEvent(this, (String)activity.getObject())); } } + logger.warn("Unknown activity: {}", jsonMapper.writeValueAsString(activity)); return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); } return new ResponseEntity<>(HttpStatus.UNAUTHORIZED); -- cgit v1.2.3