Skip to content

Commit 1b03354

Browse files
committed
fix: The conversation user is not authorized to use
1 parent 340ca6c commit 1b03354

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

apps/chat/serializers/chat.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,13 @@ def is_valid_chat_user(self):
314314
application_id = self.data.get('application_id')
315315
chat_user_type = self.data.get('chat_user_type')
316316
is_auth_chat_user = DatabaseModelManage.get_model("is_auth_chat_user")
317-
if chat_user_type == ChatUserType.CHAT_USER.value and is_auth_chat_user:
318-
is_auth = is_auth_chat_user(chat_user_id, application_id)
319-
if not is_auth:
320-
raise ChatException(500, _("The chat user is not authorized."))
317+
application_access_token = QuerySet(ApplicationAccessToken).filter(application_id=application_id).first()
318+
if application_access_token and application_access_token.authentication and application_access_token.authentication_value.get(
319+
'type') == 'login':
320+
if chat_user_type == ChatUserType.CHAT_USER.value and is_auth_chat_user:
321+
is_auth = is_auth_chat_user(chat_user_id, application_id)
322+
if not is_auth:
323+
raise ChatException(500, _("The chat user is not authorized."))
321324

322325
def chat(self, instance: dict, base_to_response: BaseToResponse = SystemToResponse()):
323326
super().is_valid(raise_exception=True)

0 commit comments

Comments
 (0)