mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-21 21:05:34 +03:00
Added FederationInfo Create function
This commit is contained in:
parent
380d3db0bf
commit
1f989f2ecd
3 changed files with 19 additions and 16 deletions
|
@ -42,3 +42,11 @@ func FindFederationInfoByHostFqdn(ctx context.Context, fqdn string) (*Federation
|
|||
}
|
||||
return info, nil
|
||||
}
|
||||
|
||||
func CreateFederationInfo(ctx context.Context, info FederationInfo) error {
|
||||
if res, err := validation.IsValid(info); !res {
|
||||
return fmt.Errorf("FederationInfo is not valid: %v", err)
|
||||
}
|
||||
_, err := db.GetEngine(ctx).Insert(info)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ func RepositoryInbox(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
federationInfo = &result
|
||||
log.Info("RepositoryInbox: nodeInfo validated: %v", federationInfo)
|
||||
log.Info("RepositoryInbox: federationInfo validated: %v", federationInfo)
|
||||
}
|
||||
|
||||
actorID, err := forgefed.NewPersonID(actorUri, string(federationInfo.NodeInfo.Source))
|
||||
|
@ -222,6 +222,10 @@ func createFederationInfo(ctx *context.APIContext, actorID forgefed.ActorID) (fo
|
|||
HostFqdn: actorID.Host,
|
||||
NodeInfo: nodeInfo,
|
||||
}
|
||||
err = forgefed.CreateFederationInfo(ctx, result)
|
||||
if err != nil {
|
||||
return forgefed.FederationInfo{}, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
|
|
21
templates/swagger/v1_json.tmpl
generated
21
templates/swagger/v1_json.tmpl
generated
|
@ -71,7 +71,7 @@
|
|||
"name": "body",
|
||||
"in": "body",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/Star"
|
||||
"$ref": "#/definitions/ForgeLike"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
@ -20480,6 +20480,11 @@
|
|||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"ForgeLike": {
|
||||
"description": "ForgeLike activity data type",
|
||||
"type": "object",
|
||||
"x-go-package": "code.gitea.io/gitea/models/forgefed"
|
||||
},
|
||||
"GPGKey": {
|
||||
"description": "GPGKey a user GPG key to sign commit and tag in repository",
|
||||
"type": "object",
|
||||
|
@ -23178,20 +23183,6 @@
|
|||
},
|
||||
"x-go-package": "code.gitea.io/gitea/modules/structs"
|
||||
},
|
||||
"SourceType": {
|
||||
"type": "string",
|
||||
"x-go-package": "code.gitea.io/gitea/models/forgefed"
|
||||
},
|
||||
"Star": {
|
||||
"description": "Star activity data type",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"Source": {
|
||||
"$ref": "#/definitions/SourceType"
|
||||
}
|
||||
},
|
||||
"x-go-package": "code.gitea.io/gitea/models/forgefed"
|
||||
},
|
||||
"StateType": {
|
||||
"description": "StateType issue state type",
|
||||
"type": "string",
|
||||
|
|
Loading…
Reference in a new issue