FIX: compatibility after allowlist rewording in Discourse

FIX: compatibility after allowlist rewording in Discourse

diff --git a/plugin.rb b/plugin.rb
index b6578ff..9800c79 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -250,8 +250,16 @@ SQL
     mount ::DiscourseSolved::Engine, at: "solution"
   end
 
-  TopicView.add_post_custom_fields_whitelister do |user|
-    ["is_accepted_answer"]
+
+  # TODO Drop after Discourse 2.6.0 release
+  if TopicView.respond_to?(:add_post_custom_fields_whitelister)
+    TopicView.add_post_custom_fields_whitelister do |user|
+      ["is_accepted_answer"]
+    end
+  else
+    TopicView.add_post_custom_fields_allowlister do |user|
+      ["is_accepted_answer"]
+    end
   end
 
   def get_schema_text(post)

GitHub sha: 10c31ffb

1 Like