Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
zerver: Update comments with "private message" or "PM".
Lauryn Menardd3f7cfccbc03
diff --git a/zerver/actions/create_user.py b/zerver/actions/create_user.pyindex 13b4b1c53b0..a4bfe3ea917 100644--- a/zerver/actions/create_user.py+++ b/zerver/actions/create_user.py@@ -213,7 +213,7 @@ def process_new_human_user(and prereg_user.referred_by is not Noneand prereg_user.referred_by.is_active):- # This is a cross-realm private message.+ # This is a cross-realm direct message.with override_language(prereg_user.referred_by.default_language):internal_send_private_message(get_system_bot(settings.NOTIFICATION_BOT, prereg_user.referred_by.realm_id),diff --git a/zerver/actions/message_delete.py b/zerver/actions/message_delete.pyindex d75a776edd9..7777793bba7 100644--- a/zerver/actions/message_delete.py+++ b/zerver/actions/message_delete.py@@ -17,7 +17,7 @@ class DeleteMessagesEvent(TypedDict, total=False):def do_delete_messages(realm: Realm, messages: Iterable[Message]) -> None:# messages in delete_message event belong to the same topic- # or is a single private message, as any other behaviour is not possible with+ # or is a single direct message, as any other behaviour is not possible with# the current callers to this method.messages = list(messages)message_ids = [message.id for message in messages]diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.pyindex 69eae217947..e474d8e31ff 100644--- a/zerver/actions/message_send.py+++ b/zerver/actions/message_send.py@@ -475,7 +475,7 @@ def get_service_bot_events(# Mention triggers, for stream messagesif is_stream and user_profile_id in mentioned_user_ids:trigger = "mention"- # PM triggers for personal and huddle messages+ # Direct message triggers for personal and huddle messageselif (not is_stream) and (user_profile_id in active_user_ids):trigger = "private_message"else:@@ -1192,8 +1192,8 @@ def send_rate_limited_pm_notification_to_bot_owner(sender: UserProfile, realm: Realm, content: str) -> None:"""- Sends a PM error notification to a bot's owner if one hasn't already- been sent in the last 5 minutes.+ Sends a direct message error notification to a bot's owner if one+ hasn't already been sent in the last 5 minutes."""if sender.realm.is_zephyr_mirror_realm or sender.realm.deactivated:return@@ -1209,7 +1209,7 @@ def send_rate_limited_pm_notification_to_bot_owner(return# We warn the user once every 5 minutes to avoid a flood of- # PMs on a misconfigured integration, re-using the+ # direct messages on a misconfigured integration, re-using the# UserProfile.last_reminder field, which is not used for bots.last_reminder = sender.last_reminderwaitperiod = datetime.timedelta(minutes=UserProfile.BOT_OWNER_STREAM_ALERT_WAITPERIOD)@@ -1316,8 +1316,8 @@ def check_private_message_policy() -> None:if realm.private_message_policy == Realm.PRIVATE_MESSAGE_POLICY_DISABLED:if sender.is_bot or (len(user_profiles) == 1 and user_profiles[0].is_bot):- # We allow PMs only between users and bots, to avoid- # breaking the tutorial as well as automated+ # We allow direct messages only between users and bots,+ # to avoid breaking the tutorial as well as automated# notifications from system bots to users.returndiff --git a/zerver/actions/users.py b/zerver/actions/users.pyindex 44da0e06bad..42efdccb8de 100644--- a/zerver/actions/users.py+++ b/zerver/actions/users.py@@ -65,7 +65,7 @@ def do_delete_user(user_profile: UserProfile, *, acting_user: Optional[UserProfiuser_profile.delete()# Recipient objects don't get deleted through CASCADE, so we need to handle# the user's personal recipient manually. This will also delete all Messages pointing- # to this recipient (all private messages sent to the user).+ # to this recipient (all direct messages sent to the user).assert personal_recipient is not Nonepersonal_recipient.delete()replacement_user = create_user(diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.pyindex 986edd2ec33..0879abeebfc 100644--- a/zerver/data_import/rocketchat.py+++ b/zerver/data_import/rocketchat.py@@ -675,7 +675,7 @@ def process_messages(# Add recipient_id to message_dictif is_pm_data:- # Message is in a PM or a huddle.+ # Message is in a 1:1 or group direct message.rc_channel_id = message["rid"]if rc_channel_id in huddle_id_to_huddle_map:huddle_id = huddle_id_mapper.get(rc_channel_id)@@ -684,7 +684,7 @@ def process_messages(rc_member_ids = direct_id_to_direct_map[rc_channel_id]["uids"]if len(rc_member_ids) == 1: # nocoverage- # PMs to yourself only have one user.+ # direct messages to yourself only have one user.rc_member_ids.append(rc_member_ids[0])if rc_sender_id == rc_member_ids[0]:zulip_member_id = user_id_mapper.get(rc_member_ids[1])@@ -1220,7 +1220,7 @@ def do_convert_data(rocketchat_data_dir: str, output_dir: str) -> None:upload_id_to_upload_data_map=upload_id_to_upload_data_map,output_dir=output_dir,)- # Process private messages+ # Process direct messagesprocess_messages(realm_id=realm_id,messages=private_messages,diff --git a/zerver/lib/addressee.py b/zerver/lib/addressee.pyindex a5a172407c0..3fe8395516d 100644--- a/zerver/lib/addressee.py+++ b/zerver/lib/addressee.py@@ -40,8 +40,8 @@ class Addressee:# around in a non-type-safe way before this class was introduced.## It also avoids some nonsense where you have to think about whether- # topic should be None or '' for a PM, or you have to make an array- # of one stream.+ # topic should be None or '' for a direct message, or you have to+ # make an array of one stream.## Eventually we can use this to cache Stream and UserProfile objects# in memory.diff --git a/zerver/lib/email_notifications.py b/zerver/lib/email_notifications.pyindex 1e2834f16fa..fdccd7129de 100644--- a/zerver/lib/email_notifications.py+++ b/zerver/lib/email_notifications.py@@ -411,12 +411,13 @@ def do_send_missedmessage_events_reply_in_zulip(user_profile: UserProfile, missed_messages: List[Dict[str, Any]], message_count: int) -> None:"""- Send a reminder email to a user if she's missed some PMs by being offline.+ Send a reminder email to a user if she's missed some direct messages+ by being offline.The email will have its reply to address set to a limited used emailaddress that will send a Zulip message to the correct recipient. This- allows the user to respond to missed PMs, huddles, and @-mentions directly- from the email.+ allows the user to respond to missed direct messages, huddles, and+ @-mentions directly from the email.`user_profile` is the user to send the reminder to`missed_messages` is a list of dictionaries to Message objects and other data@@ -639,11 +640,11 @@ def handle_missedmessage_emails(# We bucket messages by tuples that identify similar messages.# For streams it's recipient_id and topic.- # For PMs it's recipient id and sender.+ # For direct messages it's recipient id and sender.messages_by_bucket: Dict[Tuple[int, Union[int, str]], List[Message]] = defaultdict(list)for msg in messages:if msg.recipient.type == Recipient.PERSONAL:- # For PM's group using (recipient, sender).+ # For direct messages group using (recipient, sender).messages_by_bucket[(msg.recipient_id, msg.sender_id)].append(msg)else:messages_by_bucket[(msg.recipient_id, msg.topic_name().lower())].append(msg)diff --git a/zerver/lib/events.py b/zerver/lib/events.pyindex 6db628faf6c..6e7e3efab82 100644--- a/zerver/lib/events.py+++ b/zerver/lib/events.py@@ -515,10 +515,12 @@ def fetch_initial_state_data(## [{'max_message_id': 700175, 'user_ids': [801]}]#- # for all recent private message conversations, ordered by the- # highest message ID in the conversation. The user_ids list+ # for all recent direct message conversations, ordered by the+ # highest message ID in the conversation. The user_ids list# is the list of users other than the current user in the- # private message conversation (so it is [] for PMs to self).+ # direct message conversation (so it is [] for direct messages+ # to self).+ ## Note that raw_recent_private_conversations is an# intermediate form as a dictionary keyed by recipient_id,# which is more efficient to update, and is rewritten to thediff --git a/zerver/lib/export.py b/zerver/lib/export.pyindex 6fc227b736a..385aaaaa6d3 100644--- a/zerver/lib/export.py+++ b/zerver/lib/export.py@@ -1253,9 +1253,10 @@ def export_partial_message_files(# equates to a recipient object we are exporting)## TODO: In theory, you should be able to export messages in- # cross-realm PM threads; currently, this only exports cross-realm- # messages received by your realm that were sent by Zulip system- # bots (e.g. emailgateway, notification-bot).+ # cross-realm direct message threads; currently, this only+ # exports cross-realm messages received by your realm that+ # were sent by Zulip system bots (e.g. emailgateway,+ # notification-bot).# Here, "we" and "us" refers to the inner circle of users who# were specified as being allowed to be exported. "Them"@@ -1345,12 +1346,13 @@ def export_partial_message_files(message_queries.append(messages_we_received_in_protected_history_streams)# The above query is missing some messages that consenting- # users have access to, namely, PMs sent by one of the users- # in our export to another user (since the only subscriber to- # a Recipient object for Recipient.PERSONAL is the recipient,- # not the sender). The `consented_user_ids` list has- # precisely those users whose Recipient.PERSONAL recipient ID- # was already present in recipient_ids_for_us above.+ # users have access to, namely, direct messages sent by one+ # of the users in our export to another user (since the only+ # subscriber to a Recipient object for Recipient.PERSONAL is+ # the recipient, not the sender). The `consented_user_ids`+ # list has precisely those users whose Recipient.PERSONAL+ # recipient ID was already present in recipient_ids_for_us+ # above.ids_of_non_exported_possible_recipients = ids_of_our_possible_senders - consented_user_idsrecipients_for_them = Recipient.objects.filter(diff --git a/zerver/lib/message.py b/zerver/lib/message.pyindex 976ca96a6b4..12c234734bc 100644--- a/zerver/lib/message.py+++ b/zerver/lib/message.py@@ -833,7 +833,7 @@ def has_message_access(return Trueif message.recipient.type != Recipient.STREAM:- # You can't access private messages you didn't receive+ # You can't access direct messages you didn't receivereturn Falseif stream is None:@@ -1160,7 +1160,7 @@ def extract_unread_data_from_um_rows(topic = row[MESSAGE__TOPIC]if not is_row_muted(stream_id, recipient_id, topic):mentions.add(message_id)- else: # nocoverage # TODO: Test wildcard mentions in PMs.+ else: # nocoverage # TODO: Test wildcard mentions in direct messages.mentions.add(message_id)# Record whether the user had more than MAX_UNREAD_MESSAGES total@@ -1497,9 +1497,9 @@ def get_recent_conversations_recipient_id(def get_recent_private_conversations(user_profile: UserProfile) -> Dict[int, Dict[str, Any]]:"""This function uses some carefully optimized SQL queries, designedto use the UserMessage index on private_messages. It is- significantly complicated by the fact that for 1:1 private+ significantly complicated by the fact that for 1:1 directmessages, we store the message against a recipient_id of whichever- user was the recipient, and thus for 1:1 private messages sent+ user was the recipient, and thus for 1:1 direct messages sentdirectly to us, we need to look up the other user from thesender_id on those messages. You'll see that pattern repeatedboth here and also in zerver/lib/events.py.@@ -1579,8 +1579,8 @@ def get_recent_private_conversations(user_profile: UserProfile) -> Dict[int, Dic# The resulting rows will be (recipient_id, max_message_id)# objects for all parties we've had recent (group?) private- # message conversations with, including PMs with yourself (those- # will generate an empty list of user_ids).+ # message conversations with, including direct messages with+ # yourself (those will generate an empty list of user_ids).for recipient_id, max_message_id in rows:recipient_map[recipient_id] = dict(max_message_id=max_message_id,diff --git a/zerver/lib/onboarding.py b/zerver/lib/onboarding.pyindex b2b399d8046..7ad9880bd21 100644--- a/zerver/lib/onboarding.py+++ b/zerver/lib/onboarding.py@@ -245,7 +245,7 @@ def select_welcome_bot_response(human_response_lower: str) -> str:def send_welcome_bot_response(send_request: SendMessageRequest) -> None:- """Given the send_request object for a private message from the user+ """Given the send_request object for a direct message from the userto welcome-bot, trigger the welcome-bot reply."""welcome_bot = get_system_bot(settings.WELCOME_BOT, send_request.message.sender.realm_id)human_response_lower = send_request.message.content.lower()diff --git a/zerver/lib/push_notifications.py b/zerver/lib/push_notifications.pyindex b4ae0065c46..030fab67196 100644--- a/zerver/lib/push_notifications.py+++ b/zerver/lib/push_notifications.py@@ -157,7 +157,7 @@ def modernize_apns_payload(data: Mapping[str, Any]) -> Mapping[str, Any]:if "message_ids" in data:# The format sent by 1.6.0, from the earliest pre-1.6.0# version with bouncer support up until 613d093d7 pre-1.7.0:- # 'alert': str, # just sender, and text about PM/group-PM/mention+ # 'alert': str, # just sender, and text about direct message/mention# 'message_ids': List[int], # always just onereturn {"alert": data["alert"],@@ -817,7 +817,7 @@ def get_apns_alert_title(message: Message) -> str:return ", ".join(sorted(r["full_name"] for r in recipients))elif message.is_stream_message():return f"#{get_display_recipient(message.recipient)} > {message.topic_name()}"- # For personal PMs, we just show the sender name.+ # For 1:1 direct messages, we just show the sender name.return message.sender.full_name@@ -841,7 +841,8 @@ def get_apns_alert_subtitle(return _("{full_name} mentioned everyone:").format(full_name=message.sender.full_name)elif message.recipient.type == Recipient.PERSONAL:return ""- # For group PMs, or regular messages to a stream, just use a colon to indicate this is the sender.+ # For group direct messages, or regular messages to a stream,+ # just use a colon to indicate this is the sender.return message.sender.full_name + ":"diff --git a/zerver/lib/recipient_users.py b/zerver/lib/recipient_users.pyindex 7baa411609d..0802f3ec4d0 100644--- a/zerver/lib/recipient_users.py+++ b/zerver/lib/recipient_users.py@@ -28,7 +28,7 @@ def get_recipient_from_user_profiles(if forwarder_user_profile.id not in recipient_profiles_map:raise ValidationError(_("User not authorized for this query"))- # If the private message is just between the sender and+ # If the direct message is just between the sender and# another person, force it to be a personal internallyif len(recipient_profiles_map) == 2 and sender.id in recipient_profiles_map:del recipient_profiles_map[sender.id]diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.pyindex 25df47e3513..362e1fb8e45 100644--- a/zerver/lib/test_classes.py+++ b/zerver/lib/test_classes.py@@ -1945,7 +1945,7 @@ You can fix this by adding "{complete_event_type}" to ALL_EVENT_TYPES for this wWe simulate the delivery of the payload with `content_type`,and you can pass other headers via `extra`.- For the rare cases of webhooks actually sending private messages,+ For the rare cases of webhooks actually sending direct messages,see send_and_test_private_message.When no message is expected to be sent, set `expect_noop` to True.@@ -2014,7 +2014,7 @@ one or more new messages.) -> Message:"""For the rare cases that you are testing a webhook that sends- private messages, use this function.+ direct messages, use this function.Most webhooks send to streams, and you will want to look atcheck_webhook.diff --git a/zerver/models.py b/zerver/models.pyindex ffc29de71ed..52132650212 100644--- a/zerver/models.py+++ b/zerver/models.py@@ -1443,11 +1443,11 @@ class Recipient(models.Model):which is the ID of the UserProfile/Stream/Huddle object containingall the metadata for the audience. There are 3 recipient types:- 1. 1:1 private message: The type_id is the ID of the UserProfile+ 1. 1:1 direct message: The type_id is the ID of the UserProfilewho will receive any message to this Recipient. The senderof such a message is represented separately.2. Stream message: The type_id is the ID of the associated Stream.- 3. Group private message: In Zulip, group private messages are+ 3. Group direct message: In Zulip, group direct messages arerepresented by Huddle objects, which encode the set of usersin the conversation. The type_id is the ID of the associated Huddleobject; the set of users is usually retrieved via the Subscription@@ -1461,11 +1461,11 @@ class Recipient(models.Model):type = models.PositiveSmallIntegerField(db_index=True)# Valid types are {personal, stream, huddle}- # The type for 1:1 private messages.+ # The type for 1:1 direct messages.PERSONAL = 1# The type for stream messages.STREAM = 2- # The type group private messages.+ # The type group direct messages.HUDDLE = 3class Meta:@@ -1596,7 +1596,7 @@ class UserBaseSettings(models.Model):enable_followed_topic_audible_notifications = models.BooleanField(default=True)enable_followed_topic_wildcard_mentions_notify = models.BooleanField(default=True)- # PM + @-mention notifications.+ # Direct message + @-mention notifications.enable_desktop_notifications = models.BooleanField(default=True)pm_content_in_desktop_notifications = models.BooleanField(default=True)enable_sounds = models.BooleanField(default=True)@@ -3330,9 +3330,9 @@ class AbstractUserMessage(models.Model):# their history via e.g. starring the message. This is# important accounting for the "Subscribed to stream" dividers."historical",- # Whether the message is a private message; this flag is a+ # Whether the message is a direct message; this flag is a# denormalization of message.recipient.type to support an- # efficient index on UserMessage for a user's private messages.+ # efficient index on UserMessage for a user's direct messages."is_private",# Whether we've sent a push notification to the user's mobile# devices for this message that has not been revoked.@@ -3685,7 +3685,7 @@ def validate_attachment_request(messages = attachment.messages.all()if UserMessage.objects.filter(user_profile=user_profile, message__in=messages).exists():- # If it was sent in a private message or private stream+ # If it was sent in a direct message or private stream# message, then anyone who received that message can access it.return True@@ -3751,7 +3751,7 @@ class Subscription(models.Model):"""Keeps track of which users are part of theaudience for a given Recipient object.- For private and group private message Recipient objects, only the+ For 1:1 and group direct message Recipient objects, only theuser_profile and recipient fields have any meaning, defining theimmutable set of users who are in the audience for that Recipient.@@ -4038,7 +4038,7 @@ def is_cross_realm_bot_email(email: str) -> bool:class Huddle(models.Model):"""Represents a group of individuals who may have a- group private message conversation together.+ group direct message conversation together.The membership of the Huddle is stored in the Subscription table just like withStreams - for each user in the Huddle, there is a Subscription object@@ -4282,7 +4282,7 @@ class MissedMessageEmailAddress(models.Model):class NotificationTriggers:- # "private_message" is for 1:1 PMs as well as huddles+ # "private_message" is for 1:1 direct messages as well as huddlesPRIVATE_MESSAGE = "private_message"MENTION = "mentioned"WILDCARD_MENTION = "wildcard_mentioned"diff --git a/zerver/tornado/event_queue.py b/zerver/tornado/event_queue.pyindex 84bb0ccdac6..6823844dd28 100644--- a/zerver/tornado/event_queue.py+++ b/zerver/tornado/event_queue.py@@ -856,7 +856,7 @@ def maybe_enqueue_notifications(queue_json_publish("missedmessage_mobile_notifications", notice)notified["push_notified"] = True- # Send missed_message emails if a private message or a+ # Send missed_message emails if a direct message or a# mention. Eventually, we'll add settings to allow email# notifications to match the model of push notifications# above.@@ -982,8 +982,8 @@ def process_message_event(flags: Collection[str] = user_data.get("flags", [])mentioned_user_group_id: Optional[int] = user_data.get("mentioned_user_group_id")- # If the recipient was offline and the message was a single or group PM to them- # or they were @-notified potentially notify more immediately+ # If the recipient was offline and the message was a (1:1 or group) direct message+ # to them or they were @-notified potentially notify more immediatelyprivate_message = recipient_type_name == "private"user_notifications_data = UserMessageNotificationsData.from_user_id_sets(user_id=user_profile_id,@@ -1270,8 +1270,9 @@ def maybe_enqueue_notifications_for_message_update(returnif private_message:- # We don't do offline notifications for PMs, because- # we already notified the user of the original message+ # We don't do offline notifications for direct messages,+ # because we already notified the user of the original+ # message.returnif prior_mentioned:diff --git a/zerver/views/home.py b/zerver/views/home.pyindex 5a131327c53..5cb81b5f242 100644--- a/zerver/views/home.py+++ b/zerver/views/home.py@@ -113,7 +113,7 @@ def detect_narrowed_window(if "stream" in request.GET:try:- # TODO: We should support stream IDs and PMs here as well.+ # TODO: We should support stream IDs and direct messages here as well.narrow_stream_name = request.GET.get("stream")assert narrow_stream_name is not None(narrow_stream, ignored_sub) = access_stream_by_name(user_profile, narrow_stream_name)diff --git a/zerver/views/message_fetch.py b/zerver/views/message_fetch.pyindex dd8452fc455..0a5b6a08128 100644--- a/zerver/views/message_fetch.py+++ b/zerver/views/message_fetch.py@@ -113,7 +113,7 @@ def get_messages_backend(# authentication code (where we should return an auth error).## GetOldMessagesTest.test_unauthenticated_* tests ensure- # that we are not leaking any secure data (private messages and+ # that we are not leaking any secure data (direct messages and# non-web-public stream messages) via this path.if not realm.allow_web_public_streams_access():raise MissingAuthenticationErrordiff --git a/zerver/views/message_send.py b/zerver/views/message_send.pyindex 0171d4b3636..fea12afaa9c 100644--- a/zerver/views/message_send.py+++ b/zerver/views/message_send.py@@ -186,7 +186,7 @@ def send_message_backend(if client.name in ["zephyr_mirror", "irc_mirror", "jabber_mirror", "JabberMirror"]:# Here's how security works for mirroring:#- # For private messages, the message must be (1) both sent and+ # For direct messages, the message must be (1) both sent and# received exclusively by users in your realm, and (2)# received by the forwarding user.#diff --git a/zerver/worker/queue_processors.py b/zerver/worker/queue_processors.pyindex c5ba00dacf9..ff681684600 100644--- a/zerver/worker/queue_processors.py+++ b/zerver/worker/queue_processors.py@@ -1116,7 +1116,7 @@ class DeferredWorker(QueueProcessingWorker):export_event.extra_data = orjson.dumps(extra_data).decode()export_event.save(update_fields=["extra_data"])- # Send a private message notification letting the user who+ # Send a direct message notification letting the user who# triggered the export know the export finished.with override_language(user_profile.default_language):content = _(