Use the Repository AttributedTo to get owner IRI
This commit is contained in:
parent
f1e61af242
commit
ee85f7d957
2 changed files with 1 additions and 18 deletions
|
@ -77,17 +77,3 @@ func repositoryIRIToRepository(ctx context.Context, repoIRI ap.IRI) (*repo_model
|
||||||
// TODO: create remote repo if not exists
|
// TODO: create remote repo if not exists
|
||||||
return repo_model.GetRepositoryByOwnerAndName(username, reponame)
|
return repo_model.GetRepositoryByOwnerAndName(username, reponame)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the IRI of the owner of a Repository actor IRI
|
|
||||||
func repositoryIRIToOwnerIRI(repoIRI ap.IRI) (ap.IRI, error) {
|
|
||||||
r := repoIRI.String()
|
|
||||||
rSplit := strings.Split(r, "/")
|
|
||||||
if len(rSplit) < 5 {
|
|
||||||
return "", errors.New("not a Repository actor IRI")
|
|
||||||
}
|
|
||||||
|
|
||||||
username := rSplit[len(rSplit)-2]
|
|
||||||
reponame := rSplit[len(rSplit)-1]
|
|
||||||
ownerIRI := ap.IRI(strings.TrimSuffix(r, "repo/"+username+"/"+reponame) + "user/" + username)
|
|
||||||
return ownerIRI, nil
|
|
||||||
}
|
|
||||||
|
|
|
@ -14,10 +14,7 @@ import (
|
||||||
|
|
||||||
// Create a new federated repo from a Repository object
|
// Create a new federated repo from a Repository object
|
||||||
func FederatedRepoNew(ctx context.Context, repository *forgefed.Repository) error {
|
func FederatedRepoNew(ctx context.Context, repository *forgefed.Repository) error {
|
||||||
ownerIRI, err := repositoryIRIToOwnerIRI(repository.GetLink())
|
ownerIRI := repository.AttributedTo.GetLink()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
user, err := personIRIToUser(ctx, ownerIRI)
|
user, err := personIRIToUser(ctx, ownerIRI)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue