diff --git a/confirmation/models.py b/confirmation/models.py index 4cc1b5a2fe..66c0af92e7 100644 --- a/confirmation/models.py +++ b/confirmation/models.py @@ -72,6 +72,9 @@ def create_confirmation_link(obj: ContentType, host: str, realm = None if hasattr(obj, 'realm'): realm = obj.realm + elif isinstance(obj, Realm): + realm = obj + Confirmation.objects.create(content_object=obj, date_sent=timezone_now(), confirmation_key=key, realm=realm, type=confirmation_type) return confirmation_url(key, host, confirmation_type, url_args) diff --git a/zerver/tests/test_realm.py b/zerver/tests/test_realm.py index fca71673ff..df29209e3d 100644 --- a/zerver/tests/test_realm.py +++ b/zerver/tests/test_realm.py @@ -223,6 +223,15 @@ class RealmTest(ZulipTestCase): realm = get_realm('zulip') self.assertFalse(realm.deactivated) + def test_realm_reactivation_confirmation_object(self) -> None: + realm = get_realm('zulip') + do_deactivate_realm(realm) + self.assertTrue(realm.deactivated) + create_confirmation_link(realm, realm.host, Confirmation.REALM_REACTIVATION) + confirmation = Confirmation.objects.last() + self.assertEqual(confirmation.content_object, realm) + self.assertEqual(confirmation.realm, realm) + def test_do_send_realm_reactivation_email(self) -> None: realm = get_realm('zulip') do_send_realm_reactivation_email(realm)