Merge commit '4aea3f88a6d30f102a79c2da7fcfac96465ba1a8' into merging-upstream
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
||||
attributes :id, :type, :actor, :to, :cc
|
||||
attributes :id, :type, :actor, :published, :to, :cc
|
||||
|
||||
has_one :proper, key: :object, serializer: ActivityPub::NoteSerializer
|
||||
|
||||
@ -17,6 +17,10 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
||||
ActivityPub::TagManager.instance.uri_for(object.account)
|
||||
end
|
||||
|
||||
def published
|
||||
object.created_at.iso8601
|
||||
end
|
||||
|
||||
def to
|
||||
ActivityPub::TagManager.instance.to(object)
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def in_reply_to
|
||||
return unless object.reply?
|
||||
return unless object.reply? && !object.thread.nil?
|
||||
|
||||
if object.thread.uri.nil? || object.thread.uri.start_with?('http')
|
||||
ActivityPub::TagManager.instance.uri_for(object.thread)
|
||||
@ -57,7 +57,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def virtual_tags
|
||||
object.mentions + object.tags
|
||||
object.mentions + object.tags + object.emojis
|
||||
end
|
||||
|
||||
def atom_uri
|
||||
@ -67,12 +67,14 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||
end
|
||||
|
||||
def in_reply_to_atom_uri
|
||||
return unless object.reply?
|
||||
return unless object.reply? && !object.thread.nil?
|
||||
|
||||
::TagManager.instance.uri_for(object.thread)
|
||||
end
|
||||
|
||||
def conversation
|
||||
return if object.conversation.nil?
|
||||
|
||||
if object.conversation.uri?
|
||||
object.conversation.uri
|
||||
else
|
||||
@ -135,4 +137,22 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||
"##{object.name}"
|
||||
end
|
||||
end
|
||||
|
||||
class CustomEmojiSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :type, :href, :name
|
||||
|
||||
def type
|
||||
'Emoji'
|
||||
end
|
||||
|
||||
def href
|
||||
full_asset_url(object.image.url)
|
||||
end
|
||||
|
||||
def name
|
||||
":#{object.shortcode}:"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -45,7 +45,7 @@ class OEmbedSerializer < ActiveModel::Serializer
|
||||
height: height,
|
||||
}
|
||||
|
||||
content_tag(:iframe, nil, attributes) + content_tag(:script, nil, src: full_asset_url('embed.js'), async: true)
|
||||
content_tag(:iframe, nil, attributes) + content_tag(:script, nil, src: full_asset_url('embed.js', skip_pipeline: true), async: true)
|
||||
end
|
||||
|
||||
def width
|
||||
|
@ -1,8 +1,10 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :uri, :title, :description, :email,
|
||||
:version, :urls, :stats
|
||||
:version, :urls, :stats, :thumbnail
|
||||
|
||||
def uri
|
||||
Rails.configuration.x.local_domain
|
||||
@ -24,6 +26,10 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||
Mastodon::Version.to_s
|
||||
end
|
||||
|
||||
def thumbnail
|
||||
full_asset_url(instance_presenter.thumbnail.file.url) if instance_presenter.thumbnail
|
||||
end
|
||||
|
||||
def stats
|
||||
{
|
||||
user_count: instance_presenter.user_count,
|
||||
|
@ -7,11 +7,19 @@ class REST::MediaAttachmentSerializer < ActiveModel::Serializer
|
||||
:remote_url, :text_url, :meta
|
||||
|
||||
def url
|
||||
full_asset_url(object.file.url(:original))
|
||||
if object.needs_redownload?
|
||||
media_proxy_url(object.id, :original)
|
||||
else
|
||||
full_asset_url(object.file.url(:original))
|
||||
end
|
||||
end
|
||||
|
||||
def preview_url
|
||||
full_asset_url(object.file.url(:small))
|
||||
if object.needs_redownload?
|
||||
media_proxy_url(object.id, :small)
|
||||
else
|
||||
full_asset_url(object.file.url(:small))
|
||||
end
|
||||
end
|
||||
|
||||
def text_url
|
||||
|
@ -17,6 +17,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
||||
has_many :media_attachments, serializer: REST::MediaAttachmentSerializer
|
||||
has_many :mentions
|
||||
has_many :tags
|
||||
has_many :emojis
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
@ -106,4 +107,14 @@ 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
|
||||
|
Reference in New Issue
Block a user