Skip to content

Commit

Permalink
feature: function to create flow start feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJaeger committed Oct 10, 2023
1 parent 5ae38d9 commit 6ab69a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions chats/apps/api/v1/projects/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ProjectPermission,
)
from chats.apps.rooms.models import Room
from chats.apps.rooms.views import create_room_feedback_message
from chats.apps.rooms.views import create_feedback_message, create_room_feedback_message


class ProjectViewset(viewsets.ReadOnlyModelViewSet):
Expand Down Expand Up @@ -278,7 +278,7 @@ def start_flow(self, request, *args, **kwargs):
chats_flow_start.save()
feedback = {"name": chats_flow_start.name}
# TODO create feedback fs feedback
create_room_feedback_message(room, feedback, method="fs")
create_feedback_message(feedback, method="fs")
if chats_flow_start.room:
room.notify_room("update")
return Response(flow_start, status.HTTP_200_OK)
Expand Down
9 changes: 9 additions & 0 deletions chats/apps/rooms/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from chats.apps.api.v1.internal.rest_clients.flows_rest_client import FlowRESTClient
from chats.apps.dashboard.tasks import close_metrics, generate_metrics
from chats.apps.rooms.models import Room
from chats.apps.msgs.models import Message


def close_room(room_pk: str):
Expand Down Expand Up @@ -79,3 +80,11 @@ def create_room_feedback_message(room: object, feedback: dict, method: str):
seen=True,
)
msg.notify_room("create")


def create_feedback_message(feedback: dict, method: str):
msg = Message.objects.create(
text=json.dumps(create_feedback_json(method=method, content=feedback)),
seen=True,
)
msg.notify_room("create")

0 comments on commit 6ab69a5

Please sign in to comment.