Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
ed5a1bbd
Commit
ed5a1bbd
authored
Mar 07, 2019
by
lain
Browse files
Merge branch 'preserve-link-headers' into 'develop'
Preserves parameters in link headers Closes
#716
See merge request
!908
parents
0fe715f3
7342b5a4
Pipeline
#8666
passed with stages
in 3 minutes and 20 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
View file @
ed5a1bbd
...
...
@@ -190,6 +190,11 @@ def custom_emojis(conn, _params) do
end
defp
add_link_headers
(
conn
,
method
,
activities
,
param
\\
nil
,
params
\\
%{})
do
params
=
conn
.
params
|>
Map
.
drop
([
"since_id"
,
"max_id"
])
|>
Map
.
merge
(
params
)
last
=
List
.
last
(
activities
)
first
=
List
.
first
(
activities
)
...
...
test/web/mastodon_api/mastodon_api_controller_test.exs
View file @
ed5a1bbd
...
...
@@ -1955,4 +1955,36 @@ test "comment must be up to the size specified in the config", %{
|>
json_response
(
400
)
end
end
describe
"link headers"
do
test
"preserves parameters in link headers"
,
%{
conn:
conn
}
do
user
=
insert
(
:user
)
other_user
=
insert
(
:user
)
{
:ok
,
activity1
}
=
CommonAPI
.
post
(
other_user
,
%{
"status"
=>
"hi @
#{
user
.
nickname
}
"
,
"visibility"
=>
"public"
})
{
:ok
,
activity2
}
=
CommonAPI
.
post
(
other_user
,
%{
"status"
=>
"hi @
#{
user
.
nickname
}
"
,
"visibility"
=>
"public"
})
notification1
=
Repo
.
get_by
(
Notification
,
activity_id:
activity1
.
id
)
notification2
=
Repo
.
get_by
(
Notification
,
activity_id:
activity2
.
id
)
conn
=
conn
|>
assign
(
:user
,
user
)
|>
get
(
"/api/v1/notifications"
,
%{
media_only:
true
})
assert
[
link_header
]
=
get_resp_header
(
conn
,
"link"
)
assert
link_header
=~
~r/media_only=true/
assert
link_header
=~
~r/since_id=#{notification2.id}/
assert
link_header
=~
~r/max_id=#{notification1.id}/
end
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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