Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limit invites from spammers #9416

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/server/graphql/mutations/helpers/inviteToTeamHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ const inviteToTeamHelper = async (
return standardError(new Error('No valid emails'), {userId: viewerId})
}

const [total, pending] = await Promise.all([
r.table('TeamInvitation').getAll(teamId, {index: 'teamId'}).count().run(),
r
.table('TeamInvitation')
.getAll(teamId, {index: 'teamId'})
.filter({acceptedAt: null})
.count()
.run()
])
const accepted = total - pending
// if no one has accepted one of their 100+ invites, don't trust them
if (accepted === 0 && total >= 100) {
return standardError(new Error('Exceeded unaccepted invitation limit'), {userId: viewerId})
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 We need to do this before we check whether or not an email is valid, otherwise this gives spammers still some utility

const [users, team, inviter] = await Promise.all([
getUsersByEmails(validInvitees),
dataLoader.get('teams').load(teamId),
Expand Down
Loading