From 4f5f5e765b1661f9af06f3711b0ea70e7028b712 Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 18 Apr 2024 13:04:23 +0200 Subject: [PATCH] [bugfix] Fix incorrect field name for status source, add helpful message --- internal/api/client/statuses/statussource_test.go | 2 +- internal/api/model/status.go | 2 +- internal/typeutils/internaltofrontend.go | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/api/client/statuses/statussource_test.go b/internal/api/client/statuses/statussource_test.go index edb2dad3c..28b1e6852 100644 --- a/internal/api/client/statuses/statussource_test.go +++ b/internal/api/client/statuses/statussource_test.go @@ -91,7 +91,7 @@ func (suite *StatusSourceTestSuite) TestGetSource() { suite.Equal(`{ "id": "01F8MHAMCHF6Y650WCRSCP4WMY", - "source": "hello everyone!", + "text": "**STATUS EDITS ARE NOT CURRENTLY SUPPORTED IN GOTOSOCIAL (coming in 2024)**\nYou can review the original text of your status below, but you will not be able to submit this edit.\n\n---\n\nhello everyone!", "spoiler_text": "introduction post" }`, dst.String()) } diff --git a/internal/api/model/status.go b/internal/api/model/status.go index d7d3266ed..9543303eb 100644 --- a/internal/api/model/status.go +++ b/internal/api/model/status.go @@ -259,7 +259,7 @@ type StatusSource struct { // example: 01FBVD42CQ3ZEEVMW180SBX03B ID string `json:"id"` // Plain-text source of a status. - Text string `json:"source"` + Text string `json:"text"` // Plain-text version of spoiler text. SpoilerText string `json:"spoiler_text"` } diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 98e1a4611..cbd4c6c5c 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -796,9 +796,13 @@ func (c *Converter) StatusToWebStatus( // Callers should check beforehand whether a requester has permission to view the // source of the status, and ensure they're passing only a local status into this function. func (c *Converter) StatusToAPIStatusSource(ctx context.Context, s *gtsmodel.Status) (*apimodel.StatusSource, error) { + // TODO: remove this when edit support is added. + text := "**STATUS EDITS ARE NOT CURRENTLY SUPPORTED IN GOTOSOCIAL (coming in 2024)**\n" + + "You can review the original text of your status below, but you will not be able to submit this edit.\n\n---\n\n" + s.Text + return &apimodel.StatusSource{ ID: s.ID, - Text: s.Text, + Text: text, SpoilerText: s.ContentWarning, }, nil }