mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 23:36:11 +08:00
FIX: Only apply the rate limit to user exports, not downloads (#30965)
Follow-up to 7fc8d74f3eed52116add452b5321b41e02e04499. This change moves the guardian check for whether an export has been generated too recently to the endpoint handler, since we only want this check to apply when generating an export.
This commit is contained in:
@ -17,6 +17,17 @@ class ExportCsvController < ApplicationController
|
||||
|
||||
if entity == "user_archive"
|
||||
requesting_user_id = current_user.id if entity_id
|
||||
|
||||
# Rate limit user archive exports to 1 per day
|
||||
unless current_user.admin ||
|
||||
UserExport.where(
|
||||
user_id: entity_id || current_user.id,
|
||||
created_at: (Time.zone.now.beginning_of_day..Time.zone.now.end_of_day),
|
||||
).count == 0
|
||||
render_json_error I18n.t("csv_export.rate_limit_error")
|
||||
return
|
||||
end
|
||||
|
||||
Jobs.enqueue(
|
||||
:export_user_archive,
|
||||
user_id: entity_id || current_user.id,
|
||||
|
Reference in New Issue
Block a user