aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-01-30 10:19:00 +0300
committerGravatar Vitaly Takmazov2019-01-30 10:19:00 +0300
commitba5d3815a7f40c2d824bd329dad571f8b883b25e (patch)
treef22ce2df82e81a6b9f3c548ddf7ceba675de44f6 /src/main/java/com
parent50907d3e35ac194ae17f201d8ed3c425f86b87ac (diff)
ActivityPub: log inbox data
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/server/api/activity/Profile.java8
1 files changed, 7 insertions, 1 deletions
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 3e0179c8..84a3de33 100644
--- a/src/main/java/com/juick/server/api/activity/Profile.java
+++ b/src/main/java/com/juick/server/api/activity/Profile.java
@@ -30,6 +30,7 @@ import com.juick.service.MessagesService;
import com.juick.service.UserService;
import com.juick.service.activities.*;
import com.overzealous.remark.Remark;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +52,9 @@ import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import javax.inject.Inject;
+import java.io.InputStream;
import java.net.URI;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -256,7 +259,10 @@ public class Profile {
}
@PostMapping(value = "/api/inbox", consumes = {Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE})
- public ResponseEntity<Void> processInbox(@RequestBody Activity activity) throws Exception {
+ public ResponseEntity<Void> processInbox(InputStream inboxData) throws Exception {
+ String inbox = IOUtils.toString(inboxData, StandardCharsets.UTF_8);
+ logger.debug("Inbox: {}", inbox);
+ Activity activity = jsonMapper.readValue(inbox, Activity.class);
User visitor = UserUtils.getCurrentUser();
if ((StringUtils.isNotEmpty(visitor.getUri().toString()) && visitor.getUri().equals(URI.create(activity.getActor()))) || !visitor.isAnonymous()) {
if (activity instanceof Follow) {