dereference remote media

This commit is contained in:
tsmethurst 2021-05-16 20:04:12 +02:00
commit d29ebc3d27
33 changed files with 1026 additions and 403 deletions

View file

@ -29,6 +29,7 @@ import (
"time"
"github.com/go-fed/activity/pub"
"github.com/go-fed/activity/streams"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@ -304,12 +305,24 @@ func extractAttachments(i withAttachment) ([]*gtsmodel.MediaAttachment, error) {
attachmentProp := i.GetActivityStreamsAttachment()
for iter := attachmentProp.Begin(); iter != attachmentProp.End(); iter = iter.Next() {
attachmentable, ok := iter.(Attachmentable)
t := iter.GetType()
if t == nil {
fmt.Printf("\n\n\nGetType() nil\n\n\n")
continue
}
m, _ := streams.Serialize(t)
fmt.Printf("\n\n\n%s\n\n\n", m)
attachmentable, ok := t.(Attachmentable)
if !ok {
fmt.Printf("\n\n\nnot attachmentable\n\n\n")
continue
}
attachment, err := extractAttachment(attachmentable)
if err != nil {
fmt.Printf("\n\n\n%s\n\n\n", err)
continue
}
attachments = append(attachments, attachment)
@ -343,10 +356,7 @@ func extractAttachment(i Attachmentable) (*gtsmodel.MediaAttachment, error) {
attachment.Description = name
}
blurhash, err := extractBlurhash(i)
if err == nil {
attachment.Blurhash = blurhash
}
attachment.Processing = gtsmodel.ProcessingStatusReceived
return attachment, nil
}

View file

@ -69,8 +69,6 @@ type Attachmentable interface {
withMediaType
withURL
withName
withBlurhash
withFocalPoint
}
// Hashtaggable represents the minimum activitypub interface for representing a 'hashtag' tag.

View file

@ -281,7 +281,7 @@ func (c *converter) ASStatusToStatus(statusable Statusable) (*gtsmodel.Status, e
// if it's CC'ed to public, it's public or unlocked
// mentioned SPECIFIC ACCOUNTS also get added to CC'es if it's not a direct message
if isPublic(to) {
if isPublic(cc) || isPublic(to) {
visibility = gtsmodel.VisibilityPublic
}