From f7323c065a086533ce8c7f0f0cb3f69a80539992 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Sat, 26 Apr 2025 15:03:05 +0200 Subject: [feature] Update attachment format, receive + send `focalPoint` prop + use it on the frontend (#4052) * [feature] Update attachment format, receive + send `focalPoint` prop + use it on the frontend * whoops * boop * restore function signature of ExtractAttachments --- internal/ap/interfaces.go | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'internal/ap/interfaces.go') diff --git a/internal/ap/interfaces.go b/internal/ap/interfaces.go index 1dcc6afef..28b5c0d20 100644 --- a/internal/ap/interfaces.go +++ b/internal/ap/interfaces.go @@ -165,6 +165,29 @@ func ToApprovable(t vocab.Type) (Approvable, bool) { return approvable, true } +// IsAttachmentable returns whether AS vocab type name +// is something that can be cast to Attachmentable. +func IsAttachmentable(typeName string) bool { + switch typeName { + case ObjectAudio, + ObjectDocument, + ObjectImage, + ObjectVideo: + return true + default: + return false + } +} + +// ToAttachmentable safely tries to cast vocab.Type as Attachmentable. +func ToAttachmentable(t vocab.Type) (Attachmentable, bool) { + attachmentable, ok := t.(Attachmentable) + if !ok || !IsAttachmentable(t.GetTypeName()) { + return nil, false + } + return attachmentable, 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). @@ -628,9 +651,11 @@ type WithBlurhash interface { SetTootBlurhash(vocab.TootBlurhashProperty) } -// type withFocalPoint interface { -// // TODO -// } +// WithFocalPoint represents an object with TootFocalPointProperty. +type WithFocalPoint interface { + GetTootFocalPoint() vocab.TootFocalPointProperty + SetTootFocalPoint(vocab.TootFocalPointProperty) +} // WithHref represents an activity with ActivityStreamsHrefProperty type WithHref interface { -- cgit v1.2.3