diff --git a/lms/djangoapps/save_for_later/api/v1/views.py b/lms/djangoapps/save_for_later/api/v1/views.py index c7405ebf3d..42729b36b0 100644 --- a/lms/djangoapps/save_for_later/api/v1/views.py +++ b/lms/djangoapps/save_for_later/api/v1/views.py @@ -23,7 +23,7 @@ from lms.djangoapps.save_for_later.models import SavedCourse log = logging.getLogger(__name__) -POST_EMAIL_KEY = 'openedx.core.djangoapps.util.ratelimit.request_post_email' +POST_EMAIL_KEY = 'openedx.core.djangoapps.util.ratelimit.request_data_email' REAL_IP_KEY = 'openedx.core.djangoapps.util.ratelimit.real_ip' USER_SENT_EMAIL_SAVE_FOR_LATER = 'edx.bi.user.save.for.later.email.sent' diff --git a/openedx/core/djangoapps/util/ratelimit.py b/openedx/core/djangoapps/util/ratelimit.py index 6fd7266f55..611392c346 100644 --- a/openedx/core/djangoapps/util/ratelimit.py +++ b/openedx/core/djangoapps/util/ratelimit.py @@ -28,3 +28,16 @@ def request_post_email(group, request) -> str: # pylint: disable=unused-argumen email = str(uuid4()) return email + + +def request_data_email(group, request) -> str: # pylint: disable=unused-argument + """ + Return the the email data param if it exists, otherwise return a + random id. + """ + + email = request.data.get('email') + if not email: + email = str(uuid4()) + + return email