MCPcopy
hub / github.com/1Panel-dev/MaxKB / is_valid_chat_user

Method is_valid_chat_user

apps/chat/serializers/chat.py:441–454  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

439 return r
440
441 def is_valid_chat_user(self):
442 chat_user_id = self.data.get('chat_user_id')
443 application_id = self.data.get('application_id')
444 chat_user_type = self.data.get('chat_user_type')
445 is_auth_chat_user = DatabaseModelManage.get_model("is_auth_chat_user")
446 application_access_token = QuerySet(ApplicationAccessToken).filter(application_id=application_id).first()
447 if application_access_token and application_access_token.authentication and application_access_token.authentication_value.get(
448 'type') == 'login':
449 if chat_user_type == ChatUserType.ANONYMOUS_USER.value:
450 raise ChatException(500, _("The chat user is not authorized."))
451 if chat_user_type == ChatUserType.CHAT_USER.value and is_auth_chat_user:
452 is_auth = is_auth_chat_user(chat_user_id, application_id)
453 if not is_auth:
454 raise ChatException(500, _("The chat user is not authorized."))
455
456 def chat(self, instance: dict, base_to_response: BaseToResponse = SystemToResponse()):
457 super().is_valid(raise_exception=True)

Callers 1

chatMethod · 0.95

Calls 3

ChatExceptionClass · 0.90
getMethod · 0.45
get_modelMethod · 0.45

Tested by

no test coverage detected