aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2019-04-09 19:10:43 +0300
committerGravatar Vitaly Takmazov2019-04-09 19:10:43 +0300
commit81bb301742ddafdc58b63ab6d32f70b46097c789 (patch)
tree6581d25487a9081bb4a3a40bc3593299d23606aa /src/main/java/com
parent6cc6261a10f6e8fbf39185342474b88342744580 (diff)
Use preconfigured ObjectMapper for ActivityPub client
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java b/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
index d7d49355..65bfeade 100644
--- a/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
+++ b/src/main/java/com/juick/server/configuration/ActivityPubClientConfig.java
@@ -1,9 +1,11 @@
package com.juick.server.configuration;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.juick.server.api.activity.model.Activity;
import com.juick.server.helpers.HeaderRequestInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import javax.inject.Inject;
@@ -13,9 +15,18 @@ import java.util.Collections;
public class ActivityPubClientConfig {
@Inject
ActivityPubClientErrorHandler activityPubClientErrorHandler;
+ @Inject
+ ObjectMapper jsonMapper;
+ @Bean
+ public MappingJackson2HttpMessageConverter mappingJacksonHttpMessageConverter() {
+ MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
+ converter.setObjectMapper(jsonMapper);
+ return converter;
+ }
@Bean
public RestTemplate apClient() {
RestTemplate restTemplate = new RestTemplate();
+ restTemplate.getMessageConverters().add(0, mappingJacksonHttpMessageConverter());
restTemplate.setErrorHandler(activityPubClientErrorHandler);
restTemplate.setInterceptors(Collections.singletonList(
new HeaderRequestInterceptor("Accept", Activity.ACTIVITY_MEDIA_TYPE)));