tangled
alpha
login
or
join now
isabelroses.com
/
core
forked from
tangled.org/core
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
appview: state: use avatar service urls in profiles
anirudh.fi
10 months ago
8786840e
eab2518d
verified
This commit was signed with the committer's
known signature
.
anirudh.fi
SSH Key Fingerprint:
SHA256:cz35vdbiWEzCNEfuL9fMC2JVIhtXavXBHrRjv8gxpAk=
+23
-17
4 changed files
expand all
collapse all
unified
split
.gitignore
appview
config.go
state
profile.go
state.go
+1
.gitignore
···
8
8
!.gitkeep
9
9
out/
10
10
./camo/node_modules/*
11
11
+
./avatar/node_modules/*
11
12
+10
-8
appview/config.go
···
7
7
)
8
8
9
9
type Config struct {
10
10
-
CookieSecret string `env:"TANGLED_COOKIE_SECRET, default=00000000000000000000000000000000"`
11
11
-
DbPath string `env:"TANGLED_DB_PATH, default=appview.db"`
12
12
-
ListenAddr string `env:"TANGLED_LISTEN_ADDR, default=0.0.0.0:3000"`
13
13
-
Dev bool `env:"TANGLED_DEV, default=false"`
14
14
-
JetstreamEndpoint string `env:"TANGLED_JETSTREAM_ENDPOINT, default=wss://jetstream1.us-east.bsky.network/subscribe"`
15
15
-
ResendApiKey string `env:"TANGLED_RESEND_API_KEY"`
16
16
-
CamoHost string `env:"TANGLED_CAMO_HOST, default=https://camo.tangled.sh"`
17
17
-
CamoSharedSecret string `env:"TANGLED_CAMO_SHARED_SECRET"`
10
10
+
CookieSecret string `env:"TANGLED_COOKIE_SECRET, default=00000000000000000000000000000000"`
11
11
+
DbPath string `env:"TANGLED_DB_PATH, default=appview.db"`
12
12
+
ListenAddr string `env:"TANGLED_LISTEN_ADDR, default=0.0.0.0:3000"`
13
13
+
Dev bool `env:"TANGLED_DEV, default=false"`
14
14
+
JetstreamEndpoint string `env:"TANGLED_JETSTREAM_ENDPOINT, default=wss://jetstream1.us-east.bsky.network/subscribe"`
15
15
+
ResendApiKey string `env:"TANGLED_RESEND_API_KEY"`
16
16
+
CamoHost string `env:"TANGLED_CAMO_HOST, default=https://camo.tangled.sh"`
17
17
+
CamoSharedSecret string `env:"TANGLED_CAMO_SHARED_SECRET"`
18
18
+
AvatarSharedSecret string `env:"TANGLED_AVATAR_SHARED_SECRET"`
19
19
+
AvatarHost string `env:"TANGLED_AVATAR_HOST, default=https://avatar.tangled.sh"`
18
20
}
19
21
20
22
func LoadConfig(ctx context.Context) (*Config, error) {
+12
-5
appview/state/profile.go
···
1
1
package state
2
2
3
3
import (
4
4
+
"crypto/hmac"
5
5
+
"crypto/sha256"
6
6
+
"encoding/hex"
4
7
"fmt"
5
8
"log"
6
9
"net/http"
···
79
82
followStatus = db.GetFollowStatus(s.db, loggedInUser.Did, ident.DID.String())
80
83
}
81
84
82
82
-
profileAvatarUri, err := GetAvatarUri(ident.Handle.String())
83
83
-
if err != nil {
84
84
-
log.Println("failed to fetch bsky avatar", err)
85
85
-
}
86
86
-
85
85
+
profileAvatarUri := s.GetAvatarUri(ident.Handle.String())
87
86
s.pages.ProfilePage(w, pages.ProfilePageParams{
88
87
LoggedInUser: loggedInUser,
89
88
UserDid: ident.DID.String(),
···
100
99
ProfileTimeline: timeline,
101
100
})
102
101
}
102
102
+
103
103
+
func (s *State) GetAvatarUri(handle string) string {
104
104
+
secret := s.config.AvatarSharedSecret
105
105
+
h := hmac.New(sha256.New, []byte(secret))
106
106
+
h.Write([]byte(handle))
107
107
+
signature := hex.EncodeToString(h.Sum(nil))
108
108
+
return fmt.Sprintf("%s/%s/%s", s.config.AvatarHost, signature, handle)
109
109
+
}
-4
appview/state/state.go
···
742
742
return
743
743
}
744
744
}
745
745
-
746
746
-
func GetAvatarUri(handle string) (string, error) {
747
747
-
return fmt.Sprintf("https://avatars.dog/%s@webp", handle), nil
748
748
-
}