fix: IndexNow hears of deleted and edited records

RecordDeleted marks the listed rows it excludes and RecordSaved the rows
whose lastmod it moves (indexnow_pending_at); the next rebuild sends
them to IndexNow as removed or changed and clears the marks. RecordSaved
checks for a nil event before reading it. TestIndexNow now deletes and
edits through the record events, as the admin does.
This commit is contained in:
Jakub Zych
2026-11-04 23:02:09 +01:00
parent 6b67ab759b
commit f58d55555c
8 changed files with 147 additions and 12 deletions

View File

@@ -51,7 +51,10 @@ type Ref struct {
// its sitemap-images file (nil while it has none). Kind is the content
// type's kind (pact.ContentKindArticle and the others), PublishedAt the
// record's first publication and ParentRefs its parents, for the News
// sitemap and the HTML sitemap.
// sitemap and the HTML sitemap. IndexNowPendingAt is set by the record
// listeners on a row the next rebuild sends to IndexNow (a deleted
// record's listed row, an edited record's row whose lastmod moved) and
// cleared by that rebuild.
type URL struct {
ID uint64 `gorm:"column:id;primaryKey"`
Grp string `gorm:"column:grp"`
@@ -71,6 +74,8 @@ type URL struct {
ParentRefs lagoon.Jsonable[[]Ref] `gorm:"column:parent_refs"`
ExcludedReason string `gorm:"column:excluded_reason"`
UpdatedAt time.Time `gorm:"column:updated_at"`
// IndexNowPendingAt (P33-62).
IndexNowPendingAt *time.Time `gorm:"column:indexnow_pending_at"`
}
func (URL) TableName() string { return "golem15_sitemap_urls" }