projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into fix/disable-rate-limiter-for-socket-localhost
[akkoma]
/
lib
/
pleroma
/
web
/
mastodon_api
/
controllers
/
timeline_controller.ex
diff --git
a/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
b/lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
index bb8b0eb328bad899415df0d3fcb3ced0d19c8bbd..29964a1d41a46495303502f5f40d85c6519baae1 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
+++ b/
lib/pleroma/web/mastodon_api/controllers/timeline_controller.ex
@@
-9,8
+9,15
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
only: [add_link_headers: 2, add_link_headers: 3, truthy_param?: 1]
alias Pleroma.Pagination
only: [add_link_headers: 2, add_link_headers: 3, truthy_param?: 1]
alias Pleroma.Pagination
+ alias Pleroma.Plugs.OAuthScopesPlug
+ alias Pleroma.User
alias Pleroma.Web.ActivityPub.ActivityPub
alias Pleroma.Web.ActivityPub.ActivityPub
+ plug(OAuthScopesPlug, %{scopes: ["read:statuses"]} when action in [:home, :direct])
+ plug(OAuthScopesPlug, %{scopes: ["read:lists"]} when action == :list)
+
+ plug(Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug)
+
plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
# GET /api/v1/timelines/home
plug(:put_view, Pleroma.Web.MastodonAPI.StatusView)
# GET /api/v1/timelines/home
@@
-22,7
+29,7
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put("muting_user", user)
|> Map.put("user", user)
|> Map.put("muting_user", user)
|> Map.put("user", user)
- recipients = [user.ap_id |
user.following
]
+ recipients = [user.ap_id |
User.following(user)
]
activities =
recipients
activities =
recipients
@@
-64,17
+71,13
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put("blocking_user", user)
|> Map.put("muting_user", user)
|> ActivityPub.fetch_public_activities()
|> Map.put("blocking_user", user)
|> Map.put("muting_user", user)
|> ActivityPub.fetch_public_activities()
- |> Enum.reverse()
conn
|> add_link_headers(activities, %{"local" => local_only})
|> render("index.json", activities: activities, for: user, as: :activity)
end
conn
|> add_link_headers(activities, %{"local" => local_only})
|> render("index.json", activities: activities, for: user, as: :activity)
end
- # GET /api/v1/timelines/tag/:tag
- def hashtag(%{assigns: %{user: user}} = conn, params) do
- local_only = truthy_param?(params["local"])
-
+ def hashtag_fetching(params, user, local_only) do
tags =
[params["tag"], params["any"]]
|> List.flatten()
tags =
[params["tag"], params["any"]]
|> List.flatten()
@@
-92,7
+95,7
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.get("none", [])
|> Enum.map(&String.downcase(&1))
|> Map.get("none", [])
|> Enum.map(&String.downcase(&1))
- activities =
+
_
activities =
params
|> Map.put("type", "Create")
|> Map.put("local_only", local_only)
params
|> Map.put("type", "Create")
|> Map.put("local_only", local_only)
@@
-103,7
+106,13
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
|> Map.put("tag_all", tag_all)
|> Map.put("tag_reject", tag_reject)
|> ActivityPub.fetch_public_activities()
|> Map.put("tag_all", tag_all)
|> Map.put("tag_reject", tag_reject)
|> ActivityPub.fetch_public_activities()
- |> Enum.reverse()
+ end
+
+ # GET /api/v1/timelines/tag/:tag
+ def hashtag(%{assigns: %{user: user}} = conn, params) do
+ local_only = truthy_param?(params["local"])
+
+ activities = hashtag_fetching(params, user, local_only)
conn
|> add_link_headers(activities, %{"local" => local_only})
conn
|> add_link_headers(activities, %{"local" => local_only})
@@
-122,9
+131,12
@@
defmodule Pleroma.Web.MastodonAPI.TimelineController do
# we must filter the following list for the user to avoid leaking statuses the user
# does not actually have permission to see (for more info, peruse security issue #270).
# we must filter the following list for the user to avoid leaking statuses the user
# does not actually have permission to see (for more info, peruse security issue #270).
+
+ user_following = User.following(user)
+
activities =
following
activities =
following
- |> Enum.filter(fn x -> x in user
.
following end)
+ |> Enum.filter(fn x -> x in user
_
following end)
|> ActivityPub.fetch_activities_bounded(following, params)
|> Enum.reverse()
|> ActivityPub.fetch_activities_bounded(following, params)
|> Enum.reverse()