0
0
Fork 0

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
This commit is contained in:
Eugen Rochko 2019-03-05 03:51:18 +01:00 committed by GitHub
parent 0a39c81dd8
commit a198add83b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 13 deletions

View file

@ -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?