about summary refs log tree commit diff
path: root/app/serializers
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2020-02-03 09:22:58 +0100
committerThibaut Girka <thib@sitedethib.com>2020-02-03 09:22:58 +0100
commit369201a425f7b539290815402a4bc65923911e11 (patch)
tree45de36cd6aa8c22aaf4be6cefaeeb70218d4daf5 /app/serializers
parent4cd2d13bd226c005317adf9848f4c0316401b2ff (diff)
parent3adc722d1cdd28d87d2724b8952d7ec52d241b52 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/rest/announcement_serializer.rb10
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