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:
2026-10-27 15:37:02 +01:00
parent 7a03640b88
commit a6fc7cd954
5 changed files with 76 additions and 19 deletions

View File

@@ -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