user_topic: Add support for empty topic name.

This commit is a part of the work to support empty string
as a topic name.

Previously, empty string was not a valid topic name.

Now, toggling topic visibility policy operation supports
empty topic name.

Adds backward compatibility for:
- `topic_name` field in the `user_topic` event type
This commit is contained in:
Prakhar Pratyush
2024-11-14 18:45:31 +05:30
committed by Tim Abbott
parent 2dea392d9e
commit 27e95f7d33
5 changed files with 108 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ from django.db import transaction
from django.utils.timezone import now as timezone_now
from zerver.lib.timestamp import datetime_to_timestamp
from zerver.lib.topic import maybe_rename_general_chat_to_empty_topic
from zerver.lib.user_topics import (
bulk_set_user_topic_visibility_policy_in_database,
get_topic_mutes,
@@ -26,6 +27,8 @@ def bulk_do_set_user_topic_visibility_policy(
if last_updated is None:
last_updated = timezone_now()
topic_name = maybe_rename_general_chat_to_empty_topic(topic_name)
user_profiles_with_changed_user_topic_rows = bulk_set_user_topic_visibility_policy_in_database(
user_profiles,
stream.id,