diff options
Diffstat (limited to 'app/serializers/rest/status_serializer.rb')
-rw-r--r-- | app/serializers/rest/status_serializer.rb | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/app/serializers/rest/status_serializer.rb b/app/serializers/rest/status_serializer.rb index 246b12a90..e6270f902 100644 --- a/app/serializers/rest/status_serializer.rb +++ b/app/serializers/rest/status_serializer.rb @@ -8,6 +8,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attribute :favourited, if: :current_user? attribute :reblogged, if: :current_user? attribute :muted, if: :current_user? + attribute :pinned, if: :pinnable? belongs_to :reblog, serializer: REST::StatusSerializer belongs_to :application @@ -16,13 +17,26 @@ class REST::StatusSerializer < ActiveModel::Serializer has_many :media_attachments, serializer: REST::MediaAttachmentSerializer has_many :mentions has_many :tags + has_many :emojis, serializer: REST::CustomEmojiSerializer + + def id + object.id.to_s + end + + def in_reply_to_id + object.in_reply_to_id&.to_s + end + + def in_reply_to_account_id + object.in_reply_to_account_id&.to_s + end def current_user? !current_user.nil? end def uri - TagManager.instance.uri_for(object) + OStatus::TagManager.instance.uri_for(object) end def content @@ -57,6 +71,21 @@ class REST::StatusSerializer < ActiveModel::Serializer end end + def pinned + if instance_options && instance_options[:relationships] + instance_options[:relationships].pins_map[object.id] || false + else + current_user.account.pinned?(object) + end + end + + def pinnable? + current_user? && + current_user.account_id == object.account_id && + !object.reblog? && + %w(public unlisted).include?(object.visibility) + end + class ApplicationSerializer < ActiveModel::Serializer attributes :name, :website end @@ -65,7 +94,7 @@ class REST::StatusSerializer < ActiveModel::Serializer attributes :id, :username, :url, :acct def id - object.account_id + object.account_id.to_s end def username |