From 36ebeb217326c6bc23dedfde1e028ae2286afe02 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 24 Dec 2022 03:28:02 +0300 Subject: Cacheable ActivityPub profiles --- src/main/java/com/juick/www/api/activity/Profile.java | 3 +++ src/main/java/com/juick/www/api/activity/model/Context.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/juick/www/api') 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 506f5ace..404e0734 100644 --- a/src/main/java/com/juick/www/api/activity/Profile.java +++ b/src/main/java/com/juick/www/api/activity/Profile.java @@ -55,9 +55,11 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.context.ApplicationEventPublisher; import org.springframework.core.convert.ConversionService; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -268,6 +270,7 @@ public class Profile { throw new HttpNotFoundException(); } + @CacheEvict(cacheNames = "profiles", key = "{ #visitor.uri }") @PostMapping(value = "/api/inbox", consumes = { Context.LD_JSON_MEDIA_TYPE, Context.ACTIVITYSTREAMS_PROFILE_MEDIA_TYPE }) public ResponseEntity processInbox(@Visitor User visitor, InputStream inboxData) throws Exception { diff --git a/src/main/java/com/juick/www/api/activity/model/Context.java b/src/main/java/com/juick/www/api/activity/model/Context.java index 63f991cc..1eb057a6 100644 --- a/src/main/java/com/juick/www/api/activity/model/Context.java +++ b/src/main/java/com/juick/www/api/activity/model/Context.java @@ -24,6 +24,7 @@ import com.juick.www.api.activity.helpers.LinkValueDeserializer; import com.juick.www.api.activity.model.activities.*; import com.juick.www.api.activity.model.objects.*; +import java.io.Serializable; import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; @@ -59,7 +60,7 @@ import java.util.Map; @JsonSubTypes.Type(value = Group.class, name = "Group"), @JsonSubTypes.Type(value = Organization.class, name = "Organization") }) -public class Context { +public class Context implements Serializable { private List context; private String id; -- cgit v1.2.3