feat: return time of last usage for public keys and access tokens in the api (#34323) #34339
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport #34323 by @tobiasbp
In the Gitea GUI, the user can see the time that AccessTokens and PublicKeys were last used. This information is not returned by the /users/{username}/tokens and /user/keys endpoints in the API. This PR adds the missing data.
The time of last usage for for tokens & keys seem to be stored in the Updated field of the structs internally. For consistency, I have used the name updated_at for the new field returned by the API. However, for the API user, I don't think that name reflects the data returned, as I believe it is the time of last usage. I propose that we use the name last_used_at instead. Let's hear reviewers opinion on that.
Fix #34313