Document way to do notice compatibility routes with Nginx reverse-proxy instead

This commit is contained in:
Sean King 2022-07-16 23:44:37 -06:00
parent 8aba7c08d1
commit 64e16e6a4b
No known key found for this signature in database
GPG key ID: 510C52BACD6E7257
5 changed files with 13 additions and 66 deletions

View file

@ -81,6 +81,19 @@ server {
proxy_pass http://phoenix; proxy_pass http://phoenix;
} }
# Uncomment this if you want notice compatibility routes for frontends like Soapbox.
# location ~ /@.+/([^/]+) {
# proxy_pass http://phoenix/notice/$1;
# }
#
# location ~ /@.+/posts/([^/]+) {
# proxy_pass http://phoenix/notice/$1;
# }
#
# location ~ /.+/status/([^/]+) {
# proxy_pass http://phoenix/notice/$1;
# }
location ~ ^/(media|proxy) { location ~ ^/(media|proxy) {
proxy_cache pleroma_media_cache; proxy_cache pleroma_media_cache;
slice 1m; slice 1m;

View file

@ -678,11 +678,6 @@ defmodule Pleroma.Web.Router do
get("/activities/:uuid", OStatus.OStatusController, :activity) get("/activities/:uuid", OStatus.OStatusController, :activity)
get("/notice/:id", OStatus.OStatusController, :notice) get("/notice/:id", OStatus.OStatusController, :notice)
# Notice compatibility routes for other frontends
get("/@:nickname/:id", OStatus.OStatusController, :notice)
get("/@:nickname/posts/:id", OStatus.OStatusController, :notice)
get("/:nickname/status/:id", OStatus.OStatusController, :notice)
# Mastodon compatibility routes # Mastodon compatibility routes
get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object) get("/users/:nickname/statuses/:id", OStatus.OStatusController, :object)
get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity) get("/users/:nickname/statuses/:id/activity", OStatus.OStatusController, :activity)

View file

@ -167,15 +167,6 @@ defmodule Pleroma.Web.StaticFE.StaticFEController do
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)
defp assign_id(%{path_info: ["@" <> _nickname, notice_id]} = conn, _opts),
do: assign(conn, :notice_id, notice_id)
defp assign_id(%{path_info: ["@" <> _nickname, "posts", notice_id]} = conn, _opts),
do: assign(conn, :notice_id, notice_id)
defp assign_id(%{path_info: [_nickname, "status", notice_id]} = conn, _opts),
do: assign(conn, :notice_id, notice_id)
defp assign_id(%{path_info: ["users", user_id]} = conn, _opts), defp assign_id(%{path_info: ["users", user_id]} = conn, _opts),
do: assign(conn, :username_or_id, user_id) do: assign(conn, :username_or_id, user_id)

View file

@ -343,54 +343,4 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|> response(200) |> response(200)
end end
end end
describe "notice compatibility routes" do
test "Soapbox FE", %{conn: conn} do
user = insert(:user)
note_activity = insert(:note_activity, user: user)
resp =
conn
|> put_req_header("accept", "text/html")
|> get("/@#{user.nickname}/posts/#{note_activity.id}")
|> response(200)
expected =
"<meta content=\"#{Endpoint.url()}/notice/#{note_activity.id}\" property=\"og:url\">"
assert resp =~ expected
end
test "Mastodon", %{conn: conn} do
user = insert(:user)
note_activity = insert(:note_activity, user: user)
resp =
conn
|> put_req_header("accept", "text/html")
|> get("/@#{user.nickname}/#{note_activity.id}")
|> response(200)
expected =
"<meta content=\"#{Endpoint.url()}/notice/#{note_activity.id}\" property=\"og:url\">"
assert resp =~ expected
end
test "Twitter", %{conn: conn} do
user = insert(:user)
note_activity = insert(:note_activity, user: user)
resp =
conn
|> put_req_header("accept", "text/html")
|> get("/#{user.nickname}/status/#{note_activity.id}")
|> response(200)
expected =
"<meta content=\"#{Endpoint.url()}/notice/#{note_activity.id}\" property=\"og:url\">"
assert resp =~ expected
end
end
end end

View file

@ -86,8 +86,6 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
"objects", "objects",
"activities", "activities",
"notice", "notice",
"@:nickname",
":nickname",
"users", "users",
"tags", "tags",
"mailer", "mailer",