~jan0sch/smederee

Showing details for patch 398bce8aff0eee9b73e93d612a3d01eb8bf7d6c0.
2023-05-16 (Tue), 1:23 PM - Jens Grassel - 398bce8aff0eee9b73e93d612a3d01eb8bf7d6c0

Tickets: Add route to show a ticket for guests.

Summary of changes
1 files modified with 12 lines added and 2 lines removed
  • modules/hub/src/main/scala/de/smederee/tickets/TicketRoutes.scala with 12 added and 2 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/tickets/TicketRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/tickets/TicketRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/tickets/TicketRoutes.scala	2025-01-16 13:03:34.822033465 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/tickets/TicketRoutes.scala	2025-01-16 13:03:34.822033465 +0000
@@ -126,7 +126,7 @@
       projectAndId <- loadProject(user)(projectOwnerName, projectName)
       ticket       <- projectAndId.traverse(tuple => ticketRepo.findTicket(tuple._2)(ticketNumber))
       resp <- (projectAndId, ticket.getOrElse(None)) match {
-        case (Some((project, projectId)), Some(ticket)) =>
+        case (Some((project, _)), Some(ticket)) =>
           for {
             projectBaseUri <- Sync[F].delay(
               linkConfig.createFullUri(
@@ -329,6 +329,16 @@
       } yield resp
   }
 
+  private val showTicketPageForGuests: HttpRoutes[F] = HttpRoutes.of {
+    case req @ GET -> Root / UsernamePathParameter(projectOwnerName) / ProjectNamePathParameter(
+          projectName
+        ) / "tickets" / TicketNumberPathParameter(ticketNumber) =>
+      for {
+        csrf <- Sync[F].delay(req.getCsrfToken)
+        resp <- doShowTicket(csrf)(None)(projectOwnerName)(projectName)(ticketNumber)
+      } yield resp
+  }
+
   private val showTicketsPage: AuthedRoutes[Account, F] = AuthedRoutes.of {
     case ar @ GET -> Root / UsernamePathParameter(projectOwnerName) / ProjectNamePathParameter(
           projectName
@@ -351,6 +361,6 @@
 
   val protectedRoutes = addTicket <+> showCreateTicketPage <+> showTicketPage <+> showTicketsPage
 
-  val routes = showTicketsForGuests
+  val routes = showTicketPageForGuests <+> showTicketsForGuests
 
 }