mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Redirect non-local activities when /notice/:id is used
Related-to: https://git.pleroma.social/pleroma/pleroma/-/issues/2496
This commit is contained in:
parent
fd2477dfba
commit
ecff027418
3 changed files with 14 additions and 11 deletions
|
@ -22,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Deprecated `Pleroma.Uploaders.S3, :public_endpoint`. Now `Pleroma.Upload, :base_url` is the standard configuration key for all uploaders.
|
- Deprecated `Pleroma.Uploaders.S3, :public_endpoint`. Now `Pleroma.Upload, :base_url` is the standard configuration key for all uploaders.
|
||||||
- Improved Apache webserver support: updated sample configuration, MediaProxy cache invalidation verified with the included sample script
|
- Improved Apache webserver support: updated sample configuration, MediaProxy cache invalidation verified with the included sample script
|
||||||
- Improve OAuth 2.0 provider support. A missing `fqn` field was added to the response, but does not expose the user's email address.
|
- Improve OAuth 2.0 provider support. A missing `fqn` field was added to the response, but does not expose the user's email address.
|
||||||
|
- Provide redirect of external posts from `/notice/:id` to their original URL
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
@ -73,12 +73,8 @@ defmodule Pleroma.Web.OStatus.OStatusController do
|
||||||
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
|
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
|
||||||
cond do
|
cond do
|
||||||
format in ["json", "activity+json"] ->
|
format in ["json", "activity+json"] ->
|
||||||
if activity.local do
|
%{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false)
|
||||||
%{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false)
|
redirect(conn, external: redirect_url)
|
||||||
redirect(conn, external: redirect_url)
|
|
||||||
else
|
|
||||||
{:error, :not_found}
|
|
||||||
end
|
|
||||||
|
|
||||||
activity.data["type"] == "Create" ->
|
activity.data["type"] == "Create" ->
|
||||||
%Object{} = object = Object.normalize(activity, fetch: false)
|
%Object{} = object = Object.normalize(activity, fetch: false)
|
||||||
|
|
|
@ -144,13 +144,19 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
||||||
assert redirect_url == expected_redirect_url
|
assert redirect_url == expected_redirect_url
|
||||||
end
|
end
|
||||||
|
|
||||||
test "returns a 404 on remote notice when json requested", %{conn: conn} do
|
test "redirects to a proper object URL when json requested and the object is remote", %{
|
||||||
|
conn: conn
|
||||||
|
} do
|
||||||
note_activity = insert(:note_activity, local: false)
|
note_activity = insert(:note_activity, local: false)
|
||||||
|
expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
|
||||||
|
|
||||||
conn
|
redirect_url =
|
||||||
|> put_req_header("accept", "application/activity+json")
|
conn
|
||||||
|> get("/notice/#{note_activity.id}")
|
|> put_req_header("accept", "application/activity+json")
|
||||||
|> response(404)
|
|> get("/notice/#{note_activity.id}")
|
||||||
|
|> redirected_to()
|
||||||
|
|
||||||
|
assert redirect_url == expected_redirect_url
|
||||||
end
|
end
|
||||||
|
|
||||||
test "500s when actor not found", %{conn: conn} do
|
test "500s when actor not found", %{conn: conn} do
|
||||||
|
|
Loading…
Reference in a new issue