diff options
author | 2021-09-12 10:10:24 +0100 | |
---|---|---|
committer | 2021-09-12 10:10:24 +0100 | |
commit | f6492d12d948507021bbe934de94e87e20464c01 (patch) | |
tree | 6705d6ef6f3c4d70f3b3ebc77c2960d8e508cf37 /internal/media/handler.go | |
parent | Merge pull request #213 from superseriousbusiness/alpine+node_upstep (diff) | |
parent | fix keys used to access storage items (diff) | |
download | gotosocial-f6492d12d948507021bbe934de94e87e20464c01.tar.xz |
Merge pull request #214 from NyaaaWhatsUpDoc/improvement/update-storage-library
add git.iim.gay/grufwub/go-store for storage backend, replacing blob.Storage
Diffstat (limited to 'internal/media/handler.go')
-rw-r--r-- | internal/media/handler.go | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/internal/media/handler.go b/internal/media/handler.go index 9c1d3227e..70c5c0826 100644 --- a/internal/media/handler.go +++ b/internal/media/handler.go @@ -26,8 +26,8 @@ import ( "strings" "time" + "git.iim.gay/grufwub/go-store/kv" "github.com/sirupsen/logrus" - "github.com/superseriousbusiness/gotosocial/internal/blob" "github.com/superseriousbusiness/gotosocial/internal/config" "github.com/superseriousbusiness/gotosocial/internal/db" "github.com/superseriousbusiness/gotosocial/internal/gtsmodel" @@ -86,12 +86,12 @@ type Handler interface { type mediaHandler struct { config *config.Config db db.DB - storage blob.Storage + storage *kv.KVStore log *logrus.Logger } // New returns a new handler with the given config, db, storage, and logger -func New(config *config.Config, database db.DB, storage blob.Storage, log *logrus.Logger) Handler { +func New(config *config.Config, database db.DB, storage *kv.KVStore, log *logrus.Logger) Handler { return &mediaHandler{ config: config, db: database, @@ -250,19 +250,19 @@ func (mh *mediaHandler) ProcessLocalEmoji(ctx context.Context, emojiBytes []byte // serve url and storage path for the original emoji -- can be png or gif emojiURL := fmt.Sprintf("%s/%s/%s/%s/%s.%s", URLbase, instanceAccount.ID, Emoji, Original, newEmojiID, extension) - emojiPath := fmt.Sprintf("%s/%s/%s/%s/%s.%s", mh.config.StorageConfig.BasePath, instanceAccount.ID, Emoji, Original, newEmojiID, extension) + emojiPath := fmt.Sprintf("%s/%s/%s/%s.%s", instanceAccount.ID, Emoji, Original, newEmojiID, extension) // serve url and storage path for the static version -- will always be png emojiStaticURL := fmt.Sprintf("%s/%s/%s/%s/%s.png", URLbase, instanceAccount.ID, Emoji, Static, newEmojiID) - emojiStaticPath := fmt.Sprintf("%s/%s/%s/%s/%s.png", mh.config.StorageConfig.BasePath, instanceAccount.ID, Emoji, Static, newEmojiID) + emojiStaticPath := fmt.Sprintf("%s/%s/%s/%s.png", instanceAccount.ID, Emoji, Static, newEmojiID) - // store the original - if err := mh.storage.StoreFileAt(emojiPath, original.image); err != nil { + // Store the original emoji + if err := mh.storage.Put(emojiPath, original.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } - // store the static - if err := mh.storage.StoreFileAt(emojiStaticPath, static.image); err != nil { + // Store the static emoji + if err := mh.storage.Put(emojiStaticPath, static.image); err != nil { return nil, fmt.Errorf("storage error: %s", err) } @@ -293,7 +293,6 @@ func (mh *mediaHandler) ProcessLocalEmoji(ctx context.Context, emojiBytes []byte } func (mh *mediaHandler) ProcessRemoteHeaderOrAvatar(ctx context.Context, t transport.Transport, currentAttachment *gtsmodel.MediaAttachment, accountID string) (*gtsmodel.MediaAttachment, error) { - if !currentAttachment.Header && !currentAttachment.Avatar { return nil, errors.New("provided attachment was set to neither header nor avatar") } |