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 2 commits
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 @@ -37,6 +37,21 @@ const inviteToTeamHelper = async (
const operationId = dataLoader.share()
const subOptions = {mutatorId, operationId}

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})
}

const untrustedDomains = ['tempmail.cn', 'qq.com']
const filteredInvitees = invitees.filter(
(invitee) => !untrustedDomains.includes(getDomainFromEmail(invitee).toLowerCase())
Expand Down
Loading