Skip to content

Commit

Permalink
feature: verify external_id in retrieve flow warning endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJaeger committed Oct 19, 2023
1 parent ebb09f6 commit c873f5f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions chats/apps/api/v1/projects/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,32 @@ def start_flow(self, request, *args, **kwargs):
create_room_feedback_message(room, feedback, method="fs")
return Response(flow_start, status.HTTP_200_OK)

@action(detail=False, methods=["GET"], url_name="verify-flow-start")
def retrieve_flow_warning(self, request, *args, **kwargs):
flows_start_verify = {}
flows_start_verify["show_warning"] = False

try:
project = Project.objects.get(uuid=request.query_params.get("project"))
contact = Contact.objects.get(
external_id=request.query_params.get("contact")
)
except Exception as error:
return Response(
{"error": f"{type(error)}: {error}"},
status=status.HTTP_400_BAD_REQUEST,
)

try:
Room.objects.get(
contact=contact, queue__sector__project=project, is_active=True
)
except ObjectDoesNotExist:
return Response(flows_start_verify, status.HTTP_200_OK)

flows_start_verify["show_warning"] = True
return Response(flows_start_verify, status.HTTP_200_OK)


class ProjectPermissionViewset(viewsets.ReadOnlyModelViewSet):
queryset = ProjectPermission.objects.all()
Expand Down

0 comments on commit c873f5f

Please sign in to comment.