Skip to content

Commit

Permalink
Remove textarea on account deletion
Browse files Browse the repository at this point in the history
It's not really useful for me, and lots of people fill in something that
seems indicative that they don't know it's optional.
  • Loading branch information
arp242 committed Nov 5, 2024
1 parent 5c678bc commit c66f5c2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 49 deletions.
36 changes: 2 additions & 34 deletions handlers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,11 +664,6 @@ func (h settings) exportStart(w http.ResponseWriter, r *http.Request) error {

func (h settings) delete(verr *zvalidate.Validator) zhttp.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) error {
del := map[string]any{
"ContactMe": r.URL.Query().Get("contact_me") == "true",
"Reason": r.URL.Query().Get("reason"),
}

var sites goatcounter.Sites
err := sites.ForThisAccount(r.Context(), false)
if err != nil {
Expand All @@ -679,40 +674,13 @@ func (h settings) delete(verr *zvalidate.Validator) zhttp.HandlerFunc {
Globals
Sites goatcounter.Sites
Validate *zvalidate.Validator
Delete map[string]any
}{newGlobals(w, r), sites, verr, del})
}{newGlobals(w, r), sites, verr})
}
}

func (h settings) deleteDo(w http.ResponseWriter, r *http.Request) error {
var args struct {
Reason string `json:"reason"`
ContactMe bool `json:"contact_me"`
}
_, err := zhttp.Decode(r, &args)
if err != nil {
zlog.Error(err)
}

account := Account(r.Context())

if args.Reason != "" {
bgrun.RunFunction("email:deletion", func() {
contact := "false"
if args.ContactMe {
u := goatcounter.GetUser(r.Context())
contact = u.Email
}

blackmail.Send("GoatCounter deletion",
blackmail.From("GoatCounter deletion", goatcounter.Config(r.Context()).EmailFrom),
blackmail.To(goatcounter.Config(r.Context()).EmailFrom),
blackmail.Bodyf(`Deleted: %s (%d): contact_me: %s; reason: %s`,
account.Code, account.ID, contact, args.Reason))
})
}

err = account.Delete(r.Context(), true)
err := account.Delete(r.Context(), true)
if err != nil {
return err
}
Expand Down
15 changes: 0 additions & 15 deletions tpl/settings_delete.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@
data-confirm={{.T "label/delete-account-confirmation|Are you sure you want to delete your entire account?"}}>
<input type="hidden" name="csrf" value="{{.User.CSRFToken}}">

<label for="reason">{{.T `label/delete-account-reason|
It would be appreciated if you could let me know if there's anything in
particular you're missing in GoatCounter, or any other reasons you have
for wanting to delete your account. This is entirely optional.
`}}</label><br>
<textarea id="reason" name="reason" placeholder="{{.T "label/delete-account-reason-placeholder|Optional reason for deletion"}}">{{index .Delete "Reason"}}</textarea><br><br>

<label>{{checkbox (index .Delete "ContactMe") "contact_me"}} {{.T "label/delete-account-follow-up|It’s okay to follow up"}}</label><br>
<div style="max-width: 40em; color: #333;">{{.T `label/delete-account-contact|
I might contact you with some follow-up questions or commentary if you
check this. I won’t try to convince you to stay (I’m not a telecom), but
I might ask a question or two, or outline future plans if you’re missing
a particular feature.
`}}</div><br>

<button type="submit">{{.T "button/delete-account|Delete account, all sites, and all data"}}</button>
</form>

Expand Down

0 comments on commit c66f5c2

Please sign in to comment.