discourse/plugins/discourse-narrative-bot/lib/discourse_narrative_bot/post_guardian_extension.rb
Jarek Radosz e372355fd0
DEV: Clean up scope resolution operators in plugins (#34979)
Co-authored-by: Loïc Guitaut <loic@discourse.org>
2025-09-30 14:36:34 +02:00

21 lines
544 B
Ruby

# frozen_string_literal: true
module DiscourseNarrativeBot
module PostGuardianExtension
extend ActiveSupport::Concern
prepended do
alias_method :existing_can_create_post?, :can_create_post?
def can_create_post?(parent)
if SiteSetting.discourse_narrative_bot_enabled &&
parent.try(:subtype) == "system_message" &&
parent.try(:user) == DiscourseNarrativeBot::Base.new.discobot_user
return true
end
existing_can_create_post?(parent)
end
end
end
end