Add: _misskey_license
の送受信 (#968)
This commit is contained in:
parent
9c14810881
commit
c139f8947e
8 changed files with 110 additions and 3 deletions
|
@ -34,6 +34,7 @@ module ContextHelper
|
|||
license: { 'schema' => 'http://schema.org#', 'license' => 'schema:license' },
|
||||
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
||||
attribution_domains: { 'toot' => 'http://joinmastodon.org/ns#', 'attributionDomains' => { '@id' => 'toot:attributionDomains', '@type' => '@id' } },
|
||||
misskey_license: { 'misskey' => 'https://misskey-hub.net/ns#', '_misskey_license' => 'misskey:_misskey_license' },
|
||||
}.freeze
|
||||
|
||||
def full_context
|
||||
|
|
|
@ -4,6 +4,7 @@ module ActivityPub::CaseTransform
|
|||
class << self
|
||||
NO_CONVERT_VALUES = %w(
|
||||
_misskey_content
|
||||
_misskey_license
|
||||
_misskey_quote
|
||||
).freeze
|
||||
|
||||
|
|
|
@ -34,6 +34,6 @@ class ActivityPub::Parser::CustomEmojiParser
|
|||
end
|
||||
|
||||
def license
|
||||
@json['license'] || @json['licence']
|
||||
@json.dig('_misskey_license', 'freeText') || @json['license'] || @json['licence']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::MisskeyEmojiLicensePresenter < ActiveModelSerializers::Model
|
||||
attributes :free_text
|
||||
end
|
|
@ -3,11 +3,12 @@
|
|||
class ActivityPub::EmojiSerializer < ActivityPub::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
context_extensions :emoji, :license, :keywords
|
||||
context_extensions :emoji, :license, :keywords, :misskey_license
|
||||
|
||||
attributes :id, :type, :name, :keywords, :is_sensitive, :updated
|
||||
|
||||
attribute :license, if: -> { object.license.present? }
|
||||
attribute :license, if: :license?
|
||||
has_one :misskey_license, key: :_misskey_license, if: :license?, serializer: ActivityPub::MisskeyEmojiLicenseSerializer
|
||||
|
||||
has_one :icon, serializer: ActivityPub::ImageSerializer
|
||||
|
||||
|
@ -34,4 +35,12 @@ class ActivityPub::EmojiSerializer < ActivityPub::Serializer
|
|||
def name
|
||||
":#{object.shortcode}:"
|
||||
end
|
||||
|
||||
def misskey_license
|
||||
ActivityPub::MisskeyEmojiLicensePresenter.new(free_text: object.license)
|
||||
end
|
||||
|
||||
def license?
|
||||
object.license.present?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::MisskeyEmojiLicenseSerializer < ActivityPub::Serializer
|
||||
attribute :free_text, key: :freeText
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue