Working on emojis a bit more

This commit is contained in:
tsmethurst 2021-04-13 22:53:27 +02:00
commit de9718c566
8 changed files with 154 additions and 58 deletions

View file

@ -29,6 +29,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/superseriousbusiness/gotosocial/internal/db/gtsmodel"
mastotypes "github.com/superseriousbusiness/gotosocial/internal/mastotypes/mastomodel"
"github.com/superseriousbusiness/gotosocial/internal/media"
"github.com/superseriousbusiness/gotosocial/internal/oauth"
"github.com/superseriousbusiness/gotosocial/internal/util"
)
@ -217,7 +218,7 @@ func (m *accountModule) UpdateAccountAvatar(avatar *multipart.FileHeader, accoun
}
// do the setting
avatarInfo, err := m.mediaHandler.SetHeaderOrAvatarForAccountID(buf.Bytes(), accountID, "avatar")
avatarInfo, err := m.mediaHandler.ProcessHeaderOrAvatar(buf.Bytes(), accountID, media.MediaAvatar)
if err != nil {
return nil, fmt.Errorf("error processing avatar: %s", err)
}
@ -250,7 +251,7 @@ func (m *accountModule) UpdateAccountHeader(header *multipart.FileHeader, accoun
}
// do the setting
headerInfo, err := m.mediaHandler.SetHeaderOrAvatarForAccountID(buf.Bytes(), accountID, "header")
headerInfo, err := m.mediaHandler.ProcessHeaderOrAvatar(buf.Bytes(), accountID, media.MediaHeader)
if err != nil {
return nil, fmt.Errorf("error processing header: %s", err)
}

View file

@ -39,7 +39,7 @@ const (
shortcodeKey = "shortcode"
emojisPath = "emojis"
filesPath = "files"
filesPath = "files"
)
// fileServer implements the RESTAPIModule interface.

View file

@ -75,19 +75,16 @@ func (m *fileServer) ServeFile(c *gin.Context) {
// Only serve media types that are defined in our internal media module
switch mediaType {
case media.MediaHeader:
case media.MediaAvatar:
case media.MediaAttachment:
case media.MediaHeader, media.MediaAvatar, media.MediaAttachment, media.MediaEmoji:
default:
l.Debugf("mediatype %s not recognized", mediaType)
c.String(http.StatusNotFound, "404 page not found")
return
}
// This corresponds to original-sized image as it was uploaded, or small, which is the thumbnail
// This corresponds to original-sized image as it was uploaded, small (which is the thumbnail), or static
switch mediaSize {
case media.MediaOriginal:
case media.MediaSmall:
case media.MediaOriginal, media.MediaSmall, media.MediaStatic:
default:
l.Debugf("mediasize %s not recognized", mediaSize)
c.String(http.StatusNotFound, "404 page not found")

View file

@ -88,7 +88,7 @@ func (m *mediaModule) mediaCreatePOSTHandler(c *gin.Context) {
}
// allow the mediaHandler to work its magic of processing the attachment bytes, and putting them in whatever storage backend we're using
attachment, err := m.mediaHandler.ProcessAttachment(buf.Bytes(), authed.Account.ID)
attachment, err := m.mediaHandler.ProcessLocalAttachment(buf.Bytes(), authed.Account.ID)
if err != nil {
l.Debugf("error reading attachment: %s", err)
c.JSON(http.StatusBadRequest, gin.H{"error": fmt.Sprintf("could not process attachment: %s", err)})