summaryrefslogtreecommitdiff
path: root/internal/processing/media/create.go
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2023-11-10 19:29:26 +0100
committerLibravatar GitHub <noreply@github.com>2023-11-10 19:29:26 +0100
commitba9d6b467a1f03447789844048d913738c843569 (patch)
tree5a464ee4a33f26e3284179582ab6d3332d9d5388 /internal/processing/media/create.go
parent[chore/bugfix/horror] Allow `expires_in` and poll choices to be parsed from s... (diff)
downloadgotosocial-ba9d6b467a1f03447789844048d913738c843569.tar.xz
[feature] Media attachment placeholders (#2331)
* [feature] Use placeholders for unknown media types * fix read of underreported small files * switch to reduce nesting * simplify cleanup
Diffstat (limited to 'internal/processing/media/create.go')
-rw-r--r--internal/processing/media/create.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/internal/processing/media/create.go b/internal/processing/media/create.go
index b8c469dde..fe20457b4 100644
--- a/internal/processing/media/create.go
+++ b/internal/processing/media/create.go
@@ -42,18 +42,18 @@ func (p *Processor) Create(ctx context.Context, account *gtsmodel.Account, form
}
// process the media attachment and load it immediately
- media, err := p.mediaManager.PreProcessMedia(ctx, data, account.ID, &media.AdditionalMediaInfo{
+ media := p.mediaManager.PreProcessMedia(data, account.ID, &media.AdditionalMediaInfo{
Description: &form.Description,
FocusX: &focusX,
FocusY: &focusY,
})
- if err != nil {
- return nil, gtserror.NewErrorUnprocessableEntity(err)
- }
attachment, err := media.LoadAttachment(ctx)
if err != nil {
- return nil, gtserror.NewErrorUnprocessableEntity(err)
+ return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
+ } else if attachment.Type == gtsmodel.FileTypeUnknown {
+ err = gtserror.Newf("could not process uploaded file with extension %s", attachment.File.ContentType)
+ return nil, gtserror.NewErrorUnprocessableEntity(err, err.Error())
}
apiAttachment, err := p.converter.AttachmentToAPIAttachment(ctx, attachment)