Protocol blank if no canonical address

Make protocol be blank on instance if there
is no canonical address for this instance.

It was defaulting to "tcp" before.

Signed-off-by: Seth Foster <fosterbseth@gmail.com>
This commit is contained in:
Seth Foster 2024-01-31 10:51:09 -05:00 committed by Seth Foster
parent 083c05f12a
commit 48971411cc

View File

@ -5645,13 +5645,12 @@ class InstanceSerializer(BaseSerializer):
def get_reverse_peers(self, obj):
return Instance.objects.prefetch_related('peers').filter(peers__in=obj.receptor_addresses.all()).values_list('id', flat=True)
# FIXME: protocol should be blank, null, or missing if there is no canonical address
def get_protocol(self, obj):
# note: don't create a different query for receptor addresses, as this is prefetched on the View for optimization
for addr in obj.receptor_addresses.all():
if addr.canonical:
return addr.protocol
return 'tcp'
return ""
def get_consumed_capacity(self, obj):
return obj.consumed_capacity