2020-01-24 08:00:13 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V1::AnnouncementsController < Api::BaseController
|
|
|
|
before_action -> { doorkeeper_authorize! :write, :'write:accounts' }, only: :dismiss
|
|
|
|
before_action :require_user!
|
|
|
|
before_action :set_announcements, only: :index
|
|
|
|
before_action :set_announcement, except: :index
|
|
|
|
|
|
|
|
def index
|
|
|
|
render json: @announcements, each_serializer: REST::AnnouncementSerializer
|
|
|
|
end
|
|
|
|
|
|
|
|
def dismiss
|
2020-02-25 08:21:40 +11:00
|
|
|
AnnouncementMute.find_or_create_by!(account: current_account, announcement: @announcement)
|
2020-01-24 08:00:13 +11:00
|
|
|
render_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_announcements
|
2023-02-19 09:09:40 +11:00
|
|
|
@announcements = Announcement.published.chronological
|
2020-01-24 08:00:13 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_announcement
|
|
|
|
@announcement = Announcement.published.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|