diff options
author | ThibG <thib@sitedethib.com> | 2020-02-03 01:53:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-03 01:53:09 +0100 |
commit | 3adc722d1cdd28d87d2724b8952d7ec52d241b52 (patch) | |
tree | f8b08e38d3fba35c92b21b14c99ec2c3d21dd3c6 /app/serializers/rest | |
parent | 61a7390b666dc40beda291da426436a9d36f4288 (diff) |
Change how unread announcements are handled (#13020)
* 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
Diffstat (limited to 'app/serializers/rest')
-rw-r--r-- | app/serializers/rest/announcement_serializer.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/app/serializers/rest/announcement_serializer.rb b/app/serializers/rest/announcement_serializer.rb index ae962aa1d..ae72f9ace 100644 --- a/app/serializers/rest/announcement_serializer.rb +++ b/app/serializers/rest/announcement_serializer.rb @@ -4,15 +4,25 @@ class REST::AnnouncementSerializer < ActiveModel::Serializer attributes :id, :content, :starts_at, :ends_at, :all_day, :published_at, :updated_at + attribute :read, if: :current_user? + has_many :mentions has_many :tags, serializer: REST::StatusSerializer::TagSerializer has_many :emojis, serializer: REST::CustomEmojiSerializer has_many :reactions, serializer: REST::ReactionSerializer + def current_user? + !current_user.nil? + end + def id object.id.to_s end + def read + object.announcement_mutes.where(account: current_user.account).exists? + end + def content Formatter.instance.linkify(object.text) end |