From 929db81f1fea5059f9661ba5fad3708c7d6b85e9 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 16 Feb 2023 01:35:48 +0300 Subject: ActivityPub: improve logging --- src/main/java/com/juick/config/HttpClientConfig.java | 2 +- src/main/java/com/juick/www/api/activity/Profile.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/java/com/juick/config/HttpClientConfig.java b/src/main/java/com/juick/config/HttpClientConfig.java index 18b56293..457a63c8 100644 --- a/src/main/java/com/juick/config/HttpClientConfig.java +++ b/src/main/java/com/juick/config/HttpClientConfig.java @@ -37,7 +37,7 @@ public class HttpClientConfig { public OkHttpClient httpClient() { return new OkHttpClient.Builder() .addInterceptor(new HttpLoggingInterceptor(logger::debug) - .setLevel(HttpLoggingInterceptor.Level.HEADERS)) + .setLevel(HttpLoggingInterceptor.Level.BASIC)) .addInterceptor(new ActivityPubRequestInterceptor()) .addInterceptor(new ActivityPubClientErrorHandler(applicationEventPublisher)) .build(); diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java index 580ed340..f37ef6ff 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -279,8 +279,11 @@ public class Profile { @CacheEvict(cacheNames = "profiles", key = "{ #visitor.uri }") @PostMapping(value = "/api/inbox", consumes = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITY_MEDIA_TYPE, Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE, MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity processInbox(@Parameter(hidden = true) User visitor, @RequestBody Context context) + public ResponseEntity processInbox(@Parameter(hidden = true) User visitor, InputStream body) throws Exception { + var inboxBody = IOUtils.toString(body, StandardCharsets.UTF_8); + logger.debug("Inbox: {}", inboxBody); + var context = jsonMapper.readValue(inboxBody, Context.class); if (context instanceof Activity activity) { if ((StringUtils.isNotEmpty(visitor.getUri().toString()) && visitor.getUri().equals(URI.create(activity.getActor()))) || !visitor.isAnonymous()) { -- cgit v1.2.3