diff options
author | 2022-09-02 17:00:11 +0200 | |
---|---|---|
committer | 2022-09-02 17:00:11 +0200 | |
commit | 4e13408fd48105d591c3f0f716641f1ef928817c (patch) | |
tree | 70eda403e79ac7f5dca795ad212a2882c86e4684 /internal/typeutils/internaltofrontend.go | |
parent | [performance] cache recently allowed/denied domains to cut down on db calls (... (diff) | |
download | gotosocial-4e13408fd48105d591c3f0f716641f1ef928817c.tar.xz |
[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
Diffstat (limited to 'internal/typeutils/internaltofrontend.go')
-rw-r--r-- | internal/typeutils/internaltofrontend.go | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 30ce1420e..6ccbed340 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -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} } |