mirror of
https://github.com/postgres/pgweb.git
synced 2025-08-01 15:54:53 +00:00
Fix how the mailinglist subscription form handles parameters
This was plain broken for things like nomail and digest, but even with the right syntax it probably did not work right together with the fact that we require confirmation for subscriptions. Issue spotted by Amir Rohan, fix suggested by Alvaro Herrera, (broken) code by me
This commit is contained in:
@ -16,16 +16,24 @@ def subscribe(request):
|
||||
if request.POST:
|
||||
form = SubscribeForm(request.POST)
|
||||
if form.is_valid():
|
||||
mailtxt = ""
|
||||
if form.cleaned_data['action'] == 'subscribe':
|
||||
mailtxt += "subscribe %s\n" % form.cleaned_data['lists']
|
||||
mailsubject = "subscribe"
|
||||
if not form.cleaned_data['receive']:
|
||||
mailtxt += "set nomail\n"
|
||||
if form.cleaned_data['digest']:
|
||||
mailtxt += "set digest\n"
|
||||
# Default is get mail and not digest, in which case we send a regular
|
||||
# subscribe request. In other cases, we send subscribe-set which also
|
||||
# sets those flags.
|
||||
if form.cleaned_data['receive'] and not form.cleaned_data['digest']:
|
||||
mailtxt = "subscribe %s\n" % form.cleaned_data['lists']
|
||||
else:
|
||||
tags = []
|
||||
if not form.cleaned_data['receive']:
|
||||
tags.append('nomail')
|
||||
if form.cleaned_data['digest']:
|
||||
tags.append('digest')
|
||||
|
||||
mailtxt = "subscribe-set %s %s\n" % (form.cleaned_data['lists'],
|
||||
",".join(tags))
|
||||
else:
|
||||
mailtxt += "unsubscribe %s\n" % form.cleaned_data['lists']
|
||||
mailtxt = "unsubscribe %s\n" % form.cleaned_data['lists']
|
||||
mailsubject = "unsubscribe"
|
||||
|
||||
send_simple_mail(form.cleaned_data['email'],
|
||||
|
Reference in New Issue
Block a user