mirror of https://github.com/zulip/zulip.git
actions: Create send_message_to_signup_notification_stream.
This commit is contained in:
parent
13cf34f283
commit
e019045abe
|
@ -1815,12 +1815,15 @@ class StripeTest(StripeTestCase):
|
|||
mock_customer = Mock(email=user.delivery_email, default_source=None)
|
||||
with patch("corporate.views.stripe_get_customer", return_value=mock_customer):
|
||||
response = self.client_get("/billing/")
|
||||
self.assert_in_success_response([
|
||||
self.assert_in_success_response(
|
||||
[
|
||||
"Your plan will be downgraded to <strong>Zulip Limited</strong> on "
|
||||
"<strong>January 2, 2013</strong>",
|
||||
"You plan is scheduled for downgrade on <strong>January 2, 2013</strong>",
|
||||
"Cancel downgrade",
|
||||
], response)
|
||||
],
|
||||
response,
|
||||
)
|
||||
|
||||
# Verify that we still write LicenseLedger rows during the remaining
|
||||
# part of the cycle
|
||||
|
|
|
@ -344,20 +344,27 @@ def get_signups_stream(realm: Realm) -> Stream:
|
|||
return get_stream("signups", realm)
|
||||
|
||||
|
||||
def notify_new_user(user_profile: UserProfile) -> None:
|
||||
sender_email = settings.NOTIFICATION_BOT
|
||||
sender = get_system_bot(sender_email)
|
||||
def send_message_to_signup_notification_stream(
|
||||
sender: UserProfile, realm: Realm, message: str, topic_name: str = _("signups")
|
||||
) -> None:
|
||||
signup_notifications_stream = realm.get_signup_notifications_stream()
|
||||
if signup_notifications_stream is None:
|
||||
return
|
||||
|
||||
with override_language(realm.default_language):
|
||||
internal_send_stream_message(sender, signup_notifications_stream, topic_name, message)
|
||||
|
||||
|
||||
def notify_new_user(user_profile: UserProfile) -> None:
|
||||
user_count = realm_user_count(user_profile.realm)
|
||||
signup_notifications_stream = user_profile.realm.get_signup_notifications_stream()
|
||||
# Send notification to realm signup notifications stream if it exists
|
||||
# Don't send notification for the first user in a realm
|
||||
if signup_notifications_stream is not None and user_count > 1:
|
||||
with override_language(user_profile.realm.default_language):
|
||||
sender = get_system_bot(settings.NOTIFICATION_BOT)
|
||||
|
||||
is_first_user = user_count == 1
|
||||
if not is_first_user:
|
||||
message = _("{user} just signed up for Zulip. (total: {user_count})").format(
|
||||
user=f"@_**{user_profile.full_name}|{user_profile.id}**", user_count=user_count
|
||||
)
|
||||
internal_send_stream_message(sender, signup_notifications_stream, _("signups"), message)
|
||||
send_message_to_signup_notification_stream(sender, user_profile.realm, message)
|
||||
|
||||
# We also send a notification to the Zulip administrative realm
|
||||
admin_realm = sender.realm
|
||||
|
|
Loading…
Reference in New Issue