mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FIX: Incorrect rate limit applied to topics invitation flow.
This commit is contained in:
parent
5a462b930d
commit
947b6fdf46
3 changed files with 46 additions and 10 deletions
|
@ -802,6 +802,8 @@ SQL
|
|||
|
||||
true
|
||||
elsif username_or_email =~ /^.+@.+$/ && Guardian.new(invited_by).can_invite_via_email?(self)
|
||||
rate_limit_topic_invitation(invited_by)
|
||||
|
||||
if target_user
|
||||
Invite.extend_permissions(self, target_user, invited_by)
|
||||
|
||||
|
@ -815,7 +817,10 @@ SQL
|
|||
end
|
||||
|
||||
true
|
||||
elsif target_user && topic_allowed_users.create!(user_id: target_user.id)
|
||||
elsif target_user &&
|
||||
rate_limit_topic_invitation(invited_by) &&
|
||||
topic_allowed_users.create!(user_id: target_user.id)
|
||||
|
||||
create_invite_notification!(
|
||||
target_user,
|
||||
Notification.types[:invited_to_topic],
|
||||
|
@ -1296,6 +1301,17 @@ SQL
|
|||
}.to_json
|
||||
)
|
||||
end
|
||||
|
||||
def rate_limit_topic_invitation(invited_by)
|
||||
RateLimiter.new(
|
||||
invited_by,
|
||||
"topic-invitations-per-day",
|
||||
SiteSetting.max_topic_invitations_per_day,
|
||||
1.day.to_i
|
||||
).performed!
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
# == Schema Information
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue