mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-11-04 12:32:18 +01:00 
			
		
		
		
	Only give the focus to a private channel if it wasn't previously created
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
		@@ -152,6 +152,18 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
 | 
			
		||||
            await channel.asave()
 | 
			
		||||
 | 
			
		||||
            await self.channel_layer.group_add(f"chat-{channel.id}", self.channel_name)
 | 
			
		||||
 | 
			
		||||
            if user != other_user:
 | 
			
		||||
                await self.channel_layer.group_send(f"user-{other_user.id}", {
 | 
			
		||||
                    'type': 'chat.start_private_chat',
 | 
			
		||||
                    'channel': {
 | 
			
		||||
                        'id': channel.id,
 | 
			
		||||
                        'name': f"{user.first_name} {user.last_name}",
 | 
			
		||||
                        'category': channel.category,
 | 
			
		||||
                        'read_access': True,
 | 
			
		||||
                        'write_access': True,
 | 
			
		||||
                    }
 | 
			
		||||
                })
 | 
			
		||||
        else:
 | 
			
		||||
            channel = await channel_qs.afirst()
 | 
			
		||||
 | 
			
		||||
@@ -165,17 +177,6 @@ class ChatConsumer(AsyncJsonWebsocketConsumer):
 | 
			
		||||
                'write_access': True,
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
        if user != other_user:
 | 
			
		||||
            await self.channel_layer.group_send(f"user-{other_user.id}", {
 | 
			
		||||
                'type': 'chat.start_private_chat',
 | 
			
		||||
                'channel': {
 | 
			
		||||
                    'id': channel.id,
 | 
			
		||||
                    'name': f"{user.first_name} {user.last_name}",
 | 
			
		||||
                    'category': channel.category,
 | 
			
		||||
                    'read_access': True,
 | 
			
		||||
                    'write_access': True,
 | 
			
		||||
                }
 | 
			
		||||
            })
 | 
			
		||||
 | 
			
		||||
    async def chat_send_message(self, message) -> None:
 | 
			
		||||
        await self.send_json({'type': 'send_message', 'id': message['id'], 'channel_id': message['channel_id'],
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user