mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 10:12:11 +00:00
[bugfix] Fix minor API issue w/ boosted statuses (#2846)
This commit is contained in:
parent
6de5717d7f
commit
8cf685fbe9
|
@ -100,6 +100,8 @@ func (suite *StatusBoostTestSuite) TestPostBoost() {
|
|||
suite.Len(statusReply.Reblog.MediaAttachments, 1)
|
||||
suite.Len(statusReply.Reblog.Tags, 1)
|
||||
suite.Len(statusReply.Reblog.Emojis, 1)
|
||||
suite.True(statusReply.Reblogged)
|
||||
suite.True(statusReply.Reblog.Reblogged)
|
||||
suite.Equal("superseriousbusiness", statusReply.Reblog.Application.Name)
|
||||
}
|
||||
|
||||
|
@ -165,6 +167,8 @@ func (suite *StatusBoostTestSuite) TestPostBoostOwnFollowersOnly() {
|
|||
suite.Empty(responseStatus.Reblog.MediaAttachments)
|
||||
suite.Empty(responseStatus.Reblog.Tags)
|
||||
suite.Empty(responseStatus.Reblog.Emojis)
|
||||
suite.True(responseStatus.Reblogged)
|
||||
suite.True(responseStatus.Reblog.Reblogged)
|
||||
suite.Equal("really cool gts application", responseStatus.Reblog.Application.Name)
|
||||
}
|
||||
|
||||
|
|
|
@ -838,14 +838,6 @@ func (c *Converter) statusToFrontend(
|
|||
return nil, gtserror.Newf("error counting faves: %w", err)
|
||||
}
|
||||
|
||||
interacts, err := c.interactionsWithStatusForAccount(ctx, s, requestingAccount)
|
||||
if err != nil {
|
||||
log.Errorf(ctx, "error getting interactions for status %s for account %s: %v", s.ID, requestingAccount.ID, err)
|
||||
|
||||
// Ensure a non nil object
|
||||
interacts = &statusInteractions{}
|
||||
}
|
||||
|
||||
apiAttachments, err := c.convertAttachmentsToAPIAttachments(ctx, s.Attachments, s.AttachmentIDs)
|
||||
if err != nil {
|
||||
log.Errorf(ctx, "error converting status attachments: %v", err)
|
||||
|
@ -880,11 +872,6 @@ func (c *Converter) statusToFrontend(
|
|||
RepliesCount: repliesCount,
|
||||
ReblogsCount: reblogsCount,
|
||||
FavouritesCount: favesCount,
|
||||
Favourited: interacts.Faved,
|
||||
Bookmarked: interacts.Bookmarked,
|
||||
Muted: interacts.Muted,
|
||||
Reblogged: interacts.Reblogged,
|
||||
Pinned: interacts.Pinned,
|
||||
Content: s.Content,
|
||||
Reblog: nil, // Set below.
|
||||
Application: nil, // Set below.
|
||||
|
@ -941,6 +928,34 @@ func (c *Converter) statusToFrontend(
|
|||
}
|
||||
}
|
||||
|
||||
// Status interactions.
|
||||
//
|
||||
// Take from boosted status if set,
|
||||
// otherwise take from status itself.
|
||||
if apiStatus.Reblog != nil {
|
||||
apiStatus.Favourited = apiStatus.Reblog.Favourited
|
||||
apiStatus.Bookmarked = apiStatus.Reblog.Bookmarked
|
||||
apiStatus.Muted = apiStatus.Reblog.Muted
|
||||
apiStatus.Reblogged = apiStatus.Reblog.Reblogged
|
||||
apiStatus.Pinned = apiStatus.Reblog.Pinned
|
||||
} else {
|
||||
interacts, err := c.interactionsWithStatusForAccount(ctx, s, requestingAccount)
|
||||
if err != nil {
|
||||
log.Errorf(ctx,
|
||||
"error getting interactions for status %s for account %s: %v",
|
||||
s.ID, requestingAccount.ID, err,
|
||||
)
|
||||
|
||||
// Ensure non-nil object.
|
||||
interacts = new(statusInteractions)
|
||||
}
|
||||
apiStatus.Favourited = interacts.Favourited
|
||||
apiStatus.Bookmarked = interacts.Bookmarked
|
||||
apiStatus.Muted = interacts.Muted
|
||||
apiStatus.Reblogged = interacts.Reblogged
|
||||
apiStatus.Pinned = interacts.Pinned
|
||||
}
|
||||
|
||||
// If web URL is empty for whatever
|
||||
// reason, provide AP URI as fallback.
|
||||
if s.URL == "" {
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
)
|
||||
|
||||
type statusInteractions struct {
|
||||
Faved bool
|
||||
Favourited bool
|
||||
Muted bool
|
||||
Bookmarked bool
|
||||
Reblogged bool
|
||||
|
@ -51,7 +51,7 @@ func (c *Converter) interactionsWithStatusForAccount(ctx context.Context, s *gts
|
|||
if err != nil {
|
||||
return nil, fmt.Errorf("error checking if requesting account has faved status: %s", err)
|
||||
}
|
||||
si.Faved = faved
|
||||
si.Favourited = faved
|
||||
|
||||
reblogged, err := c.state.DB.IsStatusBoostedBy(ctx, s.ID, requestingAccount.ID)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue