summaryrefslogtreecommitdiff
path: root/internal/media/util.go
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-15 17:41:18 +0100
committerLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-15 17:41:18 +0100
commit723bfe8944f80fd1ef935ad6878fc555fd42b8e7 (patch)
tree388adc46e30dd1c6aab3700d592c63944f5fb129 /internal/media/util.go
parentemoji code passing muster (diff)
downloadgotosocial-723bfe8944f80fd1ef935ad6878fc555fd42b8e7.tar.xz
lint, fmt
Diffstat (limited to 'internal/media/util.go')
-rw-r--r--internal/media/util.go19
1 files changed, 1 insertions, 18 deletions
diff --git a/internal/media/util.go b/internal/media/util.go
index 16e874a99..7a3d81c0f 100644
--- a/internal/media/util.go
+++ b/internal/media/util.go
@@ -20,12 +20,10 @@ package media
import (
"bytes"
- "context"
"errors"
"fmt"
"github.com/h2non/filetype"
- "github.com/superseriousbusiness/gotosocial/internal/db"
)
// parseContentType parses the MIME content type from a file, returning it as a string in the form (eg., "image/jpeg").
@@ -65,7 +63,7 @@ func supportedImage(mimeType string) bool {
return false
}
-// supportedEmoji checks that the content type is image/png -- the only type supported for emoji.
+// supportedEmoji checks that the content type is image/png or image/gif -- the only types supported for emoji.
func supportedEmoji(mimeType string) bool {
acceptedEmojiTypes := []string{
mimeImageGif,
@@ -106,18 +104,3 @@ func ParseMediaSize(s string) (Size, error) {
}
return "", fmt.Errorf("%s not a recognized MediaSize", s)
}
-
-// putOrUpdate is just a convenience function for first trying to PUT the attachment or emoji in the database,
-// and then if that doesn't work because the attachment/emoji already exists, updating it instead.
-func putOrUpdate(ctx context.Context, database db.DB, i interface{}) error {
- if err := database.Put(ctx, i); err != nil {
- if err != db.ErrAlreadyExists {
- return fmt.Errorf("putOrUpdate: proper error while putting: %s", err)
- }
- if err := database.UpdateByPrimaryKey(ctx, i); err != nil {
- return fmt.Errorf("putOrUpdate: error while updating: %s", err)
- }
- }
-
- return nil
-}