mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 07:21:36 +01:00 
			
		
		
		
	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. * PublicKey 1. _last_used_at_: string($date-time) * AccessToken 1. _created_at_: string($date-time) (for parity with public keys) 2. _last_used_at_: string($date-time) Fix #34313 Co-authored-by: Tobias Balle-Petersen <tobiasbp@gmail.com>
		
			
				
	
	
		
			24 lines
		
	
	
		
			693 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			693 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2015 The Gogs Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package structs
 | |
| 
 | |
| import (
 | |
| 	"time"
 | |
| )
 | |
| 
 | |
| // PublicKey publickey is a user key to push code to repository
 | |
| type PublicKey struct {
 | |
| 	ID          int64  `json:"id"`
 | |
| 	Key         string `json:"key"`
 | |
| 	URL         string `json:"url,omitempty"`
 | |
| 	Title       string `json:"title,omitempty"`
 | |
| 	Fingerprint string `json:"fingerprint,omitempty"`
 | |
| 	// swagger:strfmt date-time
 | |
| 	Created  time.Time `json:"created_at,omitempty"`
 | |
| 	Updated  time.Time `json:"last_used_at,omitempty"`
 | |
| 	Owner    *User     `json:"user,omitempty"`
 | |
| 	ReadOnly bool      `json:"read_only,omitempty"`
 | |
| 	KeyType  string    `json:"key_type,omitempty"`
 | |
| }
 |