Class MessageController

java.lang.Object
fr.utc.miage.sporttrack.controller.MessageController

@Controller @RequestMapping("/messages") public class MessageController extends Object
Spring MVC controller for private messaging between friends.

Provides endpoints for the messaging inbox and sending messages to friends.

Author:
SportTrack Team
  • Constructor Summary

    Constructors
    Constructor
    Description
    MessageController(MessageService messageService, FriendshipService friendshipService, AthleteRepository athleteRepository)
    Constructs a MessageController with the required dependencies.
  • Method Summary

    Modifier and Type
    Method
    Description
    inbox(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MessageController

      public MessageController(MessageService messageService, FriendshipService friendshipService, AthleteRepository athleteRepository)
      Constructs a MessageController with the required dependencies.
      Parameters:
      messageService - the message service
      friendshipService - the friendship service
      athleteRepository - 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 display
      session - the HTTP session for athlete resolution
      model - the Spring MVC model
      redirectAttributes - 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 recipient
      content - the message content
      session - the HTTP session for athlete resolution
      redirectAttributes - flash attributes for error messaging
      Returns:
      a redirect to the conversation with the recipient