fix: dont use form_dict & frappe.call

This commit is contained in:
Sagar Vora 2023-08-05 13:02:50 +05:30
parent 4931c7379c
commit 3f3821befb

View file

@ -107,14 +107,14 @@ def rate_limit(
:returns: a decorator function that limit the number of requests per endpoint
"""
def ratelimit_decorator(fun):
@wraps(fun)
def ratelimit_decorator(fn):
@wraps(fn)
def wrapper(*args, **kwargs):
# Do not apply rate limits if method is not opted to check
if not frappe.request or (
methods != "ALL" and frappe.request.method and frappe.request.method.upper() not in methods
):
return frappe.call(fun, **frappe.form_dict or kwargs)
return fn(*args, **kwargs)
_limit = limit() if callable(limit) else limit
@ -144,7 +144,7 @@ def rate_limit(
_("You hit the rate limit because of too many requests. Please try after sometime.")
)
return frappe.call(fun, **frappe.form_dict or kwargs)
return fn(*args, **kwargs)
return wrapper