forked from AkkomaGang/akkoma
Redirect to user feed instead of directly serving it.
This commit is contained in:
parent
1854842b09
commit
92a8944dfe
3 changed files with 8 additions and 2 deletions
|
@ -4,8 +4,14 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
alias Pleroma.{User, Activity}
|
alias Pleroma.{User, Activity}
|
||||||
alias Pleroma.Web.OStatus.FeedRepresenter
|
alias Pleroma.Web.OStatus.FeedRepresenter
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
alias Pleroma.Web.OStatus
|
||||||
import Ecto.Query
|
import Ecto.Query
|
||||||
|
|
||||||
|
def feed_redirect(conn, %{"nickname" => nickname}) do
|
||||||
|
user = User.get_cached_by_nickname(nickname)
|
||||||
|
redirect conn, external: OStatus.feed_path(user)
|
||||||
|
end
|
||||||
|
|
||||||
def feed(conn, %{"nickname" => nickname}) do
|
def feed(conn, %{"nickname" => nickname}) do
|
||||||
user = User.get_cached_by_nickname(nickname)
|
user = User.get_cached_by_nickname(nickname)
|
||||||
query = from activity in Activity,
|
query = from activity in Activity,
|
||||||
|
|
|
@ -74,7 +74,7 @@ def user_fetcher(username) do
|
||||||
pipe_through :ostatus
|
pipe_through :ostatus
|
||||||
|
|
||||||
get "/users/:nickname/feed", OStatus.OStatusController, :feed
|
get "/users/:nickname/feed", OStatus.OStatusController, :feed
|
||||||
get "/users/:nickname", OStatus.OStatusController, :feed
|
get "/users/:nickname", OStatus.OStatusController, :feed_redirect
|
||||||
post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
|
post "/users/:nickname/salmon", OStatus.OStatusController, :salmon_incoming
|
||||||
post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
|
post "/push/hub/:nickname", Websub.WebsubController, :websub_subscription_request
|
||||||
get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
|
get "/push/subscriptions/:id", Websub.WebsubController, :websub_subscription_confirmation
|
||||||
|
|
|
@ -99,7 +99,7 @@ defp lease_time(_) do
|
||||||
|
|
||||||
defp valid_topic(%{"hub.topic" => topic}, user) do
|
defp valid_topic(%{"hub.topic" => topic}, user) do
|
||||||
if topic == OStatus.feed_path(user) do
|
if topic == OStatus.feed_path(user) do
|
||||||
{:ok, topic}
|
{:ok, OStatus.feed_path(user)}
|
||||||
else
|
else
|
||||||
{:error, "Wrong topic requested, expected #{OStatus.feed_path(user)}, got #{topic}"}
|
{:error, "Wrong topic requested, expected #{OStatus.feed_path(user)}, got #{topic}"}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue