diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.go index 4c6d2ead7..6a9886a48 100644 --- a/internal/schema/question_schema.go +++ b/internal/schema/question_schema.go @@ -185,7 +185,7 @@ type QuestionUpdate struct { Content string `validate:"gte=0,lte=65535" json:"content"` // html HTML string `json:"-"` - InviteUser []string `validate:"omitempty" json:"invite_user"` + InviteUser []string `validate:"omitempty,max=20" json:"invite_user"` // tags Tags []*TagItem `validate:"dive" json:"tags"` // edit summary @@ -205,7 +205,7 @@ type QuestionRecoverReq struct { type QuestionUpdateInviteUser struct { ID string `validate:"required" json:"id"` - InviteUser []string `validate:"omitempty" json:"invite_user"` + InviteUser []string `validate:"omitempty,max=20" json:"invite_user"` UserID string `json:"-"` QuestionPermission CaptchaID string `json:"captcha_id"` // captcha_id diff --git a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx index b8e29942c..3dd6c2c6b 100644 --- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx +++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx @@ -37,6 +37,8 @@ interface Props { questionId: string; readOnly?: boolean; } +const MAX_INVITE_USERS = 20; + const Index: FC = ({ questionId, readOnly = false }) => { const { t } = useTranslation('translation', { keyPrefix: 'invite_to_answer', @@ -69,6 +71,9 @@ const Index: FC = ({ questionId, readOnly = false }) => { return _.id !== user.id; }); } else { + if (userList.length >= MAX_INVITE_USERS) { + return; + } userList.push(user); } setUsers(userList);