user: move ActivityPub related functions to own file

This commit is contained in:
famfo 2025-02-26 02:32:30 +01:00
parent a018da0378
commit 28019fc67a
No known key found for this signature in database
2 changed files with 25 additions and 14 deletions

View file

@ -0,0 +1,25 @@
// Copyright 2025 The Forgejo Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package user
import (
"fmt"
"net/url"
"forgejo.org/modules/setting"
)
// APActorID returns the IRI to the api endpoint of the user
func (u *User) APActorID() string {
if u.ID == APActorUserID {
return fmt.Sprintf("%vapi/v1/activitypub/actor", setting.AppURL)
}
return fmt.Sprintf("%vapi/v1/activitypub/user-id/%v", setting.AppURL, url.PathEscape(fmt.Sprintf("%v", u.ID)))
}
// APActorKeyID returns the ID of the user's public key
func (u *User) APActorKeyID() string {
return u.APActorID() + "#main-key"
}

View file

@ -311,20 +311,6 @@ func (u *User) HTMLURL() string {
return setting.AppURL + url.PathEscape(u.Name)
}
// APActorID returns the IRI to the api endpoint of the user
func (u *User) APActorID() string {
if u.ID == APActorUserID {
return fmt.Sprintf("%vapi/v1/activitypub/actor", setting.AppURL)
}
return fmt.Sprintf("%vapi/v1/activitypub/user-id/%v", setting.AppURL, url.PathEscape(fmt.Sprintf("%v", u.ID)))
}
// APActorKeyID returns the ID of the user's public key
func (u *User) APActorKeyID() string {
return u.APActorID() + "#main-key"
}
// OrganisationLink returns the organization sub page link.
func (u *User) OrganisationLink() string {
return setting.AppSubURL + "/org/" + url.PathEscape(u.Name)