Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
mastodon
Commits
12bdd7dc
Commit
12bdd7dc
authored
6 years ago
by
valerauko
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Ignore JSON-LD profile in mime type comparison (#9179)
Ignore JSON-LD profile in mime type comparison
parent
15dcb414
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/fetch_atom_service.rb
+2
-2
app/services/fetch_atom_service.rb
spec/services/fetch_atom_service_spec.rb
+9
-2
spec/services/fetch_atom_service_spec.rb
with
11 additions
and
4 deletions
+11
-4
app/services/fetch_atom_service.rb
+
2
-
2
View file @
12bdd7dc
...
...
@@ -29,7 +29,7 @@ class FetchAtomService < BaseService
def
perform_request
(
&
block
)
accept
=
'text/html'
accept
=
'application/activity+json, application/ld+json, application/atom+xml, '
+
accept
unless
@unsupported_activity
accept
=
'application/activity+json, application/ld+json
; profile="https://www.w3.org/ns/activitystreams"
, application/atom+xml, '
+
accept
unless
@unsupported_activity
Request
.
new
(
:get
,
@url
).
add_headers
(
'Accept'
=>
accept
).
perform
(
&
block
)
end
...
...
@@ -39,7 +39,7 @@ class FetchAtomService < BaseService
if
response
.
mime_type
==
'application/atom+xml'
[
@url
,
{
prefetched_body:
response
.
body_with_limit
},
:ostatus
]
elsif
[
'application/activity+json'
,
'application/ld+json
; profile="https://www.w3.org/ns/activitystreams"
'
].
include?
(
response
.
mime_type
)
elsif
[
'application/activity+json'
,
'application/ld+json'
].
include?
(
response
.
mime_type
)
body
=
response
.
body_with_limit
json
=
body_to_json
(
body
)
if
supported_context?
(
json
)
&&
equals_or_includes_any?
(
json
[
'type'
],
ActivityPub
::
FetchRemoteAccountService
::
SUPPORTED_TYPES
)
&&
json
[
'inbox'
].
present?
...
...
This diff is collapsed.
Click to expand it.
spec/services/fetch_atom_service_spec.rb
+
9
-
2
View file @
12bdd7dc
...
...
@@ -60,8 +60,15 @@ RSpec.describe FetchAtomService, type: :service do
it
{
is_expected
.
to
eq
[
url
,
{
:prefetched_body
=>
""
},
:ostatus
]
}
end
context
'content_type is json'
do
let
(
:content_type
)
{
'application/activity+json'
}
context
'content_type is activity+json'
do
let
(
:content_type
)
{
'application/activity+json; charset=utf-8'
}
let
(
:body
)
{
json
}
it
{
is_expected
.
to
eq
[
1
,
{
prefetched_body:
body
,
id:
true
},
:activitypub
]
}
end
context
'content_type is ld+json with profile'
do
let
(
:content_type
)
{
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
}
let
(
:body
)
{
json
}
it
{
is_expected
.
to
eq
[
1
,
{
prefetched_body:
body
,
id:
true
},
:activitypub
]
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets