Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
events: Fix bug in get_recent_conversations_recipient_id.
Mateusz Mandera90636d5e81e7
diff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex c1afc2425a4..7b09a37c38c 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -1160,7 +1160,7 @@ def get_recent_conversations_recipient_id(user_profile: UserProfile,get_recent_private_conversations would have used to record thatmessage in its data structure."""- my_recipient_id = user_profile.id+ my_recipient_id = user_profile.recipient_idif recipient_id == my_recipient_id:return UserProfile.objects.values_list('recipient_id', flat=True).get(id=sender_id)return recipient_iddiff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.pyindex e1fbe197ffe..b2c9660bbd2 100644--- a/zilencer/management/commands/populate_db.py+++ b/zilencer/management/commands/populate_db.py@@ -11,6 +11,7 @@ from django.conf import settingsfrom django.contrib.sessions.models import Sessionfrom django.core.management import call_commandfrom django.core.management.base import BaseCommand, CommandParser+from django.db import connectionfrom django.db.models import F, Maxfrom django.utils.timezone import now as timezone_nowfrom django.utils.timezone import timedelta as timezone_timedelta@@ -252,6 +253,15 @@ class Command(BaseCommand):if options["test_suite"]:random.seed(0)+ with connection.cursor() as cursor:+ # Sometimes bugs relating to confusing recipient.id for recipient.type_id+ # or <object>.id for <object>.recipient_id remain undiscovered by the test suite+ # due to these numbers happening to coincide in such a way that it makes tests+ # accidentally pass. By bumping the Recipient.id sequence by a large enough number,+ # we can have those ids in a completely different range of values than object ids,+ # eliminatng the possibility of such coincidences.+ cursor.execute("SELECT setval('zerver_recipient_id_seq', 100)")+# If max_topics is not set, we set it proportional to the# number of messages.if options["max_topics"] is None: