forked from mirrors/akkoma
Transmogrifier: Remove handling of orphaned accepts
This was a Mastodon 2.3 issue and has been fixed for a long time. According to fediverse.networks, less than one percent of servers still run a version this old or older.
This commit is contained in:
parent
8b1e8bec2f
commit
da3f9b9988
2 changed files with 1 additions and 39 deletions
|
@ -391,27 +391,11 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
|
|
||||||
defp fix_content(object), do: object
|
defp fix_content(object), do: object
|
||||||
|
|
||||||
defp mastodon_follow_hack(%{"id" => id, "actor" => follower_id}, followed) do
|
defp get_follow_activity(follow_object, _followed) do
|
||||||
with true <- id =~ "follows",
|
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follower_id),
|
|
||||||
%Activity{} = activity <- Utils.fetch_latest_follow(follower, followed) do
|
|
||||||
{:ok, activity}
|
|
||||||
else
|
|
||||||
_ -> {:error, nil}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
defp mastodon_follow_hack(_, _), do: {:error, nil}
|
|
||||||
|
|
||||||
defp get_follow_activity(follow_object, followed) do
|
|
||||||
with object_id when not is_nil(object_id) <- Utils.get_ap_id(follow_object),
|
with object_id when not is_nil(object_id) <- Utils.get_ap_id(follow_object),
|
||||||
{_, %Activity{} = activity} <- {:activity, Activity.get_by_ap_id(object_id)} do
|
{_, %Activity{} = activity} <- {:activity, Activity.get_by_ap_id(object_id)} do
|
||||||
{:ok, activity}
|
{:ok, activity}
|
||||||
else
|
else
|
||||||
# Can't find the activity. This might a Mastodon 2.3 "Accept"
|
|
||||||
{:activity, nil} ->
|
|
||||||
mastodon_follow_hack(follow_object, followed)
|
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
{:error, nil}
|
{:error, nil}
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,28 +44,6 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
|
||||||
assert User.following?(follower, followed) == true
|
assert User.following?(follower, followed) == true
|
||||||
end
|
end
|
||||||
|
|
||||||
test "it works for incoming accepts which were orphaned" do
|
|
||||||
follower = insert(:user)
|
|
||||||
followed = insert(:user, locked: true)
|
|
||||||
|
|
||||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
|
||||||
|
|
||||||
accept_data =
|
|
||||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
|
||||||
|> Poison.decode!()
|
|
||||||
|> Map.put("actor", followed.ap_id)
|
|
||||||
|
|
||||||
accept_data =
|
|
||||||
Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
|
|
||||||
|
|
||||||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
|
||||||
assert activity.data["object"] == follow_activity.data["id"]
|
|
||||||
|
|
||||||
follower = User.get_cached_by_id(follower.id)
|
|
||||||
|
|
||||||
assert User.following?(follower, followed) == true
|
|
||||||
end
|
|
||||||
|
|
||||||
test "it works for incoming accepts which are referenced by IRI only" do
|
test "it works for incoming accepts which are referenced by IRI only" do
|
||||||
follower = insert(:user)
|
follower = insert(:user)
|
||||||
followed = insert(:user, locked: true)
|
followed = insert(:user, locked: true)
|
||||||
|
|
Loading…
Reference in a new issue