diff options
author | 2024-07-26 12:04:28 +0200 | |
---|---|---|
committer | 2024-07-26 12:04:28 +0200 | |
commit | 8ab2b19a946251f258446d22f420d401f61d22f6 (patch) | |
tree | 39fb674f135fd1cfcf4de5b319913f0d0c17d11a /internal/ap/interfaces.go | |
parent | [docs] Add separate migration section + instructions for moving to GtS and no... (diff) | |
download | gotosocial-8ab2b19a946251f258446d22f420d401f61d22f6.tar.xz |
[feature] Federate interaction policies + Accepts; enforce policies (#3138)
* [feature] Federate interaction policies + Accepts; enforce policies
* use Acceptable type
* fix index
* remove appendIRIStrs
* add GetAccept federatingdb function
* lock on object IRI
Diffstat (limited to 'internal/ap/interfaces.go')
-rw-r--r-- | internal/ap/interfaces.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go index 8f2e17c09..a721fa997 100644 --- a/internal/ap/interfaces.go +++ b/internal/ap/interfaces.go @@ -124,6 +124,24 @@ func ToPollOptionable(t vocab.Type) (PollOptionable, bool) { return note, true } +// IsAccept returns whether AS vocab type name +// is something that can be cast to Accept. +func IsAcceptable(typeName string) bool { + return typeName == ActivityAccept +} + +// ToAcceptable safely tries to cast vocab.Type as vocab.ActivityStreamsAccept. +// +// TODO: Add additional "Accept" types here, eg., "ApproveReply" from +// https://codeberg.org/fediverse/fep/src/branch/main/fep/5624/fep-5624.md +func ToAcceptable(t vocab.Type) (vocab.ActivityStreamsAccept, bool) { + acceptable, ok := t.(vocab.ActivityStreamsAccept) + if !ok || !IsAcceptable(t.GetTypeName()) { + return nil, false + } + return acceptable, true +} + // Activityable represents the minimum activitypub interface for representing an 'activity'. // (see: IsActivityable() for types implementing this, though you MUST make sure to check // the typeName as this bare interface may be implementable by non-Activityable types). @@ -188,6 +206,8 @@ type Statusable interface { WithAttachment WithTag WithReplies + WithInteractionPolicy + WithApprovedBy } // Pollable represents the minimum activitypub interface for representing a 'poll' (it's a subset of a status). @@ -217,6 +237,12 @@ type PollOptionable interface { WithAttributedTo } +// Acceptable represents the minimum activitypub +// interface for representing an Accept. +type Acceptable interface { + Activityable +} + // Attachmentable represents the minimum activitypub interface for representing a 'mediaAttachment'. (see: IsAttachmentable). // This interface is fulfilled by: Audio, Document, Image, Video type Attachmentable interface { @@ -657,3 +683,21 @@ type WithVotersCount interface { GetTootVotersCount() vocab.TootVotersCountProperty SetTootVotersCount(vocab.TootVotersCountProperty) } + +// WithReplies represents an object with GoToSocialInteractionPolicy. +type WithInteractionPolicy interface { + GetGoToSocialInteractionPolicy() vocab.GoToSocialInteractionPolicyProperty + SetGoToSocialInteractionPolicy(vocab.GoToSocialInteractionPolicyProperty) +} + +// WithPolicyRules represents an activity with always and approvalRequired properties. +type WithPolicyRules interface { + GetGoToSocialAlways() vocab.GoToSocialAlwaysProperty + GetGoToSocialApprovalRequired() vocab.GoToSocialApprovalRequiredProperty +} + +// WithApprovedBy represents a Statusable with the approvedBy property. +type WithApprovedBy interface { + GetGoToSocialApprovedBy() vocab.GoToSocialApprovedByProperty + SetGoToSocialApprovedBy(vocab.GoToSocialApprovedByProperty) +} |