Skip to content

Commit 9c236a3

Browse files
committed
feat: chat captcha
1 parent 695773d commit 9c236a3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

apps/chat/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
path('profile', views.AuthProfile.as_view()),
1111
path('application/profile', views.ApplicationProfile.as_view()),
1212
path('chat_message/<str:chat_id>', views.ChatView.as_view()),
13-
path('open', views.OpenView.as_view())
13+
path('open', views.OpenView.as_view()),
14+
path('captcha', views.CaptchaView.as_view(), name='captcha'),
1415
]

apps/chat/views/chat.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from common.constants.permission_constants import ChatAuth
2222
from common.exception.app_exception import AppAuthenticationFailed
2323
from common.result import result
24+
from users.api import CaptchaAPI
25+
from users.serializers.login import CaptchaSerializer
2426

2527

2628
class AnonymousAuthentication(APIView):
@@ -122,3 +124,14 @@ def get(self, request: Request):
122124
data={'application_id': request.auth.application_id,
123125
'chat_user_id': request.auth.chat_user_id, 'chat_user_type': request.auth.chat_user_type,
124126
'debug': False}).open())
127+
128+
129+
class CaptchaView(APIView):
130+
@extend_schema(methods=['GET'],
131+
summary=_("Get captcha"),
132+
description=_("Get captcha"),
133+
operation_id=_("Get captcha"), # type: ignore
134+
tags=[_("User Management")], # type: ignore
135+
responses=CaptchaAPI.get_response())
136+
def get(self, request: Request):
137+
return result.success(CaptchaSerializer().generate())

0 commit comments

Comments
 (0)