From a198add83bb527c32fa0e01404338562b157da99 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Tue, 5 Mar 2019 03:51:18 +0100 Subject: Fix various issues in polls (#10165) * Fix ActivityPub poll results being serialized even with hide_totals * Fix poll refresh button having a different font size * Display poll in OpenGraph description * Fix NoMethodError when serializing votes Regression from #10158 * Fix polls on public pages being broken for non-logged-in users * Do not show time remaining if poll has no expiration date --- app/serializers/activitypub/note_serializer.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app/serializers') diff --git a/app/serializers/activitypub/note_serializer.rb b/app/serializers/activitypub/note_serializer.rb index b2c92fdc1..b2a5f53e0 100644 --- a/app/serializers/activitypub/note_serializer.rb +++ b/app/serializers/activitypub/note_serializer.rb @@ -15,8 +15,8 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer has_one :replies, serializer: ActivityPub::CollectionSerializer, if: :local? - has_many :poll_loaded_options, key: :one_of, if: :poll_and_not_multiple? - has_many :poll_loaded_options, key: :any_of, if: :poll_and_multiple? + has_many :poll_options, key: :one_of, if: :poll_and_not_multiple? + has_many :poll_options, key: :any_of, if: :poll_and_multiple? attribute :end_time, if: :poll_and_expires? attribute :closed, if: :poll_and_expired? @@ -121,8 +121,12 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer object.account.local? end - def poll_loaded_options - object.poll.loaded_options + def poll_options + if !object.expired? && object.hide_totals? + object.poll.unloaded_options + else + object.poll.loaded_options + end end def poll_and_multiple? -- cgit