aboutsummaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-09-22 14:15:18 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-09-22 14:15:18 +0200
commitb359974d9b356bb723fe046466b178328cf9bbaf (patch)
treebf8cb3887286aaced76a46ab80c7e250afbb763e /app/serializers
parent26b810561a5b7cfd1766699358d998b5882a5876 (diff)
downloadmastodon-b359974d9b356bb723fe046466b178328cf9bbaf.tar
mastodon-b359974d9b356bb723fe046466b178328cf9bbaf.tar.gz
mastodon-b359974d9b356bb723fe046466b178328cf9bbaf.tar.bz2
mastodon-b359974d9b356bb723fe046466b178328cf9bbaf.zip
Show user what options they have voted (#11195)
* Add own_votes field to poll results in REST API Fixes #10679 * Display user votes in WebUI * Update styling * Add vote checkmark to public pages
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/poll_serializer.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/serializers/rest/poll_serializer.rb b/app/serializers/rest/poll_serializer.rb
index 356c45b83..eb98bb2d2 100644
--- a/app/serializers/rest/poll_serializer.rb
+++ b/app/serializers/rest/poll_serializer.rb
@@ -8,6 +8,7 @@ class REST::PollSerializer < ActiveModel::Serializer
has_many :emojis, serializer: REST::CustomEmojiSerializer
attribute :voted, if: :current_user?
+ attribute :own_votes, if: :current_user?
def id
object.id.to_s
@@ -21,6 +22,10 @@ class REST::PollSerializer < ActiveModel::Serializer
object.voted?(current_user.account)
end
+ def own_votes
+ object.own_votes(current_user.account)
+ end
+
def current_user?
!current_user.nil?
end