diff options
author | 2021-05-17 19:06:58 +0200 | |
---|---|---|
committer | 2021-05-17 19:06:58 +0200 | |
commit | 6cd033449fd328410128bc3e840f4b8d3d74f052 (patch) | |
tree | 9868db8439533e078dea5bb34ae4949e9460f2cb /internal/typeutils/internaltofrontend.go | |
parent | update progress (diff) | |
download | gotosocial-6cd033449fd328410128bc3e840f4b8d3d74f052.tar.xz |
Refine statuses (#26)
Remote media is now dereferenced and attached properly to incoming federated statuses.
Mentions are now dereferenced and attached properly to incoming federated statuses.
Small fixes to status visibility.
Allow URL params for filtering statuses:
// ExcludeRepliesKey is for specifying whether to exclude replies in a list of returned statuses by an account.
// PinnedKey is for specifying whether to include pinned statuses in a list of returned statuses by an account.
// MaxIDKey is for specifying the maximum ID of the status to retrieve.
// MediaOnlyKey is for specifying that only statuses with media should be returned in a list of returned statuses by an account.
Add endpoint for fetching an account's statuses.
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 19 |
1 files changed, 5 insertions, 14 deletions
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, |