feat: Added an endpoint that list all messages of a chatroom
authorKai Moritz <kai@juplo.de>
Sat, 7 Jan 2023 23:47:22 +0000 (00:47 +0100)
committerKai Moritz <kai@juplo.de>
Sun, 15 Jan 2023 18:35:59 +0000 (19:35 +0100)
src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java

index 4ce98b2..12f8d67 100644 (file)
@@ -38,6 +38,17 @@ public class ChatBackendController
     return chatHome.list().map(chatroom -> ChatroomTo.from(chatroom));
   }
 
+  @GetMapping("list/{chatroomId}")
+  public Flux<MessageTo> list(@PathVariable UUID chatroomId)
+  {
+    return chatHome
+        .getChatroom(chatroomId)
+        .map(chatroom -> chatroom
+            .getMessages()
+            .map(MessageTo::from))
+        .get();
+  }
+
   @GetMapping("get/{chatroomId}")
   public Optional<ChatroomTo> get(@PathVariable UUID chatroomId)
   {