From ee7a4a827afa9c0458cf96f0136c8019f8bbe9c9 Mon Sep 17 00:00:00 2001 From: Mathieu Fenniak Date: Wed, 15 Oct 2025 21:38:51 +0200 Subject: [PATCH] fix: OpenGraph cards for some issues show wrong timestamp (#9705) Fixes #9693. Image contents are not part of automated testing, so I manually tested this by: - Mutating the `created` field to `NULL` for a target card, verifying image generated without a cache - Double-checking by mutating the `created_unix` field for a target card, verifying image generated to correct updated date (checking my cache busting) ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/.md` to be be used for the release notes instead of the title. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/9705 Reviewed-by: Gusted Reviewed-by: Robert Wolff Co-authored-by: Mathieu Fenniak Co-committed-by: Mathieu Fenniak --- models/issues/issue.go | 2 +- routers/web/repo/card.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/issues/issue.go b/models/issues/issue.go index 14848e4c98..b1966ea50f 100644 --- a/models/issues/issue.go +++ b/models/issues/issue.go @@ -116,7 +116,7 @@ type Issue struct { DeadlineUnix timeutil.TimeStamp `xorm:"INDEX"` - Created timeutil.TimeStampNano + Created timeutil.TimeStampNano // more precise Created, but may not be populated for older issues CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"` diff --git a/routers/web/repo/card.go b/routers/web/repo/card.go index 04ea1e15b0..26e97603a9 100644 --- a/routers/web/repo/card.go +++ b/routers/web/repo/card.go @@ -330,7 +330,7 @@ func drawIssueSummaryCard(ctx *context.Context, issue *issue_model.Issue) (*card fmt.Sprintf( "%s - %s", issue.Poster.Name, - issue.Created.AsTime().Format(time.DateOnly), + issue.CreatedUnix.AsTime().Format(time.DateOnly), ), color.Gray{128}, 36, card.Middle, card.Left) if err != nil {