about summary refs log tree commit diff
path: root/app/serializers/activitypub/note_serializer.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-05 03:51:18 +0100
committerGitHub <noreply@github.com>2019-03-05 03:51:18 +0100
commita198add83bb527c32fa0e01404338562b157da99 (patch)
treec5a507a1e40092b89fe0c8ab6ffe36fa126628f1 /app/serializers/activitypub/note_serializer.rb
parent0a39c81dd87242feb84da68b8907c3e45620eadf (diff)
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
Diffstat (limited to 'app/serializers/activitypub/note_serializer.rb')
-rw-r--r--app/serializers/activitypub/note_serializer.rb12
1 files changed, 8 insertions, 4 deletions
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?