The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

29 lines
702 B

  1. # frozen_string_literal: true
  2. class Api::V1::PollsController < Api::BaseController
  3. include Authorization
  4. before_action -> { authorize_if_got_token! :read, :'read:statuses' }, only: :show
  5. before_action :set_poll
  6. before_action :refresh_poll
  7. respond_to :json
  8. def show
  9. render json: @poll, serializer: REST::PollSerializer, include_results: true
  10. end
  11. private
  12. def set_poll
  13. @poll = Poll.attached.find(params[:id])
  14. authorize @poll.status, :show?
  15. rescue Mastodon::NotPermittedError
  16. raise ActiveRecord::RecordNotFound
  17. end
  18. def refresh_poll
  19. ActivityPub::FetchRemotePollService.new.call(@poll, current_account) if user_signed_in? && @poll.possibly_stale?
  20. end
  21. end