summaryrefslogtreecommitdiff
path: root/internal/processing/media/getmedia.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/media/getmedia.go')
-rw-r--r--internal/processing/media/getmedia.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/processing/media/getmedia.go b/internal/processing/media/getmedia.go
index 380a54cc2..91608e90d 100644
--- a/internal/processing/media/getmedia.go
+++ b/internal/processing/media/getmedia.go
@@ -19,6 +19,7 @@
package media
import (
+ "context"
"errors"
"fmt"
@@ -28,9 +29,9 @@ import (
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
)
-func (p *processor) GetMedia(account *gtsmodel.Account, mediaAttachmentID string) (*apimodel.Attachment, gtserror.WithCode) {
- attachment := &gtsmodel.MediaAttachment{}
- if err := p.db.GetByID(mediaAttachmentID, attachment); err != nil {
+func (p *processor) GetMedia(ctx context.Context, account *gtsmodel.Account, mediaAttachmentID string) (*apimodel.Attachment, gtserror.WithCode) {
+ attachment, err := p.db.GetAttachmentByID(ctx, mediaAttachmentID)
+ if err != nil {
if err == db.ErrNoEntries {
// attachment doesn't exist
return nil, gtserror.NewErrorNotFound(errors.New("attachment doesn't exist in the db"))
@@ -42,7 +43,7 @@ func (p *processor) GetMedia(account *gtsmodel.Account, mediaAttachmentID string
return nil, gtserror.NewErrorNotFound(errors.New("attachment not owned by requesting account"))
}
- a, err := p.tc.AttachmentToMasto(attachment)
+ a, err := p.tc.AttachmentToMasto(ctx, attachment)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("error converting attachment: %s", err))
}