summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPhil Hagelberg <phil@hagelb.org>2019-11-12 17:19:46 -0800
committerPhil Hagelberg <phil@hagelb.org>2019-11-13 08:02:02 -0800
commit0867cb083eb469ae10cd48d424a51efb2fae4018 (patch)
tree2cbd8ec8bca47859823e98409cda01c227b69766 /lib
parent60cc5a775084fbd9362b7e682887d0c44caf5175 (diff)
downloadpleroma-0867cb083eb469ae10cd48d424a51efb2fae4018.tar.gz
pleroma-0867cb083eb469ae10cd48d424a51efb2fae4018.zip
Support redirecting by object ID in static FE.
This matches the behavior of pleroma-fe better. Fixes #1412.
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/static_fe/static_fe_controller.ex15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/pleroma/web/static_fe/static_fe_controller.ex b/lib/pleroma/web/static_fe/static_fe_controller.ex
index ba44b8a4f..b45d82c2d 100644
--- a/lib/pleroma/web/static_fe/static_fe_controller.ex
+++ b/lib/pleroma/web/static_fe/static_fe_controller.ex
@@ -119,11 +119,26 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
end
end
+ def show(%{assigns: %{object_id: _}} = conn, _params) do
+ url = Helpers.url(conn) <> conn.request_path
+ case Activity.get_create_by_object_ap_id_with_object(url) do
+ %Activity{} = activity ->
+ redirect(conn, to: "/notice/#{activity.id}")
+ _ ->
+ conn
+ |> put_status(404)
+ |> render("error.html", %{message: "Post not found.", meta: ""})
+ end
+ end
+
def assign_id(%{path_info: ["notice", notice_id]} = conn, _opts),
do: assign(conn, :notice_id, notice_id)
def assign_id(%{path_info: ["users", user_id]} = conn, _opts),
do: assign(conn, :username_or_id, user_id)
+ def assign_id(%{path_info: ["objects", object_id]} = conn, _opts),
+ do: assign(conn, :object_id, object_id)
+
def assign_id(conn, _opts), do: conn
end