mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-04-14 02:51:35 +02:00
user: move ActivityPub related functions to own file
This commit is contained in:
parent
a018da0378
commit
28019fc67a
2 changed files with 25 additions and 14 deletions
25
models/user/activitypub.go
Normal file
25
models/user/activitypub.go
Normal 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"
|
||||
}
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue