2
0

feat(blog): add subscription-only content gating

Adds SubscriptionOnly flag to blog posts to restrict full content access to active subscribers. Shows teaser/preview for non-subscribers with subscribe CTA. Integrates with repository subscription system when monetization is enabled. Updates v2 API structs and editor UI with subscription toggle. Admins and repo writers bypass the gate.
This commit is contained in:
2026-02-02 13:22:01 -05:00
parent 6bc3693cef
commit 2ba1596b02
12 changed files with 210 additions and 57 deletions

View File

@@ -43,21 +43,22 @@ func (s BlogPostStatus) String() string {
// BlogPost represents a blog article belonging to a repository.
type BlogPost struct { //revive:disable-line:exported
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX NOT NULL"`
AuthorID int64 `xorm:"INDEX NOT NULL"`
Title string `xorm:"VARCHAR(255) NOT NULL"`
Subtitle string `xorm:"VARCHAR(500)"`
Content string `xorm:"LONGTEXT NOT NULL"`
RenderedContent string `xorm:"-"`
Tags string `xorm:"TEXT"`
Series string `xorm:"VARCHAR(255)"`
FeaturedImageID int64 `xorm:"DEFAULT 0"`
Status BlogPostStatus `xorm:"SMALLINT NOT NULL DEFAULT 0"`
AllowComments bool `xorm:"NOT NULL DEFAULT true"`
PublishedUnix timeutil.TimeStamp `xorm:"INDEX"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
ID int64 `xorm:"pk autoincr"`
RepoID int64 `xorm:"INDEX NOT NULL"`
AuthorID int64 `xorm:"INDEX NOT NULL"`
Title string `xorm:"VARCHAR(255) NOT NULL"`
Subtitle string `xorm:"VARCHAR(500)"`
Content string `xorm:"LONGTEXT NOT NULL"`
RenderedContent string `xorm:"-"`
Tags string `xorm:"TEXT"`
Series string `xorm:"VARCHAR(255)"`
FeaturedImageID int64 `xorm:"DEFAULT 0"`
Status BlogPostStatus `xorm:"SMALLINT NOT NULL DEFAULT 0"`
AllowComments bool `xorm:"NOT NULL DEFAULT true"`
SubscriptionOnly bool `xorm:"NOT NULL DEFAULT false"`
PublishedUnix timeutil.TimeStamp `xorm:"INDEX"`
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
Author *user_model.User `xorm:"-"`
Repo *repo_model.Repository `xorm:"-"`