mirror of https://github.com/zulip/zulip.git
confirmation: Move one_click_unsubscribe_link out of notifications.py.
This helps prevent a problematic import sequence when we start using it from signals.py.
This commit is contained in:
parent
33c2bbf0f1
commit
17be6e9165
|
@ -123,6 +123,15 @@ _properties = {
|
|||
Confirmation.REALM_CREATION: ConfirmationType('check_prereg_key_and_redirect'),
|
||||
}
|
||||
|
||||
def one_click_unsubscribe_link(user_profile: UserProfile, email_type: str) -> str:
|
||||
"""
|
||||
Generate a unique link that a logged-out user can visit to unsubscribe from
|
||||
Zulip e-mails without having to first log in.
|
||||
"""
|
||||
return create_confirmation_link(user_profile, user_profile.realm.host,
|
||||
Confirmation.UNSUBSCRIBE,
|
||||
url_args = {'email_type': email_type})
|
||||
|
||||
# Functions related to links generated by the generate_realm_creation_link.py
|
||||
# management command.
|
||||
# Note that being validated here will just allow the user to access the create_realm
|
||||
|
|
|
@ -10,7 +10,8 @@ from django.template import loader
|
|||
from django.conf import settings
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
||||
from zerver.lib.notifications import build_message_list, one_click_unsubscribe_link
|
||||
from confirmation.models import one_click_unsubscribe_link
|
||||
from zerver.lib.notifications import build_message_list
|
||||
from zerver.lib.send_email import send_future_email, FromAddress
|
||||
from zerver.lib.url_encoding import encode_stream
|
||||
from zerver.models import UserProfile, UserMessage, Recipient, Stream, \
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
from typing import cast, Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple
|
||||
|
||||
from confirmation.models import Confirmation, create_confirmation_link
|
||||
from confirmation.models import Confirmation, one_click_unsubscribe_link
|
||||
from django.conf import settings
|
||||
from django.template import loader
|
||||
from django.utils.timezone import now as timezone_now
|
||||
|
@ -37,15 +37,6 @@ import ujson
|
|||
from collections import defaultdict
|
||||
import pytz
|
||||
|
||||
def one_click_unsubscribe_link(user_profile: UserProfile, email_type: str) -> str:
|
||||
"""
|
||||
Generate a unique link that a logged-out user can visit to unsubscribe from
|
||||
Zulip e-mails without having to first log in.
|
||||
"""
|
||||
return create_confirmation_link(user_profile, user_profile.realm.host,
|
||||
Confirmation.UNSUBSCRIBE,
|
||||
url_args = {'email_type': email_type})
|
||||
|
||||
def relative_to_full_url(base_url: str, content: str) -> str:
|
||||
# Convert relative URLs to absolute URLs.
|
||||
fragment = lxml.html.fromstring(content)
|
||||
|
|
|
@ -17,7 +17,8 @@ from mock import patch, MagicMock
|
|||
from zerver.lib.test_helpers import MockLDAP, get_test_image_file, avatar_disk_path
|
||||
|
||||
from confirmation.models import Confirmation, create_confirmation_link, MultiuseInvite, \
|
||||
generate_key, confirmation_url, get_object_from_key, ConfirmationKeyException
|
||||
generate_key, confirmation_url, get_object_from_key, ConfirmationKeyException, \
|
||||
one_click_unsubscribe_link
|
||||
from confirmation import settings as confirmation_settings
|
||||
|
||||
from zerver.forms import HomepageForm, WRONG_SUBDOMAIN_ERROR, check_subdomain_available
|
||||
|
@ -55,7 +56,7 @@ from zerver.lib.avatar import avatar_url
|
|||
from zerver.lib.mobile_auth_otp import xor_hex_strings, ascii_to_hex, \
|
||||
otp_encrypt_api_key, is_valid_otp, hex_to_ascii, otp_decrypt_api_key
|
||||
from zerver.lib.notifications import enqueue_welcome_emails, \
|
||||
one_click_unsubscribe_link, followup_day2_email_delay
|
||||
followup_day2_email_delay
|
||||
from zerver.lib.subdomains import is_root_domain_available
|
||||
from zerver.lib.test_helpers import find_key_by_email, queries_captured, \
|
||||
HostRequestMock, load_subdomain_token
|
||||
|
|
Loading…
Reference in New Issue