Skip to content

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentTreguier committed Nov 18, 2024
2 parents 2e7d829 + 08e38c6 commit 3785fc6
Show file tree
Hide file tree
Showing 14 changed files with 220 additions and 59 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
org.gradle.jvmargs=-Xmx1024M
quarkusPlatformVersion=3.16.1
quarkusPluginVersion=3.16.1
sentryVersion=7.16.0
quarkusPlatformVersion=3.16.3
quarkusPluginVersion=3.16.3
sentryVersion=7.17.0
javaXtVersion=2.1.9
twelveMonkeysVersion=3.12.0
spotlessPluginVersion=6.25.0
lombokPluginVersion=8.10.2
lombokPluginVersion=8.11
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
36 changes: 32 additions & 4 deletions src/main/java/app/fyreplace/api/endpoints/ChaptersEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import app.fyreplace.api.services.ImageService;
import app.fyreplace.api.services.SanitizationService;
import io.quarkus.cache.CacheResult;
import io.quarkus.hibernate.validator.runtime.jaxrs.ViolationReport;
import io.quarkus.panache.common.Sort;
import io.quarkus.security.Authenticated;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.ws.rs.DELETE;
Expand Down Expand Up @@ -93,7 +95,13 @@ public Response createChapter(@PathParam("id") final UUID id) {
@Authenticated
@Transactional
@APIResponse(responseCode = "204", description = "No Content")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
@CacheResult(cacheName = "requests", keyGenerator = DuplicateRequestKeyGenerator.class)
public Response deleteChapter(
Expand All @@ -111,7 +119,13 @@ public Response deleteChapter(
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
public Response setChapterPosition(
@PathParam("id") final UUID id,
Expand Down Expand Up @@ -145,12 +159,19 @@ public Response setChapterPosition(
@Authenticated
@Transactional
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
public String setChapterText(
@PathParam("id") final UUID id,
@PathParam("position") @PositiveOrZero final int position,
@NotNull @Length(max = Chapter.TEXT_MAX_LENGTH) @Schema(maxLength = Chapter.TEXT_MAX_LENGTH) String input) {
@NotNull @Length(max = Chapter.TEXT_MAX_LENGTH) @Schema(maxLength = Chapter.TEXT_MAX_LENGTH) @Valid
String input) {
final var user = User.getFromSecurityContext(context);
final var post = Post.<Post>findById(id);
Post.validateAccess(post, user, false, true);
Expand All @@ -171,6 +192,13 @@ public String setChapterText(
@Transactional
@RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM))
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
@APIResponse(responseCode = "413", description = "Payload Too Large")
@APIResponse(responseCode = "415", description = "Unsupported Media Type")
Expand Down
42 changes: 36 additions & 6 deletions src/main/java/app/fyreplace/api/endpoints/CommentsEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import app.fyreplace.api.exceptions.ExplainedFailure;
import app.fyreplace.api.exceptions.ForbiddenException;
import io.quarkus.cache.CacheResult;
import io.quarkus.hibernate.validator.runtime.jaxrs.ViolationReport;
import io.quarkus.security.Authenticated;
import jakarta.annotation.Nullable;
import jakarta.transaction.Transactional;
Expand Down Expand Up @@ -48,7 +49,13 @@ public final class CommentsEndpoint {
@GET
@Authenticated
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
public Iterable<Comment> listComments(
@PathParam("id") final UUID id, @QueryParam("page") @PositiveOrZero final int page) {
Expand All @@ -71,7 +78,13 @@ public Iterable<Comment> listComments(
description = "Created",
content =
@Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Comment.class)))
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(
responseCode = "403",
description = "Not Allowed",
Expand Down Expand Up @@ -105,7 +118,13 @@ public Response createComment(@PathParam("id") final UUID id, @NotNull @Valid fi
@Authenticated
@Transactional
@APIResponse(responseCode = "204", description = "No Content")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(
responseCode = "403",
description = "Not Allowed",
Expand Down Expand Up @@ -136,7 +155,13 @@ public Response deleteComment(
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(
responseCode = "403",
description = "Not Allowed",
Expand Down Expand Up @@ -172,7 +197,13 @@ public Response setCommentReported(
@Authenticated
@Transactional
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
public Response acknowledgeComment(
@PathParam("id") final UUID id, @PathParam("position") @PositiveOrZero final int position) {
Expand Down Expand Up @@ -200,7 +231,6 @@ public Response acknowledgeComment(
@Authenticated
@Produces(MediaType.APPLICATION_JSON)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(responseCode = "404", description = "Not Found")
public long countComments(@PathParam("id") final UUID id, @QueryParam("read") @Nullable final Boolean read) {
final var user = User.getFromSecurityContext(context);
Expand Down
23 changes: 22 additions & 1 deletion src/main/java/app/fyreplace/api/endpoints/EmailsEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import app.fyreplace.api.exceptions.ForbiddenException;
import io.quarkus.cache.CacheResult;
import io.quarkus.elytron.security.common.BcryptUtil;
import io.quarkus.hibernate.validator.runtime.jaxrs.ViolationReport;
import io.quarkus.panache.common.Sort;
import io.quarkus.security.Authenticated;
import jakarta.inject.Inject;
Expand Down Expand Up @@ -54,6 +55,13 @@ public final class EmailsEndpoint {
@GET
@Authenticated
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
public Iterable<Email> listEmails(@QueryParam("page") @PositiveOrZero final int page) {
final var user = User.getFromSecurityContext(context);
return Email.find("user", Sort.by("email"), user).page(page, pagingSize).list();
Expand All @@ -67,6 +75,13 @@ public Iterable<Email> listEmails(@QueryParam("page") @PositiveOrZero final int
responseCode = "201",
description = "Created",
content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = Email.class)))
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(
responseCode = "409",
description = "Conflict",
Expand Down Expand Up @@ -160,7 +175,13 @@ public long countEmails() {
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
@CacheResult(cacheName = "requests", keyGenerator = DuplicateRequestKeyGenerator.class)
public Response activateEmail(@NotNull @Valid final EmailActivation input) {
Expand Down
48 changes: 43 additions & 5 deletions src/main/java/app/fyreplace/api/endpoints/PostsEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import app.fyreplace.api.exceptions.ExplainedFailure;
import app.fyreplace.api.exceptions.ForbiddenException;
import io.quarkus.cache.CacheResult;
import io.quarkus.hibernate.validator.runtime.jaxrs.ViolationReport;
import io.quarkus.panache.common.Sort;
import io.quarkus.panache.common.Sort.Direction;
import io.quarkus.security.Authenticated;
Expand Down Expand Up @@ -58,7 +59,13 @@ public final class PostsEndpoint {
@GET
@Authenticated
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
public Iterable<Post> listPosts(
@QueryParam("page") @PositiveOrZero final int page,
@QueryParam("ascending") final boolean ascending,
Expand Down Expand Up @@ -134,7 +141,13 @@ public Response deletePost(@PathParam("id") final UUID id) {
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
public Response setPostSubscribed(@PathParam("id") final UUID id, @NotNull @Valid final SubscriptionUpdate input) {
final var user = User.getFromSecurityContext(context);
Expand All @@ -156,6 +169,13 @@ public Response setPostSubscribed(@PathParam("id") final UUID id, @NotNull @Vali
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(responseCode = "404", description = "Not Found")
public Response setPostReported(@PathParam("id") final UUID id, @NotNull @Valid final ReportUpdate input) {
final var user = User.getFromSecurityContext(context);
Expand All @@ -177,7 +197,13 @@ public Response setPostReported(@PathParam("id") final UUID id, @NotNull @Valid
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(
responseCode = "403",
description = "Not Allowed",
Expand Down Expand Up @@ -206,7 +232,13 @@ public Response publishPost(@PathParam("id") final UUID id, @NotNull @Valid fina
@Transactional
@RequestBody(required = true)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
@APIResponse(
responseCode = "403",
description = "Not Allowed",
Expand Down Expand Up @@ -242,7 +274,13 @@ public Response votePost(@PathParam("id") final UUID id, @NotNull @Valid final V
@Authenticated
@Produces(MediaType.APPLICATION_JSON)
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
public long countPosts(@QueryParam("type") @NotNull final PostListingType type) {
final var user = User.getFromSecurityContext(context);
return switch (type) {
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/app/fyreplace/api/endpoints/ReportsEndpoint.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package app.fyreplace.api.endpoints;

import app.fyreplace.api.data.Report;
import io.quarkus.hibernate.validator.runtime.jaxrs.ViolationReport;
import jakarta.annotation.security.RolesAllowed;
import jakarta.validation.constraints.PositiveOrZero;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;

@Path("reports")
Expand All @@ -17,7 +21,13 @@ public final class ReportsEndpoint {
@GET
@RolesAllowed("MODERATOR")
@APIResponse(responseCode = "200", description = "OK")
@APIResponse(responseCode = "400", description = "Bad Request")
@APIResponse(
responseCode = "400",
description = "Bad Request",
content =
@Content(
mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = ViolationReport.class)))
public Iterable<Report> listReports(@QueryParam("page") @PositiveOrZero final int page) {
return Report.findAll(Report.sorting()).page(page, pagingSize).list();
}
Expand Down
Loading

0 comments on commit 3785fc6

Please sign in to comment.