mirror of
https://github.com/discourse/discourse.git
synced 2026-08-02 09:29:37 -05:00
DEV: Remove obsolete feature checks (#36175)
This commit is contained in:
+13
-19
@@ -114,31 +114,25 @@ after_initialize do
|
||||
WebHook.prepend Chat::OutgoingWebHookExtension
|
||||
end
|
||||
|
||||
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?
|
||||
end
|
||||
|
||||
add_to_serializer(:user_card, :can_chat_user) do
|
||||
|
||||
@@ -228,9 +228,7 @@ module DiscourseAi
|
||||
DiscourseAi::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,
|
||||
|
||||
@@ -161,12 +161,7 @@ after_initialize do
|
||||
|
||||
on(: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?
|
||||
|
||||
@@ -83,14 +83,8 @@ after_initialize do
|
||||
reloadable_patch do
|
||||
Category.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")
|
||||
end
|
||||
|
||||
add_to_serializer :basic_category, :sort_topics_by_event_start_date do
|
||||
@@ -505,23 +499,21 @@ after_initialize do
|
||||
|
||||
on(: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
|
||||
|
||||
ids
|
||||
end
|
||||
|
||||
on(:site_setting_changed) do |name, old_val, new_val|
|
||||
|
||||
@@ -70,12 +70,10 @@ after_initialize do
|
||||
Guardian.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,
|
||||
|
||||
@@ -47,38 +47,36 @@ after_initialize do
|
||||
scope.user ? object.topic.user_voted?(scope.user) : false
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
register_category_custom_field_type("enable_topic_voting", :boolean)
|
||||
|
||||
Reference in New Issue
Block a user