feat: chat captcha (#3279)

This commit is contained in:
shaohuzhang1 2025-06-17 15:01:59 +08:00 committed by GitHub
parent 9ab90a7b21
commit a93d7ca6d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -10,5 +10,6 @@ urlpatterns = [
path('profile', views.AuthProfile.as_view()),
path('application/profile', views.ApplicationProfile.as_view()),
path('chat_message/<str:chat_id>', views.ChatView.as_view()),
path('open', views.OpenView.as_view())
path('open', views.OpenView.as_view()),
path('captcha', views.CaptchaView.as_view(), name='captcha'),
]

View File

@ -21,6 +21,8 @@ from common.auth import TokenAuth
from common.constants.permission_constants import ChatAuth
from common.exception.app_exception import AppAuthenticationFailed
from common.result import result
from users.api import CaptchaAPI
from users.serializers.login import CaptchaSerializer
class AnonymousAuthentication(APIView):
@ -122,3 +124,14 @@ class OpenView(APIView):
data={'application_id': request.auth.application_id,
'chat_user_id': request.auth.chat_user_id, 'chat_user_type': request.auth.chat_user_type,
'debug': False}).open())
class CaptchaView(APIView):
@extend_schema(methods=['GET'],
summary=_("Get captcha"),
description=_("Get captcha"),
operation_id=_("Get captcha"), # type: ignore
tags=[_("User Management")], # type: ignore
responses=CaptchaAPI.get_response())
def get(self, request: Request):
return result.success(CaptchaSerializer().generate())