perf: 同一个协作会话链接,限制同一用户仅可使用一次

pull/10327/head^2
Eric 2023-05-24 14:24:15 +08:00 committed by Jiangjie.Bai
parent 20c1f4a293
commit 440cd13fcc
2 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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):