diff options
author | 2021-08-25 15:34:33 +0200 | |
---|---|---|
committer | 2021-08-25 15:34:33 +0200 | |
commit | 2dc9fc1626507bb54417fc4a1920b847cafb27a2 (patch) | |
tree | 4ddeac479b923db38090aac8bd9209f3646851c1 /internal/processing/media/create.go | |
parent | Manually approves followers (#146) (diff) | |
download | gotosocial-2dc9fc1626507bb54417fc4a1920b847cafb27a2.tar.xz |
Pg to bun (#148)
* start moving to bun
* changing more stuff
* more
* and yet more
* tests passing
* seems stable now
* more big changes
* small fix
* little fixes
Diffstat (limited to 'internal/processing/media/create.go')
-rw-r--r-- | internal/processing/media/create.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/processing/media/create.go b/internal/processing/media/create.go index 5b8cdf604..648e4d46a 100644 --- a/internal/processing/media/create.go +++ b/internal/processing/media/create.go @@ -20,6 +20,7 @@ package media import ( "bytes" + "context" "errors" "fmt" "io" @@ -29,7 +30,7 @@ import ( "github.com/superseriousbusiness/gotosocial/internal/text" ) -func (p *processor) Create(account *gtsmodel.Account, form *apimodel.AttachmentRequest) (*apimodel.Attachment, error) { +func (p *processor) Create(ctx context.Context, account *gtsmodel.Account, form *apimodel.AttachmentRequest) (*apimodel.Attachment, error) { // open the attachment and extract the bytes from it f, err := form.File.Open() if err != nil { @@ -45,7 +46,7 @@ func (p *processor) Create(account *gtsmodel.Account, form *apimodel.AttachmentR } // allow the mediaHandler to work its magic of processing the attachment bytes, and putting them in whatever storage backend we're using - attachment, err := p.mediaHandler.ProcessAttachment(buf.Bytes(), account.ID, "") + attachment, err := p.mediaHandler.ProcessAttachment(ctx, buf.Bytes(), account.ID, "") if err != nil { return nil, fmt.Errorf("error reading attachment: %s", err) } @@ -66,13 +67,13 @@ func (p *processor) Create(account *gtsmodel.Account, form *apimodel.AttachmentR // prepare the frontend representation now -- if there are any errors here at least we can bail without // having already put something in the database and then having to clean it up again (eugh) - mastoAttachment, err := p.tc.AttachmentToMasto(attachment) + mastoAttachment, err := p.tc.AttachmentToMasto(ctx, attachment) if err != nil { return nil, fmt.Errorf("error parsing media attachment to frontend type: %s", err) } // now we can confidently put the attachment in the database - if err := p.db.Put(attachment); err != nil { + if err := p.db.Put(ctx, attachment); err != nil { return nil, fmt.Errorf("error storing media attachment in db: %s", err) } |