fix: fire RecordSaved for tags the post API creates by name
journal-tag is a content type, but tags created on the fly from names in a post write fired no event, so SEO and sitemap subscribers only heard of them from a later bulk job. Each created tag now fires a RecordSaved with Created inside the post write's transaction.
This commit is contained in:
@@ -122,6 +122,22 @@ func postSavedEvent(ctx context.Context, db *gorm.DB, before *postSnapshot, post
|
||||
}
|
||||
}
|
||||
|
||||
// tagSavedEvent is the RecordSaved of a tag a post write created by name
|
||||
// (journal-tag is a content type, D-102): Created, with its name and slug.
|
||||
func tagSavedEvent(ctx context.Context, tag *models.Tag) pact.RecordSaved {
|
||||
locale, _ := towel.Locale(ctx)
|
||||
return pact.RecordSaved{
|
||||
Model: tag.MorphName(),
|
||||
ID: strconv.FormatUint(uint64(tag.ID), 10),
|
||||
Locale: locale,
|
||||
Created: true,
|
||||
Changes: []pact.RecordChange{
|
||||
{Attribute: "name", New: tag.Name},
|
||||
{Attribute: "slug", New: tag.Slug},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// submittedTranslations lists, per locale, the translated fields a request
|
||||
// body submits with a value, in translatedEventFields order. content_html is
|
||||
// listed whenever a non-blank content is, as the write derives it from the
|
||||
|
||||
Reference in New Issue
Block a user