File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,8 @@ const keyGenerator: RateLimitKeyGenerator<Context> = (
5959 return `${ context . userId ?? context . trackingId } :createComment` ;
6060 case 'parseOpportunity' :
6161 return `${ context . userId ?? context . trackingId } :parseOpportunity` ;
62+ case 'viewPost' :
63+ return `${ context . userId ?? context . trackingId } :viewPost` ;
6264 case 'sentimentTimeSeries' :
6365 case 'sentimentHighlights' :
6466 return `${ context . userId ?? context . trackingId ?? context . req . ip } :sentiment` ;
@@ -110,6 +112,11 @@ export const onLimit: RateLimitOnLimit<Context> = (
110112 throw new RateLimitError ( {
111113 message : `You tried to parse job too many times. Try again in ${ period } or contact team for assistance.` ,
112114 } ) ;
115+ case 'viewPost' :
116+ counters ?. api ?. rateLimit ?. add ( 1 , { type : 'viewPost' } ) ;
117+ throw new RateLimitError ( {
118+ message : 'Post views are temporarily rate-limited' ,
119+ } ) ;
113120 case 'sentimentTimeSeries' :
114121 case 'sentimentHighlights' :
115122 counters ?. api ?. rateLimit ?. add ( 1 , { type : 'sentiment' } ) ;
Original file line number Diff line number Diff line change @@ -1709,7 +1709,7 @@ export const typeDefs = /* GraphQL */ `
17091709 Post to share in the source
17101710 """
17111711 id: ID!
1712- ): EmptyResponse @auth
1712+ ): EmptyResponse @auth @rateLimit(limit: 50, duration: 3600)
17131713
17141714 """
17151715 Dismiss user post feedback
You can’t perform that action at this time.
0 commit comments