summaryrefslogtreecommitdiff
path: root/internal/ap
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2025-01-23 17:18:23 +0000
committerLibravatar GitHub <noreply@github.com>2025-01-23 18:18:23 +0100
commit9333bbc4d0d5ae46c72fca1f5b1aacb3c0a7653e (patch)
treee7ccd1dc3abff5386e0b86e6baf659c9aa3b55a5 /internal/ap
parent[feature] Add warning about `trusted-proxies` to make config easier (#3675) (diff)
downloadgotosocial-9333bbc4d0d5ae46c72fca1f5b1aacb3c0a7653e.tar.xz
[feature] Serve bot accounts over AP as Service instead of Person (#3672)
* pepis * oopsie doopsie * bollocks
Diffstat (limited to 'internal/ap')
-rw-r--r--internal/ap/activitystreams.go16
-rw-r--r--internal/ap/ap_test.go11
-rw-r--r--internal/ap/interfaces.go2
3 files changed, 23 insertions, 6 deletions
diff --git a/internal/ap/activitystreams.go b/internal/ap/activitystreams.go
index 8c53ae501..50955ce2c 100644
--- a/internal/ap/activitystreams.go
+++ b/internal/ap/activitystreams.go
@@ -17,6 +17,22 @@
package ap
+import (
+ "net/url"
+
+ "github.com/superseriousbusiness/activity/pub"
+)
+
+// PublicURI returns a fresh copy of the *url.URL version of the
+// magic ActivityPub URI https://www.w3.org/ns/activitystreams#Public
+func PublicURI() *url.URL {
+ publicURI, err := url.Parse(pub.PublicActivityPubIRI)
+ if err != nil {
+ panic(err)
+ }
+ return publicURI
+}
+
// https://www.w3.org/TR/activitystreams-vocabulary
const (
ActivityAccept = "Accept" // ActivityStreamsAccept https://www.w3.org/TR/activitystreams-vocabulary/#dfn-accept
diff --git a/internal/ap/ap_test.go b/internal/ap/ap_test.go
index f982e4443..3738c8c9c 100644
--- a/internal/ap/ap_test.go
+++ b/internal/ap/ap_test.go
@@ -24,7 +24,6 @@ import (
"io"
"github.com/stretchr/testify/suite"
- "github.com/superseriousbusiness/activity/pub"
"github.com/superseriousbusiness/activity/streams"
"github.com/superseriousbusiness/activity/streams/vocab"
"github.com/superseriousbusiness/gotosocial/internal/ap"
@@ -111,7 +110,7 @@ func noteWithMentions1() vocab.ActivityStreamsNote {
// Anyone can like.
canLikeAlwaysProp := streams.NewGoToSocialAlwaysProperty()
- canLikeAlwaysProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI))
+ canLikeAlwaysProp.AppendIRI(ap.PublicURI())
canLike.SetGoToSocialAlways(canLikeAlwaysProp)
// Empty approvalRequired.
@@ -128,7 +127,7 @@ func noteWithMentions1() vocab.ActivityStreamsNote {
// Anyone can reply.
canReplyAlwaysProp := streams.NewGoToSocialAlwaysProperty()
- canReplyAlwaysProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI))
+ canReplyAlwaysProp.AppendIRI(ap.PublicURI())
canReply.SetGoToSocialAlways(canReplyAlwaysProp)
// Set empty approvalRequired.
@@ -151,7 +150,7 @@ func noteWithMentions1() vocab.ActivityStreamsNote {
// Public requires approval to announce.
canAnnounceApprovalRequiredProp := streams.NewGoToSocialApprovalRequiredProperty()
- canAnnounceApprovalRequiredProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI))
+ canAnnounceApprovalRequiredProp.AppendIRI(ap.PublicURI())
canAnnounce.SetGoToSocialApprovalRequired(canAnnounceApprovalRequiredProp)
// Set canAnnounce on the policy.
@@ -266,7 +265,7 @@ func addressable1() ap.Addressable {
note := streams.NewActivityStreamsNote()
toProp := streams.NewActivityStreamsToProperty()
- toProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI))
+ toProp.AppendIRI(ap.PublicURI())
note.SetActivityStreamsTo(toProp)
@@ -288,7 +287,7 @@ func addressable2() ap.Addressable {
note.SetActivityStreamsTo(toProp)
ccProp := streams.NewActivityStreamsCcProperty()
- ccProp.AppendIRI(testrig.URLMustParse(pub.PublicActivityPubIRI))
+ ccProp.AppendIRI(ap.PublicURI())
note.SetActivityStreamsCc(ccProp)
diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go
index 1f08fde37..fdd5e4a0b 100644
--- a/internal/ap/interfaces.go
+++ b/internal/ap/interfaces.go
@@ -188,6 +188,7 @@ type Accountable interface {
WithTag
WithPublished
WithUpdated
+ WithImage
}
// Statusable represents the minimum activitypub interface for representing a 'status'.
@@ -439,6 +440,7 @@ type WithValue interface {
// WithImage represents an activity with ActivityStreamsImageProperty
type WithImage interface {
GetActivityStreamsImage() vocab.ActivityStreamsImageProperty
+ SetActivityStreamsImage(vocab.ActivityStreamsImageProperty)
}
// WithSummary represents an activity with ActivityStreamsSummaryProperty