Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
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
Container Registry
Model registry
Operate
Environments
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
dex
pleroma
Commits
2e32012d
Commit
2e32012d
authored
6 years ago
by
eal
Browse files
Options
Downloads
Patches
Plain Diff
Add next and previous headers to user pages and tag timelines.
parent
b0d242cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+16
-6
16 additions, 6 deletions
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
with
16 additions
and
6 deletions
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+
16
−
6
View file @
2e32012d
...
...
@@ -135,14 +135,23 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
json
conn
,
mastodon_emoji
end
defp
add_link_headers
(
conn
,
method
,
activities
)
do
defp
add_link_headers
(
conn
,
method
,
activities
,
param
\\
false
)
do
last
=
List
.
last
(
activities
)
first
=
List
.
first
(
activities
)
if
last
do
min
=
last
.
id
max
=
first
.
id
next_url
=
mastodon_api_url
(
Pleroma
.
Web
.
Endpoint
,
method
,
max_id:
min
)
prev_url
=
mastodon_api_url
(
Pleroma
.
Web
.
Endpoint
,
method
,
since_id:
max
)
{
next_url
,
prev_url
}
=
if
param
do
{
mastodon_api_url
(
Pleroma
.
Web
.
Endpoint
,
method
,
param
,
max_id:
min
),
mastodon_api_url
(
Pleroma
.
Web
.
Endpoint
,
method
,
param
,
since_id:
max
)
}
else
{
mastodon_api_url
(
Pleroma
.
Web
.
Endpoint
,
method
,
max_id:
min
),
mastodon_api_url
(
Pleroma
.
Web
.
Endpoint
,
method
,
since_id:
max
)
}
end
conn
|>
put_resp_header
(
"link"
,
"<
#{
next_url
}
>; rel=
\"
next
\"
, <
#{
prev_url
}
>; rel=
\"
prev
\"
"
)
else
...
...
@@ -178,7 +187,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|>
render
(
StatusView
,
"index.json"
,
%{
activities:
activities
,
for:
user
,
as:
:activity
})
end
# TODO: Link headers
def
user_statuses
(%{
assigns:
%{
user:
user
}}
=
conn
,
params
)
do
with
%
User
{
ap_id:
ap_id
}
<-
Repo
.
get
(
User
,
params
[
"id"
])
do
params
=
params
...
...
@@ -189,7 +197,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
activities
=
ActivityPub
.
fetch_public_activities
(
params
)
|>
Enum
.
reverse
render
conn
,
StatusView
,
"index.json"
,
%{
activities:
activities
,
for:
user
,
as:
:activity
}
conn
|>
add_link_headers
(
:user_statuses
,
activities
,
params
[
"id"
])
|>
render
(
StatusView
,
"index.json"
,
%{
activities:
activities
,
for:
user
,
as:
:activity
})
end
end
...
...
@@ -333,7 +343,6 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
end
end
# TODO: Link headers
def
hashtag_timeline
(%{
assigns:
%{
user:
user
}}
=
conn
,
params
)
do
params
=
params
|>
Map
.
put
(
"type"
,
"Create"
)
...
...
@@ -344,6 +353,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController do
|>
Enum
.
reverse
conn
|>
add_link_headers
(
:hashtag_timeline
,
activities
,
params
[
"tag"
])
|>
render
(
StatusView
,
"index.json"
,
%{
activities:
activities
,
for:
user
,
as:
:activity
})
end
...
...
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