aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/controllers/Compat.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/juick/www/controllers/Compat.java')
-rw-r--r--src/main/java/com/juick/www/controllers/Compat.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main/java/com/juick/www/controllers/Compat.java b/src/main/java/com/juick/www/controllers/Compat.java
index 936a8e5c..300a0855 100644
--- a/src/main/java/com/juick/www/controllers/Compat.java
+++ b/src/main/java/com/juick/www/controllers/Compat.java
@@ -17,8 +17,11 @@
package com.juick.www.controllers;
-import com.juick.SignatureManager;
+import com.juick.service.ActivityPubService;
+import com.juick.service.WebfingerService;
import com.juick.util.HttpNotFoundException;
+import com.juick.www.api.activity.model.Context;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -30,7 +33,9 @@ import javax.inject.Inject;
@Controller
public class Compat {
@Inject
- private SignatureManager signatureManager;
+ private WebfingerService webfingerService;
+ @Inject
+ private ActivityPubService activityPubService;
@GetMapping("/share")
public RedirectView share(@RequestParam String text, RedirectAttributes attributes) {
attributes.addAttribute("body", text);
@@ -38,9 +43,10 @@ public class Compat {
}
@GetMapping("/mention")
public RedirectView mention(@RequestParam String username) {
- var profile = signatureManager.discoverPerson(username);
- if (profile.isPresent()) {
- return new RedirectView(profile.get().getUrl());
+ var uri = webfingerService.discoverAccountURI(username, MediaType.valueOf(Context.ACTIVITY_MEDIA_TYPE));
+ if (!uri.toASCIIString().isEmpty()) {
+ var context = activityPubService.get(uri).orElseThrow(HttpNotFoundException::new);
+ return new RedirectView(context.getUrl());
}
throw new HttpNotFoundException();
}