Fix lint
This commit is contained in:
parent
4b0856bc47
commit
0e06e5ddd6
|
@ -41,7 +41,7 @@ type ActiveUser struct {
|
|||
|
||||
type activeUsersMap map[int64]*ActiveUser
|
||||
|
||||
// ActiveUsersMap is the type used to save active users
|
||||
// ActiveUsers is the type used to save active users
|
||||
type ActiveUsers struct {
|
||||
users activeUsersMap
|
||||
mutex *sync.Mutex
|
||||
|
|
|
@ -35,6 +35,7 @@ import (
|
|||
"image/png"
|
||||
)
|
||||
|
||||
// Provider represents the provider implementation of the initials provider
|
||||
type Provider struct {
|
||||
}
|
||||
|
||||
|
@ -143,6 +144,7 @@ func getAvatarForUser(u *user.User) (fullSizeAvatar *image.RGBA64, err error) {
|
|||
return fullSizeAvatar, err
|
||||
}
|
||||
|
||||
// GetAvatar returns an initials avatar for a user
|
||||
func (p *Provider) GetAvatar(u *user.User, size int64) (avatar []byte, mimeType string, err error) {
|
||||
|
||||
var cached bool
|
||||
|
|
|
@ -39,9 +39,11 @@ func init() {
|
|||
resizedCache = make(map[int64]map[int64][]byte)
|
||||
}
|
||||
|
||||
// Provider represents the upload avatar provider
|
||||
type Provider struct {
|
||||
}
|
||||
|
||||
// GetAvatar returns an uploaded user avatar
|
||||
func (p *Provider) GetAvatar(u *user.User, size int64) (avatar []byte, mimeType string, err error) {
|
||||
|
||||
a, cached := resizedCache[u.ID]
|
||||
|
@ -88,6 +90,7 @@ func (p *Provider) GetAvatar(u *user.User, size int64) (avatar []byte, mimeType
|
|||
return avatar, f.Mime, err
|
||||
}
|
||||
|
||||
// InvalidateCache invalidates the avatar cache for a user
|
||||
func InvalidateCache(u *user.User) {
|
||||
resizedCacheLock.Lock()
|
||||
delete(resizedCache, u.ID)
|
||||
|
|
|
@ -143,7 +143,7 @@ func (bp *BackgroundProvider) UploadBackground(c echo.Context) error {
|
|||
if !strings.HasPrefix(mime.String(), "image") {
|
||||
return c.JSON(http.StatusBadRequest, models.Message{Message: "Uploaded file is no image."})
|
||||
}
|
||||
src.Seek(0, io.SeekStart)
|
||||
_, _ = src.Seek(0, io.SeekStart)
|
||||
|
||||
// Save the file
|
||||
f, err := files.CreateWithMime(src, file.Filename, uint64(file.Size), auth, mime.String())
|
||||
|
|
|
@ -43,6 +43,7 @@ func (p *Provider) Search(search string, page int64) (result []*background.Image
|
|||
// @Param background formData string true "The file as single file."
|
||||
// @Security JWTKeyAuth
|
||||
// @Success 200 {object} models.Message "The background was set successfully."
|
||||
// @Failure 400 {object} models.Message "File is no image."
|
||||
// @Failure 403 {object} models.Message "No access to the list."
|
||||
// @Failure 403 {object} models.Message "File too large."
|
||||
// @Failure 404 {object} models.Message "The list does not exist."
|
||||
|
|
|
@ -97,6 +97,19 @@ func GetAvatar(c echo.Context) error {
|
|||
return c.Blob(http.StatusOK, mimeType, a)
|
||||
}
|
||||
|
||||
// UploadAvatar uploads and sets a user avatar
|
||||
// @Summary Upload a user avatar
|
||||
// @Description Upload a user avatar. This will also set the user's avatar provider to "upload"
|
||||
// @tags user
|
||||
// @Accept mpfd
|
||||
// @Produce json
|
||||
// @Param avatar formData string true "The avatar as single file."
|
||||
// @Security JWTKeyAuth
|
||||
// @Success 200 {object} models.Message "The avatar was set successfully."
|
||||
// @Failure 400 {object} models.Message "File is no image."
|
||||
// @Failure 403 {object} models.Message "File too large."
|
||||
// @Failure 500 {object} models.Message "Internal error"
|
||||
// @Router /user/settings/avatar/upload [put]
|
||||
func UploadAvatar(c echo.Context) (err error) {
|
||||
|
||||
uc, err := user.GetCurrentUser(c)
|
||||
|
@ -127,7 +140,7 @@ func UploadAvatar(c echo.Context) (err error) {
|
|||
if !strings.HasPrefix(mime.String(), "image") {
|
||||
return c.JSON(http.StatusBadRequest, models.Message{Message: "Uploaded file is no image."})
|
||||
}
|
||||
src.Seek(0, io.SeekStart)
|
||||
_, _ = src.Seek(0, io.SeekStart)
|
||||
|
||||
// Remove the old file if one exists
|
||||
if u.AvatarFileID != 0 {
|
||||
|
|
Loading…
Reference in New Issue