aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/www/controllers/Compat.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-14 15:42:03 +0300
committerGravatar Vitaly Takmazov2023-01-14 15:42:03 +0300
commit23a41aebadbe13e8992856c6be84ce6d01de0175 (patch)
tree28ccc1446a8d4c1b9141454ea74703e65a9bff22 /src/main/java/com/juick/www/controllers/Compat.java
parent834fef2a7794d769144c7c087a8b1fa0a2a9bb21 (diff)
Configure test coverage reports
Diffstat (limited to 'src/main/java/com/juick/www/controllers/Compat.java')
-rw-r--r--src/main/java/com/juick/www/controllers/Compat.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/main/java/com/juick/www/controllers/Compat.java b/src/main/java/com/juick/www/controllers/Compat.java
index 4a7390f5..edd7bc29 100644
--- a/src/main/java/com/juick/www/controllers/Compat.java
+++ b/src/main/java/com/juick/www/controllers/Compat.java
@@ -21,8 +21,10 @@ import com.juick.service.ActivityPubService;
import com.juick.service.WebfingerService;
import com.juick.util.HttpNotFoundException;
import com.juick.www.api.activity.model.Context;
+import jakarta.validation.constraints.NotEmpty;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
+import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@@ -31,6 +33,7 @@ import org.springframework.web.servlet.view.RedirectView;
import javax.inject.Inject;
@Controller
+@Validated
public class Compat {
@Inject
private WebfingerService webfingerService;
@@ -42,12 +45,9 @@ public class Compat {
return new RedirectView("/post");
}
@GetMapping("/mention")
- public RedirectView mention(@RequestParam String username) {
+ public RedirectView mention(@RequestParam @NotEmpty(message = "Username may not be empty") String username) {
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();
+ var context = activityPubService.get(uri).orElseThrow(HttpNotFoundException::new);
+ return new RedirectView(context.getUrl());
}
}