From 83de18aeba9208d8a2501ee3363c5eb8a9098c45 Mon Sep 17 00:00:00 2001 From: ewin Date: Wed, 5 Mar 2025 16:20:41 -0500 Subject: [PATCH] Do include content type on status API model actually This is mostly important when deleting and redrafting. The comment on `apimodel.Status.Text` implies that it's not sent except in response to status deletion, but actually this doesn't seem to be the case; it also appears to be present in responses to creations and normal fetches and stuff. So I'm treating `ContentType` the same here. --- internal/api/model/status.go | 4 ++++ internal/typeutils/internaltofrontend.go | 1 + 2 files changed, 5 insertions(+) diff --git a/internal/api/model/status.go b/internal/api/model/status.go index 286a90dfe..d5fec77a7 100644 --- a/internal/api/model/status.go +++ b/internal/api/model/status.go @@ -110,6 +110,10 @@ type Status struct { // so the user may redraft from the source text without the client having to reverse-engineer // the original text from the HTML content. Text string `json:"text,omitempty"` + // Content type that was used to parse the status's text. Returned when + // status is deleted, so if the user is redrafting the message the client + // can default to the same content type. + ContentType StatusContentType `json:"content_type,omitempty"` // A list of filters that matched this status and why they matched, if there are any such filters. Filtered []FilterResult `json:"filtered,omitempty"` // The interaction policy for this status, as set by the status author. diff --git a/internal/typeutils/internaltofrontend.go b/internal/typeutils/internaltofrontend.go index 465f4acf5..1e8e410e1 100644 --- a/internal/typeutils/internaltofrontend.go +++ b/internal/typeutils/internaltofrontend.go @@ -1391,6 +1391,7 @@ func (c *Converter) baseStatusToFrontend( Emojis: apiEmojis, Card: nil, // TODO: implement cards Text: s.Text, + ContentType: c.ContentTypeToAPIContentType(ctx, s.ContentType), InteractionPolicy: *apiInteractionPolicy, }