fix: store registry page timestamps in UTC

- GORM stamped created_at and updated_at in the process's local time,
  which the timestamp columns keep as the wall clock; east of UTC a page
  without a content date got a sitemap lastmod in the future
- Page.BeforeSave stamps both in UTC for the admin's and the API's saves,
  and the admin's address change writes updated_at in UTC
This commit is contained in:
Jakub Zych
2026-11-04 19:24:15 +01:00
parent 49cc241f58
commit dfc85bc805
3 changed files with 70 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package seo
import (
"context"
"sort"
"time"
"git.golem15.com/golem15/sm-seo-plugin/classes"
"git.golem15.com/golem15/sm-seo-plugin/controllers"
@@ -105,7 +106,7 @@ func (p *Plugin) pagesForm() *pact.AdminFormExtension {
return pact.AdminFormSaveResult{}, refusals
}
if err := in.DB.Model(&models.Page{}).Where("id = ?", page.ID).Updates(map[string]any{
"url": page.URL, "urls": page.URLs, "title": page.Title, "titles": page.Titles,
"url": page.URL, "urls": page.URLs, "title": page.Title, "titles": page.Titles, "updated_at": time.Now().UTC(),
}).Error; err != nil {
return pact.AdminFormSaveResult{}, err
}