FIX: keep plugin compatible with older discourse versions

FIX: keep plugin compatible with older discourse versions

Per: bd5fa173 in Discourse there is no longer need re-register serializers in all descendants. This change was backported so this change to discourse voting is safe.

diff --git a/plugin.rb b/plugin.rb
index ef32bb4..fcb91a8 100755
--- a/plugin.rb
+++ b/plugin.rb
@@ -78,14 +78,12 @@ after_initialize do
     object.user_voted(scope.user) if scope.user
   }
 
-  [:basic_category, :site_category, :category].each do |serializer|
-    add_to_serializer(serializer, :can_vote, false) do
-      SiteSetting.voting_enabled
-    end
+  add_to_serializer(:basic_category, :can_vote, false) do
+    SiteSetting.voting_enabled
+  end
 
-    add_to_serializer(serializer, :include_can_vote?) do
-      Category.can_vote?(object.id)
-    end
+  add_to_serializer(:basic_category, :include_can_vote?) do
+    Category.can_vote?(object.id)
   end
 
   class ::Category

GitHub sha: d09feb47

1 Like