From 440cd13fcc74081971d2ca3cb705669df0b65b01 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 24 May 2023 14:24:15 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=90=8C=E4=B8=80=E4=B8=AA=E5=8D=8F?= =?UTF-8?q?=E4=BD=9C=E4=BC=9A=E8=AF=9D=E9=93=BE=E6=8E=A5=EF=BC=8C=E9=99=90?= =?UTF-8?q?=E5=88=B6=E5=90=8C=E4=B8=80=E7=94=A8=E6=88=B7=E4=BB=85=E5=8F=AF?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/api/session/sharing.py | 6 +++--- apps/terminal/models/session/sharing.py | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/terminal/api/session/sharing.py b/apps/terminal/api/session/sharing.py index a3d324205..9a60734fa 100644 --- a/apps/terminal/api/session/sharing.py +++ b/apps/terminal/api/session/sharing.py @@ -1,8 +1,8 @@ -from rest_framework.exceptions import MethodNotAllowed, ValidationError -from rest_framework.decorators import action -from rest_framework.response import Response from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from rest_framework.decorators import action +from rest_framework.exceptions import MethodNotAllowed, ValidationError +from rest_framework.response import Response from common.const.http import PATCH from orgs.mixins.api import OrgModelViewSet diff --git a/apps/terminal/models/session/sharing.py b/apps/terminal/models/session/sharing.py index a62e23a85..c0e83dfda 100644 --- a/apps/terminal/models/session/sharing.py +++ b/apps/terminal/models/session/sharing.py @@ -133,6 +133,13 @@ class SessionJoinRecord(JMSBaseModel, OrgModelMixin): # self if self.verify_code != self.sharing.verify_code: return False, _('Invalid verification code') + + # Link can only be joined once by the same user. + queryset = SessionJoinRecord.objects.filter( + verify_code=self.verify_code, sharing=self.sharing, + joiner=self.joiner, date_joined__lt=self.date_joined) + if queryset.exists(): + return False, _('You have already joined this session') return True, '' def join_failed(self, reason):