mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
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.
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user