From 45f17f6732bb0761f457e795546ed023e0ced9af Mon Sep 17 00:00:00 2001 From: Greg Taylor Date: Thu, 30 Apr 2009 04:20:03 +0000 Subject: [PATCH] In the strange case where someone creates two mappings with the same IMC2 name, handle it gracefully by emitting to all matching mappings instead of just assuming there'll only be one match. --- src/imc2/connection.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/imc2/connection.py b/src/imc2/connection.py index 69b699a212..3757f05382 100644 --- a/src/imc2/connection.py +++ b/src/imc2/connection.py @@ -116,14 +116,15 @@ class IMC2Protocol(StatefulTelnetProtocol): chan_name = chan_name.split(':', 1)[1] try: # Look for matching IMC2 channel maps. - mapping = IMC2ChannelMapping.objects.get(imc2_channel_name=chan_name) + mappings = IMC2ChannelMapping.objects.filter(imc2_channel_name=chan_name) # Format the message to cemit to the local channel. message = '%s@%s: %s' % (packet.sender, packet.origin, packet.optional_data.get('text')) # Bombs away. - if mapping.channel: - comsys.send_cmessage(mapping.channel, message) + for mapping in mappings: + if mapping.channel: + comsys.send_cmessage(mapping.channel, message) except IMC2ChannelMapping.DoesNotExist: # No channel mapping found for this message, ignore it. pass