summaryrefslogtreecommitdiff
path: root/internal/processing
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-08 13:45:42 +0100
committerLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-08 13:45:42 +0100
commitc2ff8f392b6320d45d8667d4e093e8eb8ddf59c1 (patch)
treed8592837da9e591b50e4fded43c8b14b77ee5f6c /internal/processing
parentstart working on thumb + full funcs (diff)
downloadgotosocial-c2ff8f392b6320d45d8667d4e093e8eb8ddf59c1.tar.xz
further refinements
Diffstat (limited to 'internal/processing')
-rw-r--r--internal/processing/media/create.go26
1 files changed, 5 insertions, 21 deletions
diff --git a/internal/processing/media/create.go b/internal/processing/media/create.go
index 68a011683..357278e64 100644
--- a/internal/processing/media/create.go
+++ b/internal/processing/media/create.go
@@ -24,11 +24,9 @@ import (
"errors"
"fmt"
"io"
- "time"
apimodel "github.com/superseriousbusiness/gotosocial/internal/api/model"
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
- "github.com/superseriousbusiness/gotosocial/internal/text"
)
func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, form *apimodel.AttachmentRequest) (*apimodel.Attachment, error) {
@@ -46,29 +44,15 @@ func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, form
return nil, errors.New("could not read provided attachment: size 0 bytes")
}
- // now parse the focus parameter
- focusx, focusy, err := parseFocus(form.Focus)
+ // process the media and load it immediately
+ media, err := p.mediaManager.ProcessMedia(ctx, buf.Bytes(), account.ID)
if err != nil {
- return nil, fmt.Errorf("couldn't parse attachment focus: %s", err)
+ return nil, err
}
- minAttachment := &gtsmodel.MediaAttachment{
- CreatedAt: time.Now(),
- UpdatedAt: time.Now(),
- AccountID: account.ID,
- Description: text.SanitizeCaption(form.Description),
- FileMeta: gtsmodel.FileMeta{
- Focus: gtsmodel.Focus{
- X: focusx,
- Y: focusy,
- },
- },
- }
-
- // allow the mediaManager to work its magic of processing the attachment bytes, and putting them in whatever storage backend we're using
- attachment, err := p.mediaManager.ProcessAttachment(ctx, buf.Bytes(), minAttachment)
+ attachment, err := media.Load(ctx)
if err != nil {
- return nil, fmt.Errorf("error reading attachment: %s", err)
+ return nil, err
}
// prepare the frontend representation now -- if there are any errors here at least we can bail without