mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Implement GPG api (#710)
* Implement GPG API * Better handle error * Apply review recommendation + simplify database operations * Remove useless comments
This commit is contained in:
		
				
					committed by
					
						 Lunny Xiao
						Lunny Xiao
					
				
			
			
				
	
			
			
			
						parent
						
							43c5469f81
						
					
				
				
					commit
					ca1c3f1926
				
			| @@ -245,6 +245,54 @@ func (err ErrKeyNameAlreadyUsed) Error() string { | ||||
| 	return fmt.Sprintf("public key already exists [owner_id: %d, name: %s]", err.OwnerID, err.Name) | ||||
| } | ||||
|  | ||||
| // ErrGPGKeyNotExist represents a "GPGKeyNotExist" kind of error. | ||||
| type ErrGPGKeyNotExist struct { | ||||
| 	ID int64 | ||||
| } | ||||
|  | ||||
| // IsErrGPGKeyNotExist checks if an error is a ErrGPGKeyNotExist. | ||||
| func IsErrGPGKeyNotExist(err error) bool { | ||||
| 	_, ok := err.(ErrGPGKeyNotExist) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func (err ErrGPGKeyNotExist) Error() string { | ||||
| 	return fmt.Sprintf("public gpg key does not exist [id: %d]", err.ID) | ||||
| } | ||||
|  | ||||
| // ErrGPGKeyIDAlreadyUsed represents a "GPGKeyIDAlreadyUsed" kind of error. | ||||
| type ErrGPGKeyIDAlreadyUsed struct { | ||||
| 	KeyID string | ||||
| } | ||||
|  | ||||
| // IsErrGPGKeyIDAlreadyUsed checks if an error is a ErrKeyNameAlreadyUsed. | ||||
| func IsErrGPGKeyIDAlreadyUsed(err error) bool { | ||||
| 	_, ok := err.(ErrGPGKeyIDAlreadyUsed) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| func (err ErrGPGKeyIDAlreadyUsed) Error() string { | ||||
| 	return fmt.Sprintf("public key already exists [key_id: %s]", err.KeyID) | ||||
| } | ||||
|  | ||||
| // ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error. | ||||
| type ErrGPGKeyAccessDenied struct { | ||||
| 	UserID int64 | ||||
| 	KeyID  int64 | ||||
| } | ||||
|  | ||||
| // IsErrGPGKeyAccessDenied checks if an error is a ErrGPGKeyAccessDenied. | ||||
| func IsErrGPGKeyAccessDenied(err error) bool { | ||||
| 	_, ok := err.(ErrGPGKeyAccessDenied) | ||||
| 	return ok | ||||
| } | ||||
|  | ||||
| // Error pretty-prints an error of type ErrGPGKeyAccessDenied. | ||||
| func (err ErrGPGKeyAccessDenied) Error() string { | ||||
| 	return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d]", | ||||
| 		err.UserID, err.KeyID) | ||||
| } | ||||
|  | ||||
| // ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error. | ||||
| type ErrKeyAccessDenied struct { | ||||
| 	UserID int64 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user