feat: gravatar - Lowercase emails before MD5 hash (#10)

This commit is contained in:
Joseph Kavanagh 2021-11-16 21:10:22 +00:00 committed by GitHub
parent efd0970971
commit 36bf3d216a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,6 +21,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strconv" "strconv"
"strings"
"time" "time"
"code.vikunja.io/api/pkg/config" "code.vikunja.io/api/pkg/config"
@ -64,7 +65,7 @@ func (g *Provider) GetAvatar(user *user.User, size int64) ([]byte, string, error
} }
if !exists || needsRefetch { if !exists || needsRefetch {
log.Debugf("Gravatar for user %d with size %d not cached, requesting from gravatar...", user.ID, size) log.Debugf("Gravatar for user %d with size %d not cached, requesting from gravatar...", user.ID, size)
req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "https://www.gravatar.com/avatar/"+utils.Md5String(user.Email)+"?s="+sizeString+"&d=mp", nil) req, err := http.NewRequestWithContext(context.Background(), http.MethodGet, "https://www.gravatar.com/avatar/"+utils.Md5String(strings.ToLower(user.Email))+"?s="+sizeString+"&d=mp", nil)
if err != nil { if err != nil {
return nil, "", err return nil, "", err
} }