Use the Repository AttributedTo to get owner IRI
parent
f1e61af242
commit
ee85f7d957
|
@ -77,17 +77,3 @@ func repositoryIRIToRepository(ctx context.Context, repoIRI ap.IRI) (*repo_model
|
|||
// TODO: create remote repo if not exists
|
||||
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
|
||||
func FederatedRepoNew(ctx context.Context, repository *forgefed.Repository) error {
|
||||
ownerIRI, err := repositoryIRIToOwnerIRI(repository.GetLink())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ownerIRI := repository.AttributedTo.GetLink()
|
||||
user, err := personIRIToUser(ctx, ownerIRI)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue