Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Added Category Experts approved WebHook Event (#28525)

Guhyoun Nam050c66516070
diff --git a/app/models/web_hook_event_type.rb b/app/models/web_hook_event_type.rb
index f4120e7cab9..e6b5043888d 100644
--- a/app/models/web_hook_event_type.rb
+++ b/app/models/web_hook_event_type.rb
@@ -17,6 +17,7 @@ class WebHookEventType < ActiveRecord::Base
USER_PROMOTED = 16
TOPIC_VOTING = 17
CHAT_MESSAGE = 18
+ CATEGORY_EXPERTS = 19
enum group: {
topic: 0,
@@ -35,6 +36,7 @@ class WebHookEventType < ActiveRecord::Base
user_promoted: 13,
voting: 14,
chat: 15,
+ category_experts: 16,
},
_scopes: false
@@ -85,6 +87,7 @@ class WebHookEventType < ActiveRecord::Base
chat_message_edited: 1802,
chat_message_trashed: 1803,
chat_message_restored: 1804,
+ category_experts_approved: 1901,
}
has_and_belongs_to_many :web_hooks
@@ -116,6 +119,9 @@ class WebHookEventType < ActiveRecord::Base
],
)
end
+ unless defined?(SiteSetting.enable_category_experts) && SiteSetting.enable_category_experts
+ ids_to_exclude.concat([TYPES[:category_experts_approved]])
+ end
self.where.not(id: ids_to_exclude)
end
end
diff --git a/db/fixtures/007_web_hook_event_types.rb b/db/fixtures/007_web_hook_event_types.rb
index e5da6fbb957..874c8f74ead 100644
--- a/db/fixtures/007_web_hook_event_types.rb
+++ b/db/fixtures/007_web_hook_event_types.rb
@@ -230,3 +230,8 @@ 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[:category_experts]
+end
diff --git a/spec/models/web_hook_event_type_spec.rb b/spec/models/web_hook_event_type_spec.rb
index 471f67bd449..f3855a05b23 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,7 @@ RSpec.describe WebHookEventType do
chat_message_edited
chat_message_trashed
chat_message_restored
+ category_experts_approved
],
)
end