refactor: Renamed `ChatRoom` into `ChatRoomData` - Aligned Code
authorKai Moritz <kai@juplo.de>
Mon, 4 Sep 2023 20:17:47 +0000 (22:17 +0200)
committerKai Moritz <kai@juplo.de>
Mon, 4 Sep 2023 20:17:47 +0000 (22:17 +0200)
src/main/java/de/juplo/kafka/chat/backend/api/ChatBackendController.java

index ac77deb..c39869c 100644 (file)
@@ -131,7 +131,14 @@ public class ChatBackendController
   @PostMapping("/store")
   public void store()
   {
-    storageStrategy.writeChatRoomInfo(chatHome.getChatRoomInfo());
-    storageStrategy.writeChatRoomData(chatHome.getChatRoomData());
+    storageStrategy.writeChatRoomInfo(
+        chatHome
+            .getChatRoomInfo()
+            .doOnNext(chatRoomInfo ->
+                storageStrategy.writeChatRoomData(
+                    chatRoomInfo.getId(),
+                    chatHome
+                        .getChatRoomData(chatRoomInfo.getId())
+                        .flatMapMany(chatRoomData -> chatRoomData.getMessages()))));
   }
 }