Skip to content

Features Follow and Timeline#3

Merged
espenia merged 2 commits intomainfrom
feature/follow
May 25, 2025
Merged

Features Follow and Timeline#3
espenia merged 2 commits intomainfrom
feature/follow

Conversation

@espenia
Copy link
Copy Markdown
Owner

@espenia espenia commented May 25, 2025

Social Interaction Features

Overview

This pull request introduces essential social interaction features to the Twitter Challenge application, including follow/unfollow functionality, timeline generation.

Key Changes

New Follow Management Features

  • Implemented complete follow/unfollow functionality between users
  • Created endpoints for managing follow relationships
  • Added follower and following list retrieval endpoints
  • Implemented validation to prevent self-follows and handle edge cases

Timeline Infrastructure

  • Built timeline generation system that combines user's own tweets with tweets from followed users
  • Implemented caching mechanism for timelines to improve performance
  • Created configurable timeline parameters (freshness timeout, tweet limits)
  • Added automatic cache invalidation and regeneration when needed

New Endpoints

Follow a User

Description: Create a new follow relationship between users

Endpoint: POST /api/follows/{followerId}

Request:

curl -X POST http://localhost:8090/api/follows/user123 \
  -H "Content-Type: application/json" \
  -d '{
    "followedId": "user456"
  }'

Request Schema:

{
  "followedId": "string"
}

Response Schema:

{
  "id": "string",
  "followerId": "string",
  "followedId": "string",
  "createdAt": "date-time"
}

Status Codes:

  • 201 Created - Follow relationship successfully created
  • 400 Bad Request - Invalid request (e.g., attempting to follow yourself)
  • 404 Not Found - User ID not found
Unfollow a User

Description: Remove an existing follow relationship between users

Endpoint: DELETE /api/follows/{followerId}/{followedId}

Request:

curl -X DELETE http://localhost:8090/api/follows/user123/user456

Response: No content

Status Codes:

  • 204 No Content - Successfully unfollowed
  • 404 Not Found - Follow relationship or user not found
Get User Timeline

Description: Retrieve a user's timeline containing tweets from the user and users they follow

Endpoint: GET /api/timeline/{userId}

Request:

curl -X GET http://localhost:8090/api/timeline/user123

Response Schema:

{
  "id": "string",
  "userId": "string",
  "tweetIds": [
    "string"
  ],
  "lastUpdated": "date-time",
  "tweets": [
    {
      "id": "string",
      "userId": "string",
      "content": "string",
      "createdAt": "date-time",
      "likeCount": 0
    }
  ]
}

Status Codes:

  • 200 OK - Timeline successfully retrieved
  • 404 Not Found - User ID not found
Get User Followers

Description: Retrieve a list of users who follow a specific user

Endpoint: GET /api/follows/followers/{userId}

Request:

curl -X GET http://localhost:8090/api/follows/followers/user123

Response Schema:

[
  {
    "id": "string",
    "followerId": "string",
    "followedId": "string",
    "createdAt": "date-time"
  }
]

Status Codes:

  • 200 OK - Followers list successfully retrieved
  • 404 Not Found - User ID not found
Get User Following

Description: Retrieve a list of users that a specific user is following

Endpoint: GET /api/follows/following/{userId}

Request:

curl -X GET http://localhost:8090/api/follows/following/user123

Response Schema:

[
  {
    "id": "string",
    "followerId": "string",
    "followedId": "string",
    "createdAt": "date-time"
  }
]

Status Codes:

  • 200 OK - Following list successfully retrieved
  • 404 Not Found - User ID not found

Related Issues

  • Closes Features Follow and Timeline #3: Implement follow/unfollow functionality
  • Closes #4: Create timeline endpoint
  • Closes #5: Add follower listing endpoints

@espenia espenia merged commit 5ba99c1 into main May 25, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant