I can confirm this is a multisite issue. The table in the multisite master database contains the supplier, the table in the other multisite databases do not, so /admin/plugins/subscription-client/suppliers returns an empty json response.
Quick (and dirty!) fix below, but there might be more issues, didn’t test that, it’s late already.
--- a/plugin.rb
+++ b/plugin.rb
@@ -39,7 +39,9 @@ after_initialize do
load File.expand_path(path, __FILE__)
end
+ RailsMultisite::ConnectionManagement.each_connection do
SubscriptionClient::Resources.find_all unless Rails.env.test?
+ end
User.has_many(:subscription_client_suppliers)
It occurred to me that it is highly undesirable to execute the find_suppliers function during startup. It introduces a direct dependency to network connectivity and external services, preventing delaying Discourse to start when one of those fail take more time .
Could this be done in an async job that is triggered upon plugin initialization? The additional benefit is that this gives you automatic multisite capabilities since Discourse will trigger a separate job for each individual multisite member.
@richard@Jrgong Sorry this has taken so long. I have a new computer and setting up the rspec environment for multisite unit tests proved harder than normal.