+ end
+ end
+
+ describe "Targets reachability filtering in `publish`" do
+ test "it federates only to reachable instances via AP" do
+ user = insert(:user)
+
+ {inbox1, inbox2} =
+ {"https://domain.com/users/nick1/inbox", "https://domain2.com/users/nick2/inbox"}
+
+ insert(:user, %{
+ local: false,
+ nickname: "nick1@domain.com",
+ ap_id: "https://domain.com/users/nick1",
+ inbox: inbox1,
+ ap_enabled: true
+ })
+
+ insert(:user, %{
+ local: false,
+ nickname: "nick2@domain2.com",
+ ap_id: "https://domain2.com/users/nick2",
+ inbox: inbox2,
+ ap_enabled: true
+ })
+
+ dt = NaiveDateTime.utc_now()
+ Instances.set_unreachable(inbox1, dt)
+
+ Instances.set_consistently_unreachable(URI.parse(inbox2).host)
+
+ {:ok, _activity} =
+ CommonAPI.post(user, %{"status" => "HI @nick1@domain.com, @nick2@domain2.com!"})
+
+ expected_dt = NaiveDateTime.to_iso8601(dt)