(self)
| 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) |
no test coverage detected