Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
824497fb
Commit
824497fb
authored
6 years ago
by
valerauko
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Ignore JSON-LD profile in mime type comparison (#9179)
Ignore JSON-LD profile in mime type comparison
parent
473998ca
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/services/fetch_atom_service.rb
+2
-2
2 additions, 2 deletions
app/services/fetch_atom_service.rb
spec/services/fetch_atom_service_spec.rb
+9
-2
9 additions, 2 deletions
spec/services/fetch_atom_service_spec.rb
with
11 additions
and
4 deletions
app/services/fetch_atom_service.rb
+
2
−
2
View file @
824497fb
...
...
@@ -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 @
824497fb
...
...
@@ -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.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment