forked from kevadesu/forgejo
integrate federation info in api call
This commit is contained in:
parent
52400f7978
commit
380d3db0bf
3 changed files with 32 additions and 13 deletions
|
@ -24,7 +24,6 @@ func (info FederationInfo) Validate() []string {
|
|||
var result []string
|
||||
result = append(result, validation.ValidateNotEmpty(string(info.HostFqdn), "HostFqdn")...)
|
||||
result = append(result, validation.ValidateMaxLen(string(info.HostFqdn), 255, "HostFqdn")...)
|
||||
result = append(result, validation.ValidateNotEmpty(info.LatestActivity, "LatestActivity")...)
|
||||
result = append(result, info.NodeInfo.Validate()...)
|
||||
|
||||
return result
|
||||
|
|
|
@ -29,13 +29,13 @@ func GetFederationInfo(ctx context.Context, ID int64) (*FederationInfo, error) {
|
|||
return info, nil
|
||||
}
|
||||
|
||||
func GetFederationInfoByHostFqdn(ctx context.Context, fqdn string) (*FederationInfo, error) {
|
||||
func FindFederationInfoByHostFqdn(ctx context.Context, fqdn string) (*FederationInfo, error) {
|
||||
info := new(FederationInfo)
|
||||
has, err := db.GetEngine(ctx).Where("host_fqdn=?", fqdn).Get(info)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, fmt.Errorf("FederationInfo record %v does not exist", fqdn)
|
||||
return nil, nil
|
||||
}
|
||||
if res, err := validation.IsValid(info); !res {
|
||||
return nil, fmt.Errorf("FederationInfo is not valid: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue