summaryrefslogtreecommitdiff
path: root/internal/processing/media/getfile.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/processing/media/getfile.go')
-rw-r--r--internal/processing/media/getfile.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/processing/media/getfile.go b/internal/processing/media/getfile.go
index c74951e38..3227cb8c8 100644
--- a/internal/processing/media/getfile.go
+++ b/internal/processing/media/getfile.go
@@ -113,7 +113,7 @@ func (p *processor) getAttachmentContent(ctx context.Context, requestingAccount
// if we have the media cached on our server already, we can now simply return it from storage
if a.Cached {
- return p.streamFromStorage(storagePath, attachmentContent)
+ return p.retrieveFromStorage(ctx, storagePath, attachmentContent)
}
// if we don't have it cached, then we can assume two things:
@@ -221,7 +221,7 @@ func (p *processor) getAttachmentContent(ctx context.Context, requestingAccount
return nil, gtserror.NewErrorNotFound(fmt.Errorf("error loading recached attachment: %s", err))
}
// ... so now we can safely return it
- return p.streamFromStorage(storagePath, attachmentContent)
+ return p.retrieveFromStorage(ctx, storagePath, attachmentContent)
}
return attachmentContent, nil
@@ -253,11 +253,15 @@ func (p *processor) getEmojiContent(ctx context.Context, wantedEmojiID string, e
return nil, gtserror.NewErrorNotFound(fmt.Errorf("media size %s not recognized for emoji", emojiSize))
}
- return p.streamFromStorage(storagePath, emojiContent)
+ return p.retrieveFromStorage(ctx, storagePath, emojiContent)
}
-func (p *processor) streamFromStorage(storagePath string, content *apimodel.Content) (*apimodel.Content, gtserror.WithCode) {
- reader, err := p.storage.GetStream(storagePath)
+func (p *processor) retrieveFromStorage(ctx context.Context, storagePath string, content *apimodel.Content) (*apimodel.Content, gtserror.WithCode) {
+ if url := p.storage.URL(ctx, storagePath); url != nil {
+ content.URL = url
+ return content, nil
+ }
+ reader, err := p.storage.GetStream(ctx, storagePath)
if err != nil {
return nil, gtserror.NewErrorNotFound(fmt.Errorf("error retrieving from storage: %s", err))
}