From 54bb2258bf428022ca1885043bc891ef173516d7 Mon Sep 17 00:00:00 2001 From: TastyHeadphones <76083688+TastyHeadphones@users.noreply.github.com> Date: Sun, 27 Sep 2026 20:23:48 +0900 Subject: [PATCH 1/2] fix: cap invite_user list at 20 The invite endpoint accepted an uncapped invite_user array, so one request could fan out a huge number of notifications. Match a 20-user server/UI limit. --- internal/schema/question_schema.go | 4 ++-- .../Questions/Detail/components/InviteToAnswer/index.tsx | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) 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); From ec5df27161b098b79aff32180bda2235d74bf817 Mon Sep 17 00:00:00 2001 From: TastyHeadphones <76083688+TastyHeadphones@users.noreply.github.com> Date: Mon, 23 Nov 2026 10:31:16 +0900 Subject: [PATCH 2/2] fix: lower the invite_user cap to 5 Per maintainer feedback on the PR, cap invites at 5 users in both the request validator and the invite UI. --- internal/schema/question_schema.go | 4 ++-- .../Questions/Detail/components/InviteToAnswer/index.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/schema/question_schema.go b/internal/schema/question_schema.go index 6a9886a48..63e94631b 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,max=20" json:"invite_user"` + InviteUser []string `validate:"omitempty,max=5" 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,max=20" json:"invite_user"` + InviteUser []string `validate:"omitempty,max=5" 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 3dd6c2c6b..db880f2f8 100644 --- a/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx +++ b/ui/src/pages/Questions/Detail/components/InviteToAnswer/index.tsx @@ -37,7 +37,7 @@ interface Props { questionId: string; readOnly?: boolean; } -const MAX_INVITE_USERS = 20; +const MAX_INVITE_USERS = 5; const Index: FC = ({ questionId, readOnly = false }) => { const { t } = useTranslation('translation', {