Add Golangci Lint (#676)
Increase golangci timeout Fix installing golangci-lint in ci Remove mage targets replaced by golangci Run golint in ci Add goheader linter Enable & fix more linters Fix lint issues Add mage target to automagically fix issues found by golangci golangci-lint run --fix Add golangci config Add golangci mage target Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/676 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
This commit is contained in:
@ -17,14 +17,16 @@
|
||||
package gravatar
|
||||
|
||||
import (
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/api/pkg/utils"
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"code.vikunja.io/api/pkg/config"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"code.vikunja.io/api/pkg/utils"
|
||||
)
|
||||
|
||||
type avatar struct {
|
||||
@ -62,10 +64,15 @@ func (g *Provider) GetAvatar(user *user.User, size int64) ([]byte, string, error
|
||||
}
|
||||
if !exists || needsRefetch {
|
||||
log.Debugf("Gravatar for user %d with size %d not cached, requesting from gravatar...", user.ID, size)
|
||||
resp, err := http.Get("https://www.gravatar.com/avatar/" + utils.Md5String(user.Email) + "?s=" + sizeString + "&d=mp")
|
||||
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "https://www.gravatar.com/avatar/"+utils.Md5String(user.Email)+"?s="+sizeString+"&d=mp", nil)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
resp, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
avatarContent, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
|
@ -18,6 +18,13 @@ package initials
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/modules/keyvalue"
|
||||
e "code.vikunja.io/api/pkg/modules/keyvalue/error"
|
||||
@ -27,12 +34,6 @@ import (
|
||||
"golang.org/x/image/font"
|
||||
"golang.org/x/image/font/gofont/goregular"
|
||||
"golang.org/x/image/math/fixed"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"image/png"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Provider represents the provider implementation of the initials provider
|
||||
@ -41,15 +42,15 @@ type Provider struct {
|
||||
|
||||
var (
|
||||
avatarBgColors = []*color.RGBA{
|
||||
{69, 189, 243, 255},
|
||||
{224, 143, 112, 255},
|
||||
{77, 182, 172, 255},
|
||||
{149, 117, 205, 255},
|
||||
{176, 133, 94, 255},
|
||||
{240, 98, 146, 255},
|
||||
{163, 211, 108, 255},
|
||||
{121, 134, 203, 255},
|
||||
{241, 185, 29, 255},
|
||||
{R: 69, G: 189, B: 243, A: 255},
|
||||
{R: 224, G: 143, B: 112, A: 255},
|
||||
{R: 77, G: 182, B: 172, A: 255},
|
||||
{R: 149, G: 117, B: 205, A: 255},
|
||||
{R: 176, G: 133, B: 94, A: 255},
|
||||
{R: 240, G: 98, B: 146, A: 255},
|
||||
{R: 163, G: 211, B: 108, A: 255},
|
||||
{R: 121, G: 134, B: 203, A: 255},
|
||||
{R: 241, G: 185, B: 29, A: 255},
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -18,16 +18,17 @@ package upload
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
|
||||
"code.vikunja.io/api/pkg/files"
|
||||
"code.vikunja.io/api/pkg/log"
|
||||
"code.vikunja.io/api/pkg/modules/keyvalue"
|
||||
e "code.vikunja.io/api/pkg/modules/keyvalue/error"
|
||||
"code.vikunja.io/api/pkg/user"
|
||||
"github.com/disintegration/imaging"
|
||||
"image"
|
||||
"image/png"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// Provider represents the upload avatar provider
|
||||
|
Reference in New Issue
Block a user