From f8406131fdbe835c52fd46ad68ddc7b0df54cffe Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 22 Dec 2022 05:43:40 +0300 Subject: `@username@example.com` urls are now redirects to ActivityPub profile --- src/main/java/com/juick/www/controllers/Compat.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main/java/com/juick/www') diff --git a/src/main/java/com/juick/www/controllers/Compat.java b/src/main/java/com/juick/www/controllers/Compat.java index ebf584dc..936a8e5c 100644 --- a/src/main/java/com/juick/www/controllers/Compat.java +++ b/src/main/java/com/juick/www/controllers/Compat.java @@ -17,17 +17,31 @@ package com.juick.www.controllers; +import com.juick.SignatureManager; +import com.juick.util.HttpNotFoundException; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.mvc.support.RedirectAttributes; import org.springframework.web.servlet.view.RedirectView; +import javax.inject.Inject; + @Controller public class Compat { + @Inject + private SignatureManager signatureManager; @GetMapping("/share") public RedirectView share(@RequestParam String text, RedirectAttributes attributes) { attributes.addAttribute("body", text); return new RedirectView("/post"); } + @GetMapping("/mention") + public RedirectView mention(@RequestParam String username) { + var profile = signatureManager.discoverPerson(username); + if (profile.isPresent()) { + return new RedirectView(profile.get().getUrl()); + } + throw new HttpNotFoundException(); + } } -- cgit v1.2.3