feat(blog): allow members to edit published posts with approval workflow - #39
Merged
Conversation
Contributor
Author
|
Usage note for admin: The admin need to go to the edit page of the blog they want to reject/aprove edit requests and on that page they can view the diff and approve/reject the changes. Also a natural follow up to this PR would be to send notifications to the admins for newly requested changes on blogs and to the authors on the admin's decisions. Opening a seperate issue for it as it is out of scope of the current PR. |
RsbhThakur
marked this pull request as ready for review
September 3, 2026 22:40
RsbhThakur
force-pushed
the
feat/blog-revisions
branch
from
September 3, 2026 22:59
1ba1b12 to
27475f7
Compare
Introduce IBlogRevision schema and pendingRevision subdocument in BlogPost model. Update blog access control helper to allow authors to access editor and stage revisions on published posts.
Support staged revisions in PATCH /api/internal/blog/[slug] with requestApproval flag, revision discard via DELETE, and create POST /api/admin/blog/[slug]/revision endpoint for approving or rejecting staged revisions with cache purging.
Extend BlogEditor with customizable action buttons. Update member dashboard and edit pages to support published blog revisions with status banners, approval submission, and revision discarding. Add direct edit article button on public blog headers for authors.
Add review banners and diff toggles with approve/reject actions to admin blog pages. Add integration tests covering member revision lifecycle, approval request, admin approval/rejection, and cache revalidation.
…blished posts Update admin revision audit actor access assertion to Head and update blog-images tests to verify authors can upload images to published posts while non-authors are forbidden.
Support matching author userId across ObjectId and string types, and improve edit button visibility and z-index on dashboard blog cards.
…s without replica set transactions
…ions Allow authors to withdraw pending review requests back to draft staging without losing their work, and provide distinct contextual actions for discarding drafts vs discarding submitted proposals.
… notifications Replace the two-tab review toggle with an inline RevisionDiffViewer component showing metadata and line-by-line Markdown changes with green additions and red deletions, and automatically dispatch in-app and push notifications to admins when revisions are submitted and to authors upon approval/rejection.
maydayv7
force-pushed
the
feat/blog-revisions
branch
from
September 3, 2026 23:21
27475f7 to
5ba2846
Compare
maydayv7
previously requested changes
Sep 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28.
Implements an editorial workflow allowing member authors to stage edits on their published blog posts without immediately modifying live content. Staged updates can be saved incrementally, previewed, withdrawn, or submitted to administrators for review. Administrators receive notifications, can inspect an inline line-by-line visual diff comparing the live post against proposed changes, and can approve or reject revisions with automatic cache invalidation and author notifications.
Key Changes
1. Data Schema & Access Control
BlogPostSchema: AddedpendingRevisionsubdocument storing staged revision content (title,content,excerpt,coverImage,coverFocalPoint,tags,updatedAt,submittedAt,submittedBy).canEditBlogDraftand exportedisBlogAuthor/canAccessBlogEditorso authors can access the editor for their published posts while maintaining strict non-author protection.2. Member Revision Flow
PATCH /api/internal/blog/[slug]:pendingRevision(staging).requestApproval: trueto submit for admin review.cancelApproval: trueto withdraw review requests back to draft staging without losing work.DELETEto discard staged revisions and revert to live content./internal/dashboard) with "My Blogs" list, direct edit links, and contextual status badges (published · draft changes saved,published · changes pending approval).3. Admin Review & Diff Inspector
POST /api/admin/blog/[slug]/revision: Endpoint supportingapprove(atomically applies revision to live fields and clears staging) andreject(discards revision) with cache and Next.js path revalidations.RevisionDiffViewer):+green) and deleted (-red) lines with line numbers.BlogEditordirectly below for live preview and admin adjustments.4. Notifications & Audit Logging
"blog_revision"toNOTIFICATION_TYPES.blog.revision.update,blog.revision.submit,blog.revision.withdraw,blog.revision.approve, andblog.revision.reject.Verification & Testing
tests/integration/blog-admin.test.ts(approval and rejection flows, cache invalidation, audit trails).tests/integration/blog-member-drafts.test.ts(revision creation, submission, and author RBAC).tests/integration/blog-images.test.ts(author image uploads against published post revisions).pnpm typecheck(tsc --noEmit) passes with 0 errors.Screenshots