From 723bfe8944f80fd1ef935ad6878fc555fd42b8e7 Mon Sep 17 00:00:00 2001 From: tsmethurst Date: Sat, 15 Jan 2022 17:41:18 +0100 Subject: lint, fmt --- internal/media/processingmedia.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'internal/media/processingmedia.go') diff --git a/internal/media/processingmedia.go b/internal/media/processingmedia.go index fade64c24..082c58607 100644 --- a/internal/media/processingmedia.go +++ b/internal/media/processingmedia.go @@ -260,31 +260,28 @@ func (p *ProcessingMedia) fetchRawData(ctx context.Context) error { return fmt.Errorf("fetchRawData: error parsing content type: %s", err) } + if !supportedImage(contentType) { + return fmt.Errorf("fetchRawData: media type %s not (yet) supported", contentType) + } + split := strings.Split(contentType, "/") if len(split) != 2 { return fmt.Errorf("fetchRawData: content type %s was not valid", contentType) } - mainType := split[0] // something like 'image' extension := split[1] // something like 'jpeg' // set some additional fields on the attachment now that // we know more about what the underlying media actually is + if extension == mimeGif { + p.attachment.Type = gtsmodel.FileTypeGif + } else { + p.attachment.Type = gtsmodel.FileTypeImage + } p.attachment.URL = uris.GenerateURIForAttachment(p.attachment.AccountID, string(TypeAttachment), string(SizeOriginal), p.attachment.ID, extension) p.attachment.File.Path = fmt.Sprintf("%s/%s/%s/%s.%s", p.attachment.AccountID, TypeAttachment, SizeOriginal, p.attachment.ID, extension) p.attachment.File.ContentType = contentType - switch mainType { - case mimeImage: - if extension == mimeGif { - p.attachment.Type = gtsmodel.FileTypeGif - } else { - p.attachment.Type = gtsmodel.FileTypeImage - } - default: - return fmt.Errorf("fetchRawData: cannot process mime type %s (yet)", mainType) - } - return nil } -- cgit v1.2.3