This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2020-01-23 13:00:13 -08: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
|
|
|
|
AnnouncementMute.create!(account: current_account, announcement: @announcement)
|
|
|
|
render_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_announcements
|
|
|
|
@announcements = begin
|
2020-02-02 16:53:09 -08:00
|
|
|
Announcement.published.chronological
|
2020-01-23 13:00:13 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_announcement
|
|
|
|
@announcement = Announcement.published.find(params[:id])
|
|
|
|
end
|
|
|
|
end
|