Documentation
¶
Overview ¶
Package modules hosts the core-side adapters between the composition root and the real v1 modules under modules/: repository-to-seam bridges whose only layer may import both sides (user policy, auth notifications, soft delete, profile pictures), plus the logger adapter. The Phase 1 transitional wrappers are fully retired — every first-party feature is a real module — so only DefaultEdition (kept for the Phase 4.1 disabled/cascade work) and the adapters remain.
Index ¶
- func ApplyDisabled(registry *kernel.Registry, candidates []kernel.Module, disabled []string, ...) (map[string]bool, error)
- func DefaultEdition() []kernel.Module
- func EffectiveCommentsEnabled(legacyEnabled bool, modulesDisabled []string, kept map[string]bool) bool
- func NewAgentCommentRoleCapabilities(service *roledomain.Service) commentagent.RoleCapabilities
- func NewAgentContentLookup(content *contentservice.Service) commentagent.ContentLookup
- func NewAgentMediaRoleCapabilities(service *roledomain.Service) mediaagent.RoleCapabilities
- func NewAllowCommentsChecker(content *contentservice.Service) commentdomain.AllowCommentsChecker
- func NewBrowserContentResolver(content *contentservice.Service) commentapi.ContentResolver
- func NewCommentRoleCapabilities(service *roledomain.Service) commentapi.RoleCapabilities
- func NewLogger(logger *util.Logger) kernel.Logger
- func NewMediaRoleCapabilities(service *roledomain.Service) mediaapi.RoleCapabilities
- func NewRoleCapabilities(service *roledomain.Service) api.RoleCapabilities
- func NewSEOPublishedPages(content *contentdomain.Service) seoapi.PublishedPages
- func NewSiteSSRContentReader(content *contentservice.Service, comments *commentdomain.Service) sitessr.ContentReader
- type AuthNotificationRecorder
- type CommentServiceAdapter
- func (a *CommentServiceAdapter) CountComments(ctx context.Context, userID int) (int, error)
- func (a *CommentServiceAdapter) DeleteComment(ctx context.Context, commentID int) error
- func (a *CommentServiceAdapter) DeleteOwnComment(ctx context.Context, commentID int, principal kernel.Principal) error
- func (a *CommentServiceAdapter) GetComment(ctx context.Context, commentID int) (*commentdomain.Comment, error)
- func (a *CommentServiceAdapter) GetCommentsByStatus(ctx context.Context, status commentdomain.CommentStatus) ([]*commentdomain.Comment, error)
- func (a *CommentServiceAdapter) GetCommentsByUserID(ctx context.Context, userID int) ([]*commentdomain.Comment, error)
- func (a *CommentServiceAdapter) GetCommentsForContent(ctx context.Context, contentID int) ([]*commentdomain.Comment, error)
- func (a *CommentServiceAdapter) GetCommentsForModeration(ctx context.Context, contentID int) ([]*commentdomain.Comment, error)
- func (a *CommentServiceAdapter) SubmitComment(ctx context.Context, contentID int, principal kernel.Principal, ...) (*commentdomain.Comment, error)
- func (a *CommentServiceAdapter) UpdateCommentStatus(ctx context.Context, commentID int, status commentdomain.CommentStatus) error
- type ProfilePictureUserRepo
- func (r *ProfilePictureUserRepo) DeleteProfilePicture(ctx context.Context, userID int) error
- func (r *ProfilePictureUserRepo) GetUserByID(ctx context.Context, userID int) (string, error)
- func (r *ProfilePictureUserRepo) UpdateProfilePicture(ctx context.Context, userID int, profilePicture string) error
- type SoftDeleteStore
- func (s *SoftDeleteStore) GetSoftDeletedContentByID(ctx context.Context, id int) (*usersapi.SoftDeletedContent, error)
- func (s *SoftDeleteStore) GetSoftDeletedContentByUser(ctx context.Context, userID int) ([]*usersapi.SoftDeletedContent, error)
- func (s *SoftDeleteStore) RestoreContent(ctx context.Context, contentType string, contentID int) error
- type UserCredentialPolicy
- func (UserCredentialPolicy) GeneratePassword(length int) (string, error)
- func (UserCredentialPolicy) HashPassword(password string) (string, error)
- func (UserCredentialPolicy) NeedsRehash(hash string) bool
- func (UserCredentialPolicy) ValidateEmail(email string) error
- func (UserCredentialPolicy) ValidatePassword(password string) error
- func (UserCredentialPolicy) ValidateUsername(username string) error
- func (UserCredentialPolicy) VerifyPassword(hash, password string) error
- type WordPressUserProvisioner
- func (p *WordPressUserProvisioner) CreateAuthor(ctx context.Context, username, email, name string) (*wordpress.AuthorAccount, error)
- func (p *WordPressUserProvisioner) FindByEmail(ctx context.Context, email string) (*wordpress.AuthorAccount, error)
- func (p *WordPressUserProvisioner) FindByUsername(ctx context.Context, username string) (*wordpress.AuthorAccount, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyDisabled ¶
func ApplyDisabled( registry *kernel.Registry, candidates []kernel.Module, disabled []string, warnf func(format string, args ...any), ) (map[string]bool, error)
ApplyDisabled prunes the disabled modules (plus cascade) from the candidates, reports each drop and each unknown name through warnf, and registers only the kept modules. It returns the kept name set for back-compat flag mapping. Register errors return; the composition root fails startup on them. Unknown names warn and are ignored so configs stay portable across editions.
func DefaultEdition ¶
DefaultEdition returns every first-party wrapper — the default composition root. Registration order is irrelevant; the registry topologically sorts. All wrappers are retired: every first-party feature is a real module, so the edition is empty until Phase 4.1 rebuilds it on the disabled/cascade matrix.
func EffectiveCommentsEnabled ¶
func EffectiveCommentsEnabled(legacyEnabled bool, modulesDisabled []string, kept map[string]bool) bool
EffectiveCommentsEnabled folds the legacy [comments] toggle and the v1 modules disabled list into the single flag every consumer reads. Disabling the comments module is equivalent to the legacy toggle; a cascaded drop (kept lacks comments) unmounts the routes the same way. Headless mode is independent: it never reaches this function.
func NewAgentCommentRoleCapabilities ¶
func NewAgentCommentRoleCapabilities(service *roledomain.Service) commentagent.RoleCapabilities
NewAgentCommentRoleCapabilities adapts the config-driven role registry to the comments module's agent seam (comment-posting gate). A nil service yields nil, and the module preserves the legacy allow-all behavior.
func NewAgentContentLookup ¶
func NewAgentContentLookup(content *contentservice.Service) commentagent.ContentLookup
NewAgentContentLookup adapts the content service to the comments module's agent seam: content ID in, visibility and gate facts out. A missing item translates to the seam's ErrContentNotFound; any other failure propagates for the handler's 500 path. It lives in core — the only layer that may import both sides.
func NewAgentMediaRoleCapabilities ¶
func NewAgentMediaRoleCapabilities(service *roledomain.Service) mediaagent.RoleCapabilities
NewAgentMediaRoleCapabilities adapts the config-driven role registry to the media module's agent seam (upload gate). A nil service yields nil, and the module preserves the legacy allow-all behavior.
func NewAllowCommentsChecker ¶
func NewAllowCommentsChecker(content *contentservice.Service) commentdomain.AllowCommentsChecker
NewAllowCommentsChecker adapts the content service to the comments module's SubmitComment gate. It lives in core — the only layer that may import both sides — until a later phase moves the seam. A missing item translates to the domain's ErrContentNotFound so the submit path maps it exactly as before; any other failure propagates for the 500 path.
func NewBrowserContentResolver ¶
func NewBrowserContentResolver(content *contentservice.Service) commentapi.ContentResolver
NewBrowserContentResolver adapts the content service to the comments module's browser seam: slug in, comment-relevant facts out. A missing item translates to the seam's ErrContentNotFound; any other failure propagates for the handler's 500 path. It lives in core — the only layer that may import both sides.
func NewCommentRoleCapabilities ¶
func NewCommentRoleCapabilities(service *roledomain.Service) commentapi.RoleCapabilities
NewCommentRoleCapabilities adapts the config-driven role registry to the comments module's browser seam (comment-posting gate). A nil service yields nil, and the module preserves the legacy allow-all behavior.
func NewLogger ¶
NewLogger adapts *util.Logger to kernel.Logger. A nil logger yields nil, and kernel.NewHost substitutes its discard sink.
func NewMediaRoleCapabilities ¶
func NewMediaRoleCapabilities(service *roledomain.Service) mediaapi.RoleCapabilities
NewMediaRoleCapabilities adapts the config-driven role registry to the media module's browser seam (upload/generate/delete gates). A nil service yields nil, and the module preserves the legacy allow-all behavior.
func NewRoleCapabilities ¶
func NewRoleCapabilities(service *roledomain.Service) api.RoleCapabilities
NewRoleCapabilities adapts the config-driven role registry to the posttypes-basic module's narrow seam. It lives in core — the only layer that may import both sides — until the users module implements the seam natively, at which point this adapter is deleted. A nil service yields nil, and the module fails its roles endpoint closed.
func NewSEOPublishedPages ¶
func NewSEOPublishedPages(content *contentdomain.Service) seoapi.PublishedPages
NewSEOPublishedPages adapts the content service to the seo module's sitemap seam: published items in, sitemap-relevant projections out. It lives in core — the only layer that may import both sides — until a later phase moves the seam. Lookup failures propagate for the handler's 500 path.
func NewSiteSSRContentReader ¶
func NewSiteSSRContentReader( content *contentservice.Service, comments *commentdomain.Service, ) sitessr.ContentReader
NewSiteSSRContentReader adapts the content and comments services to the site-ssr ContentReader seam.
Types ¶
type AuthNotificationRecorder ¶
type AuthNotificationRecorder struct {
// contains filtered or unexported fields
}
AuthNotificationRecorder adapts the notification repository to the auth module's NotificationRecorder seam. Message formatting (HTML-escaped, matching the pre-module handler text byte-for-byte) lives here so the module never imports repository notification types. It lives in core — the only layer that may import both sides.
func NewAuthNotificationRecorder ¶
func NewAuthNotificationRecorder(repo repository.NotificationRepo) *AuthNotificationRecorder
NewAuthNotificationRecorder creates an AuthNotificationRecorder.
func (*AuthNotificationRecorder) RecordUserRegistered ¶
func (r *AuthNotificationRecorder) RecordUserRegistered(ctx context.Context, username, email string) error
RecordUserRegistered records a new-registration admin notification.
func (*AuthNotificationRecorder) RecordUserVerified ¶
func (r *AuthNotificationRecorder) RecordUserVerified(ctx context.Context, username, email string) error
RecordUserVerified records an email-verified admin notification.
type CommentServiceAdapter ¶
type CommentServiceAdapter struct {
*contentservice.Service
Comments *commentdomain.Service
}
CommentServiceAdapter combines the content service with the comments module service for the surfaces that need both: the browser and agent comment handlers and the contentpage assembler. Content lookups promote from the embedded content service; comment operations delegate to the comments service. It lives in core — the only layer that may import both sides — so routes and handlers stay on a single dependency.
func NewCommentServiceAdapter ¶
func NewCommentServiceAdapter( content *contentservice.Service, comments *commentdomain.Service, ) *CommentServiceAdapter
NewCommentServiceAdapter combines the content service with the comments module service for the surfaces that need both (see CommentServiceAdapter).
func (*CommentServiceAdapter) CountComments ¶
CountComments returns the total number of comments in the given scope.
func (*CommentServiceAdapter) DeleteComment ¶
func (a *CommentServiceAdapter) DeleteComment(ctx context.Context, commentID int) error
DeleteComment removes a comment by ID (admin path).
func (*CommentServiceAdapter) DeleteOwnComment ¶
func (a *CommentServiceAdapter) DeleteOwnComment(ctx context.Context, commentID int, principal kernel.Principal) error
DeleteOwnComment removes a comment owned by the caller's user ID.
func (*CommentServiceAdapter) GetComment ¶
func (a *CommentServiceAdapter) GetComment(ctx context.Context, commentID int) (*commentdomain.Comment, error)
GetComment returns a single comment by ID.
func (*CommentServiceAdapter) GetCommentsByStatus ¶
func (a *CommentServiceAdapter) GetCommentsByStatus(ctx context.Context, status commentdomain.CommentStatus) ([]*commentdomain.Comment, error)
GetCommentsByStatus returns comments in the given moderation status.
func (*CommentServiceAdapter) GetCommentsByUserID ¶
func (a *CommentServiceAdapter) GetCommentsByUserID(ctx context.Context, userID int) ([]*commentdomain.Comment, error)
GetCommentsByUserID returns the given user's comments in newest-first order.
func (*CommentServiceAdapter) GetCommentsForContent ¶
func (a *CommentServiceAdapter) GetCommentsForContent(ctx context.Context, contentID int) ([]*commentdomain.Comment, error)
GetCommentsForContent returns the approved comments visible on a content item.
func (*CommentServiceAdapter) GetCommentsForModeration ¶
func (a *CommentServiceAdapter) GetCommentsForModeration(ctx context.Context, contentID int) ([]*commentdomain.Comment, error)
GetCommentsForModeration returns every comment on a content item in any status for the moderation queue.
func (*CommentServiceAdapter) SubmitComment ¶
func (a *CommentServiceAdapter) SubmitComment( ctx context.Context, contentID int, principal kernel.Principal, req commentdomain.CreateCommentRequest, ) (*commentdomain.Comment, error)
SubmitComment validates the text, enforces the target's AllowComments gate, and persists the comment in the pending moderation status.
func (*CommentServiceAdapter) UpdateCommentStatus ¶
func (a *CommentServiceAdapter) UpdateCommentStatus(ctx context.Context, commentID int, status commentdomain.CommentStatus) error
UpdateCommentStatus moves a comment to a validated moderation status.
type ProfilePictureUserRepo ¶
type ProfilePictureUserRepo struct {
// contains filtered or unexported fields
}
ProfilePictureUserRepo adapts repository.UserRepo to the users module's profilepicture.UserRepo seam. It lives in core — the only layer that may import both sides.
func NewProfilePictureUserRepo ¶
func NewProfilePictureUserRepo(repo repository.UserRepo) *ProfilePictureUserRepo
NewProfilePictureUserRepo creates a ProfilePictureUserRepo.
func (*ProfilePictureUserRepo) DeleteProfilePicture ¶
func (r *ProfilePictureUserRepo) DeleteProfilePicture(ctx context.Context, userID int) error
DeleteProfilePicture clears a user's profile picture.
func (*ProfilePictureUserRepo) GetUserByID ¶
GetUserByID returns the profile picture filename for a user.
func (*ProfilePictureUserRepo) UpdateProfilePicture ¶
func (r *ProfilePictureUserRepo) UpdateProfilePicture(ctx context.Context, userID int, profilePicture string) error
UpdateProfilePicture updates a user's profile picture filename.
type SoftDeleteStore ¶
type SoftDeleteStore struct {
// contains filtered or unexported fields
}
SoftDeleteStore adapts repository.SoftDeleteRepo to the users module's SoftDeleteStore seam. Database null types are converted at this boundary so the module never imports database/sql. It lives in core — the only layer that may import both sides.
func NewSoftDeleteStore ¶
func NewSoftDeleteStore(repo repository.SoftDeleteRepo) *SoftDeleteStore
NewSoftDeleteStore creates a SoftDeleteStore.
func (*SoftDeleteStore) GetSoftDeletedContentByID ¶
func (s *SoftDeleteStore) GetSoftDeletedContentByID(ctx context.Context, id int) (*usersapi.SoftDeletedContent, error)
GetSoftDeletedContentByID returns one soft-deleted content record.
func (*SoftDeleteStore) GetSoftDeletedContentByUser ¶
func (s *SoftDeleteStore) GetSoftDeletedContentByUser(ctx context.Context, userID int) ([]*usersapi.SoftDeletedContent, error)
GetSoftDeletedContentByUser returns the soft-deleted content of a user.
func (*SoftDeleteStore) RestoreContent ¶
func (s *SoftDeleteStore) RestoreContent(ctx context.Context, contentType string, contentID int) error
RestoreContent restores soft-deleted content.
type UserCredentialPolicy ¶
type UserCredentialPolicy struct{}
UserCredentialPolicy adapts the platform credential rules to the users module's CredentialPolicy seam: email/password/username syntax from internal/auth plus the registration username rule from the auth module. Password hashing uses the platform argon2id parameters, so hashes remain verifiable across the move. It lives in core — the only layer that may import both sides.
func NewUserCredentialPolicy ¶
func NewUserCredentialPolicy() UserCredentialPolicy
NewUserCredentialPolicy creates a UserCredentialPolicy. The concrete value satisfies both the users and the auth CredentialPolicy seams.
func (UserCredentialPolicy) GeneratePassword ¶
func (UserCredentialPolicy) GeneratePassword(length int) (string, error)
GeneratePassword generates a random password of the given length.
func (UserCredentialPolicy) HashPassword ¶
func (UserCredentialPolicy) HashPassword(password string) (string, error)
HashPassword hashes a password with the platform parameters.
func (UserCredentialPolicy) NeedsRehash ¶
func (UserCredentialPolicy) NeedsRehash(hash string) bool
NeedsRehash reports whether a hash uses outdated parameters.
func (UserCredentialPolicy) ValidateEmail ¶
func (UserCredentialPolicy) ValidateEmail(email string) error
ValidateEmail checks email format per platform rules, translating the platform error to the module sentinel (same message, matchable without importing internal packages).
func (UserCredentialPolicy) ValidatePassword ¶
func (UserCredentialPolicy) ValidatePassword(password string) error
ValidatePassword checks password strength per platform rules, translating the platform error to the module sentinel (same message, matchable without importing internal packages).
func (UserCredentialPolicy) ValidateUsername ¶
func (UserCredentialPolicy) ValidateUsername(username string) error
ValidateUsername checks username format per the registration rule.
func (UserCredentialPolicy) VerifyPassword ¶
func (UserCredentialPolicy) VerifyPassword(hash, password string) error
VerifyPassword verifies a password against its hash.
type WordPressUserProvisioner ¶
type WordPressUserProvisioner struct {
// contains filtered or unexported fields
}
WordPressUserProvisioner adapts the user repository to the importers module's UserProvisioner seam. Account policy stays platform-side: email syntax is enforced with auth.ValidateEmail (mapped to the module's ErrInvalidEmail sentinel so job output keeps the legacy "invalid email" failure), passwords are generated and hashed here, and provisioned accounts are Contributors with verified status. It lives in core — the only layer that may import both sides.
func NewWordPressUserProvisioner ¶
func NewWordPressUserProvisioner(users authorStore) *WordPressUserProvisioner
NewWordPressUserProvisioner creates a WordPressUserProvisioner.
func (*WordPressUserProvisioner) CreateAuthor ¶
func (p *WordPressUserProvisioner) CreateAuthor(ctx context.Context, username, email, name string) (*wordpress.AuthorAccount, error)
CreateAuthor provisions a Contributor with verified status and a platform-generated password, returning the new account with its ID populated.
func (*WordPressUserProvisioner) FindByEmail ¶
func (p *WordPressUserProvisioner) FindByEmail(ctx context.Context, email string) (*wordpress.AuthorAccount, error)
FindByEmail returns the author account for email, or (nil, nil) when no account exists.
func (*WordPressUserProvisioner) FindByUsername ¶
func (p *WordPressUserProvisioner) FindByUsername(ctx context.Context, username string) (*wordpress.AuthorAccount, error)
FindByUsername returns the author account for username, or (nil, nil) when no account exists.