mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 06:48:47 +08:00
FIX: don't allow inviting more than max_allowed_message_recipients
* FIX: don't allow inviting more than `max_allowed_message_recipients` setting allows * add specs for guardian * user preferences for auto track shouldn't be applicable to PMs (it auto watches on visit) Execlude PMs from "Automatically track topics I enter..." and "When I post in a topic, set that topic to..." user preferences * groups take only 1 slot in PM * just return if topic is a PM
This commit is contained in:
@ -523,6 +523,12 @@ class TopicsController < ApplicationController
|
||||
|
||||
topic = Topic.find_by(id: params[:topic_id])
|
||||
|
||||
unless pm_has_slots?(topic)
|
||||
return render_json_error(I18n.t("pm_reached_recipients_limit",
|
||||
recipients_limit: SiteSetting.max_allowed_message_recipients
|
||||
))
|
||||
end
|
||||
|
||||
if topic.private_message?
|
||||
guardian.ensure_can_invite_group_to_private_message!(group, topic)
|
||||
topic.invite_group(current_user, group)
|
||||
@ -543,6 +549,12 @@ class TopicsController < ApplicationController
|
||||
group_names: params[:group_names]
|
||||
)
|
||||
|
||||
unless pm_has_slots?(topic)
|
||||
return render_json_error(I18n.t("pm_reached_recipients_limit",
|
||||
recipients_limit: SiteSetting.max_allowed_message_recipients
|
||||
))
|
||||
end
|
||||
|
||||
guardian.ensure_can_invite_to!(topic, groups)
|
||||
group_ids = groups.map(&:id)
|
||||
|
||||
@ -880,4 +892,7 @@ class TopicsController < ApplicationController
|
||||
params[:email]
|
||||
end
|
||||
|
||||
def pm_has_slots?(pm)
|
||||
guardian.is_staff? || !pm.reached_recipients_limit?
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user