diff options
author | lain <lain@soykaf.club> | 2022-11-14 07:22:33 +0000 |
---|---|---|
committer | lain <lain@soykaf.club> | 2022-11-14 07:22:33 +0000 |
commit | 76ed0da09f7422e34feb61c2db151d47b8b92557 (patch) | |
tree | dfe0edf5651d2e92aa00afb8a256dd116659a32c | |
parent | a2db64b12b33b7967aa1f633231253e67ad73216 (diff) | |
parent | b2713357b9410fc43478de4fb271b2920d618956 (diff) | |
download | pleroma-76ed0da09f7422e34feb61c2db151d47b8b92557.tar.gz pleroma-76ed0da09f7422e34feb61c2db151d47b8b92557.zip |
Merge branch 'bugfix/reset-unreachable-on-fetch' into 'develop'
Object.Fetcher: Set reachable on successful fetch
See merge request pleroma/pleroma!3780
-rw-r--r-- | lib/pleroma/object/fetcher.ex | 5 | ||||
-rw-r--r-- | test/pleroma/object/fetcher_test.exs | 12 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex index d81fdcf24..a9a9eeeed 100644 --- a/lib/pleroma/object/fetcher.ex +++ b/lib/pleroma/object/fetcher.ex @@ -4,6 +4,7 @@ defmodule Pleroma.Object.Fetcher do alias Pleroma.HTTP + alias Pleroma.Instances alias Pleroma.Maps alias Pleroma.Object alias Pleroma.Object.Containment @@ -234,6 +235,10 @@ defmodule Pleroma.Object.Fetcher do {:ok, body} <- get_object(id), {:ok, data} <- safe_json_decode(body), :ok <- Containment.contain_origin_from_id(id, data) do + if not Instances.reachable?(id) do + Instances.set_reachable(id) + end + {:ok, data} else {:scheme, _} -> diff --git a/test/pleroma/object/fetcher_test.exs b/test/pleroma/object/fetcher_test.exs index 1f97f36f7..51541a42c 100644 --- a/test/pleroma/object/fetcher_test.exs +++ b/test/pleroma/object/fetcher_test.exs @@ -6,6 +6,7 @@ defmodule Pleroma.Object.FetcherTest do use Pleroma.DataCase alias Pleroma.Activity + alias Pleroma.Instances alias Pleroma.Object alias Pleroma.Object.Fetcher @@ -159,6 +160,17 @@ defmodule Pleroma.Object.FetcherTest do "https://patch.cx/media/03ca3c8b4ac3ddd08bf0f84be7885f2f88de0f709112131a22d83650819e36c2.json" ) end + + test "it resets instance reachability on successful fetch" do + id = "http://mastodon.example.org/@admin/99541947525187367" + Instances.set_consistently_unreachable(id) + refute Instances.reachable?(id) + + {:ok, object} = + Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367") + + assert Instances.reachable?(id) + end end describe "implementation quirks" do |