Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: Schedule blog post feature #1234

Open
wants to merge 19 commits into
base: dev
Choose a base branch
from

Conversation

KehindeBello
Copy link

Description

This update enhances the blog post creation functionality by enabling users to schedule blog posts for future publication. The following changes have been made:

  • Modified the existing blog post creation endpoint to allow users to schedule posts for future publication by adding optional scheduled_at in payload for blog creation endpoint
  • Ensured that the endpoint remains secured and accessible only to authorized users.
  • Modified the database schema to support scheduled_at and status fields (published or pending).
  • Stored scheduled posts in the database with a pending status and added the necessary logic to publish them later.
  • Implemented a background job to check and publish scheduled posts at the correct time.
  • Modified the GET /api/v1/blogs endpoint to return only published posts, excluding scheduled ones.

New Endpoint

  • Added a new endpoint: `GET /api/v1/blogs/scheduled for user to retrieve their scheduled blog posts

Request Sample

Request Type: GET
Request URL: /api/v1/blogs/scheduled

Headers:

Authorization: Bearer <your_access_token>  
Content-Type: application/json

Response [Success]

{
  "status": "success",
  "status_code": 200,
  "message": "Scheduled blogs retrieved successfully",
  "data": [
    {
      "content": "string",
      "image_url": "string",
      "excerpt": "string",
      "scheduled_at": "2025-03-02T17:12:00+01:00",
      "id": "067c42a4-451f-7472-8000-0d8f6e1f3511",
      "author_id": "067c31bd-b92a-7010-8000-c292a78f5a52",
      "title": "Test schedule",
      "is_deleted": false,
      "tags": "{string}",
      "status": "pending",
      "created_at": "2025-03-02T10:52:04.316293+01:00",
      "updated_at": "2025-03-02T10:52:04.316293+01:00"
    },
    {
      "content": "string",
      "image_url": "string",
      "excerpt": "string",
      "scheduled_at": "2025-04-02T17:12:00+01:00",
      "id": "067c433a-7964-7290-8000-8230c28dff99",
      "author_id": "067c31bd-b92a-7010-8000-c292a78f5a52",
      "title": "Test schedule",
      "is_deleted": false,
      "tags": "{string}",
      "status": "pending",
      "created_at": "2025-03-02T11:32:07.583033+01:00",
      "updated_at": "2025-03-02T11:32:07.583033+01:00"
    },
    {
      "content": "string",
      "image_url": "string",
      "excerpt": "string",
      "scheduled_at": "2025-04-02T17:12:00+01:00",
      "id": "067c43dc-46de-7945-8000-0892d740caa6",
      "author_id": "067c31bd-b92a-7010-8000-c292a78f5a52",
      "title": "Test schedule",
      "is_deleted": false,
      "tags": "{string}",
      "status": "pending",
      "created_at": "2025-03-02T12:15:16.414823+01:00",
      "updated_at": "2025-03-02T12:15:16.414823+01:00"
    }
  ]
}

Related Issue (Link to issue ticket)

Link to Issue

Motivation and Context

By providing a feature that automatically publishes posts at a specified time, users can plan content ahead of time and ensure consistent publishing, even when they are unavailable.

I have tested that fetching blogs only returns published blogs and that blog becomes publishe at scheduled time

Screenshots (if appropriate - Postman, etc):

Create a scheduled blog
image

Create a blog - instant publishing
image

Fetch scheduled blogs
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • [] I have updated the documentation accordingly.
  • [] I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests 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