A platform for community discussion. Free, open, simple.
DEV: Remove obsolete feature checks (#36175)
Jarek Radosz46836938881e
diff --git a/plugins/chat/plugin.rb b/plugins/chat/plugin.rbindex c01bbf66c35..2e0bd6773d2 100644--- a/plugins/chat/plugin.rb+++ b/plugins/chat/plugin.rb@@ -114,31 +114,25 @@ after_initialize doWebHook.prepend Chat::OutgoingWebHookExtensionend- if Oneboxer.respond_to?(:register_local_handler)- Oneboxer.register_local_handler("chat/chat") do |url, route|- Chat::OneboxHandler.handle(url, route)- end+ Oneboxer.register_local_handler("chat/chat") do |url, route|+ Chat::OneboxHandler.handle(url, route)end- if InlineOneboxer.respond_to?(:register_local_handler)- InlineOneboxer.register_local_handler("chat/chat") do |url, route|- Chat::InlineOneboxHandler.handle(url, route)- end+ InlineOneboxer.register_local_handler("chat/chat") do |url, route|+ Chat::InlineOneboxHandler.handle(url, route)end- if respond_to?(:register_upload_in_use)- register_upload_in_use do |upload|- Chat::Message.where(- "message LIKE ? OR message LIKE ?",+ register_upload_in_use do |upload|+ Chat::Message.where(+ "message LIKE ? OR message LIKE ?",+ "%#{upload.sha1}%",+ "%#{upload.base62_sha1}%",+ ).exists? ||+ Chat::Draft.where(+ "data LIKE ? OR data LIKE ?","%#{upload.sha1}%","%#{upload.base62_sha1}%",- ).exists? ||- Chat::Draft.where(- "data LIKE ? OR data LIKE ?",- "%#{upload.sha1}%",- "%#{upload.base62_sha1}%",- ).exists?- end+ ).exists?endadd_to_serializer(:user_card, :can_chat_user) dodiff --git a/plugins/discourse-ai/lib/ai_bot/entry_point.rb b/plugins/discourse-ai/lib/ai_bot/entry_point.rbindex 4c628ba3e01..d2d5c3270d4 100644--- a/plugins/discourse-ai/lib/ai_bot/entry_point.rb+++ b/plugins/discourse-ai/lib/ai_bot/entry_point.rb@@ -228,9 +228,7 @@ module DiscourseAiDiscourseAi::AiBot::Playground.schedule_chat_reply(chat_message, channel, user, context)end- if plugin.respond_to?(:register_editable_topic_custom_field)- plugin.register_editable_topic_custom_field(:ai_persona_id)- end+ plugin.register_editable_topic_custom_field(:ai_persona_id)plugin.add_api_key_scope(:discourse_ai,diff --git a/plugins/discourse-assign/plugin.rb b/plugins/discourse-assign/plugin.rbindex 55fc61e36fa..2d2a2c304d9 100644--- a/plugins/discourse-assign/plugin.rb+++ b/plugins/discourse-assign/plugin.rb@@ -161,12 +161,7 @@ after_initialize doon(:unassign_topic) { |topic, unassigning_user| Assigner.new(topic, unassigning_user).unassign }- if respond_to?(:register_preloaded_category_custom_fields)- register_preloaded_category_custom_fields("enable_unassigned_filter")- else- # TODO: Drop the if-statement and this if-branch in Discourse v3.2- Site.preloaded_category_custom_fields << "enable_unassigned_filter"- end+ register_preloaded_category_custom_fields("enable_unassigned_filter")BookmarkQuery.on_preload do |bookmarks, _bookmark_query|if SiteSetting.assign_enabled?diff --git a/plugins/discourse-calendar/plugin.rb b/plugins/discourse-calendar/plugin.rbindex 6907d9f920d..2c26324b231 100644--- a/plugins/discourse-calendar/plugin.rb+++ b/plugins/discourse-calendar/plugin.rb@@ -83,14 +83,8 @@ after_initialize doreloadable_patch doCategory.register_custom_field_type("sort_topics_by_event_start_date", :boolean)Category.register_custom_field_type("disable_topic_resorting", :boolean)- if respond_to?(:register_preloaded_category_custom_fields)- register_preloaded_category_custom_fields("sort_topics_by_event_start_date")- register_preloaded_category_custom_fields("disable_topic_resorting")- else- # TODO: Drop the if-statement and this if-branch in Discourse v3.2- Site.preloaded_category_custom_fields << "sort_topics_by_event_start_date"- Site.preloaded_category_custom_fields << "disable_topic_resorting"- end+ register_preloaded_category_custom_fields("sort_topics_by_event_start_date")+ register_preloaded_category_custom_fields("disable_topic_resorting")endadd_to_serializer :basic_category, :sort_topics_by_event_start_date do@@ -505,23 +499,21 @@ after_initialize doon(:user_destroyed) { |user| DiscoursePostEvent::Invitee.where(user_id: user.id).destroy_all }- if respond_to?(:add_post_revision_notifier_recipients)- add_post_revision_notifier_recipients do |post_revision|- # next if no modifications- next if !post_revision.modifications.present?+ add_post_revision_notifier_recipients do |post_revision|+ # next if no modifications+ next if !post_revision.modifications.present?- # do no notify recipients when only updating tags- next if post_revision.modifications.keys == ["tags"]+ # do no notify recipients when only updating tags+ next if post_revision.modifications.keys == ["tags"]- ids = []- post = post_revision.post+ ids = []+ post = post_revision.post- if post && post.is_first_post? && post.event- ids.concat(post.event.on_going_event_invitees.pluck(:user_id))- end-- ids+ if post && post.is_first_post? && post.event+ ids.concat(post.event.on_going_event_invitees.pluck(:user_id))end++ idsendon(:site_setting_changed) do |name, old_val, new_val|diff --git a/plugins/discourse-gamification/plugin.rb b/plugins/discourse-gamification/plugin.rbindex 4c1b2efcbb0..e700858e25b 100644--- a/plugins/discourse-gamification/plugin.rb+++ b/plugins/discourse-gamification/plugin.rb@@ -70,12 +70,10 @@ after_initialize doGuardian.include(DiscourseGamification::GuardianExtension)end- if respond_to?(:add_directory_column)- add_directory_column(- "gamification_score",- query: DiscourseGamification::DirectoryIntegration.query,- )- end+ add_directory_column(+ "gamification_score",+ query: DiscourseGamification::DirectoryIntegration.query,+ )add_to_serializer(:admin_plugin,diff --git a/plugins/discourse-topic-voting/plugin.rb b/plugins/discourse-topic-voting/plugin.rbindex 9a318a6fb9c..fcbe73cec8f 100755--- a/plugins/discourse-topic-voting/plugin.rb+++ b/plugins/discourse-topic-voting/plugin.rb@@ -47,38 +47,36 @@ after_initialize doscope.user ? object.topic.user_voted?(scope.user) : falseend- if TopicQuery.respond_to?(:results_filter_callbacks)- TopicQuery.results_filter_callbacks << ->(_type, result, user, options) do- return result unless SiteSetting.topic_voting_enabled+ TopicQuery.results_filter_callbacks << ->(_type, result, user, options) do+ return result unless SiteSetting.topic_voting_enabled- result = result.preload(:topic_vote_count)+ result = result.preload(:topic_vote_count)- if user- result =- result.select(- "topics.*, COALESCE((SELECT 1 FROM topic_voting_votes WHERE user_id = #{user.id} AND topic_id = topics.id), 0) AS current_user_voted",- )+ if user+ result =+ result.select(+ "topics.*, COALESCE((SELECT 1 FROM topic_voting_votes WHERE user_id = #{user.id} AND topic_id = topics.id), 0) AS current_user_voted",+ )- if options[:state] == "my_votes"- result =- result.joins(- "INNER JOIN topic_voting_votes ON topic_voting_votes.topic_id = topics.id AND topic_voting_votes.user_id = #{user.id}",- )- end- end-- if options[:order] == "votes"- sort_dir = (options[:ascending] == "true") ? "ASC" : "DESC"+ if options[:state] == "my_votes"result =result.joins(- "LEFT JOIN topic_voting_topic_vote_count ON topic_voting_topic_vote_count.topic_id = topics.id",- ).reorder(- "COALESCE(topic_voting_topic_vote_count.votes_count,'0')::integer #{sort_dir}, topics.bumped_at DESC",+ "INNER JOIN topic_voting_votes ON topic_voting_votes.topic_id = topics.id AND topic_voting_votes.user_id = #{user.id}",)end+ end- result+ if options[:order] == "votes"+ sort_dir = (options[:ascending] == "true") ? "ASC" : "DESC"+ result =+ result.joins(+ "LEFT JOIN topic_voting_topic_vote_count ON topic_voting_topic_vote_count.topic_id = topics.id",+ ).reorder(+ "COALESCE(topic_voting_topic_vote_count.votes_count,'0')::integer #{sort_dir}, topics.bumped_at DESC",+ )end++ resultendregister_category_custom_field_type("enable_topic_voting", :boolean)