feat: translation flows, revision conflicts, delete scopes, article moves and a target site for new articles
This commit is contained in:
1 parent
339e646eb8
commit
45fbbc33b1
93 files changed
+7630
-294
No files matched your search
@@ -216,6 +216,7 @@ const (
|
||||
ParamAssigned = "assigned"
|
||||
ParamLang = "lang"
|
||||
ParamStoryID = "story_id"
|
||||
ParamSite = "site"
|
||||
ParamSourceArticleID = "source_article_id"
|
||||
maxNameLength = 255
|
||||
maxActionLength = 64
|
||||
|
||||
@@ -27,6 +27,7 @@ type CreateArticleCommand struct {
|
||||
Body string
|
||||
Format article.BodyFormat
|
||||
Lang string
|
||||
Site *string
|
||||
Caller ContentCaller
|
||||
}
|
||||
|
||||
@@ -34,12 +35,11 @@ func NewCreateArticleUseCase(transactor transaction.Transactor, bodyRenderer art
|
||||
return &CreateArticleUseCase{transactor: transactor, bodyRenderer: bodyRenderer, recorder: recorder, sites: sites, authors: authors}
|
||||
}
|
||||
|
||||
func (g *CreateArticleUseCase) defaultSiteID() (uint32, error) {
|
||||
defaultSite, err := g.sites.GetDefault()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
func (g *CreateArticleUseCase) targetSite(key *string) (site.Site, error) {
|
||||
if key == nil {
|
||||
return g.sites.GetDefault()
|
||||
}
|
||||
return defaultSite.ID, nil
|
||||
return g.sites.GetByKey(*key)
|
||||
}
|
||||
|
||||
func (g *CreateArticleUseCase) creatorBylines(userID uint32) ([]author.Byline, error) {
|
||||
@@ -68,7 +68,11 @@ func (g *CreateArticleUseCase) CreateArticle(ctx context.Context, createArticle
|
||||
return article.Article{}, err
|
||||
}
|
||||
|
||||
siteID, err := g.defaultSiteID()
|
||||
target, err := g.targetSite(createArticle.Site)
|
||||
if errors.Is(err, site.ErrSiteNotFound) {
|
||||
failFrom(ctx, g.recorder, event, reasonFor(err))
|
||||
return article.Article{}, err
|
||||
}
|
||||
if err != nil {
|
||||
recordFailure(ctx, g.recorder, event, err)
|
||||
return article.Article{}, err
|
||||
@@ -84,7 +88,7 @@ func (g *CreateArticleUseCase) CreateArticle(ctx context.Context, createArticle
|
||||
Title: createArticle.Title,
|
||||
Body: createArticle.Body,
|
||||
IsOnline: false,
|
||||
SiteID: siteID,
|
||||
SiteID: target.ID,
|
||||
CreatedBy: createArticle.Caller.UserID,
|
||||
Authors: creditedAuthors,
|
||||
SEODismissed: []string{},
|
||||
@@ -95,6 +99,7 @@ func (g *CreateArticleUseCase) CreateArticle(ctx context.Context, createArticle
|
||||
}
|
||||
|
||||
event = articleEvent(audit.ActionArticleCreate, created)
|
||||
event.Params[audit.ParamSite] = target.Key
|
||||
g.recorder.Record(ctx, event)
|
||||
return renderArticle(g.bodyRenderer, created, createArticle.Format)
|
||||
}
|
||||
@@ -156,7 +161,3 @@ func chooseLanguage(repository localization.Repository, siteID uint32, requested
|
||||
}
|
||||
return requested, nil
|
||||
}
|
||||
|
||||
func articleTarget(a article.Article) audit.Target {
|
||||
return audit.NewTarget(audit.TargetArticle, a.ID, a.Title)
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package useCases
|
||||
|
||||
import (
|
||||
"RenewCMS/internal/domain/article"
|
||||
"RenewCMS/internal/domain/audit"
|
||||
)
|
||||
|
||||
func articleTarget(a article.Article) audit.Target {
|
||||
return audit.NewTarget(audit.TargetArticle, a.ID, a.Title)
|
||||
}
|
||||
@@ -79,6 +79,7 @@ var failureReasons = []failureReason{
|
||||
{update.ErrNothingToUpdate, "There is nothing to update."},
|
||||
{update.ErrPreflightRefused, "The update cannot be downloaded."},
|
||||
{update.ErrRestartKindMismatch, "The requested restart does not match the server state."},
|
||||
{site.ErrSiteNotFound, "That site does not exist."},
|
||||
{site.ErrSiteKeyTaken, "A site with that key already exists."},
|
||||
{site.ErrKeyImmutable, "The key of a site cannot be changed."},
|
||||
{site.ErrDefaultSite, "The default site cannot be deleted."},
|
||||
|
||||
Reference in new issue
Block a user