about summary refs log tree commit diff
path: root/app/serializers/rest
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-04-20 01:00:45 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:22 -0500
commit87f4b4d230454d4baa7116e55d9aee42199eeb9b (patch)
tree67ba4a84653cc027a414a60732227abeced2fdc0 /app/serializers/rest
parent19b78604e9dd1acb6566edd49f5c59536d5fc209 (diff)
Implement share keys and related bangtags, add `sharekey`, `network`, and `curated` to the API, remove app info from the UI, and move timestamps to the right.
Diffstat (limited to 'app/serializers/rest')
-rw-r--r--app/serializers/rest/status_serializer.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb
index ab3788d75..86e887463 100644
--- a/app/serializers/rest/status_serializer.rb
+++ b/app/serializers/rest/status_serializer.rb
@@ -4,7 +4,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
   attributes :id, :created_at, :in_reply_to_id, :in_reply_to_account_id,
              :sensitive, :spoiler_text, :visibility, :language,
              :uri, :url, :replies_count, :reblogs_count,
-             :favourites_count
+             :favourites_count, :network, :curated
 
   attribute :favourited, if: :current_user?
   attribute :reblogged, if: :current_user?
@@ -12,6 +12,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
   attribute :bookmarked, if: :current_user?
   attribute :pinned, if: :pinnable?
   attribute :local_only if :local?
+  attribute :sharekey, if: :owner?
 
   attribute :content, unless: :source_requested?
   attribute :text, if: :source_requested?
@@ -45,8 +46,12 @@ class REST::StatusSerializer < ActiveModel::Serializer
     !current_user.nil?
   end
 
+  def owner?
+    current_user? && current_user.account_id == object.account_id
+  end
+
   def show_application?
-    object.account.user_shows_application? || (current_user? && current_user.account_id == object.account_id)
+    object.account.user_shows_application? || owner?
   end
 
   def visibility