mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-14 21:22:22 +00:00
fix: assorted ActivityPub code only refactors (#8274)
Fix parts of issue https://codeberg.org/forgejo/forgejo/issues/8221 and PR https://codeberg.org/forgejo/forgejo/pulls/4767 - PostgreSQL - TestActivityPubPerson/SignedRequestValidation ``` --- FAIL: TestActivityPubPerson/SignedRequestValidation (5.01s) api_activitypub_person_test.go:51: Error Trace: /workspace/forgejo/forgejo/tests/integration/api_activitypub_person_test.go:51 Error: Received unexpected error: Get "http://127.0.0.1:3002/api/v1/activitypub/user-id/2": context deadline exceeded (Client.Timeout exceeded while awaiting headers) Test: TestActivityPubPerson/SignedRequestValidation testlogger.go:411: 2025/06/24 00:12:27 ...eb/routing/logger.go:102:func1() [I] router: completed GET /api/v1/activitypub/user-id/2 for 127.0.0.1:50456, 200 OK in 5032.2ms @ activitypub/person.go:21(activitypub.Person) ``` Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8274 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Michael Jerger <michael.jerger@meissa-gmbh.de> Co-committed-by: Michael Jerger <michael.jerger@meissa-gmbh.de>
This commit is contained in:
parent
fe22e2397c
commit
e271c24100
20 changed files with 741 additions and 69 deletions
|
@ -4,6 +4,7 @@
|
|||
package federation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/x509"
|
||||
"database/sql"
|
||||
"encoding/pem"
|
||||
|
@ -15,13 +16,12 @@ import (
|
|||
"forgejo.org/models/user"
|
||||
"forgejo.org/modules/activitypub"
|
||||
fm "forgejo.org/modules/forgefed"
|
||||
context_service "forgejo.org/services/context"
|
||||
|
||||
ap "github.com/go-ap/activitypub"
|
||||
)
|
||||
|
||||
// Factory function for ActorID. Created struct is asserted to be valid
|
||||
func NewActorIDFromKeyID(ctx *context_service.Base, uri string) (fm.ActorID, error) {
|
||||
func NewActorIDFromKeyID(ctx context.Context, uri string) (fm.ActorID, error) {
|
||||
parsedURI, err := url.Parse(uri)
|
||||
parsedURI.Fragment = ""
|
||||
if err != nil {
|
||||
|
@ -54,7 +54,7 @@ func NewActorIDFromKeyID(ctx *context_service.Base, uri string) (fm.ActorID, err
|
|||
return result, err
|
||||
}
|
||||
|
||||
func FindOrCreateFederatedUserKey(ctx *context_service.Base, keyID string) (pubKey any, err error) {
|
||||
func FindOrCreateFederatedUserKey(ctx context.Context, keyID string) (pubKey any, err error) {
|
||||
var federatedUser *user.FederatedUser
|
||||
var keyURL *url.URL
|
||||
|
||||
|
@ -122,7 +122,7 @@ func FindOrCreateFederatedUserKey(ctx *context_service.Base, keyID string) (pubK
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func FindOrCreateFederationHostKey(ctx *context_service.Base, keyID string) (pubKey any, err error) {
|
||||
func FindOrCreateFederationHostKey(ctx context.Context, keyID string) (pubKey any, err error) {
|
||||
keyURL, err := url.Parse(keyID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -183,8 +183,9 @@ func FindOrCreateFederationHostKey(ctx *context_service.Base, keyID string) (pub
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
func fetchKeyFromAp(ctx *context_service.Base, keyURL url.URL) (pubKey any, pubKeyBytes []byte, apPerson *ap.Person, err error) {
|
||||
func fetchKeyFromAp(ctx context.Context, keyURL url.URL) (pubKey any, pubKeyBytes []byte, apPerson *ap.Person, err error) {
|
||||
actionsUser := user.NewAPServerActor()
|
||||
|
||||
clientFactory, err := activitypub.GetClientFactory(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue