Class MessageController
java.lang.Object
fr.utc.miage.sporttrack.controller.MessageController
Spring MVC controller for private messaging between friends.
Provides endpoints for the messaging inbox and sending messages to friends.
- Author:
- SportTrack Team
-
Constructor Summary
ConstructorsConstructorDescriptionMessageController(MessageService messageService, FriendshipService friendshipService, AthleteRepository athleteRepository) Constructs aMessageControllerwith the required dependencies. -
Method Summary
Modifier and TypeMethodDescriptioninbox(Integer friendId, jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Displays the messaging inbox with a conversation view for the selected friend.sendMessage(Integer recipientId, String content, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Sends a message to a friend.
-
Constructor Details
-
MessageController
public MessageController(MessageService messageService, FriendshipService friendshipService, AthleteRepository athleteRepository) Constructs aMessageControllerwith the required dependencies.- Parameters:
messageService- the message servicefriendshipService- the friendship serviceathleteRepository- the athlete repository
-
-
Method Details
-
inbox
@GetMapping public String inbox(@RequestParam(name="friendId",required=false) Integer friendId, jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Displays the messaging inbox with a conversation view for the selected friend.- Parameters:
friendId- the optional identifier of the friend whose conversation to displaysession- the HTTP session for athlete resolutionmodel- the Spring MVC modelredirectAttributes- flash attributes for error messaging- Returns:
- the view name "athlete/friend/messages", or a redirect to login
-
sendMessage
@PostMapping("/send") public String sendMessage(@RequestParam("recipientId") Integer recipientId, @RequestParam("content") String content, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) Sends a message to a friend.- Parameters:
recipientId- the identifier of the message recipientcontent- the message contentsession- the HTTP session for athlete resolutionredirectAttributes- flash attributes for error messaging- Returns:
- a redirect to the conversation with the recipient
-