diff options
author | lain <lain@soykaf.club> | 2020-06-05 12:26:07 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-06-05 12:26:07 +0200 |
commit | 0efa8aa0b9567f42b1af63e2b93a9c51e9a0fb11 (patch) | |
tree | 2a2311e2b91d7d81878c7576d71edde2947e4282 /test | |
parent | cc8a7dc205a4516452c48659e6bf081f3f730496 (diff) | |
download | pleroma-0efa8aa0b9567f42b1af63e2b93a9c51e9a0fb11.tar.gz pleroma-0efa8aa0b9567f42b1af63e2b93a9c51e9a0fb11.zip |
Transmogrifier: For follows, create notifications last.
As the notification type changes depending on the follow state,
the notification should not be created and streamed out before the
state settles. For this reason, the notification creation has been
delayed until it's clear if the user has been followed or not.
This is a bit hacky but it will be properly rewritten using the
pipeline soon.
Diffstat (limited to 'test')
-rw-r--r-- | test/web/activity_pub/transmogrifier/follow_handling_test.exs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier/follow_handling_test.exs b/test/web/activity_pub/transmogrifier/follow_handling_test.exs index 6b003b51c..06c39eed6 100644 --- a/test/web/activity_pub/transmogrifier/follow_handling_test.exs +++ b/test/web/activity_pub/transmogrifier/follow_handling_test.exs @@ -13,6 +13,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do import Pleroma.Factory import Ecto.Query + import Mock setup_all do Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end) @@ -151,6 +152,23 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do assert activity.data["state"] == "reject" end + test "it rejects incoming follow requests if the following errors for some reason" do + user = insert(:user) + + data = + File.read!("test/fixtures/mastodon-follow-activity.json") + |> Poison.decode!() + |> Map.put("object", user.ap_id) + + with_mock Pleroma.User, [:passthrough], follow: fn _, _ -> {:error, :testing} end do + {:ok, %Activity{data: %{"id" => id}}} = Transmogrifier.handle_incoming(data) + + %Activity{} = activity = Activity.get_by_ap_id(id) + + assert activity.data["state"] == "reject" + end + end + test "it works for incoming follow requests from hubzilla" do user = insert(:user) |