aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/juick/SignatureManager.java2
-rw-r--r--src/main/java/com/juick/config/SecurityConfig.java2
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java3
-rw-r--r--src/main/java/com/juick/www/api/activity/model/Context.java3
4 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/com/juick/SignatureManager.java b/src/main/java/com/juick/SignatureManager.java
index 295909cc3..8032a6fac 100644
--- a/src/main/java/com/juick/SignatureManager.java
+++ b/src/main/java/com/juick/SignatureManager.java
@@ -30,6 +30,7 @@ import com.juick.www.api.webfinger.model.Link;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
@@ -160,6 +161,7 @@ public class SignatureManager {
return AnonymousUser.INSTANCE;
}
+ @Cacheable("profiles")
public Optional<Context> getContext(URI contextUri) {
try {
Context context = apClient.getForEntity(contextUri, Context.class).getBody();
diff --git a/src/main/java/com/juick/config/SecurityConfig.java b/src/main/java/com/juick/config/SecurityConfig.java
index 869a6d06b..ad189052e 100644
--- a/src/main/java/com/juick/config/SecurityConfig.java
+++ b/src/main/java/com/juick/config/SecurityConfig.java
@@ -133,7 +133,7 @@ public class SecurityConfig {
"/api/skypebotendpoint", "/api/_fblogin",
"/api/_vklogin", "/api/_tglogin",
"/api/_google", "/api/_applelogin", "/api/signup",
- "/api/inbox", "/api/events",
+ "/api/inbox", "/api/events", "/api/u/",
"/api/info/**",
"/api/nodeinfo/2.0")
.permitAll()
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 506f5acef..404e07347 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<CommandResult> 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 63f991cc8..1eb057a62 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<Object> context;
private String id;