From 3050c2930a925bc17fa8cc2a3555910138b717d6 Mon Sep 17 00:00:00 2001 From: ewin Date: Thu, 6 Mar 2025 09:49:37 -0500 Subject: [PATCH] Don't pass processContentType the entire edit form, it doesn't need it --- internal/processing/status/edit.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/processing/status/edit.go b/internal/processing/status/edit.go index f426ab944..8327d538e 100644 --- a/internal/processing/status/edit.go +++ b/internal/processing/status/edit.go @@ -86,7 +86,7 @@ func (p *Processor) Edit( } // Process incoming content type - contentType := processContentType(form, status, requester.Settings.StatusContentType) + contentType := processContentType(form.ContentType, status, requester.Settings.StatusContentType) // Process incoming status edit content fields. content, errWithCode := p.processContent(ctx, @@ -348,21 +348,21 @@ func (p *Processor) Edit( return p.c.GetAPIStatus(ctx, requester, status) } -// Returns the new content type of the status when applying an edit. +// Returns the final content type to use when creating or editing a status. func processContentType( - form *apimodel.StatusEditRequest, - status *gtsmodel.Status, + requestContentType apimodel.StatusContentType, + existingStatus *gtsmodel.Status, accountDefaultContentType string, ) gtsmodel.StatusContentType { switch { - // Content type set on form, return the new value. - case form.ContentType != "": - return typeutils.APIContentTypeToContentType(form.ContentType) + // Content type set in the request, return the new value. + case requestContentType != "": + return typeutils.APIContentTypeToContentType(requestContentType) - // No content type on the form, return the existing - // status's current content type if there is one. - case status != nil && status.ContentType != 0: - return status.ContentType + // No content type in the request, return the existing + // status's current content type if we know of one. + case existingStatus != nil && existingStatus.ContentType != 0: + return existingStatus.ContentType // We aren't editing an existing status, or if we are // it's an old one that doesn't have a saved content