diff options
Diffstat (limited to 'internal/typeutils')
-rw-r--r-- | internal/typeutils/asextractionutil.go | 38 | ||||
-rw-r--r-- | internal/typeutils/asinterfaces.go | 14 | ||||
-rw-r--r-- | internal/typeutils/astointernal.go | 2 | ||||
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 19 |
4 files changed, 36 insertions, 37 deletions
diff --git a/internal/typeutils/asextractionutil.go b/internal/typeutils/asextractionutil.go index 4ee3347bd..1c04272e0 100644 --- a/internal/typeutils/asextractionutil.go +++ b/internal/typeutils/asextractionutil.go @@ -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,23 +356,20 @@ 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 } -func extractBlurhash(i withBlurhash) (string, error) { - if i.GetTootBlurhashProperty() == nil { - return "", errors.New("blurhash property was nil") - } - if i.GetTootBlurhashProperty().Get() == "" { - return "", errors.New("empty blurhash string") - } - return i.GetTootBlurhashProperty().Get(), nil -} +// func extractBlurhash(i withBlurhash) (string, error) { +// if i.GetTootBlurhashProperty() == nil { +// return "", errors.New("blurhash property was nil") +// } +// if i.GetTootBlurhashProperty().Get() == "" { +// return "", errors.New("empty blurhash string") +// } +// return i.GetTootBlurhashProperty().Get(), nil +// } func extractHashtags(i withTag) ([]*gtsmodel.Tag, error) { tags := []*gtsmodel.Tag{} diff --git a/internal/typeutils/asinterfaces.go b/internal/typeutils/asinterfaces.go index 970ed2ecf..c31a37a25 100644 --- a/internal/typeutils/asinterfaces.go +++ b/internal/typeutils/asinterfaces.go @@ -69,8 +69,6 @@ type Attachmentable interface { withMediaType withURL withName - withBlurhash - withFocalPoint } // Hashtaggable represents the minimum activitypub interface for representing a 'hashtag' tag. @@ -212,13 +210,13 @@ type withMediaType interface { GetActivityStreamsMediaType() vocab.ActivityStreamsMediaTypeProperty } -type withBlurhash interface { - GetTootBlurhashProperty() vocab.TootBlurhashProperty -} +// type withBlurhash interface { +// GetTootBlurhashProperty() vocab.TootBlurhashProperty +// } -type withFocalPoint interface { - // TODO -} +// type withFocalPoint interface { +// // TODO +// } type withHref interface { GetActivityStreamsHref() vocab.ActivityStreamsHrefProperty diff --git a/internal/typeutils/astointernal.go b/internal/typeutils/astointernal.go index 7f0a4c1a4..4aa6e2b19 100644 --- a/internal/typeutils/astointernal.go +++ b/internal/typeutils/astointernal.go @@ -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 } diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 861350b44..e4ccab988 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -20,6 +20,7 @@ package typeutils import ( "fmt" + "strings" "time" "github.com/superseriousbusiness/gotosocial/internal/api/model" @@ -86,16 +87,12 @@ func (c *converter) AccountToMastoPublic(a *gtsmodel.Account) (*model.Account, e } // count statuses - statuses := []gtsmodel.Status{} - if err := c.db.GetStatusesByAccountID(a.ID, &statuses); err != nil { + statusesCount, err := c.db.CountStatusesByAccountID(a.ID) + if err != nil { if _, ok := err.(db.ErrNoEntries); !ok { return nil, fmt.Errorf("error getting last statuses: %s", err) } } - var statusesCount int - if statuses != nil { - statusesCount = len(statuses) - } // check when the last status was lastStatus := >smodel.Status{} @@ -195,7 +192,7 @@ func (c *converter) AppToMastoPublic(a *gtsmodel.Application) (*model.Applicatio func (c *converter) AttachmentToMasto(a *gtsmodel.MediaAttachment) (model.Attachment, error) { return model.Attachment{ ID: a.ID, - Type: string(a.Type), + Type: strings.ToLower(string(a.Type)), URL: a.URL, PreviewURL: a.Thumbnail.URL, RemoteURL: a.RemoteURL, @@ -294,7 +291,6 @@ func (c *converter) StatusToMasto( var faved bool var reblogged bool var bookmarked bool - var pinned bool var muted bool // requestingAccount will be nil for public requests without auth @@ -319,11 +315,6 @@ func (c *converter) StatusToMasto( if err != nil { return nil, fmt.Errorf("error checking if requesting account has bookmarked status: %s", err) } - - pinned, err = c.db.StatusPinnedBy(s, requestingAccount.ID) - if err != nil { - return nil, fmt.Errorf("error checking if requesting account has pinned status: %s", err) - } } var mastoRebloggedStatus *model.Status @@ -522,7 +513,7 @@ func (c *converter) StatusToMasto( Reblogged: reblogged, Muted: muted, Bookmarked: bookmarked, - Pinned: pinned, + Pinned: s.Pinned, Content: s.Content, Reblog: mastoRebloggedStatus, Application: mastoApplication, |