mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 03:53:50 +00:00 
			
		
		
		
	server: Sort user_ids in recent PM conversations.
This change should prevent test flakes, plus it's more deterministic behavior for clients, who will generally comma-join the ids into a key for their internal data structures. I was able to verify test coverage on this by making the sort reversed, which would cause test_huddle_send_message_events to fail.
This commit is contained in:
		| @@ -424,9 +424,9 @@ def apply_event(state: Dict[str, Any], | ||||
|  | ||||
|                 if recipient_id not in conversations: | ||||
|                     conversations[recipient_id] = dict( | ||||
|                         user_ids=[user_dict['id'] for user_dict in | ||||
|                         user_ids=sorted([user_dict['id'] for user_dict in | ||||
|                                          event['message']['display_recipient'] if | ||||
|                                   user_dict['id'] != user_profile.id] | ||||
|                                          user_dict['id'] != user_profile.id]) | ||||
|                     ) | ||||
|                 conversations[recipient_id]['max_message_id'] = event['message']['id'] | ||||
|             return | ||||
|   | ||||
| @@ -1133,4 +1133,9 @@ def get_recent_private_conversations(user_profile: UserProfile) -> Dict[int, Dic | ||||
|                 user_profile_id=user_profile.id).values_list( | ||||
|                     "recipient_id", "user_profile_id"): | ||||
|         recipient_map[recipient_id]['user_ids'].append(user_profile_id) | ||||
|  | ||||
|     # Sort to prevent test flakes and client bugs. | ||||
|     for rec in recipient_map.values(): | ||||
|         rec['user_ids'].sort() | ||||
|  | ||||
|     return recipient_map | ||||
|   | ||||
		Reference in New Issue
	
	Block a user