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.
 
 
 
 

34 lines
868 B

  1. # frozen_string_literal: true
  2. class Api::V1::AnnouncementsController < Api::BaseController
  3. before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: :dismiss
  4. before_action :require_user!
  5. before_action :set_announcements, only: :index
  6. before_action :set_announcement, except: :index
  7. def index
  8. render json: @announcements, each_serializer: REST::AnnouncementSerializer
  9. end
  10. def dismiss
  11. AnnouncementMute.create!(account: current_account, announcement: @announcement)
  12. render_empty
  13. end
  14. private
  15. def set_announcements
  16. @announcements = begin
  17. scope = Announcement.published
  18. scope.merge!(Announcement.without_muted(current_account)) unless truthy_param?(:with_dismissed)
  19. scope.chronological
  20. end
  21. end
  22. def set_announcement
  23. @announcement = Announcement.published.find(params[:id])
  24. end
  25. end