unarchive_stream: Prevent unarchiving a stream in the wrong realm.

This commit is contained in:
Alex Vandiver 2024-04-10 21:27:08 +00:00 committed by Tim Abbott
parent 01b59c5aa2
commit d834f1fc01
1 changed files with 4 additions and 0 deletions

View File

@ -43,6 +43,10 @@ class Command(ZulipBaseCommand):
if options["stream_id"] is not None:
stream = Stream.objects.get(id=options["stream_id"])
if stream.realm_id != realm.id:
raise CommandError(
f"Stream id {stream.id}, named '{stream.name}', is in realm '{stream.realm.string_id}', not '{realm.string_id}'"
)
if not stream.deactivated:
raise CommandError(
f"Stream id {stream.id}, named '{stream.name}', is not deactivated"