mirror of
https://github.com/kikobar/mastodon.git
synced 2024-12-27 00:04:15 +00:00
parent
32a4494926
commit
915c619394
|
@ -5,7 +5,7 @@ class ActivityPub::Activity
|
||||||
include Redisable
|
include Redisable
|
||||||
|
|
||||||
SUPPORTED_TYPES = %w(Note Question).freeze
|
SUPPORTED_TYPES = %w(Note Question).freeze
|
||||||
CONVERTED_TYPES = %w(Image Video Article Page).freeze
|
CONVERTED_TYPES = %w(Image Audio Video Article Page).freeze
|
||||||
|
|
||||||
def initialize(json, account, **options)
|
def initialize(json, account, **options)
|
||||||
@json = json
|
@json = json
|
||||||
|
|
|
@ -18,9 +18,9 @@ class ResolveURLService < BaseService
|
||||||
private
|
private
|
||||||
|
|
||||||
def process_url
|
def process_url
|
||||||
if equals_or_includes_any?(type, %w(Application Group Organization Person Service))
|
if equals_or_includes_any?(type, ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES)
|
||||||
FetchRemoteAccountService.new.call(atom_url, body, protocol)
|
FetchRemoteAccountService.new.call(atom_url, body, protocol)
|
||||||
elsif equals_or_includes_any?(type, %w(Note Article Image Video Page Question))
|
elsif equals_or_includes_any?(type, ActivityPub::Activity::Create::SUPPORTED_TYPES + ActivityPub::Activity::Create::CONVERTED_TYPES)
|
||||||
FetchRemoteStatusService.new.call(atom_url, body, protocol)
|
FetchRemoteStatusService.new.call(atom_url, body, protocol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,6 +71,39 @@ RSpec.describe ActivityPub::FetchRemoteStatusService, type: :service do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'with Audio object' do
|
||||||
|
let(:object) do
|
||||||
|
{
|
||||||
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
|
id: "https://#{valid_domain}/@foo/1234",
|
||||||
|
type: 'Audio',
|
||||||
|
name: 'Nyan Cat 10 hours remix',
|
||||||
|
attributedTo: ActivityPub::TagManager.instance.uri_for(sender),
|
||||||
|
url: [
|
||||||
|
{
|
||||||
|
type: 'Link',
|
||||||
|
mimeType: 'application/x-bittorrent',
|
||||||
|
href: "https://#{valid_domain}/12345.torrent",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
type: 'Link',
|
||||||
|
mimeType: 'text/html',
|
||||||
|
href: "https://#{valid_domain}/watch?v=12345",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates status' do
|
||||||
|
status = sender.statuses.first
|
||||||
|
|
||||||
|
expect(status).to_not be_nil
|
||||||
|
expect(status.url).to eq "https://#{valid_domain}/watch?v=12345"
|
||||||
|
expect(strip_tags(status.text)).to eq "Nyan Cat 10 hours remix https://#{valid_domain}/watch?v=12345"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'with wrong id' do
|
context 'with wrong id' do
|
||||||
let(:note) do
|
let(:note) do
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue