[bugfix] Fix status fields in_reply_to_id and in_reply_to_account_id not being nullable (#798)

* make reply status fields nullable pointers

* update tests
This commit is contained in:
tobi
2022-09-02 17:00:11 +02:00
committed by GitHub
parent d68c04a6c0
commit 4e13408fd4
5 changed files with 32 additions and 16 deletions

View File

@ -525,9 +525,6 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
}
}
var apiCard *model.Card
var apiPoll *model.Poll
statusInteractions := &statusInteractions{}
si, err := c.interactionsWithStatusForAccount(ctx, s, requestingAccount)
if err == nil {
@ -537,8 +534,8 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
apiStatus := &model.Status{
ID: s.ID,
CreatedAt: util.FormatISO8601(s.CreatedAt),
InReplyToID: s.InReplyToID,
InReplyToAccountID: s.InReplyToAccountID,
InReplyToID: nil,
InReplyToAccountID: nil,
Sensitive: *s.Sensitive,
SpoilerText: s.ContentWarning,
Visibility: c.VisToAPIVis(ctx, s.Visibility),
@ -554,17 +551,29 @@ func (c *converter) StatusToAPIStatus(ctx context.Context, s *gtsmodel.Status, r
Reblogged: statusInteractions.Reblogged,
Pinned: *s.Pinned,
Content: s.Content,
Reblog: nil,
Application: apiApplication,
Account: apiAuthorAccount,
MediaAttachments: apiAttachments,
Mentions: apiMentions,
Tags: apiTags,
Emojis: apiEmojis,
Card: apiCard, // TODO: implement cards
Poll: apiPoll, // TODO: implement polls
Card: nil, // TODO: implement cards
Poll: nil, // TODO: implement polls
Text: s.Text,
}
// nullable fields
if s.InReplyToID != "" {
i := s.InReplyToID
apiStatus.InReplyToID = &i
}
if s.InReplyToAccountID != "" {
i := s.InReplyToAccountID
apiStatus.InReplyToAccountID = &i
}
if apiRebloggedStatus != nil {
apiStatus.Reblog = &model.StatusReblogged{Status: apiRebloggedStatus}
}