Skip to content

Commit

Permalink
ChatController.sendMessage fix for review
Browse files Browse the repository at this point in the history
  • Loading branch information
Lev committed Sep 25, 2024
1 parent 1e31ec0 commit ab870c8
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ public class ChatController {
private final MessageService messageService;

@MessageMapping("/app/topic/public/{topicId}")
public void sendMessage(@DestinationVariable UUID topicId, MessageRequestDto message) {
public MessageResponseDto sendMessage(@DestinationVariable UUID topicId, MessageRequestDto message) {

log.info("Received message for topic ID: {}", topicId);

messageService.sendToTopic(topicId, message);
MessageResponseDto sendMessage = messageService.sendToTopic(topicId, message);
log.info("Message was saved in DB");

messagingTemplate.convertAndSend("/topic/public/" + topicId, message);
log.info("Message sent to topic ID: {}", topicId) ;

return sendMessage;
}
}

0 comments on commit ab870c8

Please sign in to comment.