Files
Govor/endpoints/friendsrequestquerycontroller.md
T
2025-07-24 08:07:52 +00:00

2.8 KiB

description
description
Description: Controller for querying friend request-related data, including incoming friend requests and responses to sent friend requests.

FriendsRequestQueryController

Controller Description

  • Route: api/friends
  • Authorize: Requires authenticated user ([Authorize]).

Endpoints

GetIncomingRequests

  • Description: Retrieves a list of incoming friend requests for the authenticated user.
  • Route: [GET] api/friends/requests
  • HTTP Method: GET
  • Request: None
  • Responses:
    • 200 OK: Returns a list of incoming friend requests or an empty list if none.

      [
        {
          "id": "Guid",
          "senderId": "Guid",
          "receiverId": "Guid",
          "status": "string",
          "createdAt": "DateTime"
        }
      ]
      
    • 403 Forbidden: If user lacks authorization.

      "string"
      
    • 500 Internal Server Error: Indicates an unexpected error.

      {
        "error": "Internal server error."
      }
      

GetResponses

  • Description: Retrieves a list of responses to the authenticated user's sent friend requests.
  • Route: [GET] api/friends/responses
  • HTTP Method: GET
  • Request: None
  • Responses:
    • 200 OK: Returns a list of friend request responses or an empty list if none.

      [
        {
          "id": "Guid",
          "senderId": "Guid",
          "receiverId": "Guid",
          "status": "string",
          "createdAt": "DateTime"
        }
      ]
      
    • 403 Forbidden: If user lacks authorization.

      "string"
      
    • 500 Internal Server Error: Indicates an unexpected error.

      {
        "error": "Internal server error."
      }
      

Data Models

FriendshipDto

  • Description: Data transfer object for friend request information.

  • Structure:

    {
      "id": "Guid",
      "senderId": "Guid",
      "receiverId": "Guid",
      "status": "string",
      "createdAt": "DateTime"
    }
    

Error Handling

  • Invalid User ID: Handled by ICurrentUserService, aborts if invalid.
  • Invalid Operations: Returns 200 OK with an empty list for InvalidOperationException.
  • Unexpected Errors: Caught and returned as 500 Internal Server Error.

Logging

  • Logs warnings for InvalidOperationException.
  • Logs information for successful response retrieval.
  • Logs errors for unexpected exceptions.