mirror of https://github.com/zulip/zulip.git
zerver: Replace `realm_uri` with `realm_url` in backend files.
Co-authored-by: Junyao Chen <junyao.chen@socitydao.org>
This commit is contained in:
parent
c514d39efc
commit
4430ab9cbe
|
@ -132,7 +132,7 @@ class MessageRenderingResult:
|
||||||
@dataclass
|
@dataclass
|
||||||
class DbData:
|
class DbData:
|
||||||
mention_data: MentionData
|
mention_data: MentionData
|
||||||
realm_uri: str
|
realm_url: str
|
||||||
realm_alert_words_automaton: Optional[ahocorasick.Automaton]
|
realm_alert_words_automaton: Optional[ahocorasick.Automaton]
|
||||||
active_realm_emoji: Dict[str, EmojiInfo]
|
active_realm_emoji: Dict[str, EmojiInfo]
|
||||||
sent_by_bot: bool
|
sent_by_bot: bool
|
||||||
|
@ -274,9 +274,9 @@ def rewrite_local_links_to_relative(db_data: Optional[DbData], link: str) -> str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if db_data:
|
if db_data:
|
||||||
realm_uri_prefix = db_data.realm_uri + "/"
|
realm_url_prefix = db_data.realm_url + "/"
|
||||||
if link.startswith((realm_uri_prefix + "#", realm_uri_prefix + "user_uploads/")):
|
if link.startswith((realm_url_prefix + "#", realm_url_prefix + "user_uploads/")):
|
||||||
return link[len(realm_uri_prefix) :]
|
return link[len(realm_url_prefix) :]
|
||||||
|
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
@ -2664,7 +2664,7 @@ def do_convert(
|
||||||
realm_alert_words_automaton=realm_alert_words_automaton,
|
realm_alert_words_automaton=realm_alert_words_automaton,
|
||||||
mention_data=mention_data,
|
mention_data=mention_data,
|
||||||
active_realm_emoji=active_realm_emoji,
|
active_realm_emoji=active_realm_emoji,
|
||||||
realm_uri=message_realm.url,
|
realm_url=message_realm.url,
|
||||||
sent_by_bot=sent_by_bot,
|
sent_by_bot=sent_by_bot,
|
||||||
stream_names=stream_name_info,
|
stream_names=stream_name_info,
|
||||||
translate_emoticons=translate_emoticons,
|
translate_emoticons=translate_emoticons,
|
||||||
|
|
|
@ -1449,13 +1449,13 @@ def send_test_push_notification_directly_to_devices(
|
||||||
apple_payload = copy.deepcopy(payload)
|
apple_payload = copy.deepcopy(payload)
|
||||||
android_payload = copy.deepcopy(payload)
|
android_payload = copy.deepcopy(payload)
|
||||||
|
|
||||||
realm_uri = base_payload["realm_uri"]
|
realm_url = base_payload["realm_url"]
|
||||||
realm_name = base_payload["realm_name"]
|
realm_name = base_payload["realm_name"]
|
||||||
apns_data = {
|
apns_data = {
|
||||||
"alert": {
|
"alert": {
|
||||||
"title": _("Test notification"),
|
"title": _("Test notification"),
|
||||||
"body": _("This is a test notification from {realm_name} ({realm_uri}).").format(
|
"body": _("This is a test notification from {realm_name} ({realm_url}).").format(
|
||||||
realm_name=realm_name, realm_uri=realm_uri
|
realm_name=realm_name, realm_url=realm_url
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
"sound": "default",
|
"sound": "default",
|
||||||
|
|
|
@ -467,19 +467,19 @@ def finish_mobile_flow(request: HttpRequest, user_profile: UserProfile, otp: str
|
||||||
def create_response_for_otp_flow(
|
def create_response_for_otp_flow(
|
||||||
key: str, otp: str, user_profile: UserProfile, encrypted_key_field_name: str
|
key: str, otp: str, user_profile: UserProfile, encrypted_key_field_name: str
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
realm_uri = user_profile.realm.url
|
realm_url = user_profile.realm.url
|
||||||
|
|
||||||
# Check if the mobile URI is overridden in settings, if so, replace it
|
# Check if the mobile URI is overridden in settings, if so, replace it
|
||||||
# This block should only apply to the mobile flow, so we if add others, this
|
# This block should only apply to the mobile flow, so we if add others, this
|
||||||
# needs to be conditional.
|
# needs to be conditional.
|
||||||
if realm_uri in settings.REALM_MOBILE_REMAP_URIS:
|
if realm_url in settings.REALM_MOBILE_REMAP_URIS:
|
||||||
realm_uri = settings.REALM_MOBILE_REMAP_URIS[realm_uri]
|
realm_url = settings.REALM_MOBILE_REMAP_URIS[realm_url]
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
encrypted_key_field_name: otp_encrypt_api_key(key, otp),
|
encrypted_key_field_name: otp_encrypt_api_key(key, otp),
|
||||||
"email": user_profile.delivery_email,
|
"email": user_profile.delivery_email,
|
||||||
"user_id": user_profile.id,
|
"user_id": user_profile.id,
|
||||||
"realm": realm_uri,
|
"realm": realm_url,
|
||||||
}
|
}
|
||||||
# We can't use HttpResponseRedirect, since it only allows HTTP(S) URLs
|
# We can't use HttpResponseRedirect, since it only allows HTTP(S) URLs
|
||||||
response = HttpResponse(status=302)
|
response = HttpResponse(status=302)
|
||||||
|
@ -830,7 +830,7 @@ class TwoFactorLoginView(BaseTwoFactorLoginView):
|
||||||
We need to override this function so that we can redirect to
|
We need to override this function so that we can redirect to
|
||||||
realm.url instead of '/'.
|
realm.url instead of '/'.
|
||||||
"""
|
"""
|
||||||
realm_uri = self.get_user().realm.url
|
realm_url = self.get_user().realm.url
|
||||||
# This mock.patch business is an unpleasant hack that we'd
|
# This mock.patch business is an unpleasant hack that we'd
|
||||||
# ideally like to remove by instead patching the upstream
|
# ideally like to remove by instead patching the upstream
|
||||||
# module to support better configurability of the
|
# module to support better configurability of the
|
||||||
|
@ -839,7 +839,7 @@ class TwoFactorLoginView(BaseTwoFactorLoginView):
|
||||||
# process involving pbr -> pkgresources (which is really slow).
|
# process involving pbr -> pkgresources (which is really slow).
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
with patch.object(settings, "LOGIN_REDIRECT_URL", realm_uri):
|
with patch.object(settings, "LOGIN_REDIRECT_URL", realm_url):
|
||||||
return super().done(form_list, **kwargs)
|
return super().done(form_list, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -154,12 +154,12 @@ def api_dev_list_users(request: HttpRequest) -> HttpResponse:
|
||||||
request,
|
request,
|
||||||
data=dict(
|
data=dict(
|
||||||
direct_admins=[
|
direct_admins=[
|
||||||
dict(email=u.delivery_email, realm_uri=u.realm.url)
|
dict(email=u.delivery_email, realm_url=u.realm.url)
|
||||||
for u in users
|
for u in users
|
||||||
if u.is_realm_admin
|
if u.is_realm_admin
|
||||||
],
|
],
|
||||||
direct_users=[
|
direct_users=[
|
||||||
dict(email=u.delivery_email, realm_uri=u.realm.url)
|
dict(email=u.delivery_email, realm_url=u.realm.url)
|
||||||
for u in users
|
for u in users
|
||||||
if not u.is_realm_admin
|
if not u.is_realm_admin
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue