Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/chat/api/chat_authentication_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,12 @@ def get_parameters():
class ChatOpenAPI(APIMixin):
@staticmethod
def get_parameters():
return []
return [
OpenApiParameter(
name="application_id",
description=_("Application ID"),
type=OpenApiTypes.UUID,
location=OpenApiParameter.PATH,
required=True,
)
]
2 changes: 1 addition & 1 deletion apps/chat/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
path('application/<str:application_id>/profile', views.ApplicationProfile.as_view(), name='profile'),
path('chat_message/<str:chat_id>', views.ChatView.as_view(), name='chat'),
path('chat_message/<str:chat_id>/cancel', views.CancelWorkflowView.as_view(), name='cancel_workflow'),
path('open', views.OpenView.as_view(), name='open'),
path('application/<str:application_id>/open', views.OpenView.as_view(), name='open'),
path('text_to_speech', views.TextToSpeech.as_view()),
path('speech_to_text', views.SpeechToText.as_view()),
path('captcha', views.CaptchaView.as_view(), name='captcha'),
Expand Down
9 changes: 5 additions & 4 deletions apps/chat/views/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,15 @@ class OpenView(APIView):
responses=None,
tags=[_('Chat')] # type: ignore
)
def get(self, request: Request):
@has_permissions(ChatPermissionConstants.get_aggregate_permissions())
def get(self, request: Request, application_id: str):
ip_address = _get_ip_address(request)
return result.success(OpenChatSerializers(
data={'application_id': request.auth.application_id,
'chat_user_id': request.auth.chat_user_id, 'chat_user_type': request.auth.chat_user_type,
data={'application_id': application_id,
'chat_user_id': request.user.id, 'chat_user_type': request.user.type,
'ip_address': ip_address,
'source': {
'type': ChatSourceChoices.API_CALL.value if request.auth.chat_user_type == ChatUserType.APPLICATION_API_KEY.value else ChatSourceChoices.ONLINE.value},
'type': ChatSourceChoices.API_CALL.value if request.user.type == ChatUserType.APPLICATION_API_KEY.value else ChatSourceChoices.ONLINE.value},
'debug': False}).open())


Expand Down
2 changes: 1 addition & 1 deletion apps/common/auth/struct/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ def __init__(self, _id,
profile=None,
**keywords):
self.id = _id
self._type = _type
self.type = _type
self.profile = profile
self.keywords = keywords
Loading