Merge commit 'b9f59ebcc68e9da0a7158741a1a2ef3564e1321e' into merging-upstream

This commit is contained in:
Ondřej Hruška
2017-09-28 09:18:35 +02:00
4750 changed files with 5257 additions and 3475 deletions

View File

@@ -7,6 +7,10 @@ class REST::AccountSerializer < ActiveModel::Serializer
:note, :url, :avatar, :avatar_static, :header, :header_static,
:followers_count, :following_count, :statuses_count
def id
object.id.to_s
end
def note
Formatter.instance.simplified_format(object)
end

View File

@@ -4,6 +4,10 @@ class REST::ApplicationSerializer < ActiveModel::Serializer
attributes :id, :name, :website, :redirect_uri,
:client_id, :client_secret
def id
object.id.to_s
end
def client_id
object.uid
end

View File

@@ -0,0 +1,11 @@
# frozen_string_literal: true
class REST::CustomEmojiSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :shortcode, :url
def url
full_asset_url(object.image.url)
end
end

View File

@@ -6,6 +6,10 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer
attributes :id, :type, :url, :preview_url,
:remote_url, :text_url, :meta
def id
object.id.to_s
end
def url
if object.needs_redownload?
media_proxy_url(object.id, :original)

View File

@@ -6,6 +6,10 @@ class REST::NotificationSerializer < ActiveModel::Serializer
belongs_to :from_account, key: :account, serializer: REST::AccountSerializer
belongs_to :target_status, key: :status, if: :status_type?, serializer: REST::StatusSerializer
def id
object.id.to_s
end
def status_type?
[:favourite, :reblog, :mention].include?(object.type)
end

View File

@@ -4,6 +4,10 @@ class REST::RelationshipSerializer < ActiveModel::Serializer
attributes :id, :following, :followed_by, :blocking,
:muting, :requested, :domain_blocking
def id
object.id.to_s
end
def following
instance_options[:relationships].following[object.id] || false
end

View File

@@ -2,4 +2,8 @@
class REST::ReportSerializer < ActiveModel::Serializer
attributes :id, :action_taken
def id
object.id.to_s
end
end

View File

@@ -17,14 +17,26 @@ class REST::StatusSerializer < ActiveModel::Serializer
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
has_many :mentions
has_many :tags
has_many :emojis
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
@@ -82,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
@@ -107,14 +119,4 @@ class REST::StatusSerializer < ActiveModel::Serializer
tag_url(object)
end
end
class CustomEmojiSerializer < ActiveModel::Serializer
include RoutingHelper
attributes :shortcode, :url
def url
full_asset_url(object.image.url)
end
end
end