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/<pull request number>.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 <gusted@noreply.codeberg.org>
Reviewed-by: Robert Wolff <mahlzahn@posteo.de>
Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net>
Co-committed-by: Mathieu Fenniak <mathieu@fenniak.net>
This commit is contained in:
Mathieu Fenniak 2025-10-15 21:38:51 +02:00 committed by Mathieu Fenniak
parent 6db2e23078
commit ee7a4a827a
2 changed files with 2 additions and 2 deletions

View file

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

View file

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