mirror of https://github.com/zulip/zulip.git
models: Add message type field.
This commit is contained in:
parent
ff4d7974f2
commit
bb76bc316f
|
@ -0,0 +1,26 @@
|
|||
# Generated by Django 5.0.6 on 2024-06-05 17:51
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zerver", "0535_remove_realm_create_public_stream_policy"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="archivedmessage",
|
||||
name="type",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
choices=[(1, "Normal"), (2, "Resolve Topic Notification")], db_default=1, default=1
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="message",
|
||||
name="type",
|
||||
field=models.PositiveSmallIntegerField(
|
||||
choices=[(1, "Normal"), (2, "Resolve Topic Notification")], db_default=1, default=1
|
||||
),
|
||||
),
|
||||
]
|
|
@ -40,6 +40,27 @@ class AbstractMessage(models.Model):
|
|||
# Important for efficient indexes and sharding in multi-realm servers.
|
||||
realm = models.ForeignKey(Realm, on_delete=CASCADE)
|
||||
|
||||
class MessageType(models.IntegerChoices):
|
||||
NORMAL = 1
|
||||
RESOLVE_TOPIC_NOTIFICATION = 2
|
||||
|
||||
# IMPORTANT: message.type is not to be confused with the
|
||||
# "recipient type" ("channel" or "direct"), which is is sometimes
|
||||
# called message_type in the APIs, CountStats or some variable
|
||||
# names. We intend to rename those to recipient_type.
|
||||
#
|
||||
# Type of the message, used to distinguish between "normal"
|
||||
# messages and some special kind of messages, such as notification
|
||||
# messages that may be sent by system bots.
|
||||
type = models.PositiveSmallIntegerField(
|
||||
choices=MessageType.choices,
|
||||
default=MessageType.NORMAL,
|
||||
# Note: db_default is a new feature in Django 5.0, so we don't use
|
||||
# it across the codebase yet. It's useful here to simplify the
|
||||
# associated database migration, so we're making use of it.
|
||||
db_default=MessageType.NORMAL,
|
||||
)
|
||||
|
||||
# The message's topic.
|
||||
#
|
||||
# Early versions of Zulip called this concept a "subject", as in an email
|
||||
|
|
Loading…
Reference in New Issue