DEV: Add a new type_source field to the Reviewable model. (#31325)

This change adds a new `type_source` field to the `Reviewable` model, indicating whether the Reviewable type was registered by `core`, a plugin, or an `unknown` source.

When a plugin that registered a Reviewable type is disabled, this allows us to tell the user which plugin they need to re-enable to handle any orphan reviewable items.
This commit is contained in:
Gary Pendergast
2025-02-20 09:09:47 +11:00
committed by GitHub
parent dd5901d51e
commit 29a8c6ee49
22 changed files with 232 additions and 8 deletions

View File

@ -50,6 +50,8 @@ class DiscoursePluginRegistry
define_singleton_method("register_#{register_name.to_s.singularize}") do |value, plugin|
public_send(:"_raw_#{register_name}") << { plugin: plugin, value: value }
end
yield(self) if block_given?
end
define_register :javascripts, Set
@ -129,6 +131,14 @@ class DiscoursePluginRegistry
define_filtered_register :custom_filter_mappings
define_filtered_register :reviewable_types do |singleton|
singleton.define_singleton_method("reviewable_types_lookup") do
public_send(:"_raw_reviewable_types")
.filter_map { |h| { plugin: h[:plugin].name, klass: h[:value] } if h[:plugin].enabled? }
.uniq
end
end
def self.register_auth_provider(auth_provider)
self.auth_providers << auth_provider
end