message_edit: Cleanup empty topic check.

This commit is contained in:
Vector73
2025-07-10 06:04:19 +00:00
committed by Tim Abbott
parent b198ff9f0c
commit d0bc9b8f92

View File

@@ -1485,18 +1485,15 @@ def build_message_edit_request(
topics_policy = get_stream_topics_policy(message.realm, target_stream)
empty_topic_display_name = get_topic_display_name("", user_profile.default_language)
target_topic_empty = ("(no topic)", "")
target_topic_empty = target_topic_name in ("(no topic)", "")
if (
target_topic_name in target_topic_empty
target_topic_empty
and (is_topic_edited or is_stream_edited)
and topics_policy == StreamTopicsPolicyEnum.disable_empty_topic.value
):
raise MessagesNotAllowedInEmptyTopicError(empty_topic_display_name)
if (
topics_policy == StreamTopicsPolicyEnum.empty_topic_only.value
and target_topic_name not in target_topic_empty
):
if topics_policy == StreamTopicsPolicyEnum.empty_topic_only.value and not target_topic_empty:
raise TopicsNotAllowedError(empty_topic_display_name)
return StreamMessageEditRequest(