From c980952cfbb7c14d36cdd1e4755615fd1eb3ff59 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 5 Jun 2022 12:31:20 +0200 Subject: KB66 PostResource#postComment: Return Uni. Change-Id: I58ea7a2abd24b2f45b80f401ad0506a698993a9b --- src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main/java/eu') diff --git a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java index 569c535..1870709 100644 --- a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java +++ b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java @@ -26,6 +26,7 @@ import io.quarkus.qute.CheckedTemplate; import io.quarkus.qute.TemplateExtension; import io.quarkus.qute.TemplateInstance; import io.quarkus.security.identity.SecurityIdentity; +import io.smallrye.mutiny.Uni; import java.math.BigInteger; import java.net.URI; import java.net.URLEncoder; @@ -47,7 +48,6 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; import javax.annotation.CheckForNull; @@ -309,7 +309,7 @@ public abstract class PostResource { @Produces(TEXT_PLAIN) @Path("{id}/comments") @Transactional - public Response postComment( + public Uni postComment( @PathParam("id") int postId, @FormParam("message") @NotEmpty String message, @FormParam("hashcash-salt") long hashcashSalt) @@ -358,9 +358,10 @@ public abstract class PostResource { .to(mailSenderAddress) .bcc(admins.stream().map(x -> x.email).toArray(String[]::new)) .send(); - sendJob.subscribe().asCompletionStage().get(10000, TimeUnit.SECONDS); - - return Response.seeOther(UriBuilder.fromUri("/posts/{id}").build(postId)).build(); + return sendJob + .onItem() + .transform( + unused -> Response.seeOther(UriBuilder.fromUri("/posts/{id}").build(postId)).build()); } private String makeFeed( -- cgit v1.2.3