1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-24 08:57:03 -05:00

rename fxct name

This commit is contained in:
Michael Jerger 2024-05-17 08:15:33 +02:00
parent 86db5f612c
commit 07659a5e7e
7 changed files with 14 additions and 14 deletions

View file

@ -345,10 +345,10 @@ func (repo *Repository) APIURL() string {
return setting.AppURL + "api/v1/repos/" + url.PathEscape(repo.OwnerName) + "/" + url.PathEscape(repo.Name)
}
// APAPIURL returns the activitypub repository API URL
// APActorID returns the activitypub repository API URL
// TODO: At least camel case?
// TODO: Mv federation related stuff to federated_repo
func (repo *Repository) APAPIURL() string {
func (repo *Repository) APActorID() string {
// TODO: use spintf instead of concat - might mitigate injections
return fmt.Sprintf("%vapi/v1/activitypub/repository-id/%v", setting.AppURL, url.PathEscape(fmt.Sprint(repo.ID)))
}

View file

@ -219,11 +219,11 @@ func TestComposeSSHCloneURL(t *testing.T) {
assert.Equal(t, "ssh://git@[::1]:123/user/repo.git", repo_model.ComposeSSHCloneURL("user", "repo"))
}
func TestAPAPIURL(t *testing.T) {
func TestAPActorID(t *testing.T) {
repo := repo_model.Repository{ID: 1}
url := repo.APAPIURL()
url := repo.APActorID()
expected := "https://try.gitea.io/api/v1/activitypub/repository-id/1"
if url != expected {
t.Errorf("unexpected APAPIURL, expected: %q, actual: %q", expected, url)
t.Errorf("unexpected APActorID, expected: %q, actual: %q", expected, url)
}
}

View file

@ -307,8 +307,8 @@ func (u *User) HTMLURL() string {
return setting.AppURL + url.PathEscape(u.Name)
}
// APAPIURL returns the IRI to the api endpoint of the user
func (u *User) APAPIURL() string {
// APActorID returns the IRI to the api endpoint of the user
func (u *User) APActorID() string {
return fmt.Sprintf("%vapi/v1/activitypub/user-id/%v", setting.AppURL, url.PathEscape(fmt.Sprintf("%v", u.ID)))
}

View file

@ -108,12 +108,12 @@ func TestGetAllUsers(t *testing.T) {
assert.False(t, found[user_model.UserTypeOrganization], users)
}
func TestAPAPIURL(t *testing.T) {
func TestAPActorID(t *testing.T) {
user := user_model.User{ID: 1}
url := user.APAPIURL()
url := user.APActorID()
expected := "https://try.gitea.io/api/v1/activitypub/user-id/1"
if url != expected {
t.Errorf("unexpected APAPIURL, expected: %q, actual: %q", expected, url)
t.Errorf("unexpected APActorID, expected: %q, actual: %q", expected, url)
}
}

View file

@ -582,7 +582,7 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
ctx.Data["Title"] = owner.Name + "/" + repo.Name
ctx.Data["Repository"] = repo
ctx.Data["RepositoryAPAPIURL"] = repo.APAPIURL()
ctx.Data["RepositoryAPActorID"] = repo.APActorID()
ctx.Data["Owner"] = ctx.Repo.Repository.Owner
ctx.Data["IsRepositoryOwner"] = ctx.Repo.IsOwner()
ctx.Data["IsRepositoryAdmin"] = ctx.Repo.IsAdmin()

View file

@ -255,14 +255,14 @@ func SendLikeActivities(ctx context.Context, doer user.User, repoID int64) error
for _, followingRepo := range followingRepos {
log.Info("Found following repo: %v", followingRepo)
target := followingRepo.URI
likeActivity, err := fm.NewForgeLike(doer.APAPIURL(), target, time.Now())
likeActivity, err := fm.NewForgeLike(doer.APActorID(), target, time.Now())
if err != nil {
return err
}
likeActivityList = append(likeActivityList, likeActivity)
}
apclient, err := activitypub.NewClient(ctx, &doer, doer.APAPIURL())
apclient, err := activitypub.NewClient(ctx, &doer, doer.APActorID())
if err != nil {
return err
}

View file

@ -73,7 +73,7 @@
<input type="hidden" name="action" value="federation">
<div class="field {{if .Err_FollowingRepos}}error{{end}}">
<p>{{ctx.Locale.Tr "repo.settings.federation_apapiurl"}}</p>
<p><b>{{.RepositoryAPAPIURL}}</b></p>
<p><b>{{.RepositoryAPActorID}}</b></p>
<div class="divider"></div>
<label for="following_repos">{{ctx.Locale.Tr "repo.settings.federation_following_repos"}}</label>
<input id="following_repos" name="federation_repos" value="{{.FollowingRepos}}">