Redirect to standard FE if logged in
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending

This commit is contained in:
FloatingGhost 2022-12-07 13:35:00 +00:00
parent 221a95b860
commit 1afba64464
3 changed files with 21 additions and 10 deletions

View file

@ -9,7 +9,7 @@ defmodule Pleroma.Web.Plugs.StaticFEPlug do
def init(options), do: options def init(options), do: options
def call(conn, _) do def call(conn, _) do
if enabled?() and requires_html?(conn) do if enabled?() and requires_html?(conn) and not_logged_in?(conn) do
conn conn
|> StaticFEController.call(:show) |> StaticFEController.call(:show)
|> halt() |> halt()
@ -23,4 +23,7 @@ defmodule Pleroma.Web.Plugs.StaticFEPlug do
defp requires_html?(conn) do defp requires_html?(conn) do
Phoenix.Controller.get_format(conn) == "html" Phoenix.Controller.get_format(conn) == "html"
end end
defp not_logged_in?(%{assigns: %{user: %Pleroma.User{}}}), do: false
defp not_logged_in?(_), do: true
end end

View file

@ -150,6 +150,8 @@ defmodule Pleroma.Web.Router do
end end
pipeline :static_fe do pipeline :static_fe do
plug(:fetch_session)
plug(:authenticate)
plug(Pleroma.Web.Plugs.StaticFEPlug) plug(Pleroma.Web.Plugs.StaticFEPlug)
end end

View file

@ -180,15 +180,7 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
nil nil
end end
reply_to_user = reply_to_user = in_reply_to_user(activity)
if data["inReplyTo"] do
activity
|> Activity.get_in_reply_to_activity()
|> Map.get(:actor)
|> User.get_cached_by_ap_id()
else
nil
end
total_votes = total_votes =
if data["oneOf"] do if data["oneOf"] do
@ -217,6 +209,20 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
} }
end end
defp in_reply_to_user(%Activity{object: %Object{data: %{"inReplyTo" => inReplyTo}}} = activity) when is_binary(inReplyTo) do
in_reply_to_activity = Activity.get_in_reply_to_activity(activity)
if in_reply_to_activity do
in_reply_to_activity
|> Map.get(:actor)
|> User.get_cached_by_ap_id()
else
nil
end
end
defp in_reply_to_user(_), do: nil
defp assign_id(%{path_info: ["notice", notice_id]} = conn, _opts), defp assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
do: assign(conn, :notice_id, notice_id) do: assign(conn, :notice_id, notice_id)