mirror of https://github.com/zulip/zulip.git
onboarding: Add 'OnboardingUserMessage' model.
This prep commit adds a new OnboardingUserMessage model that will be used to mark the new onboarding messages for new users as unread and the first message of each onboarding topic as starred. This table won't include the old onboarding messages.
This commit is contained in:
parent
485a8a1421
commit
fb836a4f0a
|
@ -141,6 +141,7 @@ ALL_ZULIP_TABLES = {
|
|||
"zerver_multiuseinvite_streams",
|
||||
"zerver_namedusergroup",
|
||||
"zerver_onboardingstep",
|
||||
"zerver_onboardingusermessage",
|
||||
"zerver_preregistrationrealm",
|
||||
"zerver_preregistrationuser",
|
||||
"zerver_preregistrationuser_streams",
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
# Generated by Django 5.0.6 on 2024-06-27 06:03
|
||||
|
||||
import bitfield.models
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("zerver", "0541_alter_realmauditlog_options"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="OnboardingUserMessage",
|
||||
fields=[
|
||||
(
|
||||
"id",
|
||||
models.BigAutoField(
|
||||
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||
),
|
||||
),
|
||||
("flags", bitfield.models.BitField(["read", "historical", "starred"], default=0)),
|
||||
(
|
||||
"message",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
|
||||
),
|
||||
),
|
||||
(
|
||||
"realm",
|
||||
models.ForeignKey(
|
||||
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -26,6 +26,7 @@ from zerver.models.messages import ArchivedUserMessage as ArchivedUserMessage
|
|||
from zerver.models.messages import ArchiveTransaction as ArchiveTransaction
|
||||
from zerver.models.messages import Attachment as Attachment
|
||||
from zerver.models.messages import Message as Message
|
||||
from zerver.models.messages import OnboardingUserMessage as OnboardingUserMessage
|
||||
from zerver.models.messages import Reaction as Reaction
|
||||
from zerver.models.messages import SubMessage as SubMessage
|
||||
from zerver.models.messages import UserMessage as UserMessage
|
||||
|
|
|
@ -770,3 +770,17 @@ class Attachment(AbstractAttachment):
|
|||
|
||||
post_save.connect(flush_used_upload_space_cache, sender=Attachment)
|
||||
post_delete.connect(flush_used_upload_space_cache, sender=Attachment)
|
||||
|
||||
|
||||
class OnboardingUserMessage(models.Model):
|
||||
"""
|
||||
Stores the message_id of new onboarding messages with the
|
||||
flags data that should be copied while creating UserMessage
|
||||
rows for a new user in 'add_new_user_history'.
|
||||
"""
|
||||
|
||||
realm = models.ForeignKey(Realm, on_delete=CASCADE)
|
||||
message = models.ForeignKey(Message, on_delete=CASCADE)
|
||||
|
||||
ALL_FLAGS = ["read", "historical", "starred"]
|
||||
flags: BitHandler = BitField(flags=ALL_FLAGS, default=0)
|
||||
|
|
|
@ -355,7 +355,7 @@ class DeleteMessageTest(ZulipTestCase):
|
|||
self.assertEqual(stream.first_message_id, message_ids[1])
|
||||
|
||||
all_messages = Message.objects.filter(id__in=message_ids)
|
||||
with self.assert_database_query_count(23):
|
||||
with self.assert_database_query_count(24):
|
||||
do_delete_messages(realm, all_messages)
|
||||
stream = get_stream(stream_name, realm)
|
||||
self.assertEqual(stream.first_message_id, None)
|
||||
|
|
|
@ -1143,7 +1143,7 @@ class TestDoDeleteMessages(ZulipTestCase):
|
|||
message_ids = [self.send_stream_message(cordelia, "Verona", str(i)) for i in range(10)]
|
||||
messages = Message.objects.filter(id__in=message_ids)
|
||||
|
||||
with self.assert_database_query_count(21):
|
||||
with self.assert_database_query_count(22):
|
||||
do_delete_messages(realm, messages)
|
||||
self.assertFalse(Message.objects.filter(id__in=message_ids).exists())
|
||||
|
||||
|
|
Loading…
Reference in New Issue