Spit and polish for Shy Accounts

* Add a Shy/Non-shy badge to user profile pages.
* Shy Accounts can always DM admin users.
This commit is contained in:
Noah Petherbridge 2023-02-13 22:31:50 -08:00
parent 7d17dce4d4
commit 296b5a30b8
3 changed files with 24 additions and 1 deletions

View File

@ -73,9 +73,10 @@ func Compose() http.HandlerFunc {
// Do not allow a shy user to initiate DMs with a non-shy one. // Do not allow a shy user to initiate DMs with a non-shy one.
var ( var (
imShy = currentUser.IsShy() imShy = currentUser.IsShy()
theyreShy = user.IsShy()
isShyFrom = currentUser.IsShyFrom(user) || (imShy && !models.AreFriends(currentUser.ID, user.ID)) isShyFrom = currentUser.IsShyFrom(user) || (imShy && !models.AreFriends(currentUser.ID, user.ID))
) )
if imShy && isShyFrom { if imShy && isShyFrom && !theyreShy && !user.IsAdmin {
session.FlashError(w, r, "You have a Shy Account and can not initiate Direct Messages with a non-shy member.") session.FlashError(w, r, "You have a Shy Account and can not initiate Direct Messages with a non-shy member.")
templates.Redirect(w, "/u/"+user.Username) templates.Redirect(w, "/u/"+user.Username)
return return

View File

@ -38,6 +38,12 @@ func TemplateFuncs(r *http.Request) template.FuncMap {
`<strong style="color: #FF77FF">shy</strong>`, `<strong style="color: #FF77FF">shy</strong>`,
)) ))
}, },
"PrettyTitleShort": func() template.HTML {
return template.HTML(fmt.Sprintf(
`<strong style="color: #0077FF">n</strong>` +
`<strong style="color: #FF77FF">s</strong>`,
))
},
"Pluralize": Pluralize[int], "Pluralize": Pluralize[int],
"Pluralize64": Pluralize[int64], "Pluralize64": Pluralize[int64],
"PluralizeU64": Pluralize[uint64], "PluralizeU64": Pluralize[uint64],

View File

@ -88,6 +88,22 @@
</div> </div>
{{end}} {{end}}
{{if .User.IsShy}}
<div class="pt-1">
<div class="icon-text has-text-danger">
<span class="icon">
<i class="fa fa-ghost"></i>
</span>
<strong>Shy Account</strong>
</div>
</div>
{{else}}
<div class="pt-1" title="Badge for having at least one public picture.">
{{PrettyTitleShort}}
<strong class="has-text-link ml-1">Non-shy!</strong>
</div>
{{end}}
{{if .User.IsAdmin}} {{if .User.IsAdmin}}
<div class="pt-1"> <div class="pt-1">
<div class="icon-text has-text-danger"> <div class="icon-text has-text-danger">