From 0f35f135d2bb6b0900fb5b25b310384b157e8206 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 14 Oct 2023 11:37:01 -0700 Subject: [PATCH] Inner circle removal requests --- pkg/controller/account/inner_circle.go | 30 ++++++++++++++++++++---- pkg/router/router.go | 2 +- web/templates/account/inner_circle.html | 21 ++++++++++++++++- web/templates/account/remove_circle.html | 26 ++++++++++++++++++-- web/templates/photo/gallery.html | 9 ++++--- 5 files changed, 75 insertions(+), 13 deletions(-) diff --git a/pkg/controller/account/inner_circle.go b/pkg/controller/account/inner_circle.go index 0887e21..d3b81ee 100644 --- a/pkg/controller/account/inner_circle.go +++ b/pkg/controller/account/inner_circle.go @@ -1,6 +1,7 @@ package account import ( + "fmt" "net/http" "code.nonshy.com/nonshy/website/pkg/config" @@ -124,12 +125,33 @@ func RemoveCircle() http.HandlerFunc { return } - // Add them! - if err := models.RemoveFromInnerCircle(user); err != nil { - session.FlashError(w, r, "Couldn't remove from the inner circle: %s", err) + // Admin (with the correct scope): remove them now. + if currentUser.HasAdminScope(config.ScopeCircleModerator) { + if err := models.RemoveFromInnerCircle(user); err != nil { + session.FlashError(w, r, "Couldn't remove from the inner circle: %s", err) + } + + session.Flash(w, r, "%s has been removed from the inner circle!", user.Username) + } else { + // Non-admin user: request removal only. + fb := &models.Feedback{ + Intent: "report.circle", + Subject: "Inner Circle Removal Request", + TableName: "users", + TableID: user.ID, + Message: fmt.Sprintf( + "An inner circle member has flagged that **%s** no longer qualifies to be a part of the inner circle and should be removed.", + user.Username, + ), + } + + if err := models.CreateFeedback(fb); err != nil { + session.FlashError(w, r, "Couldn't create admin notification: %s", err) + } else { + session.Flash(w, r, "A request to remove %s from the inner circle has been sent to the site admin.", user.Username) + } } - session.Flash(w, r, "%s has been removed from the inner circle!", user.Username) templates.Redirect(w, "/u/"+user.Username) return } diff --git a/pkg/router/router.go b/pkg/router/router.go index 8d578f4..d77277f 100644 --- a/pkg/router/router.go +++ b/pkg/router/router.go @@ -92,7 +92,7 @@ func New() http.Handler { mux.Handle("/admin/maintenance", middleware.AdminRequired(config.ScopeMaintenance, admin.Maintenance())) mux.Handle("/forum/admin", middleware.AdminRequired(config.ScopeForumAdmin, forum.Manage())) mux.Handle("/forum/admin/edit", middleware.AdminRequired(config.ScopeForumAdmin, forum.AddEdit())) - mux.Handle("/inner-circle/remove", middleware.AdminRequired(config.ScopeCircleModerator, account.RemoveCircle())) + mux.Handle("/inner-circle/remove", middleware.LoginRequired(account.RemoveCircle())) // JSON API endpoints. mux.HandleFunc("/v1/version", api.Version()) diff --git a/web/templates/account/inner_circle.html b/web/templates/account/inner_circle.html index e0bc77c..3e909e3 100644 --- a/web/templates/account/inner_circle.html +++ b/web/templates/account/inner_circle.html @@ -111,6 +111,25 @@ +

How does one qualify to be part of the inner circle?

+ +

+ The minimum qualifications for somebody to be in the inner circle include: +

+ +

+ On public visibility, they have at least 5 (five) photos + that show their face and nude body together. +

+ +

+ If you see an inner circle member who had dropped below that threshold later (e.g., they moved + all of their pictures to private or they deleted them all from their page), you may + request removal from the circle when viewing their photo gallery page. Help + us keep the integrity of the inner circle by requesting removals when you see somebody who + should no longer qualify to be in the circle. Removal requests are anonymous! +

+

How do I invite others to join the inner circle?

@@ -166,4 +185,4 @@ -{{end}} \ No newline at end of file +{{end}} diff --git a/web/templates/account/remove_circle.html b/web/templates/account/remove_circle.html index 2894003..06cd548 100644 --- a/web/templates/account/remove_circle.html +++ b/web/templates/account/remove_circle.html @@ -42,6 +42,7 @@ {{InputCSRF}} + {{if .CurrentUser.IsAdmin}}

Do you want to remove {{.User.Username}} from @@ -60,10 +61,31 @@

+ {{else}} +
+

+ Do you want to request removal of {{.User.Username}} + from the {{PrettyCircle}}? +

+

+ If {{.User.Username}} should no longer qualify to be a + part of the inner circle, you may flag them to be removed from the circle. For example: to + be invited into the circle someone should need to have at least 5 (five) pictures + that are on public visibility and which show their face and nude body + together. But if they have taken down their pictures and should no longer qualify to remain in + the {{PrettyCircle}}, you may request them to be removed and an admin will check them out. +

+

+ Note: removal requests are completely anonymous: we trust your judgment when + inviting others to join the circle so we also trust you to help maintain the integrity of the + circle when flagging people for removal. +

+
+ {{end}}