Documentation
¶
Overview ¶
Package cms provides services for Content Management System functionality
Index ¶
- Constants
- func RenderDraftPreview(draft *models.Draft) (cmsrender.RenderedArticleContent, error)
- type ArticleService
- func (s *ArticleService) CreateArticle(ctx context.Context, article *models.Article) error
- func (s *ArticleService) DeleteArticle(ctx context.Context, article *models.Article) error
- func (s *ArticleService) GetArticle(ctx context.Context, articleID string) (*models.Article, error)
- func (s *ArticleService) GetArticleBySlug(ctx context.Context, slug string) (*models.Article, error)
- func (s *ArticleService) GetArticleByTenantSlug(ctx context.Context, tenant string, slug string) (*models.Article, error)
- func (s *ArticleService) UpdateArticle(ctx context.Context, article *models.Article) error
- type CategoryService
- func (s *CategoryService) CreateCategory(ctx context.Context, category *models.Category) error
- func (s *CategoryService) DeleteCategory(ctx context.Context, id string) error
- func (s *CategoryService) GetCategory(ctx context.Context, id string) (*models.Category, error)
- func (s *CategoryService) ListCategories(ctx context.Context, parentID *string, limit int) ([]*models.Category, error)
- func (s *CategoryService) UpdateCategory(ctx context.Context, category *models.Category) error
- type DraftService
- func (s *DraftService) Autosave(ctx context.Context, authorID string, draft *models.Draft) error
- func (s *DraftService) CancelScheduledDraft(ctx context.Context, authorID, draftID string) error
- func (s *DraftService) CreateDraft(ctx context.Context, draft *models.Draft) error
- func (s *DraftService) DeleteDraft(ctx context.Context, authorID, draftID string) error
- func (s *DraftService) GetDraft(ctx context.Context, authorID, draftID string) (*models.Draft, error)
- func (s *DraftService) PreviewDraft(ctx context.Context, authorID, draftID string) (cmsrender.RenderedArticleContent, error)
- func (s *DraftService) PublishDraft(ctx context.Context, authorID, draftID string) (*models.Article, error)
- func (s *DraftService) ScheduleDraft(ctx context.Context, authorID, draftID string, scheduledAt time.Time) error
- func (s *DraftService) UpdateDraft(ctx context.Context, authorID string, draft *models.Draft) error
- type FederationService
- type LegacyArticleMigrationCandidate
- type LegacyArticleMigrationConflict
- type LegacyArticleMigrationPlan
- type LegacyArticleMigrationSkipped
- type PublicationService
- func (s *PublicationService) AddMember(ctx context.Context, member *models.PublicationMember) error
- func (s *PublicationService) CreatePublication(ctx context.Context, publication *models.Publication) error
- func (s *PublicationService) DeletePublication(ctx context.Context, id string) error
- func (s *PublicationService) GetMember(ctx context.Context, publicationID, userID string) (*models.PublicationMember, error)
- func (s *PublicationService) GetPublication(ctx context.Context, id string) (*models.Publication, error)
- func (s *PublicationService) ListMembers(ctx context.Context, publicationID string) ([]*models.PublicationMember, error)
- func (s *PublicationService) RemoveMember(ctx context.Context, publicationID, userID string) error
- func (s *PublicationService) UpdateMemberRole(ctx context.Context, publicationID, userID, role string) error
- func (s *PublicationService) UpdatePublication(ctx context.Context, publication *models.Publication) error
- type RevisionService
- func (s *RevisionService) CreateRevision(ctx context.Context, article *models.Article) (*models.Revision, error)
- func (s *RevisionService) GetRevision(ctx context.Context, objectID string, version int) (*models.Revision, error)
- func (s *RevisionService) ListRevisions(ctx context.Context, objectID string, limit int) ([]*models.Revision, error)
- func (s *RevisionService) RestoreRevision(ctx context.Context, objectID string, version int) (*models.Article, error)
- type SeriesService
- func (s *SeriesService) AddArticleToSeries(ctx context.Context, articleID string, seriesID string, order int) error
- func (s *SeriesService) CreateSeries(ctx context.Context, series *models.Series) error
- func (s *SeriesService) DeleteSeries(ctx context.Context, authorID, seriesID string) error
- func (s *SeriesService) GetSeries(ctx context.Context, authorID, seriesID string) (*models.Series, error)
- func (s *SeriesService) ListSeriesByAuthor(ctx context.Context, authorID string, limit int) ([]*models.Series, error)
- func (s *SeriesService) RemoveArticleFromSeries(ctx context.Context, articleID string) error
- func (s *SeriesService) ReorderArticles(ctx context.Context, seriesID string, articleOrders map[string]int) error
- func (s *SeriesService) UpdateSeries(ctx context.Context, series *models.Series) error
Constants ¶
const ( LegacyArticleSkipNil = "nil_article" LegacyArticleSkipNotArticle = "not_article" LegacyArticleSkipMissingID = "missing_id" LegacyArticleSkipAlreadyCanonical = "already_canonical_article" LegacyArticleSkipNotLegacyObjectID = "not_legacy_objects_id" LegacyArticleSkipMissingSlug = "missing_slug" LegacyArticleConflictDuplicate = "duplicate_legacy_alias" LegacyArticleConflictOccupied = "canonical_alias_occupied" )
Legacy Article migration skip and conflict reason codes.
Variables ¶
This section is empty.
Functions ¶
func RenderDraftPreview ¶ added in v1.4.9
func RenderDraftPreview(draft *models.Draft) (cmsrender.RenderedArticleContent, error)
RenderDraftPreview renders draft source through the canonical Article renderer.
Types ¶
type ArticleService ¶
type ArticleService struct {
// contains filtered or unexported fields
}
ArticleService handles business logic for articles
func NewArticleService ¶
func NewArticleService( articleRepo articleServiceRepository, actorRepo actorRepository, seriesRepo cmsSeriesArticleCountUpdater, categoryRepo cmsCategoryArticleCountUpdater, revisionService articleRevisionCreator, federation FederationService, logger *zap.Logger, ) *ArticleService
NewArticleService creates a new ArticleService
func (*ArticleService) CreateArticle ¶
CreateArticle creates a new article
func (*ArticleService) DeleteArticle ¶
DeleteArticle deletes an article and federates a Delete activity best-effort.
func (*ArticleService) GetArticle ¶
GetArticle retrieves an article by ID.
func (*ArticleService) GetArticleBySlug ¶
func (s *ArticleService) GetArticleBySlug(ctx context.Context, slug string) (*models.Article, error)
GetArticleBySlug retrieves an article by its slug index (no legacy fallback).
func (*ArticleService) GetArticleByTenantSlug ¶ added in v1.2.53
func (s *ArticleService) GetArticleByTenantSlug(ctx context.Context, tenant string, slug string) (*models.Article, error)
GetArticleByTenantSlug retrieves an article by a tenant-scoped slug index with legacy global-index compatibility. Legacy matches are only returned after the resolved article ID is verified to belong to the requested tenant.
func (*ArticleService) UpdateArticle ¶
UpdateArticle updates an existing article and records a revision if configured.
type CategoryService ¶
type CategoryService struct {
// contains filtered or unexported fields
}
CategoryService handles business logic for categories
func NewCategoryService ¶
func NewCategoryService(categoryRepo categoryRepository, logger *zap.Logger) *CategoryService
NewCategoryService creates a new CategoryService
func (*CategoryService) CreateCategory ¶
CreateCategory creates a new category
func (*CategoryService) DeleteCategory ¶
func (s *CategoryService) DeleteCategory(ctx context.Context, id string) error
DeleteCategory deletes a category
func (*CategoryService) GetCategory ¶
GetCategory retrieves a category by ID
func (*CategoryService) ListCategories ¶
func (s *CategoryService) ListCategories(ctx context.Context, parentID *string, limit int) ([]*models.Category, error)
ListCategories lists categories
func (*CategoryService) UpdateCategory ¶
UpdateCategory updates an existing category
type DraftService ¶
type DraftService struct {
// contains filtered or unexported fields
}
DraftService handles business logic for drafts
func NewDraftService ¶
func NewDraftService(draftRepo draftRepository, articleService *ArticleService, domain string, schedulingEnabled bool, logger *zap.Logger) *DraftService
NewDraftService creates a new DraftService
func (*DraftService) Autosave ¶
Autosave updates the draft content without changing its primary status
func (*DraftService) CancelScheduledDraft ¶
func (s *DraftService) CancelScheduledDraft(ctx context.Context, authorID, draftID string) error
CancelScheduledDraft cancels a scheduled draft publish.
func (*DraftService) CreateDraft ¶
CreateDraft creates a new draft
func (*DraftService) DeleteDraft ¶
func (s *DraftService) DeleteDraft(ctx context.Context, authorID, draftID string) error
DeleteDraft deletes a draft
func (*DraftService) GetDraft ¶
func (s *DraftService) GetDraft(ctx context.Context, authorID, draftID string) (*models.Draft, error)
GetDraft retrieves a draft
func (*DraftService) PreviewDraft ¶ added in v1.4.9
func (s *DraftService) PreviewDraft(ctx context.Context, authorID, draftID string) (cmsrender.RenderedArticleContent, error)
PreviewDraft renders a draft through the same Article publication renderer used for ActivityPub and public HTML.
func (*DraftService) PublishDraft ¶
func (s *DraftService) PublishDraft(ctx context.Context, authorID, draftID string) (*models.Article, error)
PublishDraft converts a draft into an article
func (*DraftService) ScheduleDraft ¶
func (s *DraftService) ScheduleDraft(ctx context.Context, authorID, draftID string, scheduledAt time.Time) error
ScheduleDraft schedules a draft for publishing
func (*DraftService) UpdateDraft ¶
UpdateDraft updates an existing draft
type FederationService ¶
type FederationService interface {
DeliverToFollowers(ctx context.Context, activity *activitypub.Activity, actor *activitypub.Actor) error
DeliverToRecipients(ctx context.Context, activity *activitypub.Activity, actor *activitypub.Actor) error
}
FederationService interface to avoid circular imports with pkg/services
type LegacyArticleMigrationCandidate ¶ added in v1.4.9
type LegacyArticleMigrationCandidate struct {
ArticleID string
Tenant string
Slug string
ProposedCanonicalID string
ProposedAliasURL string
}
LegacyArticleMigrationCandidate maps one legacy Article to its proposed browser alias. ProposedCanonicalID intentionally remains the stored legacy Article ID for the MVP so the dry-run never creates a second ActivityPub object identity for existing content.
type LegacyArticleMigrationConflict ¶ added in v1.4.9
type LegacyArticleMigrationConflict struct {
Tenant string
Slug string
AliasURL string
ArticleIDs []string
Reason string
}
LegacyArticleMigrationConflict describes a mapping that cannot be applied without creating duplicate alias/canonical identity ambiguity.
type LegacyArticleMigrationPlan ¶ added in v1.4.9
type LegacyArticleMigrationPlan struct {
Candidates []LegacyArticleMigrationCandidate
Conflicts []LegacyArticleMigrationConflict
Skipped []LegacyArticleMigrationSkipped
}
LegacyArticleMigrationPlan is the dry-run output for deciding how legacy Article IDs under /objects/<uuid> could be exposed through non-authoritative /articles/<slug> aliases without rewriting ActivityPub object identity.
func PlanLegacyArticleMigration ¶ added in v1.4.9
func PlanLegacyArticleMigration(articles []*models.Article, defaultDomain string) LegacyArticleMigrationPlan
PlanLegacyArticleMigration performs a pure dry-run over Article rows. It identifies legacy /objects/<uuid> Articles, proposes non-authoritative /articles/<slug> aliases, and reports conflicts before any write path exists.
type LegacyArticleMigrationSkipped ¶ added in v1.4.9
LegacyArticleMigrationSkipped describes an Article row that is not a legacy /objects/<uuid> Article migration candidate.
type PublicationService ¶
type PublicationService struct {
// contains filtered or unexported fields
}
PublicationService handles business logic for publications
func NewPublicationService ¶
func NewPublicationService(pubRepo publicationRepository, pubMemberRepo publicationMemberRepository, logger *zap.Logger) *PublicationService
NewPublicationService creates a new PublicationService
func (*PublicationService) AddMember ¶
func (s *PublicationService) AddMember(ctx context.Context, member *models.PublicationMember) error
AddMember adds a member to a publication
func (*PublicationService) CreatePublication ¶
func (s *PublicationService) CreatePublication(ctx context.Context, publication *models.Publication) error
CreatePublication creates a new publication
func (*PublicationService) DeletePublication ¶
func (s *PublicationService) DeletePublication(ctx context.Context, id string) error
DeletePublication deletes a publication
func (*PublicationService) GetMember ¶
func (s *PublicationService) GetMember(ctx context.Context, publicationID, userID string) (*models.PublicationMember, error)
GetMember retrieves a specific member
func (*PublicationService) GetPublication ¶
func (s *PublicationService) GetPublication(ctx context.Context, id string) (*models.Publication, error)
GetPublication retrieves a publication by ID
func (*PublicationService) ListMembers ¶
func (s *PublicationService) ListMembers(ctx context.Context, publicationID string) ([]*models.PublicationMember, error)
ListMembers lists all members of a publication
func (*PublicationService) RemoveMember ¶
func (s *PublicationService) RemoveMember(ctx context.Context, publicationID, userID string) error
RemoveMember removes a member from a publication
func (*PublicationService) UpdateMemberRole ¶
func (s *PublicationService) UpdateMemberRole(ctx context.Context, publicationID, userID, role string) error
UpdateMemberRole updates a member's role
func (*PublicationService) UpdatePublication ¶
func (s *PublicationService) UpdatePublication(ctx context.Context, publication *models.Publication) error
UpdatePublication updates an existing publication
type RevisionService ¶
type RevisionService struct {
// contains filtered or unexported fields
}
RevisionService handles business logic for content revisions
func NewRevisionService ¶
func NewRevisionService( revisionRepo revisionRepository, articleRepo articleRepositoryWithDB, seriesRepo cmsSeriesArticleCountUpdater, categoryRepo cmsCategoryArticleCountUpdater, maxRevisionsPerObject int, logger *zap.Logger, ) *RevisionService
NewRevisionService creates a new RevisionService
func (*RevisionService) CreateRevision ¶
func (s *RevisionService) CreateRevision(ctx context.Context, article *models.Article) (*models.Revision, error)
CreateRevision creates a new revision from an article state
func (*RevisionService) GetRevision ¶
func (s *RevisionService) GetRevision(ctx context.Context, objectID string, version int) (*models.Revision, error)
GetRevision retrieves a specific revision
func (*RevisionService) ListRevisions ¶
func (s *RevisionService) ListRevisions(ctx context.Context, objectID string, limit int) ([]*models.Revision, error)
ListRevisions lists revisions for a given article
func (*RevisionService) RestoreRevision ¶
func (s *RevisionService) RestoreRevision(ctx context.Context, objectID string, version int) (*models.Article, error)
RestoreRevision reverts an article to a specific revision
type SeriesService ¶
type SeriesService struct {
// contains filtered or unexported fields
}
SeriesService handles business logic for series
func NewSeriesService ¶
func NewSeriesService(seriesRepo seriesRepository, articleRepo articleSeriesRepository, logger *zap.Logger) *SeriesService
NewSeriesService creates a new SeriesService
func (*SeriesService) AddArticleToSeries ¶
func (s *SeriesService) AddArticleToSeries(ctx context.Context, articleID string, seriesID string, order int) error
AddArticleToSeries adds an article to a series
func (*SeriesService) CreateSeries ¶
CreateSeries creates a new series
func (*SeriesService) DeleteSeries ¶
func (s *SeriesService) DeleteSeries(ctx context.Context, authorID, seriesID string) error
DeleteSeries deletes a series
func (*SeriesService) GetSeries ¶
func (s *SeriesService) GetSeries(ctx context.Context, authorID, seriesID string) (*models.Series, error)
GetSeries retrieves a series by author ID and series ID
func (*SeriesService) ListSeriesByAuthor ¶
func (s *SeriesService) ListSeriesByAuthor(ctx context.Context, authorID string, limit int) ([]*models.Series, error)
ListSeriesByAuthor lists series for an author
func (*SeriesService) RemoveArticleFromSeries ¶
func (s *SeriesService) RemoveArticleFromSeries(ctx context.Context, articleID string) error
RemoveArticleFromSeries removes an article from a series
func (*SeriesService) ReorderArticles ¶
func (s *SeriesService) ReorderArticles(ctx context.Context, seriesID string, articleOrders map[string]int) error
ReorderArticles updates the order of articles in a series
func (*SeriesService) UpdateSeries ¶
UpdateSeries updates an existing series