Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit a8646b5

Browse files
authored
Merge pull request #4672 from withspectrum/rate-limit-email-invites
Rate limit email invites
2 parents f6268e5 + db90ec3 commit a8646b5

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

api/schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ const Root = /* GraphQL */ `
7373
window: Int
7474
message: String
7575
identityArgs: [String]
76+
arrayLengthField: String
7677
) on FIELD_DEFINITION
7778
7879
# The dummy queries and mutations are necessary because

api/types/Community.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ const Community = /* GraphQL */ `
311311
importSlackMembers(input: ImportSlackMembersInput!): Boolean
312312
@deprecated(reason: "Importing slack members is deprecated")
313313
sendEmailInvites(input: EmailInvitesInput!): Boolean
314+
@rateLimit(max: 5000, window: "1w", arrayLengthField: "input.contacts")
314315
pinThread(threadId: ID!, communityId: ID!, value: String): Community
315316
upgradeCommunity(input: UpgradeCommunityInput!): Community
316317
@deprecated(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"graphql-date": "^1.0.3",
113113
"graphql-depth-limit": "^1.1.0",
114114
"graphql-log": "0.1.3",
115-
"graphql-rate-limit": "^1.2.2",
115+
"graphql-rate-limit": "^1.2.4",
116116
"graphql-tag": "^2.10.0",
117117
"graphql-tools": "^4.0.3",
118118
"helmet": "^3.14.0",

src/components/emailInvitationForm/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ class EmailInvitationForm extends React.Component<Props, State> {
302302
})
303303
.filter(Boolean);
304304

305+
if (validated.length > 5000) {
306+
this.setState({
307+
importError: 'Cannot invite more than 5,000 emails.',
308+
});
309+
return;
310+
}
311+
305312
const consolidated = [
306313
...this.state.contacts.filter(
307314
contact =>
@@ -377,7 +384,7 @@ class EmailInvitationForm extends React.Component<Props, State> {
377384
<Icon size={20} glyph="upload" /> Import emails
378385
</ActionAsLabel>
379386
<ActionHelpText>
380-
Upload a .json file with an array of email addresses.
387+
Upload a .json file with an array of up to 5,000 email addresses.
381388
</ActionHelpText>
382389

383390
<Action onClick={this.toggleCustomMessage}>

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7197,10 +7197,10 @@ [email protected]:
71977197
deep-for-each "^1.0.6"
71987198
is-function "^1.0.1"
71997199

7200-
graphql-rate-limit@^1.2.2:
7201-
version "1.2.2"
7202-
resolved "https://registry.yarnpkg.com/graphql-rate-limit/-/graphql-rate-limit-1.2.2.tgz#4c97e7bcb5b8c8ca1ee67aaf194d22b88bba6f53"
7203-
integrity sha512-Osns7iZkKLAANZokorAKKIehQ3Wm03nXts2aBBy15r/QhKTNPxVwc71sXTn3IPJ7SzAfoARvPN1Jm3bmblHtiQ==
7200+
graphql-rate-limit@^1.2.4:
7201+
version "1.2.4"
7202+
resolved "https://registry.yarnpkg.com/graphql-rate-limit/-/graphql-rate-limit-1.2.4.tgz#8d28e475f77351f11cd09cc3f539adaba8dd208d"
7203+
integrity sha512-hddZL3aXPcpRpH57UFErrLzc0Wdjka570yRJSG5leG+iPXarHDf85Tl5oyj00PW0jVfml2X2K7ucOInsE8xYbw==
72047204
dependencies:
72057205
"@types/redis-mock" "^0.17.0"
72067206
graphql-tools "^4.0.3"

0 commit comments

Comments
 (0)