mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-24 17:28:07 +01:00
3adc722d1c
* Change meaning of /api/v1/announcements/:id/dismiss to mark an announcement as read * Change how unread announcements are counted in UI * Add unread marker to announcements and mark announcements as unread as they are displayed * Fixups
29 lines
744 B
Ruby
29 lines
744 B
Ruby
# 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
|
|
Announcement.published.chronological
|
|
end
|
|
end
|
|
|
|
def set_announcement
|
|
@announcement = Announcement.published.find(params[:id])
|
|
end
|
|
end
|