Skip to content

A platform for community discussion. Free, open, simple.

FIX: email summary subject order should be consistent (#19469)

Roman Rizzifa8d6860b10b
diff --git a/plugins/chat/lib/extensions/user_notifications_extension.rb b/plugins/chat/lib/extensions/user_notifications_extension.rb
index 23c77295a46..33e9abc65e2 100644
--- a/plugins/chat/lib/extensions/user_notifications_extension.rb
+++ b/plugins/chat/lib/extensions/user_notifications_extension.rb
@@ -63,7 +63,9 @@ module Chat::UserNotificationsExtension
all_channels = grouped_messages.keys
grouped_channels = all_channels.partition { |c| !c.direct_message_channel? }
channels = grouped_channels.first
- dm_users = grouped_channels.last.flat_map { |c| grouped_messages[c].map(&:user) }.uniq
+
+ dm_messages = grouped_channels.last.flat_map { |c| grouped_messages[c] }
+ dm_users = dm_messages.sort_by(&:created_at).uniq { |m| m.user_id }.map(&:user)
# Prioritize messages from regular channels over direct messages
if channels.any?