From b5f8f559af12944d312011e4f069d759742900c9 Mon Sep 17 00:00:00 2001 From: rngus2344 Date: Wed, 23 Oct 2024 10:25:56 -0500 Subject: [PATCH] Revert "DEV: Delete plugin specific webhook events" This reverts commit a5cbef5d1a33affe7a7ab8bda85fa7b855470fab. Revert due to wrong branch --- app/models/web_hook.rb | 2 ++ app/models/web_hook_event_type.rb | 7 +++++++ config/locales/client.en.yml | 2 ++ db/fixtures/007_web_hook_event_types.rb | 10 ++++++++++ spec/models/web_hook_event_type_spec.rb | 3 +++ 5 files changed, 24 insertions(+) diff --git a/app/models/web_hook.rb b/app/models/web_hook.rb index b1492d96f47..06bae70363a 100644 --- a/app/models/web_hook.rb +++ b/app/models/web_hook.rb @@ -40,6 +40,8 @@ class WebHook < ActiveRecord::Base WebHookEventType::TYPES[:post_edited], WebHookEventType::TYPES[:post_destroyed], WebHookEventType::TYPES[:post_recovered], + WebHookEventType::TYPES[:category_experts_approved], + WebHookEventType::TYPES[:category_experts_unapproved], ], ) end diff --git a/app/models/web_hook_event_type.rb b/app/models/web_hook_event_type.rb index 2a9ac2067bb..9449a81281a 100644 --- a/app/models/web_hook_event_type.rb +++ b/app/models/web_hook_event_type.rb @@ -86,6 +86,8 @@ class WebHookEventType < ActiveRecord::Base chat_message_edited: 1802, chat_message_trashed: 1803, chat_message_restored: 1804, + category_experts_approved: 1901, + category_experts_unapproved: 1902, } has_and_belongs_to_many :web_hooks @@ -117,6 +119,11 @@ class WebHookEventType < ActiveRecord::Base ], ) end + unless defined?(SiteSetting.enable_category_experts) && SiteSetting.enable_category_experts + ids_to_exclude.concat( + [TYPES[:category_experts_approved], TYPES[:category_experts_unapproved]], + ) + end self.where.not(id: ids_to_exclude) end end diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index eaef3cbaf38..c0a820bfd2e 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -5472,6 +5472,8 @@ en: post_edited: "Post is updated" post_destroyed: "Post is deleted" post_recovered: "Post is recovered" + category_experts_approved: "Post marked as category experts post" + category_experts_unapproved: "Post unmarked as category experts post" group_event: group_name: "Group Events" group_created: "Group is created" diff --git a/db/fixtures/007_web_hook_event_types.rb b/db/fixtures/007_web_hook_event_types.rb index e5da6fbb957..6f619eaee93 100644 --- a/db/fixtures/007_web_hook_event_types.rb +++ b/db/fixtures/007_web_hook_event_types.rb @@ -230,3 +230,13 @@ WebHookEventType.seed do |b| b.name = "chat_message_restored" b.group = WebHookEventType.groups[:chat] end +WebHookEventType.seed do |b| + b.id = WebHookEventType::TYPES[:category_experts_approved] + b.name = "category_experts_approved" + b.group = WebHookEventType.groups[:post] +end +WebHookEventType.seed do |b| + b.id = WebHookEventType::TYPES[:category_experts_unapproved] + b.name = "category_experts_unapproved" + b.group = WebHookEventType.groups[:post] +end diff --git a/spec/models/web_hook_event_type_spec.rb b/spec/models/web_hook_event_type_spec.rb index 471f67bd449..32821cec352 100644 --- a/spec/models/web_hook_event_type_spec.rb +++ b/spec/models/web_hook_event_type_spec.rb @@ -49,6 +49,7 @@ RSpec.describe WebHookEventType do SiteSetting.stubs(:assign_enabled).returns(true) SiteSetting.stubs(:topic_voting_enabled).returns(true) SiteSetting.stubs(:chat_enabled).returns(true) + SiteSetting.stubs(:enable_category_experts).returns(true) plugins_event_types = WebHookEventType.active.map(&:name) - core_event_types expect(plugins_event_types).to match_array( %w[ @@ -62,6 +63,8 @@ RSpec.describe WebHookEventType do chat_message_edited chat_message_trashed chat_message_restored + category_experts_approved + category_experts_unapproved ], ) end