Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Add field UserTopic.visibility_policy.

Abhijeet Prasad Bodas2153aa9495f8
diff --git a/zerver/migrations/0350_usertopic_visibility_policy.py b/zerver/migrations/0350_usertopic_visibility_policy.py
new file mode 100644
index 00000000000..04b89d1a216
--- /dev/null
+++ b/zerver/migrations/0350_usertopic_visibility_policy.py
@@ -0,0 +1,25 @@
+# Generated by Django 3.2.5 on 2021-08-02 07:29
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("zerver", "0349_alter_usertopic_table"),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name="usertopic",
+ name="visibility_policy",
+ field=models.SmallIntegerField(
+ choices=[
+ (1, "Muted topic"),
+ (2, "Unmuted topic in muted stream"),
+ (3, "Followed topic"),
+ ],
+ default=1,
+ ),
+ ),
+ ]
diff --git a/zerver/models.py b/zerver/models.py
index 0a46946e037..7c9fd456527 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -2205,6 +2205,26 @@ class UserTopic(models.Model):
default=datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
)
+ # A normal muted topic. No notifications and unreads hidden.
+ MUTED = 1
+
+ # This topic will behave like an unmuted topic in an unmuted stream even if it
+ # belongs to a muted stream.
+ UNMUTED = 2
+
+ # This topic will behave like `UNMUTED`, plus will also always trigger notifications.
+ FOLLOWED = 3
+
+ visibility_policy_choices = (
+ (MUTED, "Muted topic"),
+ (UNMUTED, "Unmuted topic in muted stream"),
+ (FOLLOWED, "Followed topic"),
+ )
+
+ visibility_policy: int = models.SmallIntegerField(
+ choices=visibility_policy_choices, default=MUTED
+ )
+
class Meta:
unique_together = ("user_profile", "stream", "topic_name")