Skip to content

Commit

Permalink
Merge branch 'feature/add-ticket-id-to-room' of github.com:weni-ai/ch…
Browse files Browse the repository at this point in the history
…ats-engine into merge/adding-list-room-field-and-add-ticket-id-to-room
  • Loading branch information
ericosta-dev committed Jan 2, 2025
2 parents d93f5e2 + c4dd7c5 commit 726707b
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions chats/apps/api/v1/external/rooms/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class RoomFlowSerializer(serializers.ModelSerializer):
contact = ContactRelationsSerializer(many=False, required=False, read_only=False)
flow_uuid = serializers.CharField(required=False, write_only=True, allow_null=True)
is_anon = serializers.BooleanField(write_only=True, required=False, default=False)
ticket_uuid = serializers.UUIDField(required=False)

class Meta:
model = Room
Expand All @@ -144,6 +145,7 @@ class Meta:
"transfer_history",
# Writable Fields
"sector_uuid",
"ticket_uuid",
"queue_uuid",
"user_email",
"contact",
Expand Down
7 changes: 4 additions & 3 deletions chats/apps/api/v1/external/rooms/viewsets.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.db import IntegrityError
from django.db.models import Q
from django.utils import timezone
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters, status, viewsets
Expand Down Expand Up @@ -150,9 +151,9 @@ def partial_update(self, request, pk=None):
project = request_permission.project
room = (
Room.objects.filter(
callback_url__endswith=pk,
project_uuid=project,
is_active=True,
(Q(ticket_uuid=pk) | Q(callback_url__endswith=pk))
& Q(project_uuid=project)
& Q(is_active=True)
)
.select_related("user", "queue__sector__project")
.first()
Expand Down
18 changes: 18 additions & 0 deletions chats/apps/rooms/migrations/0014_room_ticket_uuid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.2 on 2024-12-19 13:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("rooms", "0013_room_project_uuid_room_rooms_room_project_890f5f_idx"),
]

operations = [
migrations.AddField(
model_name="room",
name="ticket_uuid",
field=models.UUIDField(blank=True, null=True, verbose_name="ticket uuid"),
),
]
1 change: 1 addition & 0 deletions chats/apps/rooms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, *args, **kwargs):
project_uuid = models.TextField(
_("project_uuid"), null=True, blank=True, default=""
)
ticket_uuid = models.UUIDField(_("ticket uuid"), null=True, blank=True)

callback_url = models.TextField(_("Callback URL"), null=True, blank=True)

Expand Down
3 changes: 3 additions & 0 deletions chats/fixtures/fixture_room.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"mood": "angry",
"country": "brazil"
},
"ticket_uuid": "66a47111-6e6f-43b3-9fdc-a92a18bc57d2",
"callback_url": "http://localhost/test/66a47111-6e6f-43b3-9fdc-a92a18bc57d2",
"ended_at": null,
"ended_by": null,
Expand Down Expand Up @@ -43,6 +44,7 @@
"mood": "angry",
"country": "brazil"
},
"ticket_uuid": "1c830ac0-1ba7-49f9-b8c8-b96af41d4213",
"callback_url": "http://localhost/test/1c830ac0-1ba7-49f9-b8c8-b96af41d4213",
"ended_at": null,
"ended_by": null,
Expand Down Expand Up @@ -74,6 +76,7 @@
"mood": "angry",
"country": "brazil"
},
"ticket_uuid": "ac6322ca-4a5b-4e5f-bb00-050c60e93b0b",
"callback_url": "http://localhost/test/ac6322ca-4a5b-4e5f-bb00-050c60e93b0b",
"ended_at": "2023-09-03T00:20:09.559Z",
"ended_by": "agent",
Expand Down

0 comments on commit 726707b

Please sign in to comment.