Class FriendshipController

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

@Controller public class FriendshipController extends Object
Spring MVC controller for friendship-related pages and actions.

Manages friend listing, sending/accepting/rejecting friend requests, removing friends, blocking/unblocking users, and viewing friend profiles with their activities.

Author:
SportTrack Team
  • Constructor Summary

    Constructors
    Constructor
    Description
    FriendshipController(FriendshipService friendshipService, FriendshipRepository friendshipRepository, AthleteRepository athleteRepository, AthleteService athleteService, ActivityService activityService, WeatherReportService weatherReportService, BadgeService badgeService, CommentService commentService)
    Constructs a FriendshipController with the required dependencies.
  • Method Summary

    Modifier and Type
    Method
    Description
    acceptFriendRequest(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Accepts a pending friend request.
    blockUser(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Blocks another user.
    friendProfile(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model)
    Shows a friend's profile page with relationship status.
    friendsActivities(jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model)
    Shows the aggregated activity feed for all accepted friends.
    friendsPage(jakarta.servlet.http.HttpSession session, String query, String tab, org.springframework.ui.Model model)
    Shows the main friendship management page with 5 tabs.
    rejectFriendRequest(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Rejects a pending friend request.
    removeFriend(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Removes an established friendship.
    sendFriendRequest(jakarta.servlet.http.HttpSession session, Integer recipientId, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Sends a friend request to another athlete.
    unblockUser(Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
    Unblocks a previously blocked user.

    Methods inherited from class java.lang.Object

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

    • FriendshipController

      public FriendshipController(FriendshipService friendshipService, FriendshipRepository friendshipRepository, AthleteRepository athleteRepository, AthleteService athleteService, ActivityService activityService, WeatherReportService weatherReportService, BadgeService badgeService, CommentService commentService)
      Constructs a FriendshipController with the required dependencies.
      Parameters:
      friendshipService - the friendship service
      friendshipRepository - the friendship repository
      athleteRepository - the athlete repository
      athleteService - the athlete service
      activityService - the activity service
      weatherReportService - the weather report service
      badgeService - the badge service
      commentService - the comment service
  • Method Details

    • friendsPage

      @GetMapping("/friends") public String friendsPage(jakarta.servlet.http.HttpSession session, @RequestParam(name="q",required=false) String query, @RequestParam(name="tab",required=false) String tab, org.springframework.ui.Model model)
      Shows the main friendship management page with 5 tabs. Loads all data at once for all tabs.
      Parameters:
      session - the current HTTP session
      query - optional search query for the "Add friend" tab
      tab - optional tab identifier to activate
      model - the model used by the view template
      Returns:
      the friends view or a redirect to login
    • friendProfile

      @GetMapping("/friends/profile/{id}") public String friendProfile(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model)
      Shows a friend's profile page with relationship status.
      Parameters:
      id - the ID of the athlete to view
      session - the current HTTP session
      model - the model used by the view template
      Returns:
      the profile view or a redirect to login
    • friendsActivities

      @GetMapping("/friends/activities") public String friendsActivities(jakarta.servlet.http.HttpSession session, org.springframework.ui.Model model)
      Shows the aggregated activity feed for all accepted friends.
    • sendFriendRequest

      @PostMapping("/friends/send") public String sendFriendRequest(jakarta.servlet.http.HttpSession session, @RequestParam("recipientId") Integer recipientId, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      Sends a friend request to another athlete.
    • acceptFriendRequest

      @PostMapping("/friends/accept/{id}") public String acceptFriendRequest(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      Accepts a pending friend request.
    • rejectFriendRequest

      @PostMapping("/friends/reject/{id}") public String rejectFriendRequest(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      Rejects a pending friend request.
    • removeFriend

      @PostMapping("/friends/remove/{id}") public String removeFriend(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      Removes an established friendship.
    • blockUser

      @PostMapping("/friends/block/{id}") public String blockUser(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      Blocks another user.
    • unblockUser

      @PostMapping("/friends/unblock/{id}") public String unblockUser(@PathVariable("id") Integer id, jakarta.servlet.http.HttpSession session, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
      Unblocks a previously blocked user.