Return 401s when logged out of more activitypub api endpoints (#750)

Co-authored-by: slothful-vassal <89943360+slothful-vassal@users.noreply.github.com>
This commit is contained in:
Robert Clarke
2026-01-31 22:04:56 +00:00
committed by GitHub
parent 1005aa0a84
commit 029f1f134b
10 changed files with 82 additions and 22 deletions

View File

@@ -4,6 +4,7 @@ import (
"crypto/x509"
"database/sql"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
@@ -19,6 +20,8 @@ import (
"github.com/pocketbase/pocketbase/tools/security"
)
var ErrProfilePrivate = errors.New("profile is private")
type WebfingerResponse struct {
Subject string `json:"subject"`
Links []struct {
@@ -220,7 +223,7 @@ func assembleActor(actor *core.Record, dbActor *core.Record, app core.App, inclu
}
if private {
return dbActor, fmt.Errorf("profile is private")
return dbActor, ErrProfilePrivate
}
return dbActor, nil
@@ -361,7 +364,7 @@ func FetchCollection(actor *core.Record, url string) (*pub.OrderedCollection, er
}
if resp.StatusCode != http.StatusOK {
if resp.StatusCode == http.StatusNotFound {
return nil, fmt.Errorf("profile is private")
return nil, ErrProfilePrivate
}
return nil, fmt.Errorf("collection fetch %s returned: %v", url, resp.StatusCode)
}