Skip to content

Commit

Permalink
fix hashing alg for gravatar avatar fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
krustowski committed Jul 16, 2024
1 parent ed1c9f5 commit 0ebfc3b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#

APP_NAME=litter-go
APP_VERSION=0.35.11
APP_VERSION=0.35.12
GOLANG_VERSION=1.22
2 changes: 1 addition & 1 deletion api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"name": "MIT",
"url": "https://github.com/krustowski/litter-go/blob/master/LICENSE"
},
"version": "0.35.11"
"version": "0.35.12"
},
"host": "littr.n0p.cz",
"basePath": "/api/v1",
Expand Down
16 changes: 11 additions & 5 deletions pkg/backend/db/migration.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package db

import (
"crypto/md5"
"encoding/hex"
"crypto/sha256"
//"encoding/hex"
"fmt"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -183,10 +184,15 @@ func GetGravatarURL(emailInput string, channel chan string) string {
email := strings.ToLower(emailInput)
size := 150

sha := sha256.New()
sha.Write([]byte(email))

hashedStringEmail := fmt.Sprintf("%x", sha.Sum(nil))

// hash the emailInput
byteEmail := []byte(email)
hashEmail := md5.Sum(byteEmail)
hashedStringEmail := hex.EncodeToString(hashEmail[:])
//byteEmail := []byte(email)
//hashEmail := md5.Sum(byteEmail)
//hashedStringEmail := hex.EncodeToString(hashEmail[:])

url := "https://www.gravatar.com/avatar/" + hashedStringEmail + "&s=" + strconv.Itoa(size)

Expand Down
2 changes: 1 addition & 1 deletion pkg/backend/router.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @title litter-go
// @version 0.35.11
// @version 0.35.12
// @description nanoblogging platform as PWA built on go-app framework
// @termsOfService https://littr.eu/tos

Expand Down

0 comments on commit 0ebfc3b

Please sign in to comment.