Merge pull request 'Fix Pleroma’s unlisted posts' (#885) from Oneric/akkoma:pleroma_unlisted into develop
Reviewed-on: https://akkoma.dev/AkkomaGang/akkoma/pulls/885
This commit is contained in:
commit
f0653efe13
2 changed files with 43 additions and 1 deletions
|
@ -118,7 +118,7 @@ defp normalise_addressing_public_list(%{} = map, [field | fields]) do
|
||||||
|
|
||||||
Map.put(map, field, new_fval)
|
Map.put(map, field, new_fval)
|
||||||
else
|
else
|
||||||
map
|
Map.put(map, field, [])
|
||||||
end
|
end
|
||||||
|
|
||||||
normalise_addressing_public_list(map, fields)
|
normalise_addressing_public_list(map, fields)
|
||||||
|
@ -208,6 +208,19 @@ def fix_in_reply_to(%{"inReplyTo" => in_reply_to} = object, options)
|
||||||
|
|
||||||
def fix_in_reply_to(object, _options), do: object
|
def fix_in_reply_to(object, _options), do: object
|
||||||
|
|
||||||
|
# Pleroma sends unlisted posts without addressing public scope in the enclosing activity
|
||||||
|
# but we only use the ativity for access perm cheks, see:
|
||||||
|
# https://git.pleroma.social/pleroma/pleroma/-/issues/3323
|
||||||
|
defp fix_create_visibility(%{"type" => "Create", "object" => %{} = object} = activity) do
|
||||||
|
activity
|
||||||
|
|> Map.put("to", object["to"])
|
||||||
|
|> Map.put("cc", object["cc"])
|
||||||
|
|> Map.put("bto", object["bto"])
|
||||||
|
|> Map.put("bcc", object["bcc"])
|
||||||
|
end
|
||||||
|
|
||||||
|
defp fix_create_visibility(activity), do: activity
|
||||||
|
|
||||||
def fix_quote_url(object, options \\ [])
|
def fix_quote_url(object, options \\ [])
|
||||||
|
|
||||||
def fix_quote_url(%{"quoteUri" => quote_url} = object, options)
|
def fix_quote_url(%{"quoteUri" => quote_url} = object, options)
|
||||||
|
@ -513,6 +526,7 @@ defp handle_incoming_normalised(
|
||||||
)
|
)
|
||||||
when objtype in ~w{Question Answer Audio Video Event Article Note Page} do
|
when objtype in ~w{Question Answer Audio Video Event Article Note Page} do
|
||||||
fetch_options = Keyword.put(options, :depth, (options[:depth] || 0) + 1)
|
fetch_options = Keyword.put(options, :depth, (options[:depth] || 0) + 1)
|
||||||
|
data = fix_create_visibility(data)
|
||||||
|
|
||||||
object =
|
object =
|
||||||
data["object"]
|
data["object"]
|
||||||
|
|
|
@ -17,6 +17,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.NoteHandlingTest do
|
||||||
import Mock
|
import Mock
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
require Pleroma.Constants
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
:ok
|
:ok
|
||||||
|
@ -276,6 +278,32 @@ test "it ensures that address fields become lists" do
|
||||||
refute is_nil(data["cc"])
|
refute is_nil(data["cc"])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it fixes Pleroma unlisted" do
|
||||||
|
# https://git.pleroma.social/pleroma/pleroma/-/issues/3323
|
||||||
|
user1 = insert(:user)
|
||||||
|
user2 = insert(:user)
|
||||||
|
|
||||||
|
data =
|
||||||
|
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||||
|
|> Jason.decode!()
|
||||||
|
|> Map.put("actor", user1.ap_id)
|
||||||
|
|> Map.put("cc", [])
|
||||||
|
|> Map.put("to", [user2.ap_id, user1.follower_address])
|
||||||
|
|
||||||
|
object =
|
||||||
|
data["object"]
|
||||||
|
|> Map.put("attributedTo", user1.ap_id)
|
||||||
|
|> Map.put("cc", [Pleroma.Constants.as_public()])
|
||||||
|
|> Map.put("to", [user2.ap_id, user1.follower_address])
|
||||||
|
|> Map.put("id", user1.ap_id <> "/activities/12345678")
|
||||||
|
|
||||||
|
data = Map.put(data, "object", object)
|
||||||
|
|
||||||
|
{:ok, %Activity{} = activity} = Transmogrifier.handle_incoming(data)
|
||||||
|
|
||||||
|
assert "unlisted" == Pleroma.Web.ActivityPub.Visibility.get_visibility(activity)
|
||||||
|
end
|
||||||
|
|
||||||
test "it strips internal likes" do
|
test "it strips internal likes" do
|
||||||
data =
|
data =
|
||||||
File.read!("test/fixtures/mastodon-post-activity.json")
|
File.read!("test/fixtures/mastodon-post-activity.json")
|
||||||
|
|
Loading…
Reference in a new issue