mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 21:43:21 +00:00
Adds delete_expired_demo_organizations to the archive_messages management command, which is run as a cron job. Adds "demo_expired" as a `RealmDeactivationReasonType` to be used for this specific case of calling do_deactivate_realm. The function loops through non-deactivated realms that have a demo organization scheduled deletion datetime set that is less than the current datetime.
28 lines
842 B
Python
28 lines
842 B
Python
from typing import Any
|
|
|
|
from typing_extensions import override
|
|
|
|
from zerver.actions.realm_settings import (
|
|
clean_deactivated_realm_data,
|
|
delete_expired_demo_organizations,
|
|
)
|
|
from zerver.lib.management import ZulipBaseCommand, abort_unless_locked
|
|
from zerver.lib.retention import archive_messages, clean_archived_data
|
|
|
|
|
|
class Command(ZulipBaseCommand):
|
|
@override
|
|
@abort_unless_locked
|
|
def handle(self, *args: Any, **options: str) -> None:
|
|
clean_archived_data()
|
|
archive_messages()
|
|
scrub_realms()
|
|
|
|
|
|
def scrub_realms() -> None:
|
|
# First, scrub currently deactivated realms that have an expired
|
|
# scheduled deletion date. Then, deactivate and scrub realms with
|
|
# an expired scheduled demo organization deletion date.
|
|
clean_deactivated_realm_data()
|
|
delete_expired_demo_organizations()
|