FIX: active webhook types exclude inactive plugins (#26022)

Bug introduced when webhooks were granularized in this PR - c468110929

Only active webhooks should be available when webhooks is configured.

https://meta.discourse.org/t/i18n-keys-showing-on-webhooks-edit-page/297701
This commit is contained in:
Krzysztof Kotlarek
2024-03-05 12:47:04 +11:00
committed by GitHub
parent 447ed2c06c
commit 28af4031ae
2 changed files with 80 additions and 4 deletions

View File

@@ -98,16 +98,23 @@ class WebHookEventType < ActiveRecord::Base
def self.active
ids_to_exclude = []
unless defined?(SiteSetting.solved_enabled) && SiteSetting.solved_enabled
ids_to_exclude << TYPES[:solved_accept_unaccept]
ids_to_exclude.concat([TYPES[:solved_accepted_solution], TYPES[:solved_unaccepted_solution]])
end
unless defined?(SiteSetting.assign_enabled) && SiteSetting.assign_enabled
ids_to_exclude << TYPES[:assign_assign_unassign]
ids_to_exclude.concat([TYPES[:assign_assigned], TYPES[:assign_unassigned]])
end
unless defined?(SiteSetting.voting_enabled) && SiteSetting.voting_enabled
ids_to_exclude << TYPES[:voting_voted_unvoted]
ids_to_exclude.concat([TYPES[:voting_topic_upvote], TYPES[:voting_topic_unvote]])
end
unless defined?(SiteSetting.chat_enabled) && SiteSetting.chat_enabled
ids_to_exclude << TYPES[:chat_message]
ids_to_exclude.concat(
[
TYPES[:chat_message_created],
TYPES[:chat_message_edited],
TYPES[:chat_message_trashed],
TYPES[:chat_message_restored],
],
)
end
self.where.not(id: ids_to_exclude)
end