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