Handle sharing old conversation publically even if they have no slug

New conversation have a slug, but older conversation may not. This
change allows those older conversations to still be shareable by using
a random uuid for constructing their url instead
This commit is contained in:
Debanjum 2024-12-17 19:40:44 -08:00
parent 90b7ba51a4
commit 1e3f452d15

View file

@ -639,7 +639,7 @@ def verify_public_conversation(sender, instance, **kwargs):
# check if this is a new instance # check if this is a new instance
if instance._state.adding: if instance._state.adding:
slug = re.sub(r"\W+", "-", instance.slug.lower())[:50] slug = re.sub(r"\W+", "-", instance.slug.lower())[:50] if instance.slug else uuid.uuid4().hex
observed_random_id = set() observed_random_id = set()
while PublicConversation.objects.filter(slug=slug).exists(): while PublicConversation.objects.filter(slug=slug).exists():
try: try: