From 91a3cc27baa81d32082cbfd9a9aaa41066902226 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 29 Jun 2024 19:28:51 -0700 Subject: [PATCH] Add notification banners about upcoming Public Avatar change --- pkg/config/config.go | 1 + pkg/middleware/public_avatar_consent.go | 6 +-- pkg/models/shy_accounts.go | 7 ++++ pkg/templates/template_vars.go | 1 + web/templates/account/dashboard.html | 42 +++++++++++++++++++ .../account/public_avatar_consent.html | 6 +++ web/templates/chat.html | 13 ++++++ 7 files changed, 71 insertions(+), 5 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 5ce6b04..a26d3c2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -125,6 +125,7 @@ const ( // NOTE: search code base for PublicAvatar or "public avatar" for related feature code. var ( PublicAvatarEnforcementDate = time.Date(2024, time.August, 30, 12, 0, 0, 0, time.UTC) + PublicAvatarForumThread = "https://www.nonshy.com/forum/thread/667" ) // Forum settings diff --git a/pkg/middleware/public_avatar_consent.go b/pkg/middleware/public_avatar_consent.go index e05ff77..c1cd08b 100644 --- a/pkg/middleware/public_avatar_consent.go +++ b/pkg/middleware/public_avatar_consent.go @@ -18,11 +18,7 @@ func PublicAvatarConsent(user *models.User, w http.ResponseWriter, r *http.Reque } // If the current user has a non-public avatar and has not consented. - if user.ProfilePhoto.ID > 0 && user.ProfilePhoto.Visibility != models.PhotoPublic { - if user.GetProfileField("public_avatar_consent") == "true" { - return - } - + if user.NeedsPublicAvatarConsent() { templates.Redirect(w, "/settings/public-avatar-consent?next="+url.QueryEscape(r.URL.String())) return true } diff --git a/pkg/models/shy_accounts.go b/pkg/models/shy_accounts.go index 4d037c9..7bd87c4 100644 --- a/pkg/models/shy_accounts.go +++ b/pkg/models/shy_accounts.go @@ -97,6 +97,13 @@ func (um ShyMap) Get(id uint64) bool { return um[id] } +// NeedsPublicAvatarConsent returns true if the user will be impacted by the Public Avatar policy. +// +// That is, their default profile picture is non-public and they have not answered the consent form. +func (u *User) NeedsPublicAvatarConsent() bool { + return u.ProfilePhoto.ID > 0 && u.ProfilePhoto.Visibility != PhotoPublic && u.GetProfileField("public_avatar_consent") != "true" +} + // MapPublicAvatarConsent checks a set of users if they have answered the public avatar consent form. func MapPublicAvatarConsent(users []*User) (map[uint64]bool, error) { var ( diff --git a/pkg/templates/template_vars.go b/pkg/templates/template_vars.go index 339adc2..02ec866 100644 --- a/pkg/templates/template_vars.go +++ b/pkg/templates/template_vars.go @@ -25,6 +25,7 @@ func MergeVars(r *http.Request, m map[string]interface{}) { // Temporary? variables for migration efforts on PublicAvatar consent. m["PublicAvatarEnforcementDate"] = config.PublicAvatarEnforcementDate + m["PublicAvatarForumThread"] = config.PublicAvatarForumThread if r == nil { return diff --git a/web/templates/account/dashboard.html b/web/templates/account/dashboard.html index 087bd50..ca1346a 100644 --- a/web/templates/account/dashboard.html +++ b/web/templates/account/dashboard.html @@ -13,6 +13,48 @@
+ + {{if and (.CurrentUser.Certified) (.CurrentUser.NeedsPublicAvatarConsent)}} +
+
+

+ + Notification about an upcoming change in Profile Picture policy +

+
+ +
+

+ Beginning on {{.PublicAvatarEnforcementDate.Format "January 2, 2006"}}, + {{PrettyTitle}} will begin to require that your square cropped profile picture (your "avatar" image) + will need be visible to all members of the website. +

+ +

+ Please see the announcement thread in the forum + about the upcoming change, and visit the Public Avatar Consent page + for more information. +

+ +

+ You are seeing this message because your default profile picture is set to + {{if eq .CurrentUser.ProfilePhoto.Visibility "friends"}} + "Friends-only" + {{else if eq .CurrentUser.ProfilePhoto.Visibility "private"}} + "Private" + {{else if eq .CurrentUser.ProfilePhoto.Visibility "circle"}} + "Inner circle only" + {{else}} + "{{.CurrentUser.ProfilePhoto.Visibility}}" + {{end}} and your avatar currently shows as a placeholder image to members + who are not allowed to see it. This message will disappear after you have + accepted the upcoming change in policy + or you set a "Public" photo as your profile picture. +

+
+
+ {{end}} + {{if or (not .CurrentUser.Certified) (not .CurrentUser.ProfilePhoto.ID)}}
diff --git a/web/templates/account/public_avatar_consent.html b/web/templates/account/public_avatar_consent.html index c23d9da..9566b82 100644 --- a/web/templates/account/public_avatar_consent.html +++ b/web/templates/account/public_avatar_consent.html @@ -42,6 +42,12 @@ have responded to this consent form by answering the prompt at the bottom of this page.

+

+ If your profile picture is already set to "Public" visibility: no action is needed from + you at this time. However, you may be asked to respond to this consent form in the future + if you set a non-public photo to be your default profile picture. +

+
  • Summary of the change diff --git a/web/templates/chat.html b/web/templates/chat.html index f7b57d6..da6ba4d 100644 --- a/web/templates/chat.html +++ b/web/templates/chat.html @@ -56,6 +56,19 @@
{{end}} + + {{if Now.Before .PublicAvatarEnforcementDate}} +
+ + Notice of an upcoming website policy change: beginning on {{.PublicAvatarEnforcementDate.Format "January 2, 2006"}}, + all square cropped default profile pictures will need to be made visible to all {{PrettyTitle}} members. The + yellow and + purple placeholder avatars + that you sometimes see in the chat room will be going away after that time.

+ Please see the announcement post on the forum for more information. +
+ {{end}} +

{{PrettyTitle}} has a chat room! Come and check it out. It features some public rooms, direct