summaryrefslogtreecommitdiff
path: root/internal/typeutils/astointernal.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/typeutils/astointernal.go')
-rw-r--r--internal/typeutils/astointernal.go50
1 files changed, 16 insertions, 34 deletions
diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go
index 81dbc6f40..92465c790 100644
--- a/internal/typeutils/astointernal.go
+++ b/internal/typeutils/astointernal.go
@@ -216,40 +216,10 @@ func (c *Converter) ASRepresentationToAccount(ctx context.Context, accountable a
return acct, nil
}
-func (c *Converter) extractAttachments(i ap.WithAttachment) []*gtsmodel.MediaAttachment {
- attachmentProp := i.GetActivityStreamsAttachment()
- if attachmentProp == nil {
- return nil
- }
-
- attachments := make([]*gtsmodel.MediaAttachment, 0, attachmentProp.Len())
-
- for iter := attachmentProp.Begin(); iter != attachmentProp.End(); iter = iter.Next() {
- t := iter.GetType()
- if t == nil {
- continue
- }
-
- attachmentable, ok := t.(ap.Attachmentable)
- if !ok {
- log.Error(nil, "ap attachment was not attachmentable")
- continue
- }
-
- attachment, err := ap.ExtractAttachment(attachmentable)
- if err != nil {
- log.Errorf(nil, "error extracting attachment: %s", err)
- continue
- }
-
- attachments = append(attachments, attachment)
- }
-
- return attachments
-}
-
// ASStatus converts a remote activitystreams 'status' representation into a gts model status.
func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusable) (*gtsmodel.Status, error) {
+ var err error
+
status := new(gtsmodel.Status)
// status.URI
@@ -281,7 +251,19 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
// status.Attachments
//
// Media attachments for later dereferencing.
- status.Attachments = c.extractAttachments(statusable)
+ status.Attachments, err = ap.ExtractAttachments(statusable)
+ if err != nil {
+ l.Warnf("error(s) extracting attachments: %v", err)
+ }
+
+ // status.Poll
+ //
+ // Attached poll information (the statusable will actually
+ // be a Pollable, as a Question is a subset of our Status).
+ if pollable, ok := ap.ToPollable(statusable); ok {
+ // TODO: handle decoding poll data
+ _ = pollable
+ }
// status.Hashtags
//
@@ -341,7 +323,7 @@ func (c *Converter) ASStatusToStatus(ctx context.Context, statusable ap.Statusab
// error if we don't.
attributedTo, err := ap.ExtractAttributedToURI(statusable)
if err != nil {
- return nil, gtserror.Newf("%w", err)
+ return nil, gtserror.Newf("error extracting attributed to uri: %w", err)
}
accountURI := attributedTo.String()