mirror of
https://github.com/discourse/discourse.git
synced 2026-08-10 04:58:31 -05:00
FIX: Don't enqueue posts if the user can't create them (ex: closed)
This commit is contained in:
@@ -20,6 +20,7 @@ module TopicGuardian
|
||||
|
||||
def can_create_post_on_topic?(topic)
|
||||
# No users can create posts on deleted topics
|
||||
return false if topic.blank?
|
||||
return false if topic.trashed?
|
||||
return true if is_admin?
|
||||
|
||||
|
||||
@@ -80,6 +80,17 @@ class NewPostManager
|
||||
def self.default_handler(manager)
|
||||
if user_needs_approval?(manager)
|
||||
|
||||
# Can the user create the post in the first place?
|
||||
if manager.args[:topic_id]
|
||||
topic = Topic.unscoped.where(id: manager.args[:topic_id]).first
|
||||
|
||||
unless manager.user.guardian.can_create_post_on_topic?(topic)
|
||||
result = NewPostResult.new(:created_post, false)
|
||||
result.errors[:base] << I18n.t(:topic_not_found)
|
||||
return result
|
||||
end
|
||||
end
|
||||
|
||||
result = manager.enqueue('default')
|
||||
|
||||
if is_fast_typer?(manager) || matches_auto_block_regex?(manager)
|
||||
|
||||
Reference in New Issue
Block a user