Revert "DEV: Delete plugin specific webhook events"

This reverts commit a5cbef5d1a.

Revert due to wrong branch
This commit is contained in:
rngus2344 2024-10-23 10:25:56 -05:00
parent 5605bab2c2
commit b5f8f559af
No known key found for this signature in database
GPG Key ID: 4E5F7A35021FBFA6
5 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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