Skip to content

Public read-only JSON API for publicly visible stories - #2196

Open
maebeale wants to merge 11 commits into
mainfrom
maebeale/public-stories-api
Open

Public read-only JSON API for publicly visible stories#2196
maebeale wants to merge 11 commits into
mainfrom
maebeale/public-stories-api

Conversation

@maebeale

@maebeale maebeale commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

🤖 suggested review level: 3 Read 📖 small contained new endpoint; main thing to verify is the public-visibility scoping

What

  • New public, unauthenticated JSON API at /api/v1/stories (index) and /api/v1/stories/:id (show).
  • Returns only publicly featured stories (published AND publicly_visible AND publicly_featured).
  • Each story exposes: title, author, organization, url, tags (windows_type + categories grouped by category-type label + sectors), body, image_url/thumbnail_url, timestamps.
  • per_page capped (default 25, max 100), with pagination meta.

Why

  • Lets external consumers (e.g. the marketing site) pull featured public stories without a login.

Notes

  • Scoping starts from Story.publicly_featured and layers StoryPolicy via authorized_scope, so the public floor holds regardless of caller.
  • Author names go through author_credit, honoring each story's privacy preference (never raw PII).
  • Rendered with jbuilder; errors return JSON (404 / 403).

Consumers (e.g. the marketing site) need to pull stories without a login.
Expose only publicly-visible stories, each carrying its featured and
publicly_featured flags, with an optional publicly_featured filter.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 14, 2026 04:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@maebeale
maebeale marked this pull request as ready for review August 14, 2026 13:47
The endpoint should simply expose every publicly visible + published story
with its featured/publicly_featured flags, not filter by them.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 13:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Give API consumers the full tag set, split by taxonomy: categories keyed by
their category-type label, plus the flat sector list.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 13:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Untagged stories dropped the key entirely (empty jbuilder block); assign the
grouped hash directly so consumers can iterate tags.categories unconditionally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

…e_url

Nest featured and publicly_featured under a "flags" object and remove the
redundant published field (always true) and the external-link fields.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Lead with title, author, organization, url, flags, tags, body; trailing
identifiers/media/timestamps follow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Only publicly_featured is public-facing; drop featured from flags.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The slug/url already carry the id, and show resolves by it — no need for a
top-level id field.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

The url already provides the canonical link; drop the redundant slug.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

It's another story tag, so group it with categories and sectors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Both index and show now return only published + publicly_visible +
publicly_featured stories, so the per-record publicly_featured flag is
redundant and removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 14, 2026 14:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants