Use anonymized avatars in chat for non-public profile pics

face-detect
Noah Petherbridge 2023-02-12 22:23:51 -08:00
parent 5e3e02ee33
commit c4600ff6ce
1 changed files with 11 additions and 1 deletions

View File

@ -7,6 +7,7 @@ import (
"time"
"code.nonshy.com/nonshy/website/pkg/config"
"code.nonshy.com/nonshy/website/pkg/models"
"code.nonshy.com/nonshy/website/pkg/photo"
"code.nonshy.com/nonshy/website/pkg/session"
"code.nonshy.com/nonshy/website/pkg/templates"
@ -51,10 +52,19 @@ func Landing() http.HandlerFunc {
return
}
// Avatar URL - masked if non-public.
avatar := photo.URLPath(currentUser.ProfilePhoto.CroppedFilename)
switch currentUser.ProfilePhoto.Visibility {
case models.PhotoPrivate:
avatar = "/static/img/shy-private.png"
case models.PhotoFriends:
avatar = "/static/img/shy-friends.png"
}
// Create the JWT claims.
claims := Claims{
IsAdmin: currentUser.IsAdmin,
Avatar: photo.URLPath(currentUser.ProfilePhoto.CroppedFilename),
Avatar: avatar,
ProfileURL: "/u/" + currentUser.Username,
RegisteredClaims: jwt.RegisteredClaims{
// TODO: ExpiresAt 60 minutes to work around chat server reliability,