DEV: Delete plugin specific webhook event types (#29374)
Background When creating webhooks on a site without the Discourse Category Experts plugin installed, the category_experts_unapproved_event and category_experts_approved_event webhook events are getting automatically added to webhooks without a way to disable them. The category_experts_unapproved_event and category_experts_approved_event webhook events are associated with the Discourse Category Experts plugin so I am moving these webhook events into the Category Experts plugin. Changes This PR deletes Category Experts plugin specific webhook event types added into core.
This commit is contained in:
parent
0ecad3a7c9
commit
82ad7f9d17
|
@ -40,8 +40,6 @@ class WebHook < ActiveRecord::Base
|
||||||
WebHookEventType::TYPES[:post_edited],
|
WebHookEventType::TYPES[:post_edited],
|
||||||
WebHookEventType::TYPES[:post_destroyed],
|
WebHookEventType::TYPES[:post_destroyed],
|
||||||
WebHookEventType::TYPES[:post_recovered],
|
WebHookEventType::TYPES[:post_recovered],
|
||||||
WebHookEventType::TYPES[:category_experts_approved],
|
|
||||||
WebHookEventType::TYPES[:category_experts_unapproved],
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,8 +85,6 @@ class WebHookEventType < ActiveRecord::Base
|
||||||
chat_message_edited: 1802,
|
chat_message_edited: 1802,
|
||||||
chat_message_trashed: 1803,
|
chat_message_trashed: 1803,
|
||||||
chat_message_restored: 1804,
|
chat_message_restored: 1804,
|
||||||
category_experts_approved: 1901,
|
|
||||||
category_experts_unapproved: 1902,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
has_and_belongs_to_many :web_hooks
|
has_and_belongs_to_many :web_hooks
|
||||||
|
@ -118,11 +116,6 @@ class WebHookEventType < ActiveRecord::Base
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
end
|
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)
|
self.where.not(id: ids_to_exclude)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5442,8 +5442,6 @@ en:
|
||||||
post_edited: "Post is updated"
|
post_edited: "Post is updated"
|
||||||
post_destroyed: "Post is deleted"
|
post_destroyed: "Post is deleted"
|
||||||
post_recovered: "Post is recovered"
|
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_event:
|
||||||
group_name: "Group Events"
|
group_name: "Group Events"
|
||||||
group_created: "Group is created"
|
group_created: "Group is created"
|
||||||
|
|
|
@ -230,13 +230,3 @@ WebHookEventType.seed do |b|
|
||||||
b.name = "chat_message_restored"
|
b.name = "chat_message_restored"
|
||||||
b.group = WebHookEventType.groups[:chat]
|
b.group = WebHookEventType.groups[:chat]
|
||||||
end
|
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
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
class RemoveCategoryExpertsWebHookEventTypes < ActiveRecord::Migration[7.1]
|
||||||
|
def up
|
||||||
|
execute "DELETE FROM web_hook_event_types WHERE (name, id) IN (('category_experts_approved', 1901), ('category_experts_unapproved', 1902))"
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
|
@ -49,7 +49,6 @@ RSpec.describe WebHookEventType do
|
||||||
SiteSetting.stubs(:assign_enabled).returns(true)
|
SiteSetting.stubs(:assign_enabled).returns(true)
|
||||||
SiteSetting.stubs(:topic_voting_enabled).returns(true)
|
SiteSetting.stubs(:topic_voting_enabled).returns(true)
|
||||||
SiteSetting.stubs(:chat_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
|
plugins_event_types = WebHookEventType.active.map(&:name) - core_event_types
|
||||||
expect(plugins_event_types).to match_array(
|
expect(plugins_event_types).to match_array(
|
||||||
%w[
|
%w[
|
||||||
|
@ -63,8 +62,6 @@ RSpec.describe WebHookEventType do
|
||||||
chat_message_edited
|
chat_message_edited
|
||||||
chat_message_trashed
|
chat_message_trashed
|
||||||
chat_message_restored
|
chat_message_restored
|
||||||
category_experts_approved
|
|
||||||
category_experts_unapproved
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue