Skip to content

Commit

Permalink
feature: removing verify from external rooms
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJaeger committed Oct 9, 2024
1 parent a22d230 commit 7e9e9ca
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions chats/apps/api/v1/external/rooms/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,14 @@ def close(
Close a room, setting the ended_at date and turning the is_active flag as false
"""
instance = self.get_object()
for attempt in range(settings.MAX_RETRIES):
try:
with transaction.atomic():
instance.close(None, "agent")
serialized_data = RoomFlowSerializer(instance=instance)
instance.notify_queue("close")
if not settings.ACTIVATE_CALC_METRICS:
return Response(serialized_data.data, status=status.HTTP_200_OK)

close_room(str(instance.pk))
return Response(serialized_data.data, status=status.HTTP_200_OK)
except DatabaseError as error:
if attempt < settings.MAX_RETRIES - 1:
continue
else:
return Response(
{"error": f"Transaction failed after retries: {str(error)}"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
instance.close(None, "agent")
serialized_data = RoomFlowSerializer(instance=instance)
instance.notify_queue("close")
if not settings.ACTIVATE_CALC_METRICS:
return Response(serialized_data.data, status=status.HTTP_200_OK)

close_room(str(instance.pk))
return Response(serialized_data.data, status=status.HTTP_200_OK)

def create(self, request, *args, **kwargs):
try:
Expand Down

0 comments on commit 7e9e9ca

Please sign in to comment.