mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 05:53:43 +00:00
urls: Rename arguments to accounts/unsubscribe.
type -> email_type to match future work on ScheduledJob. token -> confirmation_key to match what the other confirmation views urls call this argument.
This commit is contained in:
@@ -39,14 +39,14 @@ def unsubscribe_token(user_profile):
|
||||
# unsubscription tokens.
|
||||
return Confirmation.objects.get_link_for_object(user_profile, 'unused').split("/")[-1]
|
||||
|
||||
def one_click_unsubscribe_link(user_profile, endpoint):
|
||||
def one_click_unsubscribe_link(user_profile, email_type):
|
||||
# type: (UserProfile, Text) -> Text
|
||||
"""
|
||||
Generate a unique link that a logged-out user can visit to unsubscribe from
|
||||
Zulip e-mails without having to first log in.
|
||||
"""
|
||||
token = unsubscribe_token(user_profile)
|
||||
resource_path = "accounts/unsubscribe/%s/%s" % (endpoint, token)
|
||||
resource_path = "accounts/unsubscribe/%s/%s" % (email_type, token)
|
||||
return "%s/%s" % (user_profile.realm.uri.rstrip("/"), resource_path)
|
||||
|
||||
def hash_util_encode(string):
|
||||
|
||||
@@ -49,10 +49,10 @@ email_unsubscribers = {
|
||||
}
|
||||
|
||||
# Login NOT required. These are for one-click unsubscribes.
|
||||
def email_unsubscribe(request, type, token):
|
||||
def email_unsubscribe(request, email_type, confirmation_key):
|
||||
# type: (HttpRequest, str, str) -> HttpResponse
|
||||
if type in email_unsubscribers:
|
||||
display_name, unsubscribe_function = email_unsubscribers[type]
|
||||
return process_unsubscribe(request, token, display_name, unsubscribe_function)
|
||||
if email_type in email_unsubscribers:
|
||||
display_name, unsubscribe_function = email_unsubscribers[email_type]
|
||||
return process_unsubscribe(request, confirmation_key, display_name, unsubscribe_function)
|
||||
|
||||
return render(request, 'zerver/unsubscribe_link_error.html')
|
||||
|
||||
@@ -118,7 +118,7 @@ i18n_urls = [
|
||||
|
||||
# Email unsubscription endpoint. Allows for unsubscribing from various types of emails,
|
||||
# including the welcome emails (day 1 & 2), missed PMs, etc.
|
||||
url(r'^accounts/unsubscribe/(?P<type>[\w]+)/(?P<token>[\w]+)',
|
||||
url(r'^accounts/unsubscribe/(?P<email_type>[\w]+)/(?P<confirmation_key>[\w]+)',
|
||||
zerver.views.unsubscribe.email_unsubscribe, name='zerver.views.unsubscribe.email_unsubscribe'),
|
||||
|
||||
# Portico-styled page used to provide email confirmation of terms acceptance.
|
||||
|
||||
Reference in New Issue
Block a user