mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	mattermost: Handle duplicate dm-groups.
Observed in the wild, cause unknown. Partially fixes: #24131. Co-authored-by: Mateusz Mandera <mateusz.mandera@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							989d425023
						
					
				
				
					commit
					c8c480baef
				
			@@ -244,6 +244,9 @@ def convert_direct_message_group_data(
 | 
			
		||||
    for direct_message_group in direct_message_group_data:
 | 
			
		||||
        if len(direct_message_group["members"]) > 2:
 | 
			
		||||
            direct_message_group_members = frozenset(direct_message_group["members"])
 | 
			
		||||
            if direct_message_group_id_mapper.has(direct_message_group_members):
 | 
			
		||||
                logging.info("Duplicate direct message group found in the export data. Skipping.")
 | 
			
		||||
                continue
 | 
			
		||||
            direct_message_group_id = direct_message_group_id_mapper.get(
 | 
			
		||||
                direct_message_group_members
 | 
			
		||||
            )
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
{"type":"post","post":{"team":"gryffindor","channel":"gryffindor-common-room","user":"harry","message":"Looks like this channel is empty","create_at":1553166567370,"reactions":[{"user":"ron","create_at":1553166584976,"emoji_name":"rocket"}],"replies":null,"attachments":[{"path":"20210622/teams/noteam/channels/mcrm7xee5bnpzn7u9ktsd91dwy/users/knq189b88fdxbdkeeasdynia4o/smaa5epsnp89tgjszzue1691ao/this is a file"}]}}
 | 
			
		||||
{"type":"direct_channel","direct_channel":{"members":["ron","harry"],"favorited_by":null,"header":""}}
 | 
			
		||||
{"type":"direct_channel","direct_channel":{"members":["ron","harry", "ginny"],"favorited_by":null,"header":""}}
 | 
			
		||||
{"type":"direct_channel","direct_channel":{"members":["harry","ron", "ginny"],"favorited_by":null,"header":""}}
 | 
			
		||||
{"type":"direct_post","direct_post":{"channel_members":["ron","harry"],"user":"ron","message":"hey harry","create_at":1566376137676,"flagged_by":null,"reactions":null,"replies":null,"attachments":[{"path":"20210622/teams/noteam/channels/mcrm7xee5bnpzn7u9ktsd91dwy/users/knq189b88fdxbdkeeasdynia4o/o3to4ezua3bajj31mzpkn96n5e/harry-ron.jpg"}]}}
 | 
			
		||||
{"type":"direct_post","direct_post":{"channel_members":["ron","harry"],"user":"harry","message":"what's up","create_at":1566376318568,"flagged_by":null,"reactions":null,"replies":null,"attachments":null}}
 | 
			
		||||
{"type":"direct_post","direct_post":{"channel_members":["ron","harry","ginny"],"user":"ginny","message":"Who is going to Hogsmeade this weekend?","create_at":1566376226493,"flagged_by":null,"reactions":null,"replies":null,"attachments":null}}
 | 
			
		||||
 
 | 
			
		||||
@@ -357,6 +357,7 @@ class MatterMostImporter(ZulipTestCase):
 | 
			
		||||
            team_name=team_name,
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
        with self.assertLogs(level="INFO") as mock_log:
 | 
			
		||||
            zerver_huddle = convert_direct_message_group_data(
 | 
			
		||||
                direct_message_group_data=mattermost_data["direct_channel"],
 | 
			
		||||
                user_data_map=username_to_user,
 | 
			
		||||
@@ -379,6 +380,10 @@ class MatterMostImporter(ZulipTestCase):
 | 
			
		||||
            ),
 | 
			
		||||
            {1, 2, 3},
 | 
			
		||||
        )
 | 
			
		||||
        self.assertEqual(
 | 
			
		||||
            mock_log.output,
 | 
			
		||||
            ["INFO:root:Duplicate direct message group found in the export data. Skipping."],
 | 
			
		||||
        )
 | 
			
		||||
 | 
			
		||||
    def test_write_emoticon_data(self) -> None:
 | 
			
		||||
        fixture_file_name = self.fixture_file_name("export.json", "mattermost_fixtures")
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user