feat: purge the site cache after SEO writes

- every write that records history (admin, MCP, batch, import, undo,
  automatic) queues the framework's site-cache purge (kind seo, slug the
  address or * for settings and robots.txt) after its commit, once per
  transaction; a rolled-back write never purges
- the record-deleted cleanup and the address tracking of saves outside the
  admin run in lagoon transactions, so their history purges as well
This commit is contained in:
Jakub Zych
2026-11-04 13:44:12 +01:00
parent 59f0457c69
commit 2dfc606cdc
4 changed files with 171 additions and 2 deletions

View File

@@ -7,6 +7,7 @@ import (
"git.golem15.com/golem15/sm-seo-plugin/models"
"git.golem15.com/golem15/summercms/modules/conga"
"git.golem15.com/golem15/summercms/modules/lagoon"
"git.golem15.com/golem15/summercms/modules/pact"
"gorm.io/gorm"
)
@@ -193,7 +194,9 @@ func (s *Service) RecordDeleted(ctx context.Context, ev *pact.RecordDeleted) err
return err
}
ctx = WithVia(ctx, models.ViaAuto)
return db.Transaction(func(tx *gorm.DB) error {
// A lagoon transaction, so the history it records purges the site
// cache after the commit.
return lagoon.Transaction(ctx, db, func(ctx context.Context, tx *gorm.DB) error {
entries, err := LoadEntries(tx, typ.Content.Model, ev.ID)
if err != nil || len(entries) == 0 {
return err