aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaelwenn <contact+git.pleroma.social@hacktivis.me>2021-02-04 14:26:03 +0000
committerHaelwenn <contact+git.pleroma.social@hacktivis.me>2021-02-04 14:26:03 +0000
commitea5469961a537d12ca799bf7470e53cb636b1439 (patch)
tree46d0eec9d81ef1260c6b5702ee25a05524e24e6c
parent49741961f234816c1fff278adca397e9ff7cabe7 (diff)
parentecff02741817e5622da58365855dce09c789ca83 (diff)
downloadpleroma-ea5469961a537d12ca799bf7470e53cb636b1439.tar.gz
Merge branch 'bugfix/notice-external-redirect' into 'develop'
Redirect non-local activities when /notice/:id is used See merge request pleroma/pleroma!3300
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/pleroma/web/o_status/o_status_controller.ex8
-rw-r--r--test/pleroma/web/o_status/o_status_controller_test.exs16
3 files changed, 14 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 47009abc9..1dbdb3f4e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,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.
- 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.
+- Provide redirect of external posts from `/notice/:id` to their original URL
<details>
<summary>API Changes</summary>
diff --git a/lib/pleroma/web/o_status/o_status_controller.ex b/lib/pleroma/web/o_status/o_status_controller.ex
index 450aae042..da3264149 100644
--- a/lib/pleroma/web/o_status/o_status_controller.ex
+++ b/lib/pleroma/web/o_status/o_status_controller.ex
@@ -73,12 +73,8 @@ defmodule Pleroma.Web.OStatus.OStatusController do
%User{} = user <- User.get_cached_by_ap_id(activity.data["actor"]) do
cond do
format in ["json", "activity+json"] ->
- if activity.local do
- %{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false)
- redirect(conn, external: redirect_url)
- else
- {:error, :not_found}
- end
+ %{data: %{"id" => redirect_url}} = Object.normalize(activity, fetch: false)
+ redirect(conn, external: redirect_url)
activity.data["type"] == "Create" ->
%Object{} = object = Object.normalize(activity, fetch: false)
diff --git a/test/pleroma/web/o_status/o_status_controller_test.exs b/test/pleroma/web/o_status/o_status_controller_test.exs
index 5cdca019a..2038f4ddd 100644
--- a/test/pleroma/web/o_status/o_status_controller_test.exs
+++ b/test/pleroma/web/o_status/o_status_controller_test.exs
@@ -144,13 +144,19 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
assert redirect_url == expected_redirect_url
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)
+ expected_redirect_url = Object.normalize(note_activity, fetch: false).data["id"]
- conn
- |> put_req_header("accept", "application/activity+json")
- |> get("/notice/#{note_activity.id}")
- |> response(404)
+ redirect_url =
+ conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get("/notice/#{note_activity.id}")
+ |> redirected_to()
+
+ assert redirect_url == expected_redirect_url
end
test "500s when actor not found", %{conn: conn} do