diff --git a/fediseer/apis/v1/censures.py b/fediseer/apis/v1/censures.py index 9727d03..51b9140 100644 --- a/fediseer/apis/v1/censures.py +++ b/fediseer/apis/v1/censures.py @@ -13,6 +13,7 @@ class CensuresGiven(Resource): get_parser.add_argument("min_censures", required=False, default=1, type=int, help="Limit to this amount of censures of more", location="args") get_parser.add_argument("reasons_csv", required=False, type=str, help="Only retrieve censures where their reasons include any of the text in this csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Censures_get, code=200, description='Instances', skip_none=True) @@ -151,7 +152,7 @@ class Censures(Resource): return {"domains": [instance["domain"] for instance in instance_details]},200 return {"instances": instance_details},200 - decorators = [limiter.limit("20/minute", key_func = get_request_path)] + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] put_parser = reqparse.RequestParser() put_parser.add_argument("apikey", type=str, required=True, help="The sending instance's API key.", location='headers') put_parser.add_argument("Client-Agent", default="unknown:0:unknown", type=str, required=False, help="The client name and version.", location="headers") @@ -321,4 +322,4 @@ class Censures(Resource): db.session.add(new_report) db.session.commit() logger.info(f"{instance.domain} Withdrew censure from {domain}") - return {"message":'Changed'}, 200 \ No newline at end of file + return {"message":'Changed'}, 200 diff --git a/fediseer/apis/v1/endorsements.py b/fediseer/apis/v1/endorsements.py index 5c51cd9..e9a9bbc 100644 --- a/fediseer/apis/v1/endorsements.py +++ b/fediseer/apis/v1/endorsements.py @@ -13,6 +13,7 @@ class Approvals(Resource): get_parser.add_argument("min_endorsements", required=False, default=1, type=int, help="Limit to this amount of endorsements of more", location="args") get_parser.add_argument("reasons_csv", required=False, type=str, help="Only retrieve endorsements where their reasons include any of the text in this csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Endorsed_get, code=200, description='Instances', skip_none=True) @@ -86,6 +87,7 @@ class Endorsements(Resource): get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args") get_parser.add_argument("domains", required=False, type=bool, help="Set to true to return just the domains as a list. Mutually exclusive with csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Endorsed_get, code=200, description='Instances', skip_none=True) diff --git a/fediseer/apis/v1/guarantees.py b/fediseer/apis/v1/guarantees.py index 37bebef..6a400d8 100644 --- a/fediseer/apis/v1/guarantees.py +++ b/fediseer/apis/v1/guarantees.py @@ -9,6 +9,7 @@ class Guarantors(Resource): get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args") get_parser.add_argument("domains", required=False, type=bool, help="Set to true to return just the domains as a list. Mutually exclusive with csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Whitelist_get, code=200, description='Instances', skip_none=True) @@ -35,6 +36,7 @@ class Guarantees(Resource): get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args") get_parser.add_argument("domains", required=False, type=bool, help="Set to true to return just the domains as a list. Mutually exclusive with csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Whitelist_get, code=200, description='Instances', skip_none=True) diff --git a/fediseer/apis/v1/hesitations.py b/fediseer/apis/v1/hesitations.py index 3cf0f28..409deae 100644 --- a/fediseer/apis/v1/hesitations.py +++ b/fediseer/apis/v1/hesitations.py @@ -13,6 +13,7 @@ class HesitationsGiven(Resource): get_parser.add_argument("min_hesitations", required=False, default=1, type=int, help="Limit to this amount of hesitations of more", location="args") get_parser.add_argument("reasons_csv", required=False, type=str, help="Only retrieve hesitations where their reasons include any of the text in this csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Hesitations_get, code=200, description='Instances', skip_none=True) @@ -91,6 +92,7 @@ class Hesitations(Resource): get_parser.add_argument("csv", required=False, type=bool, help="Set to true to return just the domains as a csv. Mutually exclusive with domains", location="args") get_parser.add_argument("domains", required=False, type=bool, help="Set to true to return just the domains as a list. Mutually exclusive with csv", location="args") + decorators = [limiter.limit("30/minute"), limiter.limit("5/minute", key_func = get_request_path)] @api.expect(get_parser) @cache.cached(timeout=10, query_string=True) @api.marshal_with(models.response_model_model_Hesitations_get, code=200, description='Instances', skip_none=True) @@ -306,4 +308,4 @@ class Hesitations(Resource): db.session.add(new_report) db.session.commit() logger.info(f"{instance.domain} Withdrew hesitation from {domain}") - return {"message":'Changed'}, 200 \ No newline at end of file + return {"message":'Changed'}, 200